DictionaryDataService.java 3.5 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.DictionaryDataConvert;
  8. import com.dk.mdm.model.pojo.mst.DictionaryData;
  9. import com.dk.mdm.mapper.mst.DictionaryDataMapper;
  10. import com.dk.common.service.BaseService;
  11. import com.dk.common.mapper.BaseMapper;
  12. import com.dk.mdm.model.query.mst.DictionaryDataQuery;
  13. import com.dk.mdm.model.response.mst.DictionaryDataResponse;
  14. import com.dk.mdm.model.vo.mst.DictionaryDataVO;
  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.HashMap;
  21. import java.util.Map;
  22. @Service
  23. @Transactional
  24. public class DictionaryDataService extends BaseService<DictionaryData> {
  25. @Override
  26. public BaseMapper<DictionaryData> getRepository() {
  27. return dictionaryDataMapper;
  28. }
  29. @Autowired
  30. private DictionaryDataMapper dictionaryDataMapper;
  31. @Autowired
  32. private CommonService commonService;
  33. @Autowired
  34. private DictionaryDataConvert dictionaryDataConvert;
  35. /**
  36. * @desc : 重写主键
  37. * @author : 于继渤
  38. * @date : 2024/2/29 20:29
  39. */
  40. @Override
  41. public String getPrimaryKey() {
  42. return "data_id";
  43. }
  44. /**
  45. * @desc : 查询
  46. * @author : 于继渤
  47. * @date : 2023/1/5 9:39
  48. */
  49. @Pagination
  50. public ResponseResultVO<PageList<DictionaryDataResponse>> selectByCond(DictionaryDataQuery dictionaryDataQuery) {
  51. return super.mergeListWithCount(dictionaryDataQuery, dictionaryDataMapper.selectByCond(dictionaryDataQuery),
  52. dictionaryDataMapper.countByCond(dictionaryDataQuery));
  53. }
  54. /**
  55. * @desc : 新建
  56. * @author : 于继渤
  57. * @date : 2023/1/5 9:39
  58. */
  59. @Transactional(
  60. rollbackFor = {Exception.class}
  61. )
  62. public ResponseResultVO<?> insert(DictionaryDataVO dictionaryDataVO) {
  63. //实体转换
  64. DictionaryData dictionaryData = dictionaryDataConvert.convertToPo(dictionaryDataVO);
  65. Map<String, Object> map = new HashMap<>();
  66. map.put("dictCode",dictionaryDataVO.getDictCode());
  67. //设置序号
  68. dictionaryData.setDisplayNo(commonService.getMaxDisplayNo(Constant.DisplayNoTable.DICTIONARYDATA,map));
  69. //设置编码
  70. Map<String, Object> uniqueNoteCode = commonService.getUniqueNoteCode(dictionaryDataVO.getDictCode(), true);
  71. dictionaryData.setDataId(uniqueNoteCode.get("outId").toString());
  72. dictionaryData.setDataCode(uniqueNoteCode.get("outNote").toString());
  73. //新建
  74. dictionaryDataMapper.insert(dictionaryData);
  75. return ResponseResultUtil.success();
  76. }
  77. /**
  78. * @desc : 编辑
  79. * @author : 于继渤
  80. * @date : 2023/1/5 9:39
  81. */
  82. @Transactional(
  83. rollbackFor = {Exception.class}
  84. )
  85. public ResponseResultVO<?> update(DictionaryDataVO dictionaryDataVO) {
  86. DictionaryData dictionaryData = dictionaryDataConvert.convertToPo(dictionaryDataVO);
  87. super.updateByUuid(dictionaryData);
  88. return ResponseResultUtil.success();
  89. }
  90. /**
  91. * @desc : 批量编辑序号
  92. * @author : 于继渤
  93. * @date : 2023/1/4 9:39
  94. */
  95. @Transactional(
  96. rollbackFor = {Exception.class}
  97. )
  98. public ResponseResultVO<?> updateBatchDictionaryDataDisplayNo(DictionaryDataVO dictionaryDataVO) {
  99. dictionaryDataMapper.updateBatchDictionaryDataDisplayNo(dictionaryDataVO.getDataIds());
  100. return ResponseResultUtil.success();
  101. }
  102. }