数据字典表
This commit is contained in:
parent
ac3db129cc
commit
c42f4d6e63
|
|
@ -0,0 +1,84 @@
|
||||||
|
package com.bonus.sgzb.base.api.domain;
|
||||||
|
|
||||||
|
import com.bonus.sgzb.common.core.annotation.Excel;
|
||||||
|
import com.bonus.sgzb.common.core.web.domain.BaseEntity;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典类型对象 sys_dict_type
|
||||||
|
*
|
||||||
|
* @author bonus
|
||||||
|
* @date 2023-12-11
|
||||||
|
*/
|
||||||
|
public class SysDict extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 字典主键 */
|
||||||
|
private Long dictId;
|
||||||
|
|
||||||
|
/** 字典名称 */
|
||||||
|
@Excel(name = "字典名称")
|
||||||
|
private String dictName;
|
||||||
|
|
||||||
|
/** 字典类型 */
|
||||||
|
@Excel(name = "字典类型")
|
||||||
|
private String dictType;
|
||||||
|
|
||||||
|
/** 状态(0正常 1停用) */
|
||||||
|
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
public void setDictId(Long dictId)
|
||||||
|
{
|
||||||
|
this.dictId = dictId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getDictId()
|
||||||
|
{
|
||||||
|
return dictId;
|
||||||
|
}
|
||||||
|
public void setDictName(String dictName)
|
||||||
|
{
|
||||||
|
this.dictName = dictName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDictName()
|
||||||
|
{
|
||||||
|
return dictName;
|
||||||
|
}
|
||||||
|
public void setDictType(String dictType)
|
||||||
|
{
|
||||||
|
this.dictType = dictType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDictType()
|
||||||
|
{
|
||||||
|
return dictType;
|
||||||
|
}
|
||||||
|
public void setStatus(String status)
|
||||||
|
{
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus()
|
||||||
|
{
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("dictId", getDictId())
|
||||||
|
.append("dictName", getDictName())
|
||||||
|
.append("dictType", getDictType())
|
||||||
|
.append("status", getStatus())
|
||||||
|
.append("createBy", getCreateBy())
|
||||||
|
.append("createTime", getCreateTime())
|
||||||
|
.append("updateBy", getUpdateBy())
|
||||||
|
.append("updateTime", getUpdateTime())
|
||||||
|
.append("remark", getRemark())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,105 @@
|
||||||
|
package com.bonus.sgzb.base.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.bonus.sgzb.base.api.domain.SysDict;
|
||||||
|
import com.bonus.sgzb.base.service.ISysDictService;
|
||||||
|
import com.bonus.sgzb.common.core.utils.poi.ExcelUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.bonus.sgzb.common.log.annotation.Log;
|
||||||
|
import com.bonus.sgzb.common.log.enums.BusinessType;
|
||||||
|
import com.bonus.sgzb.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.bonus.sgzb.common.core.web.controller.BaseController;
|
||||||
|
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||||
|
import com.bonus.sgzb.common.core.web.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典类型Controller
|
||||||
|
*
|
||||||
|
* @author bonus
|
||||||
|
* @date 2023-12-11
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/type")
|
||||||
|
public class SysDictController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private ISysDictService sysDictService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询字典类型列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("domain:type:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(SysDict sysDict)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<SysDict> list = sysDictService.selectSysDictTypeList(sysDict);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出字典类型列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("domain:type:export")
|
||||||
|
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, SysDict sysDict)
|
||||||
|
{
|
||||||
|
List<SysDict> list = sysDictService.selectSysDictTypeList(sysDict);
|
||||||
|
ExcelUtil<SysDict> util = new ExcelUtil<SysDict>(SysDict.class);
|
||||||
|
util.exportExcel(response, list, "字典类型数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取字典类型详细信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("domain:type:query")
|
||||||
|
@GetMapping(value = "/{dictId}")
|
||||||
|
public AjaxResult getInfo(@PathVariable("dictId") Long dictId)
|
||||||
|
{
|
||||||
|
return success(sysDictService.selectSysDictTypeByDictId(dictId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增字典类型
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("domain:type:add")
|
||||||
|
@Log(title = "字典类型", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@RequestBody SysDict sysDict)
|
||||||
|
{
|
||||||
|
return toAjax(sysDictService.insertSysDictType(sysDict));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改字典类型
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("domain:type:edit")
|
||||||
|
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@RequestBody SysDict sysDict)
|
||||||
|
{
|
||||||
|
return toAjax(sysDictService.updateSysDictType(sysDict));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除字典类型
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("domain:type:remove")
|
||||||
|
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{dictIds}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] dictIds)
|
||||||
|
{
|
||||||
|
return toAjax(sysDictService.deleteSysDictTypeByDictIds(dictIds));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.bonus.sgzb.base.mapper;
|
||||||
|
|
||||||
|
import com.bonus.sgzb.base.api.domain.SysDict;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典类型Mapper接口
|
||||||
|
*
|
||||||
|
* @author bonus
|
||||||
|
* @date 2023-12-11
|
||||||
|
*/
|
||||||
|
public interface SysDictMapper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询字典类型
|
||||||
|
*
|
||||||
|
* @param dictId 字典类型主键
|
||||||
|
* @return 字典类型
|
||||||
|
*/
|
||||||
|
public SysDict selectSysDictByDictId(Long dictId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询字典类型列表
|
||||||
|
*
|
||||||
|
* @param sysDict 字典类型
|
||||||
|
* @return 字典类型集合
|
||||||
|
*/
|
||||||
|
public List<SysDict> selectSysDictList(SysDict sysDict);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增字典类型
|
||||||
|
*
|
||||||
|
* @param sysDict 字典类型
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertSysDict(SysDict sysDict);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改字典类型
|
||||||
|
*
|
||||||
|
* @param sysDict 字典类型
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateSysDict(SysDict sysDict);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除字典类型
|
||||||
|
*
|
||||||
|
* @param dictId 字典类型主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteSysDictByDictId(Long dictId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除字典类型
|
||||||
|
*
|
||||||
|
* @param dictIds 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteSysDictByDictIds(Long[] dictIds);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
package com.bonus.sgzb.base.service;
|
||||||
|
|
||||||
|
import com.bonus.sgzb.base.api.domain.SysDict;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典类型Service接口
|
||||||
|
*
|
||||||
|
* @author bonus
|
||||||
|
* @date 2023-12-11
|
||||||
|
*/
|
||||||
|
public interface ISysDictService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询字典类型
|
||||||
|
*
|
||||||
|
* @param dictId 字典类型主键
|
||||||
|
* @return 字典类型
|
||||||
|
*/
|
||||||
|
public SysDict selectSysDictTypeByDictId(Long dictId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询字典类型列表
|
||||||
|
*
|
||||||
|
* @param sysDict 字典类型
|
||||||
|
* @return 字典类型集合
|
||||||
|
*/
|
||||||
|
public List<SysDict> selectSysDictTypeList(SysDict sysDict);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增字典类型
|
||||||
|
*
|
||||||
|
* @param sysDict 字典类型
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertSysDictType(SysDict sysDict);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改字典类型
|
||||||
|
*
|
||||||
|
* @param sysDict 字典类型
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateSysDictType(SysDict sysDict);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除字典类型
|
||||||
|
*
|
||||||
|
* @param dictIds 需要删除的字典类型主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteSysDictTypeByDictIds(Long[] dictIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除字典类型信息
|
||||||
|
*
|
||||||
|
* @param dictId 字典类型主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteSysDictTypeByDictId(Long dictId);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,98 @@
|
||||||
|
package com.bonus.sgzb.base.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.bonus.sgzb.base.api.domain.SysDict;
|
||||||
|
import com.bonus.sgzb.base.mapper.SysDictMapper;
|
||||||
|
import com.bonus.sgzb.base.service.ISysDictService;
|
||||||
|
import com.bonus.sgzb.common.core.utils.DateUtils;
|
||||||
|
import com.bonus.sgzb.system.api.domain.SysDictType;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典类型Service业务层处理
|
||||||
|
*
|
||||||
|
* @author bonus
|
||||||
|
* @date 2023-12-11
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SysDictServiceImpl implements ISysDictService
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private SysDictMapper sysDictMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询字典类型
|
||||||
|
*
|
||||||
|
* @param dictId 字典类型主键
|
||||||
|
* @return 字典类型
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SysDict selectSysDictTypeByDictId(Long dictId)
|
||||||
|
{
|
||||||
|
return sysDictMapper.selectSysDictByDictId(dictId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询字典类型列表
|
||||||
|
*
|
||||||
|
* @param sysDict 字典类型
|
||||||
|
* @return 字典类型
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SysDict> selectSysDictTypeList(SysDict sysDict)
|
||||||
|
{
|
||||||
|
return sysDictMapper.selectSysDictList(sysDict);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增字典类型
|
||||||
|
*
|
||||||
|
* @param sysDict 字典类型
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertSysDictType(SysDict sysDict)
|
||||||
|
{
|
||||||
|
sysDict.setCreateTime(DateUtils.getNowDate());
|
||||||
|
return sysDictMapper.insertSysDict(sysDict);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改字典类型
|
||||||
|
*
|
||||||
|
* @param sysDict 字典类型
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateSysDictType(SysDict sysDict)
|
||||||
|
{
|
||||||
|
sysDict.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
return sysDictMapper.updateSysDict(sysDict);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除字典类型
|
||||||
|
*
|
||||||
|
* @param dictIds 需要删除的字典类型主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteSysDictTypeByDictIds(Long[] dictIds)
|
||||||
|
{
|
||||||
|
return sysDictMapper.deleteSysDictByDictIds(dictIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除字典类型信息
|
||||||
|
*
|
||||||
|
* @param dictId 字典类型主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteSysDictTypeByDictId(Long dictId)
|
||||||
|
{
|
||||||
|
return sysDictMapper.deleteSysDictByDictId(dictId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,86 @@
|
||||||
|
<?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.bonus.sgzb.base.mapper.SysDictMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.bonus.sgzb.base.api.domain.SysDict" id="SysDictTypeResult">
|
||||||
|
<result 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" />
|
||||||
|
<result property="remark" column="remark" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectSysDictTypeVo">
|
||||||
|
select dict_id, dict_name, dict_type, status, create_by, create_time, update_by, update_time, remark from sys_dict_type
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectSysDictList" parameterType="com.bonus.sgzb.base.api.domain.SysDict" resultMap="SysDictTypeResult">
|
||||||
|
<include refid="selectSysDictTypeVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="dictName != null and dictName != ''"> and dict_name like concat('%', #{dictName}, '%')</if>
|
||||||
|
<if test="dictType != null and dictType != ''"> and dict_type = #{dictType}</if>
|
||||||
|
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectSysDictByDictId" parameterType="Long" resultMap="SysDictTypeResult">
|
||||||
|
<include refid="selectSysDictTypeVo"/>
|
||||||
|
where dict_id = #{dictId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertSysDict" parameterType="com.bonus.sgzb.base.api.domain.SysDict" useGeneratedKeys="true" keyProperty="dictId">
|
||||||
|
insert into sys_dict_type
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="dictName != null">dict_name,</if>
|
||||||
|
<if test="dictType != null">dict_type,</if>
|
||||||
|
<if test="status != null">status,</if>
|
||||||
|
<if test="createBy != null">create_by,</if>
|
||||||
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="updateBy != null">update_by,</if>
|
||||||
|
<if test="updateTime != null">update_time,</if>
|
||||||
|
<if test="remark != null">remark,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="dictName != null">#{dictName},</if>
|
||||||
|
<if test="dictType != null">#{dictType},</if>
|
||||||
|
<if test="status != null">#{status},</if>
|
||||||
|
<if test="createBy != null">#{createBy},</if>
|
||||||
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
<if test="remark != null">#{remark},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateSysDict" parameterType="com.bonus.sgzb.base.api.domain.SysDict">
|
||||||
|
update sys_dict_type
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="dictName != null">dict_name = #{dictName},</if>
|
||||||
|
<if test="dictType != null">dict_type = #{dictType},</if>
|
||||||
|
<if test="status != null">status = #{status},</if>
|
||||||
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
|
</trim>
|
||||||
|
where dict_id = #{dictId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteSysDictByDictId" parameterType="Long">
|
||||||
|
delete from sys_dict_type where dict_id = #{dictId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteSysDictByDictIds" parameterType="String">
|
||||||
|
delete from sys_dict_type where dict_id in
|
||||||
|
<foreach item="dictId" collection="array" open="(" separator="," close=")">
|
||||||
|
#{dictId}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue