using System; using System.Collections.Generic; using System.Linq; using System.Text; using Edu.Model.Entity.Mall; using Edu.Model.ViewModel.Mall; namespace Edu.Repository.Mall { public class RB_GoodsRepository : BaseRepository { /// /// 分页列表 /// /// 页码 /// 每页显示条数 /// 总条数 /// 查询条件 /// public List GetGoodsPage(int pageIndex, int pageSize, out long rowCount, RB_Goods_Extend dmodel) { string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify=2 and g.{nameof(RB_Goods_Extend.GoodsStatus)}=1 "; if (dmodel.TenantId > 0) { where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}"; } if (dmodel.MallBaseId > 0) { where += $@" and g.{nameof(RB_Goods_Extend.MallBaseId)}={dmodel.MallBaseId}"; } if (dmodel.Id > 0) { where += $@" and g.{nameof(RB_Goods_Extend.Id)}={dmodel.Id}"; } if (!string.IsNullOrEmpty(dmodel.GoodsIds)) { where += $@" and g.{nameof(RB_Goods_Extend.Id)} in({dmodel.GoodsIds})"; } if (!string.IsNullOrEmpty(dmodel.Name)) { where += $@" and g.{nameof(RB_Goods_Extend.Name)} like '%{dmodel.Name}%'"; } if (dmodel.IsProcurement > 0) { where += $@" and g.{nameof(RB_Goods_Extend.IsProcurement)}={dmodel.IsProcurement}"; } if (dmodel.IsProxy > 0) { where += $@" and g.{nameof(RB_Goods_Extend.IsProxy)}={dmodel.IsProxy}"; } if (dmodel.SupplierId > 0) { where += $@" and g.{nameof(RB_Goods_Extend.SupplierId)}={dmodel.SupplierId}"; } string orderBy = " g.Sort desc"; string sql = $@" SELECT g.* from rb_goods as g where {where} order by {orderBy}"; return GetPage(pageIndex, pageSize, out rowCount, sql).ToList(); } /// /// 商品列表 /// /// /// public List GetGoodsList(RB_Goods_Extend dmodel) { string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0 "; if (dmodel.TenantId > 0) { where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}"; } if (dmodel.MallBaseId > 0) { where += $@" and g.{nameof(RB_Goods_Extend.MallBaseId)}={dmodel.MallBaseId}"; } if (dmodel.Id > 0) { where += $@" and g.{nameof(RB_Goods_Extend.Id)}={dmodel.Id}"; } if (!string.IsNullOrEmpty(dmodel.GoodsIds)) { where += $@" and g.{nameof(RB_Goods_Extend.Id)} in({dmodel.GoodsIds})"; } if (!string.IsNullOrEmpty(dmodel.Name)) { where += $@" and g.{nameof(RB_Goods_Extend.Name)} like '%{dmodel.Name}%'"; } if (dmodel.IsProcurement > 0) { where += $@" and g.{nameof(RB_Goods_Extend.IsProcurement)}={dmodel.IsProcurement}"; } if (dmodel.IsProxy > 0) { where += $@" and g.{nameof(RB_Goods_Extend.IsProxy)}={dmodel.IsProxy}"; } if (dmodel.SupplierId > 0) { where += $@" and g.{nameof(RB_Goods_Extend.SupplierId)}={dmodel.SupplierId}"; } string orderBy = " g.Sort desc"; string sql = $@" SELECT g.* from rb_goods as g where {where} order by {orderBy}"; return Get(sql).ToList(); } } }