| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- package com.dk.mdm.service.mst;
- import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
- import com.dk.common.infrastructure.annotaiton.Pagination;
- import com.dk.common.infrastructure.constant.Constant;
- import com.dk.common.model.pojo.PageList;
- import com.dk.common.response.ResponseResultUtil;
- import com.dk.common.response.ResponseResultVO;
- import com.dk.mdm.infrastructure.convert.mst.MoneyAccountConvert;
- import com.dk.mdm.model.pojo.mst.MoneyAccount;
- import com.dk.mdm.mapper.mst.MoneyAccountMapper;
- import com.dk.common.service.BaseService;
- import com.dk.common.mapper.BaseMapper;
- import com.dk.mdm.model.query.mst.MoneyAccountQuery;
- import com.dk.mdm.model.response.mst.MoneyAccountResponse;
- import com.dk.mdm.model.vo.mst.MoneyAccountVO;
- import com.dk.mdm.service.common.CommonService;
- import org.springframework.stereotype.Service;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.transaction.annotation.Transactional;
- import java.util.Map;
- import java.util.UUID;
- @Service
- @Transactional
- public class MoneyAccountService extends BaseService<MoneyAccount> {
- @Override
- public BaseMapper<MoneyAccount> getRepository() {
- return moneyAccountMapper;
- }
- @Autowired
- private MoneyAccountMapper moneyAccountMapper;
- @Autowired
- private MoneyAccountConvert moneyAccountConvert;
- @Autowired
- private CommonService commonService;
- /**
- * @desc : 重写主键
- * @author : 宋扬
- * @date : 2023/1/9 10:39
- */
- @Override
- public String getPrimaryKey() {
- return "mac_id";
- }
- /**
- * @desc : 条件查询
- * @author : 宋扬
- * @date : 2023/2/29 10:40
- */
- @Pagination
- public ResponseResultVO<PageList<MoneyAccountResponse>> selectByCond(MoneyAccountQuery moneyAccountQuery) {
- return super.mergeListWithCount(moneyAccountQuery, moneyAccountMapper.selectByCond(moneyAccountQuery),
- moneyAccountMapper.countByCond(moneyAccountQuery));
- }
- /**
- * @desc : 保存方法
- * @author : 宋扬
- * @date : 2023/2/29 10:49
- */
- @Transactional(
- rollbackFor = {Exception.class}
- )
- public ResponseResultVO<?> insert(MoneyAccountVO moneyAccountVO) {
- // 转化实体
- MoneyAccount moneyAccount = moneyAccountConvert.convertToPo(moneyAccountVO);
- Integer displayNo = moneyAccountMapper.selectDisplayNo(new MoneyAccountQuery());
- if (displayNo != null) {
- //插入序号
- moneyAccount.setDisplayNo(displayNo);
- } else {
- moneyAccount.setDisplayNo(0);
- }
- // 获取编码和主键UuId
- Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.MONEYACCOUNT.getName(),true);
- moneyAccount.setMacId(codeMap.get("outId").toString());
- moneyAccount.setMacCode(codeMap.get("outNote").toString());
- return super.insert(moneyAccount);
- }
- /**
- * @desc : 编辑方法
- * @author : 宋扬
- * @date : 2023/2/29 10:49
- */
- @Transactional(
- rollbackFor = {Exception.class}
- )
- public ResponseResultVO<Boolean> update(MoneyAccountVO moneyAccountVO) {
- // 转化实体
- MoneyAccount moneyAccount = moneyAccountConvert.convertToPo(moneyAccountVO);
- return ResponseResultUtil.success(super.update(moneyAccount, new UpdateWrapper<MoneyAccount>().lambda().eq(MoneyAccount::getMacId,
- UUID.fromString(moneyAccount.getMacId()))));
- }
- }
|