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.ResponseCodeEnum; 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.pojo.mst.Staff; import com.dk.mdm.model.query.mst.GoodsBrandQuery; 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.model.vo.mst.StaffVO; 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 org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import java.util.Map; import java.util.UUID; @Service @Transactional public class MoneyAccountService extends BaseService { @Override public BaseMapper getRepository() { return moneyAccountMapper; } @Autowired private MoneyAccountMapper moneyAccountMapper; @Autowired private MoneyAccountConvert moneyAccountConvert; @Autowired private CommonService commonService; /** * @desc : 重写主键 * @author : songy * @date : 2023/1/9 10:39 */ @Override public String getPrimaryKey() { return "moneyAccount_id"; } /** * @desc : 条件查询 * @author : songy * @date : 2023/2/29 10:40 */ @Pagination public ResponseResultVO> selectByCond(MoneyAccountQuery moneyAccountQuery) { return super.mergeListWithCount(moneyAccountQuery, moneyAccountMapper.selectByCond(moneyAccountQuery), moneyAccountMapper.countByCond(moneyAccountQuery)); } /** * @desc : 保存方法 * @author : songy * @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 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 : songy * @date : 2023/2/29 10:49 */ @Transactional( rollbackFor = {Exception.class} ) public ResponseResultVO update(MoneyAccountVO moneyAccountVO) { // 转化实体 MoneyAccount moneyAccount = moneyAccountConvert.convertToPo(moneyAccountVO); return ResponseResultUtil.success(super.update(moneyAccount, new UpdateWrapper().lambda().eq(MoneyAccount::getMacId, UUID.fromString(moneyAccount.getMacId())))); } }