Ejemplo n.º 1
0
        public virtual async Task <HumanSearchResponse <RewardPunishmentResponse> > SearchRewardPunishmentInfo(UserInfo user, RewardPunishmentSearchRequest condition, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (condition == null)
            {
                throw new ArgumentNullException(nameof(condition));
            }

            var Response = new HumanSearchResponse <RewardPunishmentResponse>();
            var sql      = @"SELECT a.* from XYH_HU_REWARDPUNISHMENT as a where";

            string connectstr = " ";

            if (!string.IsNullOrEmpty(condition?.KeyWord))
            {
                sql       += connectstr + @"LOCATE('" + condition.KeyWord + "', a.`Name`)>0";
                connectstr = " and ";
            }
            else
            {
                sql       += connectstr + @"a.`ID`!=''";
                connectstr = " and ";
            }

            if (condition?.CreateDate != null && condition.CreateDate.Year > 2017)
            {
                sql       += connectstr + @"(a.`WorkDate`='" + condition.CreateDate + "'";
                connectstr = " and ";
            }

            try
            {
                var query = _Store.DapperSelect <RewardPunishmentInfo>(sql).ToList();

                Response.ValidityContractCount = query.Count;
                Response.TotalCount            = query.Count;

                List <RewardPunishmentInfo> result = new List <RewardPunishmentInfo>();
                var begin = (condition.pageIndex) * condition.pageSize;
                var end   = (begin + condition.pageSize) > query.Count ? query.Count : (begin + condition.pageSize);

                for (; begin < end; begin++)
                {
                    result.Add(query.ElementAt(begin));
                }

                Response.PageIndex = condition.pageIndex;
                Response.PageSize  = condition.pageSize;
                Response.Extension = _mapper.Map <List <RewardPunishmentResponse> >(result);
            }
            catch (Exception e)
            {
                throw;
            }

            return(Response);
        }
Ejemplo n.º 2
0
        public async Task <ResponseMessage <HumanSearchResponse <RewardPunishmentResponse> > > SearchRewardPunishment(UserInfo User, [FromBody] RewardPunishmentSearchRequest condition)
        {
            var pagingResponse = new ResponseMessage <HumanSearchResponse <RewardPunishmentResponse> >();

            if (!ModelState.IsValid)
            {
                pagingResponse.Code = ResponseCodeDefines.ModelStateInvalid;
                Logger.Warn($"用户{User?.UserName ?? ""}({User?.Id ?? ""})查询行政奖惩(PostCustomerListSaleMan)模型验证失败:\r\n{pagingResponse.Message ?? ""},\r\n请求参数为:\r\n" + (condition != null ? JsonHelper.ToJson(condition) : ""));
                return(pagingResponse);
            }

            try
            {
                pagingResponse.Extension = await _rpManage.SearchRewardPunishmentInfo(User, condition, HttpContext.RequestAborted);

                pagingResponse.Message = "searchattendencelst ok";
            }
            catch (Exception e)
            {
                pagingResponse.Code    = ResponseCodeDefines.ServiceError;
                pagingResponse.Message = "服务器错误:" + e.ToString();
                Logger.Error($"用户{User?.UserName ?? ""}({User?.Id ?? ""})查询行政奖惩(PostCustomerListSaleMan)请求失败:\r\n{pagingResponse.Message ?? ""},\r\n请求参数为:\r\n" + (condition != null ? JsonHelper.ToJson(condition) : ""));
            }
            return(pagingResponse);
        }