招聘后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
3.7 KiB

using Dapper;
using System.Collections.Generic;
using System.Threading.Tasks;
using Znyc.Recruitment.Admin.Commons.Enums;
using Znyc.Recruitment.Admin.Commons.IDbContext;
using Znyc.Recruitment.Admin.Commons.Pages;
using Znyc.Recruitment.Admin.Commons.Repositories;
using Znyc.Recruitment.Admin.Security.Dtos;
using Znyc.Recruitment.Admin.Security.Entitys;
using Znyc.Recruitment.Admin.Security.IRepositories;
namespace Znyc.Recruitment.Admin.Security.Repositories
{
/// <summary>
/// </summary>
public class UserRepository : BaseRepository<UserEntity, long>, IUserRepository
{
/// <summary>
/// </summary>
public UserRepository()
{
}
public UserRepository(IDbContextCore dbContext) : base(dbContext)
{
}
/// <summary>
/// �����û�UnionId��ѯ�û���Ϣ
/// </summary>
/// <param name="unionId"></param>
/// <returns></returns>
public async Task<UserEntity> GetUserByUnionId(string unionId)
{
string sql = @"SELECT * FROM rm_user t WHERE t.UnionId = @UnionId";
return await DapperConn.QueryFirstOrDefaultAsync<UserEntity>(sql, new { UnionId = unionId });
}
public async Task<List<UserEntity>> FindUserWithPagerAsync(SearchUserModel search, PagerInfo info)
{
bool order = search.Order == "asc" ? false : true;
string strwhere = "";
if (search.CertificationStatus >= 0 && search.CertificationStatus != (int)UserCertificationEnum.None)
{
strwhere = $" AND znyc.sys_certification.`Status`={search.CertificationStatus}";
}
if (search.CertificationStatus == (int)UserCertificationEnum.None)
{
strwhere = $" AND znyc_recruitment.rm_user.`IsRealAuthentication`=0";
}
if (!string.IsNullOrEmpty(search.Keywords))
{
strwhere += string.Format(" and (znyc_recruitment.rm_user.UserName like '%{0}%'or znyc_recruitment.rm_user.Phone like '%{0}%')", search.Keywords);
}
if (search.Status > 0)
{
strwhere += string.Format(" and znyc_recruitment.rm_user.Status={0}", search.Status);
}
if (!string.IsNullOrEmpty(search.StartTime))
{
strwhere += " and znyc_recruitment.rm_user.CreatedTime >='" + search.StartTime + " 00:00:00'";
}
if (!string.IsNullOrEmpty(search.EndTime))
{
strwhere += " and znyc_recruitment.rm_user.CreatedTime <='" + search.EndTime + " 23:59:59'";
}
string countSQL = $"select count(znyc_recruitment.rm_user.Id) as Total from znyc_recruitment.rm_user " +
$"LEFT JOIN znyc.sys_certification ON znyc_recruitment.rm_user.UnionId = znyc.sys_certification.UnionId " +
$"Where znyc_recruitment.rm_user.IsDeleted = 0 {strwhere};";
int minRow = search.PageSize * (search.CurrenetPageIndex - 1);
string sql = $"select * from znyc_recruitment.rm_user where Id IN(select t.Id from (select znyc_recruitment.rm_user.Id from znyc_recruitment.rm_user " +
$"LEFT JOIN znyc.sys_certification ON znyc_recruitment.rm_user.UnionId = znyc.sys_certification.UnionId " +
$"Where znyc_recruitment.rm_user.IsDeleted = 0 {strwhere} )as t) " +
$"order by znyc_recruitment.rm_user.{search.Sort} {search.Order} limit {minRow},{search.PageSize}; ";
SqlMapper.GridReader reader = await DapperConnRead.QueryMultipleAsync(countSQL + sql);
info.RecordCount = reader.ReadFirst<int>();
List<UserEntity> list = reader.Read<UserEntity>().AsList();
return list;
}
}
}