SaleChannelService.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. package com.dk.mdm.service.mst;
  2. import com.dk.common.infrastructure.annotaiton.Pagination;
  3. import com.dk.common.infrastructure.constant.Constant;
  4. import com.dk.common.model.pojo.PageList;
  5. import com.dk.common.response.ResponseResultUtil;
  6. import com.dk.common.response.ResponseResultVO;
  7. import com.dk.mdm.infrastructure.convert.mst.SaleChannelConvert;
  8. import com.dk.mdm.model.pojo.mst.SaleChannel;
  9. import com.dk.mdm.mapper.mst.SaleChannelMapper;
  10. import com.dk.common.service.BaseService;
  11. import com.dk.common.mapper.BaseMapper;
  12. import com.dk.mdm.model.query.mst.SaleChannelQuery;
  13. import com.dk.mdm.model.response.mst.WarehouseResponse;
  14. import com.dk.mdm.model.vo.mst.SaleChannelVO;
  15. import com.dk.mdm.model.vo.mst.WarehouseVO;
  16. import com.dk.mdm.service.common.CommonService;
  17. import org.springframework.stereotype.Service;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.transaction.annotation.Transactional;
  20. import java.util.Map;
  21. @Service
  22. @Transactional
  23. public class SaleChannelService extends BaseService<SaleChannel> {
  24. @Override
  25. public BaseMapper<SaleChannel> getRepository() {
  26. return saleChannelMapper;
  27. }
  28. @Autowired
  29. private SaleChannelMapper saleChannelMapper;
  30. @Autowired
  31. private CommonService commonService;
  32. @Autowired
  33. private SaleChannelConvert saleChannelConvert;
  34. /**
  35. * @desc : 重写主键
  36. * @author : 于继渤
  37. * @date : 2024/2/29 20:29
  38. */
  39. @Override
  40. public String getPrimaryKey() {
  41. return "channel_id";
  42. }
  43. /**
  44. * @desc : 查询
  45. * @author : 于继渤
  46. * @date : 2023/1/5 9:39
  47. */
  48. @Pagination
  49. public ResponseResultVO<PageList<WarehouseResponse>> selectByCond(SaleChannelQuery saleChannelQuery) {
  50. return super.mergeListWithCount(saleChannelQuery, saleChannelMapper.selectByCond(saleChannelQuery),
  51. saleChannelMapper.countByCond(saleChannelQuery));
  52. }
  53. /**
  54. * @desc : 新建
  55. * @author : 于继渤
  56. * @date : 2023/1/5 9:39
  57. */
  58. @Transactional(
  59. rollbackFor = {Exception.class}
  60. )
  61. public ResponseResultVO<?> insert(SaleChannelVO saleChannelVO) {
  62. //实体转换
  63. SaleChannel saleChannel = saleChannelConvert.convertToPo(saleChannelVO);
  64. //设置序号
  65. saleChannel.setDisplayNo(commonService.getMaxDisplayNo(Constant.DisplayNoTable.SALECHANNEL));
  66. //设置编码
  67. Map<String, Object> uniqueNoteCode = commonService.getUniqueNoteCode(Constant.docNameConstant.SALECHANNEL.getName(), true);
  68. saleChannel.setChannelId(uniqueNoteCode.get("outId").toString());
  69. saleChannel.setChannelCode(uniqueNoteCode.get("outNote").toString());
  70. //新建
  71. saleChannelMapper.insert(saleChannel);
  72. return ResponseResultUtil.success();
  73. }
  74. /**
  75. * @desc : 编辑
  76. * @author : 于继渤
  77. * @date : 2023/1/5 9:39
  78. */
  79. @Transactional(
  80. rollbackFor = {Exception.class}
  81. )
  82. public ResponseResultVO<?> update(SaleChannelVO saleChannelVO) {
  83. SaleChannel saleChannel = saleChannelConvert.convertToPo(saleChannelVO);
  84. super.updateByUuid(saleChannel);
  85. return ResponseResultUtil.success();
  86. }
  87. /**
  88. * @desc : 批量编辑序号
  89. * @author : 于继渤
  90. * @date : 2023/1/4 9:39
  91. */
  92. @Transactional(
  93. rollbackFor = {Exception.class}
  94. )
  95. public ResponseResultVO<?> updateBatchSaleChannelDisplayNo(SaleChannelVO saleChannelVO) {
  96. saleChannelMapper.updateBatchSaleChannelDisplayNo(saleChannelVO.getDataIds());
  97. return ResponseResultUtil.success();
  98. }
  99. }