MoneyAccountService.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. package com.dk.mdm.service.mst;
  2. import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
  3. import com.dk.common.infrastructure.annotaiton.Pagination;
  4. import com.dk.common.infrastructure.constant.Constant;
  5. import com.dk.common.model.pojo.PageList;
  6. import com.dk.common.response.ResponseCodeEnum;
  7. import com.dk.common.response.ResponseResultUtil;
  8. import com.dk.common.response.ResponseResultVO;
  9. import com.dk.mdm.infrastructure.convert.mst.MoneyAccountConvert;
  10. import com.dk.mdm.model.pojo.mst.MoneyAccount;
  11. import com.dk.mdm.mapper.mst.MoneyAccountMapper;
  12. import com.dk.common.service.BaseService;
  13. import com.dk.common.mapper.BaseMapper;
  14. import com.dk.mdm.model.pojo.mst.Staff;
  15. import com.dk.mdm.model.query.mst.GoodsBrandQuery;
  16. import com.dk.mdm.model.query.mst.MoneyAccountQuery;
  17. import com.dk.mdm.model.response.mst.MoneyAccountResponse;
  18. import com.dk.mdm.model.vo.mst.MoneyAccountVO;
  19. import com.dk.mdm.model.vo.mst.StaffVO;
  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 org.springframework.web.bind.annotation.PathVariable;
  25. import org.springframework.web.bind.annotation.PostMapping;
  26. import java.util.Map;
  27. import java.util.UUID;
  28. @Service
  29. @Transactional
  30. public class MoneyAccountService extends BaseService<MoneyAccount> {
  31. @Override
  32. public BaseMapper<MoneyAccount> getRepository() {
  33. return moneyAccountMapper;
  34. }
  35. @Autowired
  36. private MoneyAccountMapper moneyAccountMapper;
  37. @Autowired
  38. private MoneyAccountConvert moneyAccountConvert;
  39. @Autowired
  40. private CommonService commonService;
  41. /**
  42. * @desc : 重写主键
  43. * @author : songy
  44. * @date : 2023/1/9 10:39
  45. */
  46. @Override
  47. public String getPrimaryKey() {
  48. return "moneyAccount_id";
  49. }
  50. /**
  51. * @desc : 条件查询
  52. * @author : songy
  53. * @date : 2023/2/29 10:40
  54. */
  55. @Pagination
  56. public ResponseResultVO<PageList<MoneyAccountResponse>> selectByCond(MoneyAccountQuery moneyAccountQuery) {
  57. return super.mergeListWithCount(moneyAccountQuery, moneyAccountMapper.selectByCond(moneyAccountQuery),
  58. moneyAccountMapper.countByCond(moneyAccountQuery));
  59. }
  60. /**
  61. * @desc : 保存方法
  62. * @author : songy
  63. * @date : 2023/2/29 10:49
  64. */
  65. @Transactional(
  66. rollbackFor = {Exception.class}
  67. )
  68. public ResponseResultVO<?> insert(MoneyAccountVO moneyAccountVO) {
  69. // 转化实体
  70. MoneyAccount moneyAccount = moneyAccountConvert.convertToPo(moneyAccountVO);
  71. Integer displayNo = moneyAccountMapper.selectDisplayNo(new MoneyAccountQuery());
  72. if (displayNo != null) {
  73. //插入序号
  74. moneyAccount.setDisplayNo(displayNo);
  75. } else {
  76. moneyAccount.setDisplayNo(0);
  77. }
  78. // 获取编码和主键UuId
  79. Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.MONEYACCOUNT.getName(),true);
  80. moneyAccount.setMacId(codeMap.get("outId").toString());
  81. moneyAccount.setMacCode(codeMap.get("outNote").toString());
  82. return super.insert(moneyAccount);
  83. }
  84. /**
  85. * @desc : 编辑方法
  86. * @author : songy
  87. * @date : 2023/2/29 10:49
  88. */
  89. @Transactional(
  90. rollbackFor = {Exception.class}
  91. )
  92. public ResponseResultVO<Boolean> update(MoneyAccountVO moneyAccountVO) {
  93. // 转化实体
  94. MoneyAccount moneyAccount = moneyAccountConvert.convertToPo(moneyAccountVO);
  95. return ResponseResultUtil.success(super.update(moneyAccount, new UpdateWrapper<MoneyAccount>().lambda().eq(MoneyAccount::getMacId,
  96. UUID.fromString(moneyAccount.getMacId()))));
  97. }
  98. }