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<RB_Goods> { /// <summary> /// 分页列表 /// </summary> /// <param name="pageIndex">页码</param> /// <param name="pageSize">每页显示条数</param> /// <param name="rowCount">总条数</param> /// <param name="dmodel">查询条件</param> /// <returns></returns> public List<RB_Goods_Extend> 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<RB_Goods_Extend>(pageIndex, pageSize, out rowCount, sql).ToList(); } /// <summary> /// 商品列表 /// </summary> /// <param name="dmodel"></param> /// <returns></returns> public List<RB_Goods_Extend> 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<RB_Goods_Extend>(sql).ToList(); } } }