GoodsSeriesService.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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.GoodsBrandConvert;
  8. import com.dk.mdm.infrastructure.convert.mst.GoodsSeriesConvert;
  9. import com.dk.mdm.model.pojo.mst.GoodsBrand;
  10. import com.dk.mdm.model.pojo.mst.GoodsSeries;
  11. import com.dk.mdm.mapper.mst.GoodsSeriesMapper;
  12. import com.dk.common.service.BaseService;
  13. import com.dk.common.mapper.BaseMapper;
  14. import com.dk.mdm.model.query.mst.GoodsBrandQuery;
  15. import com.dk.mdm.model.query.mst.GoodsSeriesQuery;
  16. import com.dk.mdm.model.response.mst.GoodsBrandResponse;
  17. import com.dk.mdm.model.response.mst.GoodsSeriesResponse;
  18. import com.dk.mdm.model.vo.mst.GoodsBrandVO;
  19. import com.dk.mdm.model.vo.mst.GoodsSeriesVO;
  20. import com.dk.mdm.service.common.CommonService;
  21. import org.springframework.stereotype.Service;
  22. import org.springframework.beans.factory.annotation.Autowired;
  23. import org.springframework.transaction.annotation.Transactional;
  24. import java.util.List;
  25. import java.util.Map;
  26. @Service
  27. @Transactional
  28. public class GoodsSeriesService extends BaseService<GoodsSeries> {
  29. @Override
  30. public BaseMapper<GoodsSeries> getRepository() {
  31. return goodsSeriesMapper;
  32. }
  33. @Autowired
  34. private GoodsSeriesMapper goodsSeriesMapper;
  35. @Autowired
  36. private GoodsSeriesConvert goodsSeriesConvert;
  37. @Autowired
  38. private CommonService commonService;
  39. /**
  40. * @desc : 重写主键
  41. * @author : 于继渤
  42. * @date : 2024/2/29 20:29
  43. */
  44. @Override
  45. public String getPrimaryKey() {
  46. return "series_id";
  47. }
  48. /**
  49. * @desc : 查询
  50. * @author : 于继渤
  51. * @date : 2023/1/5 9:39
  52. */
  53. @Pagination
  54. public ResponseResultVO<PageList<GoodsSeriesResponse>> selectByCond(GoodsSeriesQuery goodsSeriesQuery) {
  55. return super.mergeListWithCount(goodsSeriesQuery, goodsSeriesMapper.selectByCond(goodsSeriesQuery),
  56. goodsSeriesMapper.countByCond(goodsSeriesQuery));
  57. }
  58. /**
  59. * @desc : 查询
  60. * @author : 王英杰
  61. * @date : 2023/1/5 9:39
  62. */
  63. @Pagination
  64. public ResponseResultVO<List<GoodsSeriesResponse>> listByNopage(GoodsSeriesQuery goodsSeriesQuery) {
  65. return ResponseResultUtil.success(goodsSeriesMapper.listByNopage(goodsSeriesQuery)) ;
  66. }
  67. /**
  68. * @desc : 新建
  69. * @author : 于继渤
  70. * @date : 2023/1/5 9:39
  71. */
  72. @Transactional(
  73. rollbackFor = {Exception.class}
  74. )
  75. public ResponseResultVO<?> insert(GoodsSeriesVO goodsSeriesVO) {
  76. //实体转换
  77. GoodsSeries goodsSeries = goodsSeriesConvert.convertToPo(goodsSeriesVO);
  78. //设置序号
  79. goodsSeries.setDisplayNo(commonService.getMaxDisplayNo(Constant.DisplayNoTable.GOODSSERIES));
  80. //设置编码
  81. Map<String, Object> uniqueNoteCode = commonService.getUniqueNoteCode(Constant.docNameConstant.SERIES.getName(), true);
  82. goodsSeries.setSeriesId(uniqueNoteCode.get("outId").toString());
  83. goodsSeries.setSeriesCode(uniqueNoteCode.get("outNote").toString());
  84. //新建
  85. goodsSeriesMapper.insert(goodsSeries);
  86. return ResponseResultUtil.success(goodsSeries);
  87. }
  88. /**
  89. * @desc : 编辑
  90. * @author : 于继渤
  91. * @date : 2023/1/5 9:39
  92. */
  93. @Transactional(
  94. rollbackFor = {Exception.class}
  95. )
  96. public ResponseResultVO<?> update(GoodsSeriesVO goodsSeriesVO) {
  97. GoodsSeries goodsSeries = goodsSeriesConvert.convertToPo(goodsSeriesVO);
  98. super.updateByUuid(goodsSeries);
  99. return ResponseResultUtil.success();
  100. }
  101. }