忽略dll文件git

This commit is contained in:
“wanyongkang”
2023-07-29 10:19:42 +08:00
parent 7f97317bcc
commit b562aba2b1
3868 changed files with 63608 additions and 385427 deletions

View File

@@ -1,71 +1,71 @@
using Hncore.Infrastructure.EF;
using Hncore.Pass.Manage.Configs;
using Hncore.Pass.Manage.Domain;
using Hncore.Pass.Manage.Repository;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
using System;
using System.Linq;
using System.Linq.Expressions;
namespace Hncore.Pass.Manage.Service
{
/// <summary>
/// 父业务逻辑类
/// </summary>
///
public abstract class BaseService
{
/// <summary>
/// 配置文件数据承载对象
/// </summary>
protected readonly AppSettings _appSettings;
/// <summary>
/// EF上下文对象
/// </summary>
protected readonly EfDbContext _dbCtx;
/// <summary>
/// 数据库连接字符串
/// </summary>
public string OldDbConString { get { return _appSettings.OldDbConString; } }
/// <summary>
/// 构造函数
/// </summary>
/// <param name="hca">HTTP上下文访问对象</param>
public BaseService(IHttpContextAccessor hca)
{
this._dbCtx= hca.HttpContext.RequestServices.GetService(typeof(EfDbContext)) as EfDbContext;
//获取当前应用配置信息承载对象
var oa=hca.HttpContext.RequestServices.GetService(typeof(IOptionsMonitor<AppSettings>)) as IOptionsMonitor<AppSettings>;
this._appSettings = oa.CurrentValue;
}
/// <summary>
/// 获取操作员有权操作的项目编码列表(可直接用于EF查询中的Labmda查询条件中)
/// </summary>
/// <param name="operaterId">操作员数据库ID</param>
/// <param name="ownerId">隶属的物业ID</param>
/// <returns>有权操作的项目编码列表没有就返回null</returns>
public IQueryable<int> GetManagerProjectCodeList(int operaterId, int ownerId = 0)
{
if (operaterId <= 0)
return null;
Expression<Func<AuthorityManagerDataDomain, bool>> expression = c => c.DeleteTag == 0 && c.ManagerId == operaterId;
if (ownerId > 0)
{//如果传递了物业ID需要动态将物业ID追加到Lambda表达式中去
var p1 = expression.Parameters[0];
var ownerIdExpression = Expression.PropertyOrField(p1, "OwnerId");
var m3 = Expression.Equal(ownerIdExpression, Expression.Constant(ownerId));
var body= Expression.And(expression.Body, m3);
expression = Expression.Lambda<Func<AuthorityManagerDataDomain, bool>>(body, p1);
}
IQueryable<int> list = _dbCtx.Set<AuthorityManagerDataDomain>().GetQueryable().Where(expression).Select(c => c.ProjectCode);
return list;
}
}
}
using Hncore.Infrastructure.EF;
using Hncore.Pass.Manage.Configs;
using Hncore.Pass.Manage.Domain;
using Hncore.Pass.Manage.Repository;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
using System;
using System.Linq;
using System.Linq.Expressions;
namespace Hncore.Pass.Manage.Service
{
/// <summary>
/// 父业务逻辑类
/// </summary>
///
public abstract class BaseService
{
/// <summary>
/// 配置文件数据承载对象
/// </summary>
protected readonly AppSettings _appSettings;
/// <summary>
/// EF上下文对象
/// </summary>
protected readonly EfDbContext _dbCtx;
/// <summary>
/// 数据库连接字符串
/// </summary>
public string OldDbConString { get { return _appSettings.OldDbConString; } }
/// <summary>
/// 构造函数
/// </summary>
/// <param name="hca">HTTP上下文访问对象</param>
public BaseService(IHttpContextAccessor hca)
{
this._dbCtx= hca.HttpContext.RequestServices.GetService(typeof(EfDbContext)) as EfDbContext;
//获取当前应用配置信息承载对象
var oa=hca.HttpContext.RequestServices.GetService(typeof(IOptionsMonitor<AppSettings>)) as IOptionsMonitor<AppSettings>;
this._appSettings = oa.CurrentValue;
}
/// <summary>
/// 获取操作员有权操作的项目编码列表(可直接用于EF查询中的Labmda查询条件中)
/// </summary>
/// <param name="operaterId">操作员数据库ID</param>
/// <param name="ownerId">隶属的物业ID</param>
/// <returns>有权操作的项目编码列表没有就返回null</returns>
public IQueryable<int> GetManagerProjectCodeList(int operaterId, int ownerId = 0)
{
if (operaterId <= 0)
return null;
Expression<Func<AuthorityManagerDataDomain, bool>> expression = c => c.DeleteTag == 0 && c.ManagerId == operaterId;
if (ownerId > 0)
{//如果传递了物业ID需要动态将物业ID追加到Lambda表达式中去
var p1 = expression.Parameters[0];
var ownerIdExpression = Expression.PropertyOrField(p1, "OwnerId");
var m3 = Expression.Equal(ownerIdExpression, Expression.Constant(ownerId));
var body= Expression.And(expression.Body, m3);
expression = Expression.Lambda<Func<AuthorityManagerDataDomain, bool>>(body, p1);
}
IQueryable<int> list = _dbCtx.Set<AuthorityManagerDataDomain>().GetQueryable().Where(expression).Select(c => c.ProjectCode);
return list;
}
}
}

