public async Task <ResponseMessage> HumanLeave(UserInfo user, HumanInfoLeaveRequest humanLeaveRequest) { ResponseMessage response = new ResponseMessage(); return(response); }
public async Task <ResponseMessage <HumanInfoLeaveResponse> > CreateAsync(UserInfo user, HumanInfoLeaveRequest humanInfoLeaveRequest, CancellationToken cancellationToken = default(CancellationToken)) { ResponseMessage <HumanInfoLeaveResponse> response = new ResponseMessage <HumanInfoLeaveResponse>(); if (user == null) { throw new ArgumentNullException(nameof(user)); } if (humanInfoLeaveRequest == null) { throw new ArgumentNullException(nameof(humanInfoLeaveRequest)); } var humaninfo = await _humanInfoStore.GetAsync(a => a.Where(b => b.Id == humanInfoLeaveRequest.HumanId && !b.IsDeleted), cancellationToken); if (humaninfo == null) { response.Code = ResponseCodeDefines.NotFound; response.Message = "操作的人事信息未找到"; return(response); } var org = await _permissionExpansionManager.GetOrganizationOfPermission(user.Id, "HumanLeave"); if (org == null || org.Count == 0 || !org.Contains(humaninfo.DepartmentId)) { response.Code = ResponseCodeDefines.NotAllow; response.Message = "没有权限"; return(response); } if (string.IsNullOrEmpty(humanInfoLeaveRequest.Id)) { humanInfoLeaveRequest.Id = Guid.NewGuid().ToString(); } var gatwayurl = ApplicationContext.Current.AppGatewayUrl.EndsWith("/") ? ApplicationContext.Current.AppGatewayUrl.TrimEnd('/') : ApplicationContext.Current.AppGatewayUrl; GatewayInterface.Dto.ExamineSubmitRequest examineSubmitRequest = new GatewayInterface.Dto.ExamineSubmitRequest(); examineSubmitRequest.ContentId = humanInfoLeaveRequest.Id; examineSubmitRequest.ContentType = "HumanLeave"; examineSubmitRequest.ContentName = humaninfo.Name; examineSubmitRequest.Content = "新增员工人事离职信息"; examineSubmitRequest.Source = user.FilialeName; examineSubmitRequest.SubmitDefineId = humanInfoLeaveRequest.Id; examineSubmitRequest.CallbackUrl = gatwayurl + "/api/humanleave/humanleavecallback"; examineSubmitRequest.StepCallbackUrl = gatwayurl + "/api/humanleave/humanleavestepcallback"; examineSubmitRequest.Action = "HumanLeave"; examineSubmitRequest.TaskName = $"新增员工人事离职信息:{humaninfo.Name}"; examineSubmitRequest.Desc = $"新增员工人事离职调动信息"; GatewayInterface.Dto.UserInfo userInfo = new GatewayInterface.Dto.UserInfo() { Id = user.Id, KeyWord = user.KeyWord, OrganizationId = user.OrganizationId, OrganizationName = user.OrganizationName, UserName = user.UserName }; examineSubmitRequest.UserInfo = userInfo; string tokenUrl = $"{ApplicationContext.Current.AuthUrl}/connect/token"; string examineCenterUrl = $"{ApplicationContext.Current.ExamineCenterUrl}"; Logger.Info($"新增员工人事离职信息提交审核,\r\ntokenUrl:{tokenUrl ?? ""},\r\nexamineCenterUrl:{examineCenterUrl ?? ""},\r\nexamineSubmitRequest:" + (examineSubmitRequest != null ? JsonHelper.ToJson(examineSubmitRequest) : "")); var tokenManager = new TokenManager(tokenUrl, ApplicationContext.Current.ClientID, ApplicationContext.Current.ClientSecret); var response2 = await tokenManager.Execute(async (token) => { return(await _restClient.PostWithToken <ResponseMessage>(examineCenterUrl, examineSubmitRequest, token)); }); if (response2.Code != ResponseCodeDefines.SuccessCode) { response.Code = ResponseCodeDefines.ServiceError; response.Message = "向审核中心发起审核请求失败:" + response2.Message; Logger.Info($"新增员工人事离职信息提交审核失败:" + response2.Message); return(response); } response.Extension = _mapper.Map <HumanInfoLeaveResponse>(await Store.CreateAsync(user, _mapper.Map <HumanInfoLeave>(humanInfoLeaveRequest), cancellationToken)); return(response); }
public async Task <ResponseMessage <HumanInfoLeaveResponse> > UpdateAsync(UserInfo user, string id, HumanInfoLeaveRequest humanInfoLeaveRequest, CancellationToken cancellationToken = default(CancellationToken)) { ResponseMessage <HumanInfoLeaveResponse> response = new ResponseMessage <HumanInfoLeaveResponse>(); if (user == null) { throw new ArgumentNullException(nameof(user)); } if (humanInfoLeaveRequest == null) { throw new ArgumentNullException(nameof(humanInfoLeaveRequest)); } var humaninfo = await _humanInfoStore.GetAsync(a => a.Where(b => b.Id == humanInfoLeaveRequest.HumanId && !b.IsDeleted), cancellationToken); if (humaninfo == null) { response.Code = ResponseCodeDefines.NotFound; response.Message = "操作的人事信息未找到"; return(response); } var org = await _permissionExpansionManager.GetOrganizationOfPermission(user.Id, "HumanLeave"); if (org == null || org.Count == 0 || !org.Contains(humaninfo.DepartmentId)) { response.Code = ResponseCodeDefines.NotAllow; response.Message = "没有权限"; return(response); } var humanInfoLeave = _mapper.Map <HumanInfoLeave>(humanInfoLeaveRequest); humanInfoLeave.Id = id; response.Extension = _mapper.Map <HumanInfoLeaveResponse>(await Store.UpdateAsync(user, humanInfoLeave, cancellationToken)); return(response); }
public async Task <ResponseMessage <HumanInfoLeaveResponse> > CreateHumanInfoLeave(UserInfo user, [FromBody] HumanInfoLeaveRequest humanInfoLeaveRequest) { Logger.Trace($"用户{user?.UserName ?? ""}({user?.Id ?? ""})新增人事离职信息(CreateHumanInfoLeave),请求体为:\r\n" + (humanInfoLeaveRequest != null ? JsonHelper.ToJson(humanInfoLeaveRequest) : "")); ResponseMessage <HumanInfoLeaveResponse> response = new ResponseMessage <HumanInfoLeaveResponse>(); if (!ModelState.IsValid) { response.Code = ResponseCodeDefines.ModelStateInvalid; response.Message = ModelState.GetAllErrors(); Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})新增人事离职信息(CreateHumanInfoLeave)模型验证失败:{response.Message}请求体为:\r\n" + (humanInfoLeaveRequest != null ? JsonHelper.ToJson(humanInfoLeaveRequest) : "")); return(response); } try { return(await _humanInfoLeaveManager.CreateAsync(user, humanInfoLeaveRequest, HttpContext.RequestAborted)); } catch (Exception e) { response.Code = ResponseCodeDefines.ServiceError; response.Message = e.Message; Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})新增人事离职信息(CreateHumanInfoLeave)失败:{response.Message}请求体为:\r\n" + (humanInfoLeaveRequest != null ? JsonHelper.ToJson(humanInfoLeaveRequest) : "")); } return(response); }