/// <summary> /// 查询供应商列表 /// </summary> /// <param name="request"></param> /// <returns></returns> public static BasePageResponse <SupplierModel> GetList(SupplierSearchRequest request) { var data = H_SupplierAccess.GetList(request); var response = new BasePageResponse <SupplierModel>() { IsSuccess = data.IsSuccess, Total = data.Total, List = new List <SupplierModel>() }; data?.List?.ForEach(x => { response.List.Add(new SupplierModel { Code = x.SCode, Id = x.Id, Linker = x.SLinker, Name = x.SName, SourceId = x.SSourceId, Source = Sys_BaseDictionaryAccess.GetDicModel(0, x.SSourceId)?.DName ?? string.Empty, PmName = x.SPMName, }); }); return(response); }
/// <summary> /// 查询供应商列表 /// </summary> /// <param name="request"></param> /// <returns></returns> public static BasePageResponse <H_SupplierModel> GetList(SupplierSearchRequest request) { var response = new BasePageResponse <H_SupplierModel>(); var sql = new StringBuilder(); var sqlTotal = new StringBuilder(); var sqlWhere = new StringBuilder(); var para = new DynamicParameters(); #region Where条件 if (request.Id > 0) { sqlWhere.Append(" AND Id = @Id "); para.Add("@Id", request.Id); } if (request.SourceId > 0) { sqlWhere.Append(" AND SSourceId = @SourceId "); para.Add("@SourceId", request.SourceId); } if (request.IsValid > 0) { sqlWhere.Append(" AND SIsValid = @IsValid "); para.Add("@IsValid", request.IsValid == 1 ? 1 : 0); } if (!string.IsNullOrEmpty(request.Code)) { sqlWhere.Append(" AND SCode = @Code "); para.Add("@Code", request.Code); } if (!string.IsNullOrEmpty(request.Name)) { sqlWhere.Append(" AND SName Like @Name "); para.Add("@Name", $"%{request.Name}%"); } if (!string.IsNullOrEmpty(request.LinkerName)) { sqlWhere.Append(" AND SLinker Like @LinkerName "); para.Add("@LinkerName", $"%{request.LinkerName}%"); } #endregion sqlTotal.Append(" SELECT Count(1) FROM H_Supplier WHERE 1=1 "); sqlTotal.Append(sqlWhere); var total = MysqlHelper.GetScalar <int>(sqlTotal.ToString(), para); response.IsSuccess = 1; if (total > 0) { sql.Append(" SELECT * FROM H_Supplier WHERE 1=1 "); sql.Append(sqlWhere); sql.Append(" ORDER BY ID DESC "); sql.Append(MysqlHelper.GetPageSql(request.PageIndex, request.PageSize)); response.Total = total; response.List = MysqlHelper.GetList <H_SupplierModel>(sql.ToString(), para); } return(response); }