工厂字典

master
shaoyong 9 months ago
parent 6c71264935
commit d2e58e871c

@ -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<SysDictData> 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<SysDictData> list = dictDataService.selectDictDataList(dictData);
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(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<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
if (StringUtils.isNull(data)) {
data = new ArrayList<SysDictData>();
}
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();
}
}

@ -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<SysDictType> 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<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(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<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
return success(dictTypes);
}
}

@ -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<SysDictData> selectDictDataList(SysDictData dictData);
/**
*
*
* @param dictType
* @return
*/
public List<SysDictData> 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);
}

@ -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<SysDictType> selectDictTypeList(SysDictType dictType);
/**
*
*
* @return
*/
public List<SysDictType> 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);
}

@ -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<SysDictData> 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);
}

@ -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<SysDictType> selectDictTypeList(SysDictType dictType);
/**
*
*
* @return
*/
public List<SysDictType> selectDictTypeAll();
/**
*
*
* @param dictType
* @return
*/
public List<SysDictData> 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);
}

@ -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<SysDictData> 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<SysDictData> 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<SysDictData> 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<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
DictUtils.setDictCache(data.getDictType(), dictDatas);
}
return row;
}
}

@ -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<SysDictType> selectDictTypeList(SysDictType dictType) {
return dictTypeMapper.selectDictTypeList(dictType);
}
/**
*
*
* @return
*/
@Override
public List<SysDictType> selectDictTypeAll() {
return dictTypeMapper.selectDictTypeAll();
}
/**
*
*
* @param dictType
* @return
*/
@Override
public List<SysDictData> selectDictDataByType(String dictType) {
List<SysDictData> 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<String, List<SysDictData>> dictDataMap = dictDataMapper.selectDictDataList(dictData).stream()
.collect(Collectors.groupingBy(SysDictData::getDictType));
for (Map.Entry<String, List<SysDictData>> 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<SysDictData> 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;
}
}

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.op.wms.mapper.BaseDictDataMapper">
<resultMap type="SysDictData" id="SysDictTypeResult">
<id property="dictCode" column="dict_code"/>
<result property="dictSort" column="dict_sort"/>
<result property="dictLabel" column="dict_label"/>
<result property="dictValue" column="dict_value"/>
<result property="dictType" column="dict_type"/>
<result property="cssClass" column="css_class"/>
<result property="listClass" column="list_class"/>
<result property="isDefault" column="is_default"/>
<result property="status" column="status"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<sql id="selectDictDataVo">
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
</sql>
<select id="selectDictDataList" parameterType="SysDictType" resultMap="SysDictTypeResult">
<include refid="selectDictDataVo"/>
<where>
<if test="dictType != null and dictType != ''">
AND dict_type = #{dictType}
</if>
<if test="dictLabel != null and dictLabel != ''">
AND dict_label like concat('%', #{dictLabel}, '%')
</if>
<if test="status != null and status != ''">
AND status = #{status}
</if>
</where>
order by dict_sort asc
</select>
<select id="selectDictDataByType" parameterType="SysDictType" resultMap="SysDictTypeResult">
<include refid="selectDictDataVo"/>
where status = '0' and dict_type = #{dictType} order by dict_sort asc
</select>
<select id="selectDictLabel" resultType="String">
select dict_label from base_dict_data
where dict_type = #{dictType} and dict_value = #{dictValue}
</select>
<select id="selectDictDataById" parameterType="Long" resultMap="SysDictTypeResult">
<include refid="selectDictDataVo"/>
where dict_code = #{dictCode}
</select>
<select id="countDictDataByType" resultType="Integer">
select count(1) from base_dict_data where dict_type=#{dictType}
</select>
<delete id="deleteDictDataById" parameterType="Long">
delete from base_dict_data where dict_code = #{dictCode}
</delete>
<delete id="deleteDictDataByIds" parameterType="Long">
delete from base_dict_data where dict_code in
<foreach collection="array" item="dictCode" open="(" separator="," close=")">
#{dictCode}
</foreach>
</delete>
<update id="updateDictData" parameterType="SysDictType">
update base_dict_data
<set>
<if test="dictSort != null">dict_sort = #{dictSort},</if>
<if test="dictLabel != null and dictLabel != ''">dict_label = #{dictLabel},</if>
<if test="dictValue != null and dictValue != ''">dict_value = #{dictValue},</if>
<if test="dictType != null and dictType != ''">dict_type = #{dictType},</if>
<if test="cssClass != null">css_class = #{cssClass},</if>
<if test="listClass != null">list_class = #{listClass},</if>
<if test="isDefault != null and isDefault != ''">is_default = #{isDefault},</if>
<if test="status != null">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = GETDATE()
</set>
where dict_code = #{dictCode}
</update>
<update id="updateDictDataType" parameterType="String">
update base_dict_data set dict_type = #{newDictType} where dict_type = #{oldDictType}
</update>
<insert id="insertDictData" parameterType="SysDictType">
insert into base_dict_data(
<if test="dictSort != null">dict_sort,</if>
<if test="dictLabel != null and dictLabel != ''">dict_label,</if>
<if test="dictValue != null and dictValue != ''">dict_value,</if>
<if test="dictType != null and dictType != ''">dict_type,</if>
<if test="cssClass != null and cssClass != ''">css_class,</if>
<if test="listClass != null and listClass != ''">list_class,</if>
<if test="isDefault != null and isDefault != ''">is_default,</if>
<if test="status != null">status,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="dictSort != null">#{dictSort},</if>
<if test="dictLabel != null and dictLabel != ''">#{dictLabel},</if>
<if test="dictValue != null and dictValue != ''">#{dictValue},</if>
<if test="dictType != null and dictType != ''">#{dictType},</if>
<if test="cssClass != null and cssClass != ''">#{cssClass},</if>
<if test="listClass != null and listClass != ''">#{listClass},</if>
<if test="isDefault != null and isDefault != ''">#{isDefault},</if>
<if test="status != null">#{status},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
GETDATE()
)
</insert>
</mapper>

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.op.wms.mapper.BaseDictTypeMapper">
<resultMap type="SysDictType" id="SysDictTypeResult">
<id property="dictId" column="dict_id"/>
<result property="dictName" column="dict_name"/>
<result property="dictType" column="dict_type"/>
<result property="status" column="status"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<sql id="selectDictTypeVo">
select dict_id, dict_name, dict_type, status, create_by, create_time, remark
from base_dict_type
</sql>
<select id="selectDictTypeList" parameterType="SysDictType" resultMap="SysDictTypeResult">
<include refid="selectDictTypeVo"/>
<where>
<if test="dictName != null and dictName != ''">
AND dict_name like concat('%', #{dictName}, '%')
</if>
<if test="status != null and status != ''">
AND status = #{status}
</if>
<if test="dictType != null and dictType != ''">
AND dict_type like concat('%', #{dictType}, '%')
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
</where>
</select>
<select id="selectDictTypeAll" resultMap="SysDictTypeResult">
<include refid="selectDictTypeVo"/>
</select>
<select id="selectDictTypeById" parameterType="Long" resultMap="SysDictTypeResult">
<include refid="selectDictTypeVo"/>
where dict_id = #{dictId}
</select>
<select id="selectDictTypeByType" parameterType="String" resultMap="SysDictTypeResult">
<include refid="selectDictTypeVo"/>
where dict_type = #{dictType}
</select>
<select id="checkDictTypeUnique" parameterType="String" resultMap="SysDictTypeResult">
select top 1 dict_id, dict_name, dict_type, status, create_by, create_time, remark
from base_dict_type
where dict_type = #{dictType}
</select>
<delete id="deleteDictTypeById" parameterType="Long">
delete from base_dict_type where dict_id = #{dictId}
</delete>
<delete id="deleteDictTypeByIds" parameterType="Long">
delete from base_dict_type where dict_id in
<foreach collection="array" item="dictId" open="(" separator="," close=")">
#{dictId}
</foreach>
</delete>
<update id="updateDictType" parameterType="SysDictType">
update base_dict_type
<set>
<if test="dictName != null and dictName != ''">dict_name = #{dictName},</if>
<if test="dictType != null and dictType != ''">dict_type = #{dictType},</if>
<if test="status != null">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = GETDATE()
</set>
where dict_id = #{dictId}
</update>
<insert id="insertDictType" parameterType="SysDictType">
insert into base_dict_type(
<if test="dictName != null and dictName != ''">dict_name,</if>
<if test="dictType != null and dictType != ''">dict_type,</if>
<if test="status != null">status,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="dictName != null and dictName != ''">#{dictName},</if>
<if test="dictType != null and dictType != ''">#{dictType},</if>
<if test="status != null">#{status},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
GETDATE()
)
</insert>
</mapper>
Loading…
Cancel
Save