|
|
|
@ -4,11 +4,17 @@ using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.AppDictionaries.O |
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.Auth.Output; |
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.Auth.Output; |
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.Menu.Output; |
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.Menu.Output; |
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.Role.Output; |
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.Role.Output; |
|
|
|
|
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.SMS; |
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.User; |
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.User; |
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.User.Input; |
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.User.Input; |
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.User.Output; |
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.User.Output; |
|
|
|
|
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppCaseManagements.AppCaseManagement; |
|
|
|
|
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.PunchRecordServices.Output; |
|
|
|
|
|
|
|
using ATS.NonCustodial.Application.Impl.Business.CaseManagements; |
|
|
|
using ATS.NonCustodial.Domain.Entities.Admins; |
|
|
|
using ATS.NonCustodial.Domain.Entities.Admins; |
|
|
|
|
|
|
|
using ATS.NonCustodial.Domain.Entities.Business.CaseManagements; |
|
|
|
using ATS.NonCustodial.Domain.Shared.AggRootEntities.Dtos; |
|
|
|
using ATS.NonCustodial.Domain.Shared.AggRootEntities.Dtos; |
|
|
|
|
|
|
|
using ATS.NonCustodial.Domain.Shared.Enums; |
|
|
|
using ATS.NonCustodial.Domain.Shared.OrmRepositories.Basic.EfCore; |
|
|
|
using ATS.NonCustodial.Domain.Shared.OrmRepositories.Basic.EfCore; |
|
|
|
using ATS.NonCustodial.DynamicApi; |
|
|
|
using ATS.NonCustodial.DynamicApi; |
|
|
|
using ATS.NonCustodial.DynamicApi.Attributes; |
|
|
|
using ATS.NonCustodial.DynamicApi.Attributes; |
|
|
|
@ -28,6 +34,7 @@ using Castle.Components.DictionaryAdapter; |
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
|
|
|
|
using StackExchange.Profiling.Internal; |
|
|
|
using Yitter.IdGenerator; |
|
|
|
using Yitter.IdGenerator; |
|
|
|
|
|
|
|
|
|
|
|
namespace ATS.NonCustodial.Application.Impl.Admins |
|
|
|
namespace ATS.NonCustodial.Application.Impl.Admins |
|
|
|
@ -50,16 +57,21 @@ namespace ATS.NonCustodial.Application.Impl.Admins |
|
|
|
private readonly IEfRepository<AppRolePermission?, long> _rolePermissionRepository; |
|
|
|
private readonly IEfRepository<AppRolePermission?, long> _rolePermissionRepository; |
|
|
|
private readonly IEfRepository<App_Menu?, long> _MenuRepository; |
|
|
|
private readonly IEfRepository<App_Menu?, long> _MenuRepository; |
|
|
|
private readonly IAppDictionaryService _appDictionaryService; |
|
|
|
private readonly IAppDictionaryService _appDictionaryService; |
|
|
|
|
|
|
|
private readonly ISMSService _smsService; |
|
|
|
|
|
|
|
private readonly IEfRepository<AppCaseManagement, long> _appCaseManagementRepository; |
|
|
|
|
|
|
|
private readonly IEfRepository<AppCaseSupervisedPerson, long> _appSupervisedPersonRepository; |
|
|
|
|
|
|
|
|
|
|
|
public UserService( |
|
|
|
public UserService( |
|
|
|
IEfRepository<AppUser?, long> userRepository, |
|
|
|
IEfRepository<AppUser?, long> userRepository, IEfRepository<AppCaseManagement, long> appCaseManagementRepository, |
|
|
|
|
|
|
|
IEfRepository<AppCaseSupervisedPerson, long> appSupervisedPersonRepository, |
|
|
|
IEfRepository<AppUserRole?, long> userRoleRepository, |
|
|
|
IEfRepository<AppUserRole?, long> userRoleRepository, |
|
|
|
IEfRepository<AppApi?, long> apiRepository, |
|
|
|
IEfRepository<AppApi?, long> apiRepository, |
|
|
|
IEfRepository<AppRole?, long> roleRepository, |
|
|
|
IEfRepository<AppRole?, long> roleRepository, |
|
|
|
IEfRepository<AppPermissionApi?, long> permissionApiRepository, |
|
|
|
IEfRepository<AppPermissionApi?, long> permissionApiRepository, |
|
|
|
IEfRepository<AppRolePermission?, long> rolePermissionRepository, |
|
|
|
IEfRepository<AppRolePermission?, long> rolePermissionRepository, |
|
|
|
IEfRepository<App_Menu?, long> MenuRepository, |
|
|
|
IEfRepository<App_Menu?, long> MenuRepository, |
|
|
|
IAppDictionaryService appDictionaryService |
|
|
|
IAppDictionaryService appDictionaryService, |
|
|
|
|
|
|
|
ISMSService smsService |
|
|
|
) |
|
|
|
) |
|
|
|
{ |
|
|
|
{ |
|
|
|
_userRepository = userRepository; |
|
|
|
_userRepository = userRepository; |
|
|
|
@ -70,6 +82,10 @@ namespace ATS.NonCustodial.Application.Impl.Admins |
|
|
|
_rolePermissionRepository = rolePermissionRepository; |
|
|
|
_rolePermissionRepository = rolePermissionRepository; |
|
|
|
_appDictionaryService = appDictionaryService; |
|
|
|
_appDictionaryService = appDictionaryService; |
|
|
|
_MenuRepository = MenuRepository; |
|
|
|
_MenuRepository = MenuRepository; |
|
|
|
|
|
|
|
_smsService = smsService; |
|
|
|
|
|
|
|
_appCaseManagementRepository = appCaseManagementRepository; |
|
|
|
|
|
|
|
_appSupervisedPersonRepository = appSupervisedPersonRepository; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endregion Identity |
|
|
|
#endregion Identity |
|
|
|
@ -381,7 +397,14 @@ namespace ATS.NonCustodial.Application.Impl.Admins |
|
|
|
{ |
|
|
|
{ |
|
|
|
//if (await _userRepository.AnyAsync(x => x.ReceiveName == input.ReceiveName)) return ResultOutput.NotOk("账号已经存在"); |
|
|
|
//if (await _userRepository.AnyAsync(x => x.ReceiveName == input.ReceiveName)) return ResultOutput.NotOk("账号已经存在"); |
|
|
|
if (await _userRepository.AnyAsync(w => w.UserName == input.UserName)) return ResultOutput.NotOk("姓名已经存在"); |
|
|
|
if (await _userRepository.AnyAsync(w => w.UserName == input.UserName)) return ResultOutput.NotOk("姓名已经存在"); |
|
|
|
|
|
|
|
if (!input.Phone.HasValue()) return ResultOutput.NotOk("请输入手机号"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var result = await CheckPhone(input.Phone); |
|
|
|
|
|
|
|
if (!result) { return ResultOutput.NotOk("手机号已在系统中已存在"); } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!input.Code.HasValue()) return ResultOutput.NotOk("请输入验证码"); |
|
|
|
|
|
|
|
result = await _smsService.CheckCodeAsync(input.Phone, input.Code, "CheckCode"); |
|
|
|
|
|
|
|
if (!result) { return ResultOutput.NotOk("验证码错误"); } |
|
|
|
var entity = Mapper.Map<AppUser>(input); |
|
|
|
var entity = Mapper.Map<AppUser>(input); |
|
|
|
entity.Id = YitIdHelper.NextId(); |
|
|
|
entity.Id = YitIdHelper.NextId(); |
|
|
|
entity.PasswordSalt = InfraHelper.Security.GenerateRandomCode(5); |
|
|
|
entity.PasswordSalt = InfraHelper.Security.GenerateRandomCode(5); |
|
|
|
@ -524,7 +547,16 @@ namespace ATS.NonCustodial.Application.Impl.Admins |
|
|
|
if (!(user?.Id > 0)) return ResultOutput.NotOk("用户不存在!"); |
|
|
|
if (!(user?.Id > 0)) return ResultOutput.NotOk("用户不存在!"); |
|
|
|
//监管人和管理员手机号不能重复 |
|
|
|
//监管人和管理员手机号不能重复 |
|
|
|
if (await _userRepository.AnyAsync(w => w.Id != input.Id && w.UserName == input.UserName && w.ChatPersonType != ChatPersonTypeEnum.SupervisedPerson)) return ResultOutput.NotOk("姓名不能重复"); |
|
|
|
if (await _userRepository.AnyAsync(w => w.Id != input.Id && w.UserName == input.UserName && w.ChatPersonType != ChatPersonTypeEnum.SupervisedPerson)) return ResultOutput.NotOk("姓名不能重复"); |
|
|
|
|
|
|
|
if (!input.Phone.HasValue()) return ResultOutput.NotOk("请输入手机号"); |
|
|
|
|
|
|
|
if (user.Phone != input.Phone) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var result = await CheckPhone(input.Phone); |
|
|
|
|
|
|
|
if (!result) { return ResultOutput.NotOk("手机号已在系统中已存在"); } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!input.Code.HasValue()) return ResultOutput.NotOk("请输入验证码"); |
|
|
|
|
|
|
|
result = await _smsService.CheckCodeAsync(input.Phone, input.Code, "CheckCode"); |
|
|
|
|
|
|
|
if (!result) { return ResultOutput.NotOk("验证码错误"); } |
|
|
|
|
|
|
|
} |
|
|
|
Mapper.Map(input, user); |
|
|
|
Mapper.Map(input, user); |
|
|
|
|
|
|
|
|
|
|
|
await _userRepository.UpdateAsync(user, UpdatingProps<AppUser>( |
|
|
|
await _userRepository.UpdateAsync(user, UpdatingProps<AppUser>( |
|
|
|
@ -539,8 +571,8 @@ namespace ATS.NonCustodial.Application.Impl.Admins |
|
|
|
if (input.RoleIds != null && input.RoleIds.Count() > 0) |
|
|
|
if (input.RoleIds != null && input.RoleIds.Count() > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var roleList = await _roleRepository.AsQueryable(false, true) |
|
|
|
var roleList = await _roleRepository.AsQueryable(false, true) |
|
|
|
.Where(w=> w.Code == "admin" || w.Code == "supervisor") |
|
|
|
.Where(w => w.Code == "admin" || w.Code == "supervisor") |
|
|
|
.Select(s=>s.Id).ToListAsync(); |
|
|
|
.Select(s => s.Id).ToListAsync(); |
|
|
|
|
|
|
|
|
|
|
|
await _userRoleRepository.DeleteAsync(a => a.UserId == user.Id && roleList.Contains(a.RoleId)); |
|
|
|
await _userRoleRepository.DeleteAsync(a => a.UserId == user.Id && roleList.Contains(a.RoleId)); |
|
|
|
|
|
|
|
|
|
|
|
@ -558,6 +590,44 @@ namespace ATS.NonCustodial.Application.Impl.Admins |
|
|
|
return ResultOutput.Ok(); |
|
|
|
return ResultOutput.Ok(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// 校验手机号是否有运行中的按键 |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
/// <param name="phone"></param> |
|
|
|
|
|
|
|
/// <returns></returns> |
|
|
|
|
|
|
|
private async Task<bool> CheckPhone(string phone) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var allUsers = await _userRepository.Where(w => w.Phone == phone && !string.IsNullOrEmpty(w.RoleName)).ToListAsync(); |
|
|
|
|
|
|
|
if (allUsers.Any()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
foreach (var item in allUsers) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var caseList = await (from c in _appCaseManagementRepository.AsQueryable(false, true) |
|
|
|
|
|
|
|
join cspr in _appSupervisedPersonRepository.AsQueryable(false, true) on c.Id equals cspr.CaseId |
|
|
|
|
|
|
|
where c.CaseProgress != CaseProgressEnum.Closed |
|
|
|
|
|
|
|
&& item.Id == cspr.SupervisedPersonId |
|
|
|
|
|
|
|
select new CheckPunchRecordForJobOutput() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
CaseId = c.Id, |
|
|
|
|
|
|
|
CaseName = c.Name, |
|
|
|
|
|
|
|
CaseBeginTime = c.CaseBeginTime, |
|
|
|
|
|
|
|
CheckInFrequency = c.CheckInFrequency, |
|
|
|
|
|
|
|
RestBeginTime = c.RestBeginTime, |
|
|
|
|
|
|
|
RestEndTime = c.RestEndTime, |
|
|
|
|
|
|
|
SupervisedPersonId = cspr.SupervisedPersonId, |
|
|
|
|
|
|
|
SupervisedPersonName = cspr.SupervisedPersonName, |
|
|
|
|
|
|
|
TimedClock = c.TimedClock |
|
|
|
|
|
|
|
}).ToListAsync(); |
|
|
|
|
|
|
|
if(caseList.Any()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// 更新用户基本信息 |
|
|
|
/// 更新用户基本信息 |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
@ -863,7 +933,7 @@ namespace ATS.NonCustodial.Application.Impl.Admins |
|
|
|
|
|
|
|
|
|
|
|
var rtn = await _userRepository.AsQueryable(false, true) |
|
|
|
var rtn = await _userRepository.AsQueryable(false, true) |
|
|
|
.Where(w => w.ChatPersonType != ChatPersonTypeEnum.SupervisedPerson && w.DataStatus != DataStatusEnum.Disable && !w.UserName.Contains("_aks")) |
|
|
|
.Where(w => w.ChatPersonType != ChatPersonTypeEnum.SupervisedPerson && w.DataStatus != DataStatusEnum.Disable && !w.UserName.Contains("_aks")) |
|
|
|
.WhereIf(codeList.Count>0,w=> w.PositionId == codeList.FirstOrDefault().Id) |
|
|
|
.WhereIf(codeList.Count > 0, w => w.PositionId == codeList.FirstOrDefault().Id) |
|
|
|
// .WhereIf(!userRoles.IsAdmin, w => w.Id == User.Id) 2025 -10-20 段肖确认修改 |
|
|
|
// .WhereIf(!userRoles.IsAdmin, w => w.Id == User.Id) 2025 -10-20 段肖确认修改 |
|
|
|
.Select(w => new KeyValueDto() |
|
|
|
.Select(w => new KeyValueDto() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|