BasRegionService.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System;
  2. using SqlSugar;
  3. using Infrastructure.Attribute;
  4. using ZR.Model;
  5. using ZR.Repository;
  6. using System.Linq;
  7. using System.Collections.Generic;
  8. using ZR.Model.System;
  9. using ZR.Service.Business.IBusinessService.BaseSet;
  10. using ZR.Model.Dto.BaseSet;
  11. using ZR.Model.Models.BaseSet;
  12. namespace ZR.Service.Business
  13. {
  14. /// <summary>
  15. /// 基础资料/库区信息表Service业务层处理
  16. ///
  17. /// @author admin
  18. /// @date 2023-04-10
  19. /// </summary>
  20. [AppService(ServiceType = typeof(IBasRegionService), ServiceLifetime = LifeTime.Transient)]
  21. public class BasRegionService : BaseService<BasRegion>, IBasRegionService
  22. {
  23. #region 业务逻辑代码
  24. /// <summary>
  25. /// 查询基础资料/库区信息表列表
  26. /// </summary>
  27. /// <param name="parm"></param>
  28. /// <returns></returns>
  29. public PagedInfo<BasRegionDto> GetList(BasRegionQueryDto parm)
  30. {
  31. //开始拼装查询条件
  32. var predicate = Expressionable.Create<BasRegion>();
  33. predicate.AndIF(!string.IsNullOrEmpty(parm.RegionCode), it => it.RegionCode.Contains(parm.RegionCode));
  34. predicate.AndIF(!string.IsNullOrEmpty(parm.RegionName), it => it.RegionName.Contains(parm.RegionName));
  35. predicate.AndIF(!string.IsNullOrEmpty(parm.Visible), it => it.Visible == parm.Visible);
  36. predicate.AndIF(!string.IsNullOrEmpty(parm.Status), it => it.Status.Equals(parm.Status));
  37. //搜索条件查询语法参考Sqlsugar
  38. var response = Queryable()
  39. .Where(predicate.ToExpression())
  40. .ToPage<BasRegion, BasRegionDto>(parm);
  41. return response;
  42. }
  43. /// <summary>
  44. /// 添加基础资料/库区信息表
  45. /// </summary>
  46. /// <param name="model"></param>
  47. /// <returns></returns>
  48. public int AddBasRegion(BasRegion model)
  49. {
  50. return Add(model, true);
  51. //return Insertable(model).ExecuteReturnBigIdentity();
  52. }
  53. /// <summary>
  54. /// 修改基础资料/库区信息表
  55. /// </summary>
  56. /// <param name="model"></param>
  57. /// <returns></returns>
  58. public int UpdateBasRegion(BasRegion model)
  59. {
  60. //var response = Update(w => w.RegionId == model.RegionId, it => new BasRegion()
  61. //{
  62. // RegionCode = model.RegionCode,
  63. // RegionName = model.RegionName,
  64. // Describe = model.Describe,
  65. // Visible = model.Visible,
  66. // Status = model.Status,
  67. // UpdateBy = model.UpdateBy,
  68. // UpdateTime = model.UpdateTime,
  69. // Remark = model.Remark,
  70. //});
  71. //return response;
  72. return Update(model, true);
  73. }
  74. /// <summary>
  75. /// 清空基础资料/库区信息表
  76. /// </summary>
  77. /// <returns></returns>
  78. public void TruncateBasRegion()
  79. {
  80. Truncate();
  81. }
  82. public List<BasRegion> GetAll()
  83. {
  84. return Queryable().ToList();
  85. }
  86. #endregion
  87. }
  88. }