|
@@ -23,6 +23,7 @@ using GxPress.EnumConst;
|
|
|
using GxPress.Request.App.Flow;
|
|
|
using GxPress.Repository.Interface.WaitHandle;
|
|
|
using GxPress.Request.AddressBookGroup;
|
|
|
+using GxPress.Repository.Interface.DepartmentUser;
|
|
|
|
|
|
namespace GxPress.Service.Implement
|
|
|
{
|
|
@@ -39,9 +40,10 @@ namespace GxPress.Service.Implement
|
|
|
private readonly IFlowRepository _flowRepository;
|
|
|
private readonly IFlowTodoRepository _flowTodoRepository;
|
|
|
private readonly IWaitHandleRepository waitHandleRepository;
|
|
|
+ private readonly IDepartmentUserRepository departmentUserRepository;
|
|
|
public UserService(IUserRepository userRepository, IDepartmentRepository departmentRepository,
|
|
|
IAddressBookGroupRepository addressBookGroupRepository, IBlacklistUserRepository blacklistUserRepository,
|
|
|
- IMapper mapper, IWebHostEnvironment webHostEnvironment, IRoleRepository roleRepository, IIMService imService, IFlowRepository flowRepository, IFlowTodoRepository flowTodoRepository, IWaitHandleRepository waitHandleRepository)
|
|
|
+ IMapper mapper, IWebHostEnvironment webHostEnvironment, IRoleRepository roleRepository, IIMService imService, IFlowRepository flowRepository, IFlowTodoRepository flowTodoRepository, IWaitHandleRepository waitHandleRepository, IDepartmentUserRepository departmentUserRepository)
|
|
|
{
|
|
|
|
|
|
_userRepository = userRepository;
|
|
@@ -55,6 +57,7 @@ namespace GxPress.Service.Implement
|
|
|
_flowRepository = flowRepository;
|
|
|
_flowTodoRepository = flowTodoRepository;
|
|
|
this.waitHandleRepository = waitHandleRepository;
|
|
|
+ this.departmentUserRepository = departmentUserRepository;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -221,6 +224,8 @@ namespace GxPress.Service.Implement
|
|
|
var query = Q.NewQuery();
|
|
|
if (departmentId > 0)
|
|
|
{
|
|
|
+ var userIds = await departmentUserRepository.GetUserIdsAsync(departmentId);
|
|
|
+ query.WhereIn(nameof(User.Id), userIds);
|
|
|
query.Where(nameof(User.DepartmentId), departmentId);
|
|
|
}
|
|
|
|
|
@@ -257,7 +262,9 @@ namespace GxPress.Service.Implement
|
|
|
var query = Q.ForPage(page, perPage);
|
|
|
if (departmentId > 0)
|
|
|
{
|
|
|
- query.Where(nameof(User.DepartmentId), departmentId);
|
|
|
+ var userIds = await departmentUserRepository.GetUserIdsAsync(departmentId);
|
|
|
+ query.WhereIn(nameof(User.Id), userIds);
|
|
|
+ //query.Where(nameof(User.DepartmentId), departmentId);
|
|
|
}
|
|
|
|
|
|
if (roleId > 0)
|
|
@@ -283,7 +290,9 @@ namespace GxPress.Service.Implement
|
|
|
var query = Q.ForPage(request.Page, request.PerPage);
|
|
|
if (request.DepartmentId > 0)
|
|
|
{
|
|
|
- query.Where(nameof(User.DepartmentId), request.DepartmentId);
|
|
|
+ var userIds = await departmentUserRepository.GetUserIdsAsync(request.DepartmentId);
|
|
|
+ query.WhereIn(nameof(User.Id), userIds);
|
|
|
+ //query.Where(nameof(User.DepartmentId), request.DepartmentId);
|
|
|
}
|
|
|
|
|
|
if (request.RoleId > 0)
|
|
@@ -401,5 +410,57 @@ namespace GxPress.Service.Implement
|
|
|
};
|
|
|
return result;
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 更新用户信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<bool> UpdateAsync(int id, UserInfoRequest request)
|
|
|
+ {
|
|
|
+ var user = await _userRepository.GetAsync(id);
|
|
|
+ if (user == null) throw new BusinessException("该用户不存在");
|
|
|
+ if (request.DepartmentId.Count() > 0)
|
|
|
+ {
|
|
|
+ await departmentUserRepository.AddDepartmentUserAsync(request.DepartmentId, id);
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrEmpty(request.Nick))
|
|
|
+ user.Nick = request.Nick;
|
|
|
+ if (!string.IsNullOrEmpty(request.Description))
|
|
|
+ user.Description = request.Description;
|
|
|
+ if (!string.IsNullOrEmpty(request.Gender))
|
|
|
+ user.Gender = request.Gender;
|
|
|
+ if (!string.IsNullOrEmpty(request.Name))
|
|
|
+ user.Name = request.Name;
|
|
|
+ if (!string.IsNullOrEmpty(request.Position))
|
|
|
+ user.Position = request.Position;
|
|
|
+ if (request.RoleId > 0)
|
|
|
+ user.RoleId = request.RoleId;
|
|
|
+ if (!string.IsNullOrEmpty(request.Signature))
|
|
|
+ user.Signature = request.Signature;
|
|
|
+ //用户头像
|
|
|
+ if (!string.IsNullOrEmpty(request.AvatarUrl))
|
|
|
+ {
|
|
|
+ user.HistoryAvatarUrl = user.AvatarUrl;
|
|
|
+ user.AvatarUrl = StringUtils.RemoveDomain(request.AvatarUrl);
|
|
|
+ }
|
|
|
+ user.Email = request.Email;
|
|
|
+ if (!string.IsNullOrWhiteSpace(request.Phone))
|
|
|
+ user.Phone = request.Phone;
|
|
|
+ user.QRCoder = StringUtils.RemoveDomain(user.QRCoder);
|
|
|
+ if (request.IsDisable > 0)
|
|
|
+ user.IsDisable = request.IsDisable == 1;
|
|
|
+ if (request.IsFreeze > 0)
|
|
|
+ user.IsFreeze = request.IsFreeze == 1;
|
|
|
+ if (request.IsVip > 0)
|
|
|
+ user.IsVip = request.IsVip == 1;
|
|
|
+ if (request.IsLeader > 0)
|
|
|
+ user.IsLeader = request.IsLeader == 1;
|
|
|
+ if (request.IsMute > 0)
|
|
|
+ user.IsMute = request.IsMute == 1;
|
|
|
+ if (!string.IsNullOrWhiteSpace(request.DisableTiem))
|
|
|
+ user.DisableTiem = Convert.ToDateTime(request.DisableTiem);
|
|
|
+ return await _userRepository.UpdateAsync(user);
|
|
|
+ }
|
|
|
}
|
|
|
}
|