123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?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.liang.dao.BaseDictDao">
- <!--查询一个枚举,公共方法-->
- <select id="getDictByCode" parameterType="string" resultType="map">
- select dict_id, dict_key as code, dict_value as name
- from sys_dict_info
- where status = '0'
- and del_flag = '0'
- and dict_code = #{_parameter}
- order by order_num
- </select>
- <resultMap id="SysDict" type="com.liang.entity.DictInfo">
- <id column="dict_id" jdbcType="VARCHAR" property="dictId"/>
- <result column="descript" jdbcType="VARCHAR" property="descript"/>
- <result column="dict_code" jdbcType="VARCHAR" property="dictCode"/>
- <result column="dict_name" jdbcType="VARCHAR" property="dictName"/>
- <result column="dict_key" jdbcType="VARCHAR" property="dictKey"/>
- <result column="dict_value" jdbcType="VARCHAR" property="dictValue"/>
- <result column="order_num" jdbcType="INTEGER" property="orderNum"/>
- <result column="status" jdbcType="CHAR" property="status"/>
- <result column="create_user" jdbcType="VARCHAR" property="createUser"/>
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
- <result column="del_flag" jdbcType="CHAR" property="delFlag"/>
- <result column="update_user" jdbcType="VARCHAR" property="updateUser"/>
- </resultMap>
- <!--根据条件,查询所有枚举-->
- <select id="getAllBaseDict" resultMap="SysDict" parameterType="map">
- select
- max(dict_code) as dict_code,
- max(dict_name) as dict_name,
- max(status) as status,
- max(create_user) as create_user,
- max(create_time) as create_time,
- max(del_flag) as del_flag,
- max(update_time) as update_time,
- max(update_user) as update_user,
- max(descript) as descript
- from sys_dict_info
- where del_flag = '0'
- <if test="dictCode != null and dictCode != ''">
- and dict_code like CONCAT('%',#{dictCode},'%')
- </if>
- <if test="dictName != null and dictName != ''">
- and dict_name like CONCAT('%',#{dictName},'%')
- </if>
- <if test="status != null and status != ''">
- and status = #{status}
- </if>
- group by dict_code
- order by dict_code
- </select>
- <!-- 判断字典code是否已存在 -->
- <select id="checkExistByDictCode" parameterType="string" resultType="integer">
- SELECT 1 FROM sys_dict_info WHERE del_flag = '0' and dict_code = #{_parameter} LIMIT 1
- </select>
- <!--根据条件,查询所有枚举-->
- <select id="getDictByDictCode" resultMap="SysDict" parameterType="java.lang.String">
- select * from sys_dict_info where del_flag = '0' and dict_code = #{_parameter}
- </select>
- <!--插入一个枚举-->
- <insert id="addOneDict" parameterType="com.liang.entity.DictInfo">
- insert into sys_dict_info (
- <if test="dictId != null and dictId != ''">dict_id,</if>
- <if test="dictCode != null and dictCode != ''">dict_code,</if>
- <if test="dictName != null and dictName != ''">dict_name,</if>
- <if test="dictKey != null and dictKey != ''">dict_key,</if>
- <if test="dictValue != null and dictValue != ''">dict_value,</if>
- <if test="orderNum != null">order_num,</if>
- <if test="createUser != null and createUser != ''">create_user,</if>
- <if test="descript != null and descript != ''">descript,</if>
- status,
- del_flag
- )
- values (
- <if test="dictId != null and dictId != ''">#{dictId},</if>
- <if test="dictCode != null and dictCode != ''">#{dictCode},</if>
- <if test="dictName != null and dictName != ''">#{dictName},</if>
- <if test="dictKey != null and dictKey != ''">#{dictKey},</if>
- <if test="dictValue != null and dictValue != ''">#{dictValue},</if>
- <if test="orderNum != null"> #{orderNum},</if>
- <if test="createUser != null and createUser != ''">#{createUser},</if>
- <if test="descript != null and descript != ''">#{descript},</if>
- #{status},
- #{delFlag}
- )
- </insert>
- <!--逻辑删除一个枚举-->
- <update id="deleteDict" parameterType="java.lang.String">
- update sys_dict_info set del_flag = '1' where dict_code = #{_parameter}
- </update>
- <!--物理删除一个枚举-->
- <delete id="realDeleteDict" parameterType="java.lang.String">
- delete from sys_dict_info where dict_code = #{_parameter}
- </delete>
- <!--禁用一个枚举-->
- <update id="forbidDict" parameterType="java.lang.String">
- update sys_dict_info set status = '1' where dict_code = #{_parameter}
- </update>
- <!--启用一个枚举-->
- <update id="enableDict" parameterType="java.lang.String">
- update sys_dict_info set status = '0' where dict_code = #{_parameter}
- </update>
- </mapper>
|