|
|
|
@ -15,6 +15,7 @@ using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Yitter.IdGenerator;
|
|
|
|
|
using Furion;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Core.Service;
|
|
|
|
|
|
|
|
|
@ -59,7 +60,7 @@ public class SysUserService : ISysUserService, IDynamicApiController, ITransient
|
|
|
|
|
var searchValue = input.SearchValue;
|
|
|
|
|
var pid = input.SysEmpParam.OrgId;
|
|
|
|
|
var users = await _sysUserRep.AsQueryable().InnerJoin<SysEmp>((u, e) => u.Id == e.Id)
|
|
|
|
|
.InnerJoin<SysOrg>((u, e, o)=> e.OrgId == o.Id)
|
|
|
|
|
.InnerJoin<SysOrg>((u, e, o) => e.OrgId == o.Id)
|
|
|
|
|
.InnerJoin<SysTenant>((u, e, o, t) => u.TenantId == t.Id)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(searchValue), (u, e, o) => u.Account.Contains(input.SearchValue.Trim()) ||
|
|
|
|
|
u.Name.Contains(input.SearchValue.Trim()) ||
|
|
|
|
@ -68,9 +69,9 @@ public class SysUserService : ISysUserService, IDynamicApiController, ITransient
|
|
|
|
|
o.Pids.Contains(pid.Trim()))
|
|
|
|
|
.WhereIF(Enum.IsDefined(typeof(CommonStatus), input.SearchStatus), (u, e, o) => u.Status == input.SearchStatus)
|
|
|
|
|
.Where((u, e, o) => u.AdminType == AdminType.None)
|
|
|
|
|
.Select<UserOutput>("u.*,t.Name As TenantName ").ToDataFilter("u","Id",FilterType.User).ToPagedListAsync(input.PageNo, input.PageSize);
|
|
|
|
|
.Select<UserOutput>("u.*,t.Name As TenantName ").ToDataFilter("u", "Id", FilterType.User).ToPagedListAsync(input.PageNo, input.PageSize);
|
|
|
|
|
|
|
|
|
|
var empInfos =await _sysEmpService.GetEmpInfo(users.Items.Select(m => long.Parse(m.Id)).ToList());
|
|
|
|
|
var empInfos = await _sysEmpService.GetEmpInfo(users.Items.Select(m => long.Parse(m.Id)).ToList());
|
|
|
|
|
foreach (var user in users.Items)
|
|
|
|
|
{
|
|
|
|
|
user.SysEmpInfo = empInfos.FirstOrDefault(m => m.Id == long.Parse(user.Id));
|
|
|
|
@ -97,9 +98,10 @@ public class SysUserService : ISysUserService, IDynamicApiController, ITransient
|
|
|
|
|
var isExist = await _sysUserRep.AnyAsync(u => u.Account == input.Account);
|
|
|
|
|
if (isExist) throw Oops.Oh(ErrorCode.D1003);
|
|
|
|
|
|
|
|
|
|
var keyDES = App.GetOptions<EncryptKeyOptions>().DES;
|
|
|
|
|
var user = input.Adapt<SysUser>();
|
|
|
|
|
user.AdminType = AdminType.None;
|
|
|
|
|
user.Password = MD5Encryption.Encrypt(input.Password);
|
|
|
|
|
user.Password = DESCEncryption.Encrypt(input.Password, keyDES);
|
|
|
|
|
if (string.IsNullOrEmpty(user.Name))
|
|
|
|
|
user.Name = user.Account;
|
|
|
|
|
if (string.IsNullOrEmpty(user.NickName))
|
|
|
|
@ -148,7 +150,7 @@ public class SysUserService : ISysUserService, IDynamicApiController, ITransient
|
|
|
|
|
{
|
|
|
|
|
_sysUserRep.CurrentBeginTran();
|
|
|
|
|
// 直接删除用户
|
|
|
|
|
await _sysUserRep.AsUpdateable(new SysUser {IsDeleted = true}).UpdateColumns(user.FalseDeleteColumn()).Where(wh => wh.Id == user.Id).ExecuteCommandAsync();
|
|
|
|
|
await _sysUserRep.AsUpdateable(new SysUser { IsDeleted = true }).UpdateColumns(user.FalseDeleteColumn()).Where(wh => wh.Id == user.Id).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
// 删除员工及附属机构职位信息
|
|
|
|
|
await _sysEmpService.DeleteEmpInfoByUserId(user.Id);
|
|
|
|
@ -297,10 +299,11 @@ public class SysUserService : ISysUserService, IDynamicApiController, ITransient
|
|
|
|
|
[HttpPost("/sysUser/updatePwd")]
|
|
|
|
|
public async Task UpdateUserPwd(ChangePasswordUserInput input)
|
|
|
|
|
{
|
|
|
|
|
var keyDES = App.GetOptions<EncryptKeyOptions>().DES;
|
|
|
|
|
var user = await _sysUserRep.FirstOrDefaultAsync(u => u.Id == input.Id);
|
|
|
|
|
if (MD5Encryption.Encrypt(input.Password) != user.Password)
|
|
|
|
|
if (DESCEncryption.Encrypt(input.Password, keyDES) != user.Password)
|
|
|
|
|
throw Oops.Oh(ErrorCode.D1004);
|
|
|
|
|
user.Password = MD5Encryption.Encrypt(input.NewPassword);
|
|
|
|
|
user.Password = DESCEncryption.Encrypt(input.NewPassword, keyDES);
|
|
|
|
|
await _sysUserRep.AsUpdateable(user).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -334,8 +337,9 @@ public class SysUserService : ISysUserService, IDynamicApiController, ITransient
|
|
|
|
|
[HttpPost("/sysUser/resetPwd")]
|
|
|
|
|
public async Task ResetUserPwd(QueryUserInput input)
|
|
|
|
|
{
|
|
|
|
|
var keyDES = App.GetOptions<EncryptKeyOptions>().DES;
|
|
|
|
|
var user = await _sysUserRep.FirstOrDefaultAsync(u => u.Id == input.Id);
|
|
|
|
|
user.Password = MD5Encryption.Encrypt(await _sysConfigService.GetDefaultPassword());
|
|
|
|
|
user.Password = DESCEncryption.Encrypt(await _sysConfigService.GetDefaultPassword(), keyDES);
|
|
|
|
|
await _sysUserRep.AsUpdateable(user).IgnoreColumns(it => new { it.AdminType }).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -382,7 +386,7 @@ public class SysUserService : ISysUserService, IDynamicApiController, ITransient
|
|
|
|
|
|
|
|
|
|
//这里如果报错看下AdminType的值 不能是0,必须是在枚举值内的
|
|
|
|
|
var users = await _sysUserRep.ToListAsync();
|
|
|
|
|
if(!users.Any())
|
|
|
|
|
if (!users.Any())
|
|
|
|
|
throw Oops.Oh("没有数据");
|
|
|
|
|
var memoryStream = new MemoryStream();
|
|
|
|
|
memoryStream.SaveAs(users);
|
|
|
|
@ -492,7 +496,7 @@ public class SysUserService : ISysUserService, IDynamicApiController, ITransient
|
|
|
|
|
if (!UserManager.IsSuperAdmin)
|
|
|
|
|
{
|
|
|
|
|
var dataScopes = await GetUserDataScopeIdList(UserManager.UserId);
|
|
|
|
|
if (dataScopes == null ||orgId <= 0|| !dataScopes.Contains(orgId))
|
|
|
|
|
if (dataScopes == null || orgId <= 0 || !dataScopes.Contains(orgId))
|
|
|
|
|
throw Oops.Oh(ErrorCode.D1013);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -503,10 +507,10 @@ public class SysUserService : ISysUserService, IDynamicApiController, ITransient
|
|
|
|
|
[NonAction]
|
|
|
|
|
public async Task<List<long>> GetDataScopeIdUserList(long userId = 0)
|
|
|
|
|
{
|
|
|
|
|
userId = userId<=0? UserManager.UserId: userId;
|
|
|
|
|
userId = userId <= 0 ? UserManager.UserId : userId;
|
|
|
|
|
var list = await _sysCacheService.GetUsersDataScope(userId); // 先从缓存里面读取
|
|
|
|
|
if (list == null || list.Count < 1)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
var dataScopes = await GetUserDataScopeIdList(userId);
|
|
|
|
|
list = (await _sysEmpService.HasOrgEmp(dataScopes)).Select(a => a.Id).ToList();
|
|
|
|
|
list.Add(userId);
|
|
|
|
|