public ResponseTPLListSearch TPLListSearch([FromBody] RequestTPLListSearch request) { try { TPLBLL bll = new TPLBLL(); return(bll.TPLListSearch(request)); } catch (Exception ex) { throw new HttpResponseException( Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public ResponseTPLListSearch TPLListSearch(RequestTPLListSearch request) { ResponseTPLListSearch response = new ResponseTPLListSearch(); using (cnn = GetConnection()) { var ts = cnn.BeginTransaction(); try { var user = this.UserInfoGet(request.Token, ts); string where = string.Empty; string sql = this.GetPageSql("A.* ", @" TKS_FAS_DocTPL A where A.accountId=@AccountId and type=@Type and tplTarget=0 and isCustom=1",//用户自定义 " A.createDate desc,A.updateDate desc ", request.PageSize, request.PageIndex); if (request.Type == "-1") { sql = this.GetPageSql("A.* ", @" TKS_FAS_DocTPL A where A.accountId=@AccountId and tplTarget=0 and isCustom=1",//用户自定义 " A.createDate desc,A.updateDate desc ", request.PageSize, request.PageIndex); } List <TKS_FAS_DocTPL> data = cnn.Query <TKS_FAS_DocTPL>(sql, new { AccountId = user.AccountId, Type = request.Type }, ts).ToList(); string countSql = @"select count(1) from TKS_FAS_DocTPL where accountId=@AccountId and type=@Type and tplTarget=0 and isCustom=1"; if (request.Type == "-1") { countSql = @"select count(1) from TKS_FAS_DocTPL where accountId=@AccountId and tplTarget=0 and isCustom=1"; } int total = int.Parse(cnn.ExecuteScalar(countSql, new { AccountId = user.AccountId, Type = request.Type }, ts).ToString()); ts.Commit(); response.IsSuccess = true; response.Message = "加载完毕"; response.PageIndex = request.PageIndex; response.Data = data; response.Total = total; return(response); } catch (Exception ex) { ts.Rollback(); return(this.DealException(response, ex) as ResponseTPLListSearch); } } }