using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Common; using Common.DJYModel; using Common.Extensions; using djy.IService.Djy; namespace djy.Service.DjyService { /// /// /// public class DjyUserService :DbContext, IDjyUserService { public ReturnResult GetUserBaseinfo(string usergid) { var rs = new ReturnResult(); rs.Data = DbBus.Get(DbList.djyolddb).Select().Where(w => w.USERID == usergid).ToOne(); rs.OK(); return rs; } public ReturnResult GetUserInfo(string usergid) { var rs = new ReturnResult(); var user = DjyTools.RedisGet("UserInfo_"+usergid); if (user==null) { user = DbBus.Get(DbList.djyolddb).Select().Where(w => w.GID == usergid).ToOne(); if (user != null) { DjyTools.RedisSet("UserInfo_" + usergid, user, sysOptionConfig.Webconfig.cache_time); } } rs.Data = user; rs.OK(); return rs; } public ReturnResult GetUserAuthority(Guid? UserId, string PageKeyName) { var rs =new ReturnResult(); var getdata = GetUserAuthorityList(new DJyUserAuthorityDto {UserId=UserId,KeyName=PageKeyName }); if (getdata.Status) { if (getdata.Data.Count > 0) { rs.Data = getdata.Data[0]; rs.OK(); } } return rs; } /// /// 获取大简云用户权限列表 查询条件[KeyName] /// /// public ReturnResult> GetUserAuthorityList(DJyUserAuthorityDto Dto) { var rs = new ReturnResult>(); try { if (Dto == null || Dto.UserId == null) { rs.Not("userid 丢失"); return rs; } var userid = Dto.UserId; List list; var rkey = "UserAuthorityList_" + userid.ToString(); list = DjyTools.RedisGet>(rkey); var getlist=new List(); if (list == null || list.Count == 0) { var strSql = new StringBuilder(); strSql.Append("SELECT * FROM ( "); strSql.Append("SELECT GID,USERID,VISIBLERANGE,OPERATERANGE,AUTHORITYID,DESCRIPTION,NAME as KeyName,ISNULL((case VISIBLERANGE when 0 then '全部' when 1 then '本公司' "); strSql.Append("when 2 then '本部门' when 3 then '本人' when 4 then '无' when 5 then '选择公司' "); strSql.Append("when 6 then '选择人员' when 7 then '注册公司' end),'') VISIBLERANGEREF,ISNULL((case OPERATERANGE when 0 then '全部' when 1 then '本公司' "); strSql.Append("when 2 then '本部门' when 3 then '本人' when 4 then '无' when 5 then '选择公司' "); strSql.Append("when 6 then '选择人员' when 7 then '注册公司' end),'') OPERATERANGEREF "); strSql.Append(" from VW_User_Authority "); strSql.Append(" where USERID='" + userid + "'"); strSql.Append(" UNION SELECT '' GID,'" + userid + "' USERID, 4 VISIBLERANGE,4 OPERATERANGE,GID AUTHORITYID,DESCRIPTION,NAME, "); strSql.Append(" '无' VISIBLERANGEREF,'无' OPERATERANGEREF "); strSql.Append(" from user_authority_info "); strSql.Append(" where GID NOT IN (SELECT AUTHORITYID FROM user_authority_range WHERE USERID='" + userid + "')"); strSql.Append(" ) AS DL "); list = DbBus.Get(DbList.djyolddb).Ado.Query(strSql.ToString()); DjyTools.RedisSet(rkey,list, sysOptionConfig.Webconfig.cache_time); } if (Dto.KeyName.IsNotNull()) { getlist = list.Where(w => w.KeyName == Dto.KeyName).ToList(); } rs.Data = getlist; rs.OK(); } catch { } return rs; } } }