View File

@@ -1,155 +1,155 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using Etor.Infrastructure.Common;
using Etor.Infrastructure.Data;
using Etor.Infrastructure.Extension;
using Etor.PSIP.Manage.Models;
using Etor.PSIP.Manage.Request;
using Etor.PSIP.Manage.Response;
using JWT;
using JWT.Algorithms;
using JWT.Serializers;
using Microsoft.EntityFrameworkCore;
namespace Etor.PSIP.Manage.Service
{
public class ManageService
{
private static string _secret = "etor_yh_lzh_20f_2020_YES";
private EtorPropertyDbContext _dbContext;
public ManageService(EtorPropertyDbContext dbContext)
{
_dbContext = dbContext;
}
public async Task<LoginResponse> Login(LoginRequestData request)
{
if (request == null
|| !request.Code.Has()
|| !request.CodeKey.Has()
|| !request.Logincode.Has()
|| !request.Password.Has()
)
{
BusinessException.Throw("登陆信息异常");
}
string valCode = await RedisHelper.GetAsync(request.CodeKey);
if (!valCode.Has() || valCode.ToLower() != request.Code.ToLower())
{
BusinessException.Throw("验证码错误");
}
var manage = await _dbContext.Set<etor_authority_manager>()
.FirstOrDefaultAsync(m => (m.logincode == request.Logincode || m.phone == request.Logincode)
&& m.DeleteTag == 0
&& m.state == (int) ManagerState.Enabled);
if (manage == null)
{
BusinessException.Throw("登录名不存在");
}
if (HashPassword(request.Password).ToUpper() != manage.password.ToUpper())
{
BusinessException.Throw("密码错误");
}
var tokenDic = new Dictionary<string, object>()
{
{"LoginName", manage.logincode},
{"RoleName", ""},
{"OperaterID", manage.ID},
{"OwnerID", manage.owner_id}
};
var isRoot = await _dbContext.Set<etor_authority_role>().AnyAsync(r => r.DeleteTag == 0
&& r.ID == manage.roleid
&& r.owner_id == manage.owner_id
&& r.isroot);
if (!isRoot)
{
int[] domains = await _dbContext.Set<etor_authority_managerdatadomain>()
.Where(p => p.owner_id == manage.owner_id && p.DeleteTag == 0 && p.managerid == manage.ID)
.Select(t => t.projectcode)
.ToArrayAsync();
tokenDic.Add("DataDomain", domains);
}
var minutes = (DateTime.Now.AddYears(1) - DateTime.Now).TotalMinutes;
var token = GenerateToken(tokenDic, Convert.ToInt32(minutes));
var response = new LoginManagerResponse().FromEntity(manage);
var property = await _dbContext.Set<etor_property>()
.FirstOrDefaultAsync(f => f.ID == manage.owner_id && f.DeleteTag == 0);
response.PropertyCompanyName = property.companyname;
response.ExpiredTime = property.ExpiredTime;
response.ValidDays = (property.ExpiredTime - DateTime.Now.Date).Days;
response.IsRootUser = isRoot;
if (response.Phone.Has())
{
var employee = await _dbContext.EtorNinternalStaff.FirstOrDefaultAsync(_ => _.DeleteTag == 0
&& _.Mobile ==
response.Phone);
if (employee != null)
{
response.WorkerName = employee.Position;
var departmentName = await _dbContext.Set<etor_ninternal_department>()
.Where(_ => _.DeleteTag == 0 && _.ID == employee.Departmentid)
.Select(t => t.departmentname)
.FirstOrDefaultAsync();
response.DepartmentName = departmentName;
}
}
return new LoginResponse()
{
Token = token,
Manager = response
};
}
private static string GenerateToken(Dictionary<string, object> param, int timeoutMinutes = 120)
{
IJwtAlgorithm algorithm = new HMACSHA256Algorithm();
IJsonSerializer serializer = new JsonNetSerializer();
IBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();
IJwtEncoder encoder = new JwtEncoder(algorithm, serializer, urlEncoder);
IDateTimeProvider provider = new UtcDateTimeProvider();
var now = provider.GetNow();
var secondsSinceEpoch = Math.Round((now - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds);
param["exp"] = secondsSinceEpoch + Math.Max(0, timeoutMinutes) * 60; //什么时候签发的
//param["exp"] = secondsSinceEpoch + 1;//什么时候签发的
var token = encoder.Encode(param, _secret);
return token;
}
public static string HashPassword(string password)
{
using (MD5 md5 = MD5.Create())
{
byte[] bytes = md5.ComputeHash(Encoding.UTF8.GetBytes(password));
return Convert.ToBase64String(bytes);
}
}
}
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using Etor.Infrastructure.Common;
using Etor.Infrastructure.Data;
using Etor.Infrastructure.Extension;
using Etor.PSIP.Manage.Models;
using Etor.PSIP.Manage.Request;
using Etor.PSIP.Manage.Response;
using JWT;
using JWT.Algorithms;
using JWT.Serializers;
using Microsoft.EntityFrameworkCore;
namespace Etor.PSIP.Manage.Service
{
public class ManageService
{
private static string _secret = "etor_yh_lzh_20f_2020_YES";
private EtorPropertyDbContext _dbContext;
public ManageService(EtorPropertyDbContext dbContext)
{
_dbContext = dbContext;
}
public async Task<LoginResponse> Login(LoginRequestData request)
{
if (request == null
|| !request.Code.Has()
|| !request.CodeKey.Has()
|| !request.Logincode.Has()
|| !request.Password.Has()
)
{
BusinessException.Throw("登陆信息异常");
}
string valCode = await RedisHelper.GetAsync(request.CodeKey);
if (!valCode.Has() || valCode.ToLower() != request.Code.ToLower())
{
BusinessException.Throw("验证码错误");
}
var manage = await _dbContext.Set<etor_authority_manager>()
.FirstOrDefaultAsync(m => (m.logincode == request.Logincode || m.phone == request.Logincode)
&& m.DeleteTag == 0
&& m.state == (int) ManagerState.Enabled);
if (manage == null)
{
BusinessException.Throw("登录名不存在");
}
if (HashPassword(request.Password).ToUpper() != manage.password.ToUpper())
{
BusinessException.Throw("密码错误");
}
var tokenDic = new Dictionary<string, object>()
{
{"LoginName", manage.logincode},
{"RoleName", ""},
{"OperaterID", manage.ID},
{"OwnerID", manage.owner_id}
};
var isRoot = await _dbContext.Set<etor_authority_role>().AnyAsync(r => r.DeleteTag == 0
&& r.ID == manage.roleid
&& r.owner_id == manage.owner_id
&& r.isroot);
if (!isRoot)
{
int[] domains = await _dbContext.Set<etor_authority_managerdatadomain>()
.Where(p => p.owner_id == manage.owner_id && p.DeleteTag == 0 && p.managerid == manage.ID)
.Select(t => t.projectcode)
.ToArrayAsync();
tokenDic.Add("DataDomain", domains);
}
var minutes = (DateTime.Now.AddYears(1) - DateTime.Now).TotalMinutes;
var token = GenerateToken(tokenDic, Convert.ToInt32(minutes));
var response = new LoginManagerResponse().FromEntity(manage);
var property = await _dbContext.Set<etor_property>()
.FirstOrDefaultAsync(f => f.ID == manage.owner_id && f.DeleteTag == 0);
response.PropertyCompanyName = property.companyname;
response.ExpiredTime = property.ExpiredTime;
response.ValidDays = (property.ExpiredTime - DateTime.Now.Date).Days;
response.IsRootUser = isRoot;
if (response.Phone.Has())
{
var employee = await _dbContext.EtorNinternalStaff.FirstOrDefaultAsync(_ => _.DeleteTag == 0
&& _.Mobile ==
response.Phone);
if (employee != null)
{
response.WorkerName = employee.Position;
var departmentName = await _dbContext.Set<etor_ninternal_department>()
.Where(_ => _.DeleteTag == 0 && _.ID == employee.Departmentid)
.Select(t => t.departmentname)
.FirstOrDefaultAsync();
response.DepartmentName = departmentName;
}
}
return new LoginResponse()
{
Token = token,
Manager = response
};
}
private static string GenerateToken(Dictionary<string, object> param, int timeoutMinutes = 120)
{
IJwtAlgorithm algorithm = new HMACSHA256Algorithm();
IJsonSerializer serializer = new JsonNetSerializer();
IBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();
IJwtEncoder encoder = new JwtEncoder(algorithm, serializer, urlEncoder);
IDateTimeProvider provider = new UtcDateTimeProvider();
var now = provider.GetNow();
var secondsSinceEpoch = Math.Round((now - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds);
param["exp"] = secondsSinceEpoch + Math.Max(0, timeoutMinutes) * 60; //什么时候签发的
//param["exp"] = secondsSinceEpoch + 1;//什么时候签发的
var token = encoder.Encode(param, _secret);
return token;
}
public static string HashPassword(string password)
{
using (MD5 md5 = MD5.Create())
{
byte[] bytes = md5.ComputeHash(Encoding.UTF8.GetBytes(password));
return Convert.ToBase64String(bytes);
}
}
}
}

View File

@@ -1,144 +1,144 @@
using Hncore.Infrastructure.Common;
using Hncore.Infrastructure.DDD;
using Hncore.Infrastructure.WebApi;
using Hncore.Pass.Manage.Domain;
using Hncore.Pass.Manage.Request;
using Hncore.Pass.Manage.Response;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Hncore.Infrastructure.EntitiesExtension;
using Hncore.Pass.Manage.Repository;
using Hncore.Infrastructure.EF;
namespace Hncore.Pass.Manage.Service
{
/// <summary>
/// 管理员业务逻辑类
/// </summary>
///
public class ManagerPermissionService : BaseService
{
EfDbContext m_DbContext { get; set; }
/// <summary>
/// 构造函数
/// </summary>
/// <param name="">管理员标签查询对象</param>
public ManagerPermissionService(EfDbContext _DbContext,
IHttpContextAccessor hca) : base(hca)
{
m_DbContext = _DbContext;
}
/// <summary>
/// 获取管理员权限
/// </summary>
/// <param name="request">请求对象</param>
/// <returns>响应列表对象</returns>
public async Task<List<QueryPermissionResponse>> GetByOperator(QueryByIdRequest param,bool showAll)
{
//获取到所拥有的所有权限
// var meCodes = m_DbContext.Set<ManagerToPermission>().GetQueryable().Where(c => c.DeleteTag == 0 && c.ManagerId == param.Id).Select(c => c.PermissionCode);
// var search = m_DbContext.Set<Permission>().GetQueryable().Where(c => c.DeleteTag == 0 && c.Systemid == 100 && meCodes.Contains(c.Permissioncode));
var managerpPrmissions = new List<ManagerToPermission>();
var manager = await m_DbContext.Set<Manager>().FindByIdAsync(param.Id);
var permissions = m_DbContext.Set<Permission>().GetQueryable()
.Where(c => c.DeleteTag == 0 && c.Systemid == 100)
.OrderBy(m => m.Sortorder)
.ToList();
if (manager.IsRoot)
{
permissions.ForEach(m => {
managerpPrmissions.Add(new ManagerToPermission()
{
AllowAdd = 1,
AllowDel = 1,
AllowEdit = 1,
AllowView = 1,
ManagerId = manager.Id,
PermissionCode = m.Permissioncode,
TenantId = manager.TenantId,
});
});
}
else
{
managerpPrmissions = m_DbContext.Set<ManagerToPermission>().GetQueryable().Where(c => c.DeleteTag == 0 && c.ManagerId == param.Id).ToList();
}
List<QueryPermissionResponse> result = CreatePermissionList(permissions, "0", managerpPrmissions, showAll);
return result;
}
/// <summary>
/// 组装权限列表
/// </summary>
/// <param name="all">所有的权限列表</param>
/// <param name="parentCode">父级权限编码</param>
/// <returns>组装好的列表</returns>
private List<QueryPermissionResponse> CreatePermissionList(List<Permission> all, string parentCode, List<ManagerToPermission> mlist, bool showAll=true)
{
var list = all.Where(c => c.Parentcode == parentCode);
if (list == null || list.Count() <= 0)
return null;
List<QueryPermissionResponse> result = new List<QueryPermissionResponse>();
foreach (var item in list)
{
QueryPermissionResponse mdl = ConvertToQueryPermission(item, mlist, showAll);
if (mdl == null) continue;
var child = all.Where(c => c.Parentcode == item.Permissioncode);
if (child != null && child.Count() > 0)
mdl.Children = CreatePermissionList(all, item.Permissioncode, mlist, showAll);
result.Add(mdl);
}
return result;
}
/// <summary>
/// 实体转换返回数据对象
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
private QueryPermissionResponse ConvertToQueryPermission(Permission item, List<ManagerToPermission> mlist,bool showAll=true)
{
var one = mlist.FirstOrDefault(t => t.PermissionCode == item.Permissioncode);
QueryPermissionResponse mp = new QueryPermissionResponse();
if (one != null)
{
mp.AllowAdd = true;
mp.AllowDel = true;
mp.AllowEdit = true;
mp.AllowView = true;
}
if (one == null && !showAll) return null;
mp.Id = item.Id;
mp.Permissioncode = item.Permissioncode;
mp.Permissionlabel = item.Permissionlabel;
mp.Permissionurl = item.Permissionurl;
mp.Parentcode = item.Parentcode;
mp.DeleteTag = item.DeleteTag;
mp.CreatorId = item.CreatorId;
mp.CreateTime = item.CreateTime;
mp.UpdateTime = item.UpdateTime;
mp.Sortorder = item.Sortorder;
mp.Icon = item.Icon;
mp.Iconactivate = item.Iconactivate;
mp.Systemid = item.Systemid;
mp.isnew = item.isnew;
return mp;
}
}
}
using Hncore.Infrastructure.Common;
using Hncore.Infrastructure.DDD;
using Hncore.Infrastructure.WebApi;
using Hncore.Pass.Manage.Domain;
using Hncore.Pass.Manage.Request;
using Hncore.Pass.Manage.Response;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Hncore.Infrastructure.EntitiesExtension;
using Hncore.Pass.Manage.Repository;
using Hncore.Infrastructure.EF;
namespace Hncore.Pass.Manage.Service
{
/// <summary>
/// 管理员业务逻辑类
/// </summary>
///
public class ManagerPermissionService : BaseService
{
EfDbContext m_DbContext { get; set; }
/// <summary>
/// 构造函数
/// </summary>
/// <param name="">管理员标签查询对象</param>
public ManagerPermissionService(EfDbContext _DbContext,
IHttpContextAccessor hca) : base(hca)
{
m_DbContext = _DbContext;
}
/// <summary>
/// 获取管理员权限
/// </summary>
/// <param name="request">请求对象</param>
/// <returns>响应列表对象</returns>
public async Task<List<QueryPermissionResponse>> GetByOperator(QueryByIdRequest param,bool showAll)
{
//获取到所拥有的所有权限
// var meCodes = m_DbContext.Set<ManagerToPermission>().GetQueryable().Where(c => c.DeleteTag == 0 && c.ManagerId == param.Id).Select(c => c.PermissionCode);
// var search = m_DbContext.Set<Permission>().GetQueryable().Where(c => c.DeleteTag == 0 && c.Systemid == 100 && meCodes.Contains(c.Permissioncode));
var managerpPrmissions = new List<ManagerToPermission>();
var manager = await m_DbContext.Set<Manager>().FindByIdAsync(param.Id);
var permissions = m_DbContext.Set<Permission>().GetQueryable()
.Where(c => c.DeleteTag == 0 && c.Systemid == 100)
.OrderBy(m => m.Sortorder)
.ToList();
if (manager.IsRoot)
{
permissions.ForEach(m => {
managerpPrmissions.Add(new ManagerToPermission()
{
AllowAdd = 1,
AllowDel = 1,
AllowEdit = 1,
AllowView = 1,
ManagerId = manager.Id,
PermissionCode = m.Permissioncode,
TenantId = manager.TenantId,
});
});
}
else
{
managerpPrmissions = m_DbContext.Set<ManagerToPermission>().GetQueryable().Where(c => c.DeleteTag == 0 && c.ManagerId == param.Id).ToList();
}
List<QueryPermissionResponse> result = CreatePermissionList(permissions, "0", managerpPrmissions, showAll);
return result;
}
/// <summary>
/// 组装权限列表
/// </summary>
/// <param name="all">所有的权限列表</param>
/// <param name="parentCode">父级权限编码</param>
/// <returns>组装好的列表</returns>
private List<QueryPermissionResponse> CreatePermissionList(List<Permission> all, string parentCode, List<ManagerToPermission> mlist, bool showAll=true)
{
var list = all.Where(c => c.Parentcode == parentCode);
if (list == null || list.Count() <= 0)
return null;
List<QueryPermissionResponse> result = new List<QueryPermissionResponse>();
foreach (var item in list)
{
QueryPermissionResponse mdl = ConvertToQueryPermission(item, mlist, showAll);
if (mdl == null) continue;
var child = all.Where(c => c.Parentcode == item.Permissioncode);
if (child != null && child.Count() > 0)
mdl.Children = CreatePermissionList(all, item.Permissioncode, mlist, showAll);
result.Add(mdl);
}
return result;
}
/// <summary>
/// 实体转换返回数据对象
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
private QueryPermissionResponse ConvertToQueryPermission(Permission item, List<ManagerToPermission> mlist,bool showAll=true)
{
var one = mlist.FirstOrDefault(t => t.PermissionCode == item.Permissioncode);
QueryPermissionResponse mp = new QueryPermissionResponse();
if (one != null)
{
mp.AllowAdd = true;
mp.AllowDel = true;
mp.AllowEdit = true;
mp.AllowView = true;
}
if (one == null && !showAll) return null;
mp.Id = item.Id;
mp.Permissioncode = item.Permissioncode;
mp.Permissionlabel = item.Permissionlabel;
mp.Permissionurl = item.Permissionurl;
mp.Parentcode = item.Parentcode;
mp.DeleteTag = item.DeleteTag;
mp.CreatorId = item.CreatorId;
mp.CreateTime = item.CreateTime;
mp.UpdateTime = item.UpdateTime;
mp.Sortorder = item.Sortorder;
mp.Icon = item.Icon;
mp.Iconactivate = item.Iconactivate;
mp.Systemid = item.Systemid;
mp.isnew = item.isnew;
return mp;
}
}
}

View File

@@ -1,96 +1,96 @@
using Hncore.Infrastructure.Common;
using Hncore.Infrastructure.DDD;
using Hncore.Infrastructure.EF;
using Hncore.Infrastructure.WebApi;
using Hncore.Pass.Manage.Domain;
using Hncore.Pass.Manage.Repository;
using Hncore.Pass.Manage.Request;
using Hncore.Pass.Manage.Response;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace Hncore.Pass.Manage.Service
{
/// <summary>
/// 管理员业务逻辑类
/// </summary>
///
public class ManagerService : BaseService
{
EfDbContext m_DbContext { get; set; }
/// <summary>
/// 构造函数
/// </summary>
/// <param name="">管理员标签查询对象</param>
public ManagerService(EfDbContext _DbContext,
IHttpContextAccessor hca) : base(hca)
{
m_DbContext = _DbContext;
}
/// <summary>
/// 获取管理员列表
/// </summary>
/// <param name="request">请求对象</param>
/// <returns>响应列表对象</returns>
public async Task<(int total, List<QueryListManagerResponse> list)> Get(QueryListManagerRequest request)
{
var root =m_DbContext.Set<Manager>().GetOne(p=>p.Id==request.OperaterId && p.IsRoot == true);
IQueryable<Manager> managers;
if (null ==root)
{
managers = m_DbContext.Set<Manager>().GetQueryable().Where(m => m.CreatorId == request.OperaterId && m.IsRoot == false);
}else
{
managers = m_DbContext.Set<Manager>().GetQueryable().Where(m => m.TenantId == request.TenantId && m.DeleteTag == 0);
//是否过滤超级管理员
if (request.IsRoot == 1)
managers = managers.Where(m => m.IsRoot == false);
}
var search = managers;
//过滤关键字
if (!string.IsNullOrEmpty(request.KeyWord))
search = search.Where(m => m.LoginCode.Contains(request.KeyWord) || m.RealName.Contains(request.KeyWord) || m.Phone.Contains(request.KeyWord));
int total = await search.CountAsync();//异步查询记录总数
//排序分页
var list = search.OrderByDescending(m => m.UpdateTime).Skip((request.PageIndex-1) * request.PageSize).Take(request.PageSize).ToList();
List<QueryListManagerResponse> result = new List<QueryListManagerResponse>();
foreach (var item in list)
{
QueryListManagerResponse m = new QueryListManagerResponse();
m.Id = item.Id;
m.LoginCode = item.LoginCode;
m.OwnerId = request.TenantId;
m.Phone = item.Phone;
m.Photourl = item.PhotoUrl;
m.RealName = item.RealName;
m.CreateTime = item.CreateTime;
m.UpdateTime = item.UpdateTime;
m.CreatorId = item.CreatorId;
m.UpdatorId = item.UpdatorId;
m.DeleteTag = item.DeleteTag;
m.Wxopenid = item.WxOpenid;
m.roleid = item.RoleId;
result.Add(m);
}
return (total,result);
}
}
}
using Hncore.Infrastructure.Common;
using Hncore.Infrastructure.DDD;
using Hncore.Infrastructure.EF;
using Hncore.Infrastructure.WebApi;
using Hncore.Pass.Manage.Domain;
using Hncore.Pass.Manage.Repository;
using Hncore.Pass.Manage.Request;
using Hncore.Pass.Manage.Response;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace Hncore.Pass.Manage.Service
{
/// <summary>
/// 管理员业务逻辑类
/// </summary>
///
public class ManagerService : BaseService
{
EfDbContext m_DbContext { get; set; }
/// <summary>
/// 构造函数
/// </summary>
/// <param name="">管理员标签查询对象</param>
public ManagerService(EfDbContext _DbContext,
IHttpContextAccessor hca) : base(hca)
{
m_DbContext = _DbContext;
}
/// <summary>
/// 获取管理员列表
/// </summary>
/// <param name="request">请求对象</param>
/// <returns>响应列表对象</returns>
public async Task<(int total, List<QueryListManagerResponse> list)> Get(QueryListManagerRequest request)
{
var root =m_DbContext.Set<Manager>().GetOne(p=>p.Id==request.OperaterId && p.IsRoot == true);
IQueryable<Manager> managers;
if (null ==root)
{
managers = m_DbContext.Set<Manager>().GetQueryable().Where(m => m.CreatorId == request.OperaterId && m.IsRoot == false);
}else
{
managers = m_DbContext.Set<Manager>().GetQueryable().Where(m => m.TenantId == request.TenantId && m.DeleteTag == 0);
//是否过滤超级管理员
if (request.IsRoot == 1)
managers = managers.Where(m => m.IsRoot == false);
}
var search = managers;
//过滤关键字
if (!string.IsNullOrEmpty(request.KeyWord))
search = search.Where(m => m.LoginCode.Contains(request.KeyWord) || m.RealName.Contains(request.KeyWord) || m.Phone.Contains(request.KeyWord));
int total = await search.CountAsync();//异步查询记录总数
//排序分页
var list = search.OrderByDescending(m => m.UpdateTime).Skip((request.PageIndex-1) * request.PageSize).Take(request.PageSize).ToList();
List<QueryListManagerResponse> result = new List<QueryListManagerResponse>();
foreach (var item in list)
{
QueryListManagerResponse m = new QueryListManagerResponse();
m.Id = item.Id;
m.LoginCode = item.LoginCode;
m.OwnerId = request.TenantId;
m.Phone = item.Phone;
m.Photourl = item.PhotoUrl;
m.RealName = item.RealName;
m.CreateTime = item.CreateTime;
m.UpdateTime = item.UpdateTime;
m.CreatorId = item.CreatorId;
m.UpdatorId = item.UpdatorId;
m.DeleteTag = item.DeleteTag;
m.Wxopenid = item.WxOpenid;
m.roleid = item.RoleId;
result.Add(m);
}
return (total,result);
}
}
}

View File

@@ -1,107 +1,107 @@
using Hncore.Infrastructure.DDD;
using Hncore.Infrastructure.WebApi;
using Hncore.Pass.Manage.Domain;
using Hncore.Pass.Manage.Request;
using Hncore.Pass.Manage.Response;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Hncore.Infrastructure.Common;
using Hncore.Infrastructure.Serializer;
using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers;
using Hncore.Pass.Manage.Repository;
using Hncore.Infrastructure.EF;
namespace Hncore.Pass.Manage.Service
{
/// <summary>
/// 管理员标签业务逻辑类
/// </summary>
///
public class ManagerTagService : BaseService
{
EfDbContext m_DbContext { get; set; }
/// <summary>
/// 构造函数
/// </summary>
/// <param name="feePayRecordQuery">管理员标签查询对象</param>
public ManagerTagService(EfDbContext _DbContext,
IHttpContextAccessor hca) : base(hca)
{
m_DbContext = _DbContext;
}
/// <summary>
/// 获取管理员标签
/// </summary>
/// <param name="request">请求对象</param>
/// <returns>响应列表对象</returns>
public async Task<(int total, List<ManagerTagResponse> list)> GetTagList(ManagerTagRequest request)
{
Expression<Func<ManagerTag, bool>> exp = c =>(c.OwnerId==request.TenantId && c.DeleteTag == 0 && c.ManagerId == request.ManagerId && c.TagType==0)|| c.TagType==1;
var search = m_DbContext.Set<ManagerTag>().GetQueryable().Where(exp);
if (!EnvironmentVariableHelper.IsAspNetCoreProduction)
{
LogHelper.Debug("获取管理员标签",request.ToJson(true));
}
int total = await search.CountAsync();//异步查询记录总数
var paged = await search.OrderByDescending(c=>c.TagType).ToListAsync();
List<ManagerTagResponse> list = new List<ManagerTagResponse>();
foreach (var item in paged)
{
ManagerTagResponse mtr =new ManagerTagResponse() ;
mtr.Id = item.Id;
mtr.Tag = item.Tag;
mtr.TagType = item.TagType;
mtr.ManagerId = item.ManagerId;
mtr.CreateTime = item.CreateTime;
mtr.UpdateTime = item.UpdateTime;
list.Add(mtr);
}
return (total, list);
}
/// <summary>
/// 获取管理员标签权限信息
/// </summary>
/// <param name="request">请求对象</param>
/// <returns>响应列表对象</returns>
public async Task<(int total, List<ManagerTagToPermissionResponse> list)> GetTagToPerssionList(ManagerTagToPerRequest request)
{
Expression<Func<ManagerTagToPermission, bool>> exp = c => c.ManagerTagId == request.ManagerTagId;
var search = m_DbContext.Set<ManagerTagToPermission>().GetQueryable().Where(exp);
int total = await search.CountAsync();//异步查询记录总数
var paged = await search.OrderByDescending(c => c.Id).ToListAsync();
List<ManagerTagToPermissionResponse> list = new List<ManagerTagToPermissionResponse>();
foreach (var item in paged)
{
ManagerTagToPermissionResponse mp = new ManagerTagToPermissionResponse();
mp.Id = item.Id;
mp.ManagerTagId = item.ManagerTagId;
mp.PermissionCode = item.PermissionCode;
mp.AllowView = item.AllowView;
mp.AllowAdd = item.AllowAdd;
mp.AllowEdit = item.AllowEdit;
mp.AllowDel = item.AllowDel;
mp.CreateTime = item.CreateTime;
mp.UpdateTime = item.UpdateTime;
list.Add(mp);
}
return (total, list);
}
}
}
using Hncore.Infrastructure.DDD;
using Hncore.Infrastructure.WebApi;
using Hncore.Pass.Manage.Domain;
using Hncore.Pass.Manage.Request;
using Hncore.Pass.Manage.Response;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Hncore.Infrastructure.Common;
using Hncore.Infrastructure.Serializer;
using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers;
using Hncore.Pass.Manage.Repository;
using Hncore.Infrastructure.EF;
namespace Hncore.Pass.Manage.Service
{
/// <summary>
/// 管理员标签业务逻辑类
/// </summary>
///
public class ManagerTagService : BaseService
{
EfDbContext m_DbContext { get; set; }
/// <summary>
/// 构造函数
/// </summary>
/// <param name="feePayRecordQuery">管理员标签查询对象</param>
public ManagerTagService(EfDbContext _DbContext,
IHttpContextAccessor hca) : base(hca)
{
m_DbContext = _DbContext;
}
/// <summary>
/// 获取管理员标签
/// </summary>
/// <param name="request">请求对象</param>
/// <returns>响应列表对象</returns>
public async Task<(int total, List<ManagerTagResponse> list)> GetTagList(ManagerTagRequest request)
{
Expression<Func<ManagerTag, bool>> exp = c =>(c.OwnerId==request.TenantId && c.DeleteTag == 0 && c.ManagerId == request.ManagerId && c.TagType==0)|| c.TagType==1;
var search = m_DbContext.Set<ManagerTag>().GetQueryable().Where(exp);
if (!EnvironmentVariableHelper.IsAspNetCoreProduction)
{
LogHelper.Debug("获取管理员标签",request.ToJson(true));
}
int total = await search.CountAsync();//异步查询记录总数
var paged = await search.OrderByDescending(c=>c.TagType).ToListAsync();
List<ManagerTagResponse> list = new List<ManagerTagResponse>();
foreach (var item in paged)
{
ManagerTagResponse mtr =new ManagerTagResponse() ;
mtr.Id = item.Id;
mtr.Tag = item.Tag;
mtr.TagType = item.TagType;
mtr.ManagerId = item.ManagerId;
mtr.CreateTime = item.CreateTime;
mtr.UpdateTime = item.UpdateTime;
list.Add(mtr);
}
return (total, list);
}
/// <summary>
/// 获取管理员标签权限信息
/// </summary>
/// <param name="request">请求对象</param>
/// <returns>响应列表对象</returns>
public async Task<(int total, List<ManagerTagToPermissionResponse> list)> GetTagToPerssionList(ManagerTagToPerRequest request)
{
Expression<Func<ManagerTagToPermission, bool>> exp = c => c.ManagerTagId == request.ManagerTagId;
var search = m_DbContext.Set<ManagerTagToPermission>().GetQueryable().Where(exp);
int total = await search.CountAsync();//异步查询记录总数
var paged = await search.OrderByDescending(c => c.Id).ToListAsync();
List<ManagerTagToPermissionResponse> list = new List<ManagerTagToPermissionResponse>();
foreach (var item in paged)
{
ManagerTagToPermissionResponse mp = new ManagerTagToPermissionResponse();
mp.Id = item.Id;
mp.ManagerTagId = item.ManagerTagId;
mp.PermissionCode = item.PermissionCode;
mp.AllowView = item.AllowView;
mp.AllowAdd = item.AllowAdd;
mp.AllowEdit = item.AllowEdit;
mp.AllowDel = item.AllowDel;
mp.CreateTime = item.CreateTime;
mp.UpdateTime = item.UpdateTime;
list.Add(mp);
}
return (total, list);
}
}
}