Example #1
0
        public async Task <ResponseMessage> HumanParttime(UserInfo user, HumanInfoPartPositionRequest humanParttimeRequest)
        {
            ResponseMessage response = new ResponseMessage();



            return(response);
        }
Example #2
0
        public async Task <ResponseMessage <HumanInfoPartPositionResponse> > CreateAsync(UserInfo user, HumanInfoPartPositionRequest humanInfoPartPostionRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            ResponseMessage <HumanInfoPartPositionResponse> response = new ResponseMessage <HumanInfoPartPositionResponse>();

            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }
            if (humanInfoPartPostionRequest == null)
            {
                throw new ArgumentNullException(nameof(humanInfoPartPostionRequest));
            }
            var humaninfo = await _humanInfoStore.GetAsync(a => a.Where(b => b.Id == humanInfoPartPostionRequest.HumanId && !b.IsDeleted), cancellationToken);

            if (humaninfo == null)
            {
                response.Code    = ResponseCodeDefines.NotFound;
                response.Message = "操作的人事信息未找到";
                return(response);
            }
            var org = await _permissionExpansionManager.GetOrganizationOfPermission(user.Id, "HumanPartPosition");

            if (org == null || org.Count == 0 || !org.Contains(humanInfoPartPostionRequest.DepartmentId) || !org.Contains(humaninfo.DepartmentId))
            {
                response.Code    = ResponseCodeDefines.NotAllow;
                response.Message = "没有权限";
                return(response);
            }
            if (string.IsNullOrEmpty(humanInfoPartPostionRequest.Id))
            {
                humanInfoPartPostionRequest.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       = humanInfoPartPostionRequest.Id;
            examineSubmitRequest.ContentType     = "HumanPartPosition";
            examineSubmitRequest.ContentName     = humaninfo.Name;
            examineSubmitRequest.Content         = "新增员工人事兼职信息";
            examineSubmitRequest.Source          = user.FilialeName;
            examineSubmitRequest.SubmitDefineId  = humanInfoPartPostionRequest.Id;
            examineSubmitRequest.CallbackUrl     = gatwayurl + "/api/humanpartposition/humanpartpositioncallback";
            examineSubmitRequest.StepCallbackUrl = gatwayurl + "/api/humanpartposition/HumanPartPositionStepCallback";
            examineSubmitRequest.Action          = "HumanPartPosition";
            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 <HumanInfoPartPositionResponse>(await Store.CreateAsync(user, _mapper.Map <HumanInfoPartPosition>(humanInfoPartPostionRequest), cancellationToken));
            return(response);
        }
Example #3
0
        public async Task <ResponseMessage <HumanInfoPartPositionResponse> > UpdateAsync(UserInfo user, string id, HumanInfoPartPositionRequest humanInfoPartPostionRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            ResponseMessage <HumanInfoPartPositionResponse> response = new ResponseMessage <HumanInfoPartPositionResponse>();

            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }
            if (humanInfoPartPostionRequest == null)
            {
                throw new ArgumentNullException(nameof(humanInfoPartPostionRequest));
            }
            var humaninfo = await _humanInfoStore.GetAsync(a => a.Where(b => b.Id == humanInfoPartPostionRequest.HumanId && !b.IsDeleted), cancellationToken);

            if (humaninfo == null)
            {
                response.Code    = ResponseCodeDefines.NotFound;
                response.Message = "操作的人事信息未找到";
                return(response);
            }
            var org = await _permissionExpansionManager.GetOrganizationOfPermission(user.Id, "HumanPartPosition");

            if (org == null || org.Count == 0 || !org.Contains(humanInfoPartPostionRequest.DepartmentId) || !org.Contains(humaninfo.DepartmentId))
            {
                response.Code    = ResponseCodeDefines.NotAllow;
                response.Message = "没有权限";
                return(response);
            }
            var humanInfoPartPostion = _mapper.Map <HumanInfoPartPosition>(humanInfoPartPostionRequest);

            humanInfoPartPostion.Id = id;
            response.Extension      = _mapper.Map <HumanInfoPartPositionResponse>(await Store.UpdateAsync(user, humanInfoPartPostion, cancellationToken));
            return(response);
        }
Example #4
0
        public async Task <ResponseMessage <HumanInfoPartPositionResponse> > PutHumanInfoPartPosition(UserInfo user, [FromRoute] string id, [FromBody] HumanInfoPartPositionRequest humanInfoPartPositionRequest)
        {
            Logger.Trace($"用户{user?.UserName ?? ""}({user?.Id ?? ""})更新人事兼职信息(PutHumanInfoPartPosition),请求体为:\r\n" + (humanInfoPartPositionRequest != null ? JsonHelper.ToJson(humanInfoPartPositionRequest) : ""));
            ResponseMessage <HumanInfoPartPositionResponse> response = new ResponseMessage <HumanInfoPartPositionResponse>();

            if (!ModelState.IsValid)
            {
                response.Code    = ResponseCodeDefines.ModelStateInvalid;
                response.Message = ModelState.GetAllErrors();
                Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})更新人事兼职信息(PutHumanInfoPartPosition)模型验证失败:{response.Message}请求体为:\r\n" + (humanInfoPartPositionRequest != null ? JsonHelper.ToJson(humanInfoPartPositionRequest) : ""));
                return(response);
            }
            try
            {
                return(await _humanInfoPartPositionManager.UpdateAsync(user, id, humanInfoPartPositionRequest, HttpContext.RequestAborted));
            }
            catch (Exception e)
            {
                response.Code    = ResponseCodeDefines.ServiceError;
                response.Message = e.Message;
                Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})更新人事兼职信息(PutHumanInfoPartPosition)失败:{response.Message}请求体为:\r\n" + (humanInfoPartPositionRequest != null ? JsonHelper.ToJson(humanInfoPartPositionRequest) : ""));
            }
            return(response);
        }