123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- using AutoMapper;
- using OASystem.Domain;
- using OASystem.Domain.Entities.System;
- using OASystem.Domain.ViewModels.System;
- using SqlSugar;
- using StackExchange.Redis;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace OASystem.Infrastructure.Repositories.System
- {
- public class UsersRepository : BaseRepository<UserInfo, UserInfoWebView>
- {
- public UsersRepository(SqlSugarClient sqlSugar) : base(sqlSugar){}
- /// <summary>
- /// 用户查询列表
- /// </summary>
- /// <param name="_userRep"></param>
- /// <returns></returns>
- public async Task<Result> GetUserList(int portType,string sqlWhere)
- {
- Result result = new Result() { Code = -2 };
-
- //List<UserInfoWebView> _userList = _sqlSugar.Queryable<Sys_Users>()
- // .InnerJoin<Sys_Company>((u, c) => u.CompanyId == c.Id) //若是多个条件 用 &&
- // .InnerJoin<Sys_Department>((u, c, d) => u.DepId == d.Id)
- // .InnerJoin<Sys_JobPost>((u, c, d, j) => u.JobPostId == j.Id)
- // .Where((u) => u.Id == 208)
- // .Select
- // ((u, c, d, j) => new UserInfoWebView
- // {
- // Number = u.Number,
- // CompanyId = u.CompanyId,
- // CompanyName = c.CompanyName,
- // DepId=u.DepId,
- // DepName = d.DepName,
- // JobPostId = u.JobPostId,
- // JobName = j.JobName,
- // Id = u.Id,
- // CnName = u.CnName,
- // Phone = u.Phone,
- // UrgentPhone = u.UrgentPhone,
- // Ext =u.Ext,
- // Email = u.Email,
- // })
- // .ToList();
- if (portType == 1) //web
- {
- string userSqlWhere = string.Format(@"Select su.CompanyId, sc.CompanyName,su.DepId,sd.DepName,su.JobPostId,sjp.JobName,
- su.Id UserId,su.CnName,su.CnName,su.Number,su.Ext,su.Phone,su.UrgentPhone,su.Email
- From Sys_Users su
- Inner Join Sys_Company sc On su.CompanyId = sc.Id
- Inner Join Sys_Department sd On su.DepId = sd.Id
- Inner Join Sys_JobPost sjp On su.JobPostId = sjp.Id Where su.IsDel = 0");
- var _userList = await _sqlSugar.SqlQueryable<UserInfoWebView>(userSqlWhere).ToListAsync();
- if (_userList.Count != 0)
- {
- result.Code = 0;
- result.Msg = "成功!";
- result.Data = _userList;
- }
- else
- {
- result.Msg = "暂无数据!";
- }
- }
- else if (portType == 2) //Android
- {
- string userSqlWhere = string.Format(@"Select su.CompanyId, sc.CompanyName,su.DepId,sd.DepName,su.JobPostId,sjp.JobName,
- su.Id UserId,su.CnName,su.CnName,su.Number,su.Ext,su.Phone,su.UrgentPhone,su.Email
- From Sys_Users su
- Inner Join Sys_Company sc On su.CompanyId = sc.Id
- Inner Join Sys_Department sd On su.DepId = sd.Id
- Inner Join Sys_JobPost sjp On su.JobPostId = sjp.Id ");
- var _userList = await _sqlSugar.SqlQueryable<UserInfoWebView>(userSqlWhere).ToListAsync();
- if (_userList.Count != 0)
- {
- result.Code = 0;
- result.Msg = "成功!";
- result.Data = _userList;
- }
- else
- {
- result.Msg = "暂无数据!";
- }
- }
- else if (portType == 3) //IOS
- {
- }
- else
- {
- result.Msg = "暂无数据!";
- }
-
- return result;
- }
- /// <summary>
- /// 用户查询列表
- /// </summary>
- /// <param name="_userRep"></param>
- /// <returns></returns>
- public async Task<Result> GetUserNameList(int portType)
- {
- Result result = new Result() { Code = -2 };
- if (portType == 1 || portType == 2) //web
- {
- string sql = string.Format(@"Select Id,CnName From Sys_Users Where Isdel=0 And HrAudit = 1");
- var _userList = await _sqlSugar.SqlQueryable<UserNameView>(sql).ToListAsync();
- if (_userList.Count != 0)
- {
- result.Code = 0;
- result.Msg = "成功!";
- result.Data = _userList;
- }
- else
- {
- result.Msg = "暂无数据!";
- }
- }
- else if (portType == 2) //Android
- {
-
- }
- else if (portType == 3) //IOS
- {
- }
- else
- {
- result.Msg = "暂无数据!";
- }
- return result;
- }
- public async Task<List<UserInfo>> QueryUser(string sqlWhere)
- {
- string sql = string.Format(@"Select sc.CompanyName,sd.DepName,sjp.JobName,su.* From Sys_Users su
- left Join Sys_Company sc On su.CompanyId = sc.Id
- left Join Sys_Department sd On su.DepId = sd.Id
- left Join Sys_JobPost sjp On su.JobPostId = sjp.Id {0}", sqlWhere);
- return await _sqlSugar.SqlQueryable<UserInfo>(sql).ToListAsync();
- }
- }
- }
|