BrandService.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using ZR.Mall.Model;
  2. using ZR.Mall.Model.Dto;
  3. using ZR.Mall.Service.IService;
  4. namespace ZR.Mall.Service
  5. {
  6. /// <summary>
  7. /// 品牌表Service业务层处理
  8. /// </summary>
  9. [AppService(ServiceType = typeof(IBrandService))]
  10. public class BrandService : BaseService<Brand>, IBrandService
  11. {
  12. /// <summary>
  13. /// 查询品牌表列表
  14. /// </summary>
  15. /// <param name="parm"></param>
  16. /// <returns></returns>
  17. public PagedInfo<BrandDto> GetList(ShopBrandQueryDto parm)
  18. {
  19. var predicate = QueryExp(parm);
  20. var response = Queryable()
  21. .Where(predicate.ToExpression())
  22. .ToPage<Brand, BrandDto>(parm);
  23. return response;
  24. }
  25. /// <summary>
  26. /// 获取详情
  27. /// </summary>
  28. /// <param name="Id"></param>
  29. /// <returns></returns>
  30. public Brand GetInfo(long Id)
  31. {
  32. var response = Queryable()
  33. .Where(x => x.Id == Id)
  34. .First();
  35. return response;
  36. }
  37. /// <summary>
  38. /// 添加品牌表
  39. /// </summary>
  40. /// <param name="model"></param>
  41. /// <returns></returns>
  42. public Brand AddShopBrand(Brand model)
  43. {
  44. return Insertable(model).ExecuteReturnEntity();
  45. }
  46. /// <summary>
  47. /// 修改品牌表
  48. /// </summary>
  49. /// <param name="model"></param>
  50. /// <returns></returns>
  51. public int UpdateShopBrand(Brand model)
  52. {
  53. return Update(model, true, "修改品牌表");
  54. }
  55. /// <summary>
  56. /// 导出品牌表
  57. /// </summary>
  58. /// <param name="parm"></param>
  59. /// <returns></returns>
  60. public PagedInfo<BrandDto> ExportList(ShopBrandQueryDto parm)
  61. {
  62. var predicate = QueryExp(parm);
  63. var response = Queryable()
  64. .Where(predicate.ToExpression())
  65. .Select((it) => new BrandDto()
  66. {
  67. }, true)
  68. .ToPage(parm);
  69. return response;
  70. }
  71. /// <summary>
  72. /// 查询导出表达式
  73. /// </summary>
  74. /// <param name="parm"></param>
  75. /// <returns></returns>
  76. private static Expressionable<Brand> QueryExp(ShopBrandQueryDto parm)
  77. {
  78. var predicate = Expressionable.Create<Brand>();
  79. predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.Name), it => it.Name == parm.Name);
  80. return predicate;
  81. }
  82. }
  83. }