diff --git a/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseDictDataController.java b/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseDictDataController.java new file mode 100644 index 00000000..446d6447 --- /dev/null +++ b/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseDictDataController.java @@ -0,0 +1,116 @@ +package com.op.wms.controller; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.op.common.core.utils.StringUtils; +import com.op.common.core.utils.poi.ExcelUtil; +import com.op.common.core.web.controller.BaseController; +import com.op.common.core.web.domain.AjaxResult; +import com.op.common.core.web.page.TableDataInfo; +import com.op.common.log.annotation.Log; +import com.op.common.log.enums.BusinessType; +import com.op.common.security.annotation.RequiresPermissions; +import com.op.common.security.utils.SecurityUtils; + +import com.op.system.api.domain.SysDictData; +import com.op.wms.service.IBaseDictDataService; +import com.op.wms.service.IBaseDictTypeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.List; + +/** + * 数据字典信息 + * + * @author OP + */ +@RestController +@RequestMapping("/dict/data") +public class BaseDictDataController extends BaseController { + @Autowired + private IBaseDictDataService dictDataService; + + @Autowired + private IBaseDictTypeService dictTypeService; + + @RequiresPermissions("factory:dict:list") + @GetMapping("/list") + @DS("#header.poolName") + public TableDataInfo list(SysDictData dictData) { + startPage(); + List list = dictDataService.selectDictDataList(dictData); + return getDataTable(list); + } + + @Log(title = "字典数据", businessType = BusinessType.EXPORT) + @RequiresPermissions("factory:dict:export") + @PostMapping("/export") + @DS("#header.poolName") + public void export(HttpServletResponse response, SysDictData dictData) { + List list = dictDataService.selectDictDataList(dictData); + ExcelUtil util = new ExcelUtil(SysDictData.class); + util.exportExcel(response, list, "字典数据"); + } + + /** + * 查询字典数据详细 + */ + @RequiresPermissions("factory:dict:query") + @GetMapping(value = "/{dictCode}") + @DS("#header.poolName") + public AjaxResult getInfo(@PathVariable Long dictCode) { + return success(dictDataService.selectDictDataById(dictCode)); + } + + /** + * 根据字典类型查询字典数据信息 + */ + @GetMapping(value = "/type/{dictType}") + @DS("#header.poolName") + public AjaxResult dictType(@PathVariable String dictType) { + List data = dictTypeService.selectDictDataByType(dictType); + if (StringUtils.isNull(data)) { + data = new ArrayList(); + } + return success(data); + } + + /** + * 新增字典类型 + */ + @RequiresPermissions("factory:dict:add") + @Log(title = "字典数据", businessType = BusinessType.INSERT) + @PostMapping + @DS("#header.poolName") + public AjaxResult add(@Validated @RequestBody SysDictData dict) { + dict.setCreateBy(SecurityUtils.getUsername()); + return toAjax(dictDataService.insertDictData(dict)); + } + + /** + * 修改保存字典类型 + */ + @RequiresPermissions("factory:dict:edit") + @Log(title = "字典数据", businessType = BusinessType.UPDATE) + @PutMapping + @DS("#header.poolName") + public AjaxResult edit(@Validated @RequestBody SysDictData dict) { + dict.setUpdateBy(SecurityUtils.getUsername()); + return toAjax(dictDataService.updateDictData(dict)); + } + + /** + * 删除字典类型 + */ + @RequiresPermissions("factory:dict:remove") + @Log(title = "字典类型", businessType = BusinessType.DELETE) + @DeleteMapping("/{dictCodes}") + @DS("#header.poolName") + public AjaxResult remove(@PathVariable Long[] dictCodes) { + dictDataService.deleteDictDataByIds(dictCodes); + return success(); + } +} diff --git a/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseDictTypeController.java b/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseDictTypeController.java new file mode 100644 index 00000000..b59fd38a --- /dev/null +++ b/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseDictTypeController.java @@ -0,0 +1,125 @@ +package com.op.wms.controller; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.op.common.core.utils.poi.ExcelUtil; +import com.op.common.core.web.controller.BaseController; +import com.op.common.core.web.domain.AjaxResult; +import com.op.common.core.web.page.TableDataInfo; +import com.op.common.log.annotation.Log; +import com.op.common.log.enums.BusinessType; +import com.op.common.security.annotation.RequiresPermissions; +import com.op.common.security.utils.SecurityUtils; +import com.op.system.api.domain.SysDictType; + +import com.op.wms.service.IBaseDictTypeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * 数据字典信息 + * + * @author OP + */ +@RestController +@RequestMapping("/dict/type") +public class BaseDictTypeController extends BaseController { + @Autowired + private IBaseDictTypeService dictTypeService; + + @RequiresPermissions("factory:dict:list") + @GetMapping("/list") + @DS("#header.poolName") + public TableDataInfo list(SysDictType dictType) { + startPage(); + List list = dictTypeService.selectDictTypeList(dictType); + return getDataTable(list); + } + + @Log(title = "字典类型", businessType = BusinessType.EXPORT) + @RequiresPermissions("factory:dict:export") + @PostMapping("/export") + @DS("#header.poolName") + public void export(HttpServletResponse response, SysDictType dictType) { + List list = dictTypeService.selectDictTypeList(dictType); + ExcelUtil util = new ExcelUtil(SysDictType.class); + util.exportExcel(response, list, "字典类型"); + } + + /** + * 查询字典类型详细 + */ + @RequiresPermissions("factory:dict:query") + @GetMapping(value = "/{dictId}") + @DS("#header.poolName") + public AjaxResult getInfo(@PathVariable Long dictId) { + return success(dictTypeService.selectDictTypeById(dictId)); + } + + /** + * 新增字典类型 + */ + @RequiresPermissions("factory:dict:add") + @Log(title = "字典类型", businessType = BusinessType.INSERT) + @PostMapping + @DS("#header.poolName") + public AjaxResult add(@Validated @RequestBody SysDictType dict) { + if (!dictTypeService.checkDictTypeUnique(dict)) { + return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在"); + } + dict.setCreateBy(SecurityUtils.getUsername()); + return toAjax(dictTypeService.insertDictType(dict)); + } + + /** + * 修改字典类型 + */ + @RequiresPermissions("factory:dict:edit") + @Log(title = "字典类型", businessType = BusinessType.UPDATE) + @PutMapping + @DS("#header.poolName") + public AjaxResult edit(@Validated @RequestBody SysDictType dict) { + if (!dictTypeService.checkDictTypeUnique(dict)) { + return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在"); + } + dict.setUpdateBy(SecurityUtils.getUsername()); + return toAjax(dictTypeService.updateDictType(dict)); + } + + /** + * 删除字典类型 + */ + @RequiresPermissions("factory:dict:remove") + @Log(title = "字典类型", businessType = BusinessType.DELETE) + @DeleteMapping("/{dictIds}") + @DS("#header.poolName") + public AjaxResult remove(@PathVariable Long[] dictIds) { + dictTypeService.deleteDictTypeByIds(dictIds); + return success(); + } + + /** + * 刷新字典缓存 + */ + @RequiresPermissions("factory:dict:remove") + @Log(title = "字典类型", businessType = BusinessType.CLEAN) + @DeleteMapping("/refreshCache") + @DS("#header.poolName") + public AjaxResult refreshCache() { + dictTypeService.resetDictCache(); + return success(); + } + + /** + * 获取字典选择框列表 + */ + @GetMapping("/optionselect") + @DS("#header.poolName") + public AjaxResult optionselect() { + List dictTypes = dictTypeService.selectDictTypeAll(); + return success(dictTypes); + } +} diff --git a/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseDictDataMapper.java b/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseDictDataMapper.java new file mode 100644 index 00000000..98874b80 --- /dev/null +++ b/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseDictDataMapper.java @@ -0,0 +1,95 @@ +package com.op.wms.mapper; + +import com.op.system.api.domain.SysDictData; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 字典表 数据层 + * + * @author OP + */ +public interface BaseDictDataMapper { + /** + * 根据条件分页查询字典数据 + * + * @param dictData 字典数据信息 + * @return 字典数据集合信息 + */ + public List selectDictDataList(SysDictData dictData); + + /** + * 根据字典类型查询字典数据 + * + * @param dictType 字典类型 + * @return 字典数据集合信息 + */ + public List selectDictDataByType(String dictType); + + /** + * 根据字典类型和字典键值查询字典数据信息 + * + * @param dictType 字典类型 + * @param dictValue 字典键值 + * @return 字典标签 + */ + public String selectDictLabel(@Param("dictType") String dictType, @Param("dictValue") String dictValue); + + /** + * 根据字典数据ID查询信息 + * + * @param dictCode 字典数据ID + * @return 字典数据 + */ + public SysDictData selectDictDataById(Long dictCode); + + /** + * 查询字典数据 + * + * @param dictType 字典类型 + * @return 字典数据 + */ + public int countDictDataByType(String dictType); + + /** + * 通过字典ID删除字典数据信息 + * + * @param dictCode 字典数据ID + * @return 结果 + */ + public int deleteDictDataById(Long dictCode); + + /** + * 批量删除字典数据信息 + * + * @param dictCodes 需要删除的字典数据ID + * @return 结果 + */ + public int deleteDictDataByIds(Long[] dictCodes); + + /** + * 新增字典数据信息 + * + * @param dictData 字典数据信息 + * @return 结果 + */ + public int insertDictData(SysDictData dictData); + + /** + * 修改字典数据信息 + * + * @param dictData 字典数据信息 + * @return 结果 + */ + public int updateDictData(SysDictData dictData); + + /** + * 同步修改字典类型 + * + * @param oldDictType 旧字典类型 + * @param newDictType 新旧字典类型 + * @return 结果 + */ + public int updateDictDataType(@Param("oldDictType") String oldDictType, @Param("newDictType") String newDictType); +} diff --git a/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseDictTypeMapper.java b/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseDictTypeMapper.java new file mode 100644 index 00000000..7441114d --- /dev/null +++ b/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseDictTypeMapper.java @@ -0,0 +1,83 @@ +package com.op.wms.mapper; + +import com.op.system.api.domain.SysDictType; + +import java.util.List; + +/** + * 字典表 数据层 + * + * @author OP + */ +public interface BaseDictTypeMapper { + /** + * 根据条件分页查询字典类型 + * + * @param dictType 字典类型信息 + * @return 字典类型集合信息 + */ + public List selectDictTypeList(SysDictType dictType); + + /** + * 根据所有字典类型 + * + * @return 字典类型集合信息 + */ + public List selectDictTypeAll(); + + /** + * 根据字典类型ID查询信息 + * + * @param dictId 字典类型ID + * @return 字典类型 + */ + public SysDictType selectDictTypeById(Long dictId); + + /** + * 根据字典类型查询信息 + * + * @param dictType 字典类型 + * @return 字典类型 + */ + public SysDictType selectDictTypeByType(String dictType); + + /** + * 通过字典ID删除字典信息 + * + * @param dictId 字典ID + * @return 结果 + */ + public int deleteDictTypeById(Long dictId); + + /** + * 批量删除字典类型信息 + * + * @param dictIds 需要删除的字典ID + * @return 结果 + */ + public int deleteDictTypeByIds(Long[] dictIds); + + /** + * 新增字典类型信息 + * + * @param dictType 字典类型信息 + * @return 结果 + */ + public int insertDictType(SysDictType dictType); + + /** + * 修改字典类型信息 + * + * @param dictType 字典类型信息 + * @return 结果 + */ + public int updateDictType(SysDictType dictType); + + /** + * 校验字典类型称是否唯一 + * + * @param dictType 字典类型 + * @return 结果 + */ + public SysDictType checkDictTypeUnique(String dictType); +} diff --git a/op-modules/op-wms/src/main/java/com/op/wms/service/IBaseDictDataService.java b/op-modules/op-wms/src/main/java/com/op/wms/service/IBaseDictDataService.java new file mode 100644 index 00000000..983c1e00 --- /dev/null +++ b/op-modules/op-wms/src/main/java/com/op/wms/service/IBaseDictDataService.java @@ -0,0 +1,61 @@ +package com.op.wms.service; + + +import com.op.system.api.domain.SysDictData; + +import java.util.List; + +/** + * 字典 业务层 + * + * @author OP + */ +public interface IBaseDictDataService { + /** + * 根据条件分页查询字典数据 + * + * @param dictData 字典数据信息 + * @return 字典数据集合信息 + */ + public List selectDictDataList(SysDictData dictData); + + /** + * 根据字典类型和字典键值查询字典数据信息 + * + * @param dictType 字典类型 + * @param dictValue 字典键值 + * @return 字典标签 + */ + public String selectDictLabel(String dictType, String dictValue); + + /** + * 根据字典数据ID查询信息 + * + * @param dictCode 字典数据ID + * @return 字典数据 + */ + public SysDictData selectDictDataById(Long dictCode); + + /** + * 批量删除字典数据信息 + * + * @param dictCodes 需要删除的字典数据ID + */ + public void deleteDictDataByIds(Long[] dictCodes); + + /** + * 新增保存字典数据信息 + * + * @param dictData 字典数据信息 + * @return 结果 + */ + public int insertDictData(SysDictData dictData); + + /** + * 修改保存字典数据信息 + * + * @param dictData 字典数据信息 + * @return 结果 + */ + public int updateDictData(SysDictData dictData); +} diff --git a/op-modules/op-wms/src/main/java/com/op/wms/service/IBaseDictTypeService.java b/op-modules/op-wms/src/main/java/com/op/wms/service/IBaseDictTypeService.java new file mode 100644 index 00000000..65f8c9d0 --- /dev/null +++ b/op-modules/op-wms/src/main/java/com/op/wms/service/IBaseDictTypeService.java @@ -0,0 +1,99 @@ +package com.op.wms.service; + + +import com.op.system.api.domain.SysDictData; +import com.op.system.api.domain.SysDictType; + +import java.util.List; + +/** + * 字典 业务层 + * + * @author OP + */ +public interface IBaseDictTypeService { + /** + * 根据条件分页查询字典类型 + * + * @param dictType 字典类型信息 + * @return 字典类型集合信息 + */ + public List selectDictTypeList(SysDictType dictType); + + /** + * 根据所有字典类型 + * + * @return 字典类型集合信息 + */ + public List selectDictTypeAll(); + + /** + * 根据字典类型查询字典数据 + * + * @param dictType 字典类型 + * @return 字典数据集合信息 + */ + public List selectDictDataByType(String dictType); + + /** + * 根据字典类型ID查询信息 + * + * @param dictId 字典类型ID + * @return 字典类型 + */ + public SysDictType selectDictTypeById(Long dictId); + + /** + * 根据字典类型查询信息 + * + * @param dictType 字典类型 + * @return 字典类型 + */ + public SysDictType selectDictTypeByType(String dictType); + + /** + * 批量删除字典信息 + * + * @param dictIds 需要删除的字典ID + */ + public void deleteDictTypeByIds(Long[] dictIds); + + /** + * 加载字典缓存数据 + */ + public void loadingDictCache(); + + /** + * 清空字典缓存数据 + */ + public void clearDictCache(); + + /** + * 重置字典缓存数据 + */ + public void resetDictCache(); + + /** + * 新增保存字典类型信息 + * + * @param dictType 字典类型信息 + * @return 结果 + */ + public int insertDictType(SysDictType dictType); + + /** + * 修改保存字典类型信息 + * + * @param dictType 字典类型信息 + * @return 结果 + */ + public int updateDictType(SysDictType dictType); + + /** + * 校验字典类型称是否唯一 + * + * @param dictType 字典类型 + * @return 结果 + */ + public boolean checkDictTypeUnique(SysDictType dictType); +} diff --git a/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseDictDataServiceImpl.java b/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseDictDataServiceImpl.java new file mode 100644 index 00000000..13998818 --- /dev/null +++ b/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseDictDataServiceImpl.java @@ -0,0 +1,102 @@ +package com.op.wms.service.impl; + +import com.op.common.security.utils.DictUtils; +import com.op.system.api.domain.SysDictData; +import com.op.wms.mapper.BaseDictDataMapper; +import com.op.wms.service.IBaseDictDataService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 字典 业务层处理 + * + * @author OP + */ +@Service +public class BaseDictDataServiceImpl implements IBaseDictDataService { + @Autowired + private BaseDictDataMapper dictDataMapper; + + /** + * 根据条件分页查询字典数据 + * + * @param dictData 字典数据信息 + * @return 字典数据集合信息 + */ + @Override + public List selectDictDataList(SysDictData dictData) { + return dictDataMapper.selectDictDataList(dictData); + } + + /** + * 根据字典类型和字典键值查询字典数据信息 + * + * @param dictType 字典类型 + * @param dictValue 字典键值 + * @return 字典标签 + */ + @Override + public String selectDictLabel(String dictType, String dictValue) { + return dictDataMapper.selectDictLabel(dictType, dictValue); + } + + /** + * 根据字典数据ID查询信息 + * + * @param dictCode 字典数据ID + * @return 字典数据 + */ + @Override + public SysDictData selectDictDataById(Long dictCode) { + return dictDataMapper.selectDictDataById(dictCode); + } + + /** + * 批量删除字典数据信息 + * + * @param dictCodes 需要删除的字典数据ID + */ + @Override + public void deleteDictDataByIds(Long[] dictCodes) { + for (Long dictCode : dictCodes) { + SysDictData data = selectDictDataById(dictCode); + dictDataMapper.deleteDictDataById(dictCode); + List dictDatas = dictDataMapper.selectDictDataByType(data.getDictType()); + DictUtils.setDictCache(data.getDictType(), dictDatas); + } + } + + /** + * 新增保存字典数据信息 + * + * @param data 字典数据信息 + * @return 结果 + */ + @Override + public int insertDictData(SysDictData data) { + int row = dictDataMapper.insertDictData(data); + if (row > 0) { + List dictDatas = dictDataMapper.selectDictDataByType(data.getDictType()); + DictUtils.setDictCache(data.getDictType(), dictDatas); + } + return row; + } + + /** + * 修改保存字典数据信息 + * + * @param data 字典数据信息 + * @return 结果 + */ + @Override + public int updateDictData(SysDictData data) { + int row = dictDataMapper.updateDictData(data); + if (row > 0) { + List dictDatas = dictDataMapper.selectDictDataByType(data.getDictType()); + DictUtils.setDictCache(data.getDictType(), dictDatas); + } + return row; + } +} diff --git a/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseDictTypeServiceImpl.java b/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseDictTypeServiceImpl.java new file mode 100644 index 00000000..e8bb51f1 --- /dev/null +++ b/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseDictTypeServiceImpl.java @@ -0,0 +1,205 @@ +package com.op.wms.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.op.common.core.constant.UserConstants; +import com.op.common.core.exception.ServiceException; +import com.op.common.core.utils.StringUtils; +import com.op.common.security.utils.DictUtils; +import com.op.system.api.domain.SysDictData; +import com.op.system.api.domain.SysDictType; +import com.op.wms.mapper.BaseDictDataMapper; +import com.op.wms.mapper.BaseDictTypeMapper; +import com.op.wms.service.IBaseDictTypeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 字典 业务层处理 + * + * @author OP + */ +@Service +public class BaseDictTypeServiceImpl implements IBaseDictTypeService { + @Autowired + private BaseDictTypeMapper dictTypeMapper; + + @Autowired + private BaseDictDataMapper dictDataMapper; + + /** + * 项目启动时,初始化字典到缓存 + */ + /*@PostConstruct + public void init() { + loadingDictCache(); + } +*/ + /** + * 根据条件分页查询字典类型 + * + * @param dictType 字典类型信息 + * @return 字典类型集合信息 + */ + @Override + public List selectDictTypeList(SysDictType dictType) { + return dictTypeMapper.selectDictTypeList(dictType); + } + + /** + * 根据所有字典类型 + * + * @return 字典类型集合信息 + */ + @Override + public List selectDictTypeAll() { + return dictTypeMapper.selectDictTypeAll(); + } + + /** + * 根据字典类型查询字典数据 + * + * @param dictType 字典类型 + * @return 字典数据集合信息 + */ + @Override + public List selectDictDataByType(String dictType) { + List dictDatas = DictUtils.getDictCache(dictType); + if (StringUtils.isNotEmpty(dictDatas)) { + return dictDatas; + } + dictDatas = dictDataMapper.selectDictDataByType(dictType); + if (StringUtils.isNotEmpty(dictDatas)) { + DictUtils.setDictCache(dictType, dictDatas); + return dictDatas; + } + return null; + } + + /** + * 根据字典类型ID查询信息 + * + * @param dictId 字典类型ID + * @return 字典类型 + */ + @Override + public SysDictType selectDictTypeById(Long dictId) { + return dictTypeMapper.selectDictTypeById(dictId); + } + + /** + * 根据字典类型查询信息 + * + * @param dictType 字典类型 + * @return 字典类型 + */ + @Override + public SysDictType selectDictTypeByType(String dictType) { + return dictTypeMapper.selectDictTypeByType(dictType); + } + + /** + * 批量删除字典类型信息 + * + * @param dictIds 需要删除的字典ID + */ + @Override + public void deleteDictTypeByIds(Long[] dictIds) { + for (Long dictId : dictIds) { + SysDictType dictType = selectDictTypeById(dictId); + if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0) { + throw new ServiceException(String.format("%1$s已分配,不能删除", dictType.getDictName())); + } + dictTypeMapper.deleteDictTypeById(dictId); + DictUtils.removeDictCache(dictType.getDictType()); + } + } + + /** + * 加载字典缓存数据 + */ + @Override + @DS("#header.poolName") + public void loadingDictCache() { + SysDictData dictData = new SysDictData(); + dictData.setStatus("0"); + Map> dictDataMap = dictDataMapper.selectDictDataList(dictData).stream() + .collect(Collectors.groupingBy(SysDictData::getDictType)); + for (Map.Entry> entry : dictDataMap.entrySet()) { + DictUtils.setDictCache(entry.getKey(), entry.getValue().stream() + .sorted(Comparator.comparing(SysDictData::getDictSort)).collect(Collectors.toList())); + } + } + + /** + * 清空字典缓存数据 + */ + @Override + public void clearDictCache() { + DictUtils.clearDictCache(); + } + + /** + * 重置字典缓存数据 + */ + @Override + public void resetDictCache() { + clearDictCache(); + loadingDictCache(); + } + + /** + * 新增保存字典类型信息 + * + * @param dict 字典类型信息 + * @return 结果 + */ + @Override + public int insertDictType(SysDictType dict) { + int row = dictTypeMapper.insertDictType(dict); + if (row > 0) { + DictUtils.setDictCache(dict.getDictType(), null); + } + return row; + } + + /** + * 修改保存字典类型信息 + * + * @param dict 字典类型信息 + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int updateDictType(SysDictType dict) { + SysDictType oldDict = dictTypeMapper.selectDictTypeById(dict.getDictId()); + dictDataMapper.updateDictDataType(oldDict.getDictType(), dict.getDictType()); + int row = dictTypeMapper.updateDictType(dict); + if (row > 0) { + List dictDatas = dictDataMapper.selectDictDataByType(dict.getDictType()); + DictUtils.setDictCache(dict.getDictType(), dictDatas); + } + return row; + } + + /** + * 校验字典类型称是否唯一 + * + * @param dict 字典类型 + * @return 结果 + */ + @Override + public boolean checkDictTypeUnique(SysDictType dict) { + Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId(); + SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType()); + if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } +} diff --git a/op-modules/op-wms/src/main/resources/mapper/wms/BaseDictDataMapper.xml b/op-modules/op-wms/src/main/resources/mapper/wms/BaseDictDataMapper.xml new file mode 100644 index 00000000..0a50f4e9 --- /dev/null +++ b/op-modules/op-wms/src/main/resources/mapper/wms/BaseDictDataMapper.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + select dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark + from base_dict_data + + + + + + + + + + + + + + delete from base_dict_data where dict_code = #{dictCode} + + + + delete from base_dict_data where dict_code in + + #{dictCode} + + + + + update base_dict_data + + dict_sort = #{dictSort}, + dict_label = #{dictLabel}, + dict_value = #{dictValue}, + dict_type = #{dictType}, + css_class = #{cssClass}, + list_class = #{listClass}, + is_default = #{isDefault}, + status = #{status}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = GETDATE() + + where dict_code = #{dictCode} + + + + update base_dict_data set dict_type = #{newDictType} where dict_type = #{oldDictType} + + + + insert into base_dict_data( + dict_sort, + dict_label, + dict_value, + dict_type, + css_class, + list_class, + is_default, + status, + remark, + create_by, + create_time + )values( + #{dictSort}, + #{dictLabel}, + #{dictValue}, + #{dictType}, + #{cssClass}, + #{listClass}, + #{isDefault}, + #{status}, + #{remark}, + #{createBy}, + GETDATE() + ) + + + diff --git a/op-modules/op-wms/src/main/resources/mapper/wms/BaseDictTypeMapper.xml b/op-modules/op-wms/src/main/resources/mapper/wms/BaseDictTypeMapper.xml new file mode 100644 index 00000000..bbf7ff29 --- /dev/null +++ b/op-modules/op-wms/src/main/resources/mapper/wms/BaseDictTypeMapper.xml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + select dict_id, dict_name, dict_type, status, create_by, create_time, remark + from base_dict_type + + + + + + + + + + + + + + delete from base_dict_type where dict_id = #{dictId} + + + + delete from base_dict_type where dict_id in + + #{dictId} + + + + + update base_dict_type + + dict_name = #{dictName}, + dict_type = #{dictType}, + status = #{status}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = GETDATE() + + where dict_id = #{dictId} + + + + insert into base_dict_type( + dict_name, + dict_type, + status, + remark, + create_by, + create_time + )values( + #{dictName}, + #{dictType}, + #{status}, + #{remark}, + #{createBy}, + GETDATE() + ) + + +