You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
4.1 KiB
C#
111 lines
4.1 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class DjyUserService :DbContext, IDjyUserService
|
|
{
|
|
public ReturnResult<UserBaseinfo> GetUserBaseinfo(string usergid)
|
|
{
|
|
var rs = new ReturnResult<UserBaseinfo>();
|
|
rs.Data = DbBus.Get(DbList.djyolddb).Select<UserBaseinfo>().Where(w => w.USERID == usergid).ToOne();
|
|
rs.OK();
|
|
return rs;
|
|
}
|
|
|
|
public ReturnResult<User> GetUserInfo(string usergid)
|
|
{
|
|
|
|
var rs = new ReturnResult<User>();
|
|
var user = DjyTools.RedisGet<User>("UserInfo_"+usergid);
|
|
if (user==null) {
|
|
user = DbBus.Get(DbList.djyolddb).Select<User>().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<DJyUserAuthorityDto> GetUserAuthority(Guid? UserId, string PageKeyName)
|
|
{
|
|
var rs =new ReturnResult<DJyUserAuthorityDto>();
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取大简云用户权限列表 查询条件[KeyName]
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public ReturnResult<List<DJyUserAuthorityDto>> GetUserAuthorityList(DJyUserAuthorityDto Dto) {
|
|
|
|
var rs = new ReturnResult<List<DJyUserAuthorityDto>>();
|
|
try
|
|
{
|
|
if (Dto == null || Dto.UserId == null)
|
|
{
|
|
rs.Not("userid 丢失");
|
|
|
|
return rs;
|
|
}
|
|
|
|
var userid = Dto.UserId;
|
|
List<DJyUserAuthorityDto> list;
|
|
var rkey = "UserAuthorityList_" + userid.ToString();
|
|
list = DjyTools.RedisGet<List<DJyUserAuthorityDto>>(rkey);
|
|
var getlist=new List<DJyUserAuthorityDto>();
|
|
|
|
if (list == null || list.Count == 0)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
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 + "'");
|
|
|
|
|
|
list = DbBus.Get(DbList.djyolddb).Ado.Query<DJyUserAuthorityDto>(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;
|
|
}
|
|
}
|
|
}
|