package com.dk.mdm.service.mst; 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.DictionaryDataConvert; import com.dk.mdm.model.pojo.mst.DictionaryData; import com.dk.mdm.mapper.mst.DictionaryDataMapper; import com.dk.common.service.BaseService; import com.dk.common.mapper.BaseMapper; import com.dk.mdm.model.query.mst.DictionaryDataQuery; import com.dk.mdm.model.response.mst.DictionaryDataResponse; import com.dk.mdm.model.vo.mst.DictionaryDataVO; import com.dk.mdm.model.vo.mst.WarehouseVO; 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.HashMap; import java.util.Map; @Service @Transactional public class DictionaryDataService extends BaseService { @Override public BaseMapper getRepository() { return dictionaryDataMapper; } @Autowired private DictionaryDataMapper dictionaryDataMapper; @Autowired private CommonService commonService; @Autowired private DictionaryDataConvert dictionaryDataConvert; /** * @desc : 重写主键 * @author : 于继渤 * @date : 2024/2/29 20:29 */ @Override public String getPrimaryKey() { return "data_id"; } /** * @desc : 查询 * @author : 于继渤 * @date : 2023/1/5 9:39 */ @Pagination public ResponseResultVO> selectByCond(DictionaryDataQuery dictionaryDataQuery) { return super.mergeListWithCount(dictionaryDataQuery, dictionaryDataMapper.selectByCond(dictionaryDataQuery), dictionaryDataMapper.countByCond(dictionaryDataQuery)); } /** * @desc : 新建 * @author : 于继渤 * @date : 2023/1/5 9:39 */ @Transactional( rollbackFor = {Exception.class} ) public ResponseResultVO insert(DictionaryDataVO dictionaryDataVO) { //实体转换 DictionaryData dictionaryData = dictionaryDataConvert.convertToPo(dictionaryDataVO); Map map = new HashMap<>(); map.put("dictCode",dictionaryDataVO.getDictCode()); //设置序号 dictionaryData.setDisplayNo(commonService.getMaxDisplayNo(Constant.DisplayNoTable.DICTIONARYDATA,map)); //设置编码 Map uniqueNoteCode = commonService.getUniqueNoteCode(dictionaryDataVO.getDictCode(), true); dictionaryData.setDataId(uniqueNoteCode.get("outId").toString()); dictionaryData.setDataCode(uniqueNoteCode.get("outNote").toString()); //新建 dictionaryDataMapper.insert(dictionaryData); return ResponseResultUtil.success(); } /** * @desc : 编辑 * @author : 于继渤 * @date : 2023/1/5 9:39 */ @Transactional( rollbackFor = {Exception.class} ) public ResponseResultVO update(DictionaryDataVO dictionaryDataVO) { DictionaryData dictionaryData = dictionaryDataConvert.convertToPo(dictionaryDataVO); super.updateByUuid(dictionaryData); return ResponseResultUtil.success(); } /** * @desc : 批量编辑序号 * @author : 于继渤 * @date : 2023/1/4 9:39 */ @Transactional( rollbackFor = {Exception.class} ) public ResponseResultVO updateBatchDictionaryDataDisplayNo(DictionaryDataVO dictionaryDataVO) { dictionaryDataMapper.updateBatchDictionaryDataDisplayNo(dictionaryDataVO.getDataIds()); return ResponseResultUtil.success(); } }