123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- <?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.huaxu.dao.DictMapper">
- <!-- 结果集 -->
- <resultMap type="com.huaxu.entity.Dict" id="DictMap">
- <result property="id" column="ID" jdbcType="INTEGER"/>
- <result property="dictName" column="DICT_NAME" jdbcType="VARCHAR"/>
- <result property="dictCode" column="DICT_CODE" jdbcType="VARCHAR"/>
- <result property="dictValue" column="DICT_VALUE" jdbcType="VARCHAR"/>
- <result property="parentDictId" column="PARENT_DICT_ID" jdbcType="INTEGER"/>
- <result property="remark" column="REMARK" jdbcType="VARCHAR"/>
- <result property="status" column="STATUS" jdbcType="INTEGER"/>
- <result property="createBy" column="CREATE_BY" jdbcType="VARCHAR"/>
- <result property="dateCreate" column="DATE_CREATE" jdbcType="TIMESTAMP"/>
- <result property="updateBy" column="UPDATE_BY" jdbcType="VARCHAR"/>
- <result property="dateUpdate" column="DATE_UPDATE" jdbcType="TIMESTAMP"/>
- </resultMap>
- <!-- 基本字段 -->
- <sql id="Base_Column_List">
- ID,DICT_NAME,DICT_CODE,DICT_VALUE, PARENT_DICT_ID, REMARK, STATUS, DATE_CREATE,CREATE_BY,DATE_UPDATE,UPDATE_BY</sql>
- <!-- 查询单个 -->
- <select id="selectById" resultMap="DictMap">
- select
- <include refid="Base_Column_List"/>
- from uims_dict
- where ID = #{id}
- </select>
- <!-- 查询全部 -->
- <select id="selectAll" resultMap="DictMap">
- select
- <include refid="Base_Column_List"/>
- from uims_dict
- </select>
- <!--通过实体作为筛选条件查询-->
- <select id="selectList" resultMap="DictMap">
- select
- <include refid="Base_Column_List"/>
- from uims_dict
- <where>
- <if test="id != null">
- and ID = #{id}
- </if>
- <if test="dictName != null and dictName != ''">
- and DICT_NAME = #{dictName}
- </if>
- <if test="dictCode != null and dictCode != ''">
- and (DICT_CODE LIKE CONCAT('%',#{dictCode},'%')
- or DICT_VALUE LIKE CONCAT('%',#{dictCode},'%'))
- </if>
- <if test="parentDictId != null and parentDictId != ''">
- and PARENT_DICT_ID = #{parentDictId}
- </if>
- <if test="parentDictCode != null and parentDictCode != ''">
- and PARENT_DICT_ID in (select ID from uims_dict where DICT_CODE=#{parentDictCode})
- </if>
- and STATUS =1
- </where>
- order by DICT_NAME,DICT_VALUE
- </select>
- <!-- 新增所有列 -->
- <insert id="insert" keyProperty="id" useGeneratedKeys="true">
- insert into uims_dict(ID,DICT_NAME,DICT_CODE,DICT_VALUE,PARENT_DICT_ID, REMARK, STATUS, CREATE_BY,DATE_CREATE,UPDATE_BY,DATE_UPDATE)
- values ( #{id}, #{dictName}, #{dictCode}, #{dictValue}, #{parentDictId}, #{remark}, 1, #{createBy}, #{dateCreate}, #{updateBy}, #{dateUpdate})
- </insert>
- <!-- 批量新增 -->
- <insert id="batchInsert">
- insert into uims_dict(ID,DICT_NAME,DICT_CODE,DICT_VALUE,PARENT_DICT_ID, REMARK, STATUS, CREATE_BY,DATE_CREATE,UPDATE_BY,DATE_UPDATE)
- values
- <foreach collection="dicts" item="item" index="index" separator=",">
- (
- #{item.id}, #{item.dictName}, #{item.dictCode}, #{item.dictValue}, #{item.parentDictId}, #{item.remark}, 1,
- #{item.createBy}, #{item.dateCreate}, #{item.updateBy}, #{item.dateUpdate})
- </foreach>
- </insert>
- <!-- 通过主键修改数据 -->
- <update id="update">
- update uims.uims_dict
- <set>
- <if test="dictName != null and dictName != ''">
- DICT_NAME = #{dictName},
- </if>
- <if test="dictCode != null and dictCode != ''">
- DICT_CODE = #{dictCode},
- </if>
- <if test="dictValue != null and dictValue != ''">
- DICT_VALUE = #{dictValue},
- </if>
- <if test="parentDictId != null and parentDictId != ''">
- PARENT_DICT_ID = #{parentDictId},
- </if>
- <if test="remark != null and remark != ''">
- REMARK = #{remark},
- </if>
- <if test="status != null">
- STATUS = #{status},
- </if>
- <if test="createBy != null and createBy != ''">
- CREATE_BY = #{createBy},
- </if>
- <if test="dateCreate != null">
- DATE_CREATE = #{dateCreate},
- </if>
- <if test="updateBy != null and updateBy != ''">
- UPDATE_BY = #{updateBy},
- </if>
- <if test="dateUpdate != null">
- DATE_UPDATE = #{dateUpdate},
- </if>
- </set>
- where ID = #{id}
- </update>
- <!--通过主键删除-物理删除-->
- <!--<delete id="deleteById" parameterType="java.util.List">
- delete from uims_dict where ID IN
- <foreach item="item" index="index" collection="ids" open="("
- separator="," close=")">
- #{item}
- </foreach>
- or PARENT_DICT_ID in
- <foreach item="item" index="index" collection="ids" open="("
- separator="," close=")">
- #{item}
- </foreach>
- </delete>-->
- <!--通过主键删除-逻辑删除-->
- <update id="deleteById" parameterType="java.util.List">
- update uims.uims_dict
- set STATUS=0
- where ID in
- <foreach item="item" index="index" collection="ids" open="("
- separator="," close=")">
- #{item}
- </foreach>
- or PARENT_DICT_ID in
- <foreach item="item" index="index" collection="ids" open="("
- separator="," close=")">
- #{item}
- </foreach>
- </update>
- <!-- 总数 -->
- <select id="count" resultType="int">
- select count(*) from uims_dict
- </select>
- <select id="selectPage" resultMap="DictMap">
- select
- <include refid="Base_Column_List"/>
- from uims_dict
- <where>
- <if test="dict.id != null">
- and ID = #{dict.id}
- </if>
- <if test="dict.parentDictId == null and dict.dictCode != null and dict.dictCode != ''">
- and (DICT_NAME LIKE CONCAT('%',#{dict.dictCode},'%')
- or DICT_CODE LIKE CONCAT('%',#{dict.dictCode},'%'))
- </if>
- <if test="dict.parentDictId != null and dict.dictCode != null and dict.dictCode != ''">
- and (DICT_VALUE LIKE CONCAT('%',#{dict.dictCode},'%')
- or DICT_CODE LIKE CONCAT('%',#{dict.dictCode},'%'))
- </if>
- <if test="dict.parentDictId != null ">
- and PARENT_DICT_ID = #{dict.parentDictId}
- </if>
- <if test="dict.parentDictId == null">
- and PARENT_DICT_ID IS NULL
- </if>
- and STATUS =1
- </where>
- order by DICT_NAME,DICT_VALUE
- </select>
- </mapper>
|