266 lines
9.8 KiB
XML
266 lines
9.8 KiB
XML
<?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.nis.web.dao.basics.SysDictInfoDao" >
|
|
|
|
<resultMap id="dictResultMap" type="com.nis.domain.basics.SysDictInfo" >
|
|
<id column="sys_dict_id" property="sysDictId" jdbcType="INTEGER" />
|
|
<result column="item_type" property="itemType" jdbcType="INTEGER" />
|
|
<result column="item_code" property="itemCode" jdbcType="VARCHAR" />
|
|
<result column="item_value" property="itemValue" jdbcType="VARCHAR" />
|
|
<result column="item_desc" property="itemDesc" jdbcType="VARCHAR" />
|
|
<result column="is_leaf" property="isLeaf" jdbcType="INTEGER" />
|
|
<result column="level_no" property="levelNo" jdbcType="INTEGER" />
|
|
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
|
|
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
|
|
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
|
|
<!-- 父id -->
|
|
<association property="parent" javaType="com.nis.domain.basics.SysDictInfo">
|
|
<id column="parent_id" property="sysDictId" jdbcType="INTEGER" />
|
|
</association>
|
|
<!-- 创建人员 -->
|
|
<association property="sysDictCreator" javaType="com.nis.domain.SysUser">
|
|
<id property="id" column="creator_id"/>
|
|
<result property="loginId" column="login_id"/>
|
|
<result property="name" column="name"/>
|
|
</association>
|
|
<!-- 修改人员 -->
|
|
<association property="sysDictEditor" javaType="com.nis.domain.SysUser">
|
|
<id property="id" column="editor_id"/>
|
|
<result property="loginId" column="login_id"/>
|
|
<result property="name" column="name"/>
|
|
</association>
|
|
</resultMap>
|
|
<sql id="sysDictInfoColumns">
|
|
s.sys_dict_id AS sysDictId,
|
|
s.item_type AS itemType,
|
|
s.item_code AS itemCode,
|
|
s.item_value AS itemValue,
|
|
s.item_desc AS itemDesc,
|
|
s.parent_id AS "parent.sysDictId",
|
|
s.is_leaf AS isLeaf,
|
|
s.level_no AS levelNo,
|
|
s.is_valid AS isValid,
|
|
s.creator_id AS "sysDictCreator.id",
|
|
s.create_time AS createTime,
|
|
s.editor_id AS "sysDictEditor.id",
|
|
s.edit_time AS editTime,
|
|
s.is_initianlize AS isInitianlize
|
|
</sql>
|
|
|
|
<sql id="menuJoins">
|
|
LEFT JOIN sys_dict_info p ON p.sys_dict_id = s.parent_id
|
|
</sql>
|
|
|
|
<!-- 查出所有 有效数据-->
|
|
<select id="findAllDictList" resultType="sysDictInfo">
|
|
SELECT
|
|
<include refid="sysDictInfoColumns"/>
|
|
FROM sys_dict_info s
|
|
<include refid="menuJoins"/>
|
|
WHERE s.is_valid =1
|
|
</select>
|
|
|
|
<!-- 查询顶层分页 -->
|
|
<select id="findTopDictList" resultMap="dictResultMap" parameterType="com.nis.domain.basics.SysDictInfo">
|
|
SELECT * FROM sys_dict_info s WHERE s.is_valid=1
|
|
<if test="conditionType != null and conditionType.size()>0 " >
|
|
AND s.item_type in
|
|
<foreach collection="conditionType" item="singleType" index="index"
|
|
open="(" close=")" separator=",">
|
|
#{singleType}
|
|
</foreach>
|
|
</if>
|
|
<if test="itemCode != null and itemCode != '' " >
|
|
AND s.item_code like '%${itemCode}%'
|
|
</if>
|
|
<if test="itemValue!= null and itemValue != '' " >
|
|
AND s.item_value like '%${itemValue}%'
|
|
</if>
|
|
<if test="itemType != null and itemType != '' " >
|
|
AND s.item_type = ${itemType}
|
|
</if>
|
|
<if test="beginDate !=null" >
|
|
AND s.create_time >= #{beginDate,jdbcType=TIMESTAMP}
|
|
</if>
|
|
<if test="endDate !=null" >
|
|
AND s.create_time <= #{endDate,jdbcType=TIMESTAMP}
|
|
</if>
|
|
<if test="editBeginDate !=null" >
|
|
AND edit_time >= #{editBeginDate,jdbcType=TIMESTAMP}
|
|
</if>
|
|
<if test="editEndDate !=null" >
|
|
AND edit_time <= #{editEndDate,jdbcType=TIMESTAMP}
|
|
</if>
|
|
AND s.parent_id not in (
|
|
SELECT s2.sys_dict_id FROM sys_dict_info s2 WHERE s2.is_valid=1
|
|
<if test="conditionType != null and conditionType.size()>0 " >
|
|
AND s2.item_type in
|
|
<foreach collection="conditionType" item="singleType" index="index"
|
|
open="(" close=")" separator=",">
|
|
#{singleType}
|
|
</foreach>
|
|
</if>
|
|
<if test="itemCode != null and itemCode != '' " >
|
|
AND s2.item_code like '%${itemCode}%'
|
|
</if>
|
|
<if test="itemValue!= null and itemValue != '' " >
|
|
AND s2.item_value like '%${itemValue}%'
|
|
</if>
|
|
<if test="itemType != null and itemType != '' " >
|
|
AND s2.item_type = ${itemType}
|
|
</if>
|
|
<if test="beginDate !=null" >
|
|
AND s2.create_time >= #{beginDate,jdbcType=TIMESTAMP}
|
|
</if>
|
|
<if test="endDate !=null" >
|
|
AND s2.create_time <= #{endDate,jdbcType=TIMESTAMP}
|
|
</if>
|
|
<if test="editBeginDate !=null" >
|
|
AND edit_time >= #{editBeginDate,jdbcType=TIMESTAMP}
|
|
</if>
|
|
<if test="editEndDate !=null" >
|
|
AND edit_time <= #{editEndDate,jdbcType=TIMESTAMP}
|
|
</if>
|
|
)
|
|
<choose>
|
|
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
|
ORDER BY s.${page.orderBy}
|
|
</when>
|
|
<otherwise>
|
|
ORDER BY s.create_time desc
|
|
</otherwise>
|
|
</choose>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 查询所有符合条件列表 -->
|
|
<select id="findAllSysDictInfo" resultMap="dictResultMap">
|
|
SELECT * FROM sys_dict_info WHERE is_valid=1
|
|
|
|
<if test="sysDictInfo.conditionType != null and sysDictInfo.conditionType.size()>0 " >
|
|
AND item_type in
|
|
<foreach collection="sysDictInfo.conditionType" item="singleType" index="index"
|
|
open="(" close=")" separator=",">
|
|
#{singleType}
|
|
</foreach>
|
|
</if>
|
|
|
|
<if test="sysDictInfo.itemType != null and sysDictInfo.itemType != '' " >
|
|
AND item_type = ${sysDictInfo.itemType}
|
|
</if>
|
|
<if test="sysDictInfo.itemCode != null and sysDictInfo.itemCode != '' " >
|
|
AND item_code like '%${sysDictInfo.itemCode}%'
|
|
</if>
|
|
<if test="sysDictInfo.itemValue!= null and sysDictInfo.itemValue != '' " >
|
|
AND item_value like '%${sysDictInfo.itemValue}%'
|
|
</if>
|
|
<if test="sysDictInfo.beginDate !=null" >
|
|
AND create_time >= #{sysDictInfo.beginDate,jdbcType=TIMESTAMP}
|
|
</if>
|
|
<if test="sysDictInfo.endDate !=null" >
|
|
AND create_time <= #{sysDictInfo.endDate,jdbcType=TIMESTAMP}
|
|
</if>
|
|
<if test="sysDictInfo.editBeginDate !=null" >
|
|
AND edit_time >= #{sysDictInfo.editBeginDate,jdbcType=TIMESTAMP}
|
|
</if>
|
|
<if test="sysDictInfo.editEndDate !=null" >
|
|
AND edit_time <= #{sysDictInfo.editEndDate,jdbcType=TIMESTAMP}
|
|
</if>
|
|
<choose>
|
|
<when test="orderBy != null and orderBy != ''">
|
|
ORDER BY ${orderBy}
|
|
</when>
|
|
<otherwise>
|
|
ORDER BY create_time desc
|
|
</otherwise>
|
|
</choose>
|
|
</select>
|
|
<!-- 根据主键查询字典详细信息 -->
|
|
|
|
<select id="getDictById" resultType="com.nis.domain.basics.SysDictInfo">
|
|
select
|
|
<include refid="sysDictInfoColumns"/>
|
|
from sys_dict_info s where s.sys_dict_id = #{sysDictId}
|
|
</select>
|
|
|
|
<!-- 新增字典信息 -->
|
|
|
|
<insert id="insertDict" parameterType="com.nis.domain.basics.SysDictInfo" useGeneratedKeys="true" keyProperty="id" >
|
|
insert into sys_dict_info (item_type, item_code, item_value, item_desc, parent_id, is_leaf,level_no, is_valid, creator_id, create_time, editor_id, edit_time)
|
|
values ( #{itemType,jdbcType=INTEGER}, #{itemCode,jdbcType=VARCHAR},
|
|
#{itemValue,jdbcType=VARCHAR}, #{itemDesc,jdbcType=VARCHAR},
|
|
#{parent.sysDictId,jdbcType=INTEGER}, #{isLeaf,jdbcType=INTEGER}, #{levelNo,jdbcType=INTEGER}, #{isValid,jdbcType=INTEGER},
|
|
#{sysDictCreator.id,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
|
|
#{sysDictEditor.id,jdbcType=INTEGER}, #{editTime,jdbcType=TIMESTAMP})
|
|
</insert>
|
|
|
|
|
|
|
|
<!-- 查询所有非叶子配置 -->
|
|
<select id="findAllNoLeafDictList" resultType="com.nis.domain.basics.SysDictInfo" parameterType="java.lang.Integer">
|
|
SELECT
|
|
<include refid="sysDictInfoColumns"/>
|
|
FROM sys_dict_info s
|
|
WHERE s.is_valid = 1 AND s.is_leaf = 0 AND item_type = #{itemType}
|
|
</select>
|
|
|
|
<!-- 修改 -->
|
|
<update id="update">
|
|
UPDATE sys_dict_info s SET
|
|
s.sys_dict_id = #{sysDictId},
|
|
s.item_type = #{itemType},
|
|
s.item_code = #{itemCode},
|
|
s.item_value = #{itemValue},
|
|
s.item_desc = #{itemDesc},
|
|
s.parent_id = #{parent.sysDictId},
|
|
s.is_leaf = #{isLeaf},
|
|
s.level_no = #{levelNo},
|
|
s.creator_id = #{sysDictCreator.id},
|
|
s.editor_id = #{sysDictEditor.id},
|
|
s.edit_time = #{editTime}
|
|
WHERE s.sys_dict_id = #{sysDictId}
|
|
</update>
|
|
|
|
<!-- 删除 -->
|
|
|
|
<update id="delete">
|
|
UPDATE sys_dict_info s set s.is_valid = #{isValid} where s.sys_dict_id = #{sysDictId}
|
|
</update>
|
|
|
|
|
|
<!-- 根据itemCode查询字典对象列表 -->
|
|
|
|
<select id="findByItemCode" resultType="com.nis.domain.basics.SysDictInfo">
|
|
select
|
|
<include refid="sysDictInfoColumns"/>
|
|
from sys_dict_info s where s.item_code = #{itemCode}
|
|
</select>
|
|
|
|
<!-- 根据上级id选出所有下级 -->
|
|
|
|
<select id="getDictByParentId" resultMap="dictResultMap">
|
|
select *
|
|
from sys_dict_info s where parent_id = #{parentId} and is_valid = 1
|
|
</select>
|
|
|
|
<!-- 查询最大itemCode值 -->
|
|
<select id="findMaxItemCode" resultType="java.lang.Integer">
|
|
select max(s.item_code) from sys_dict_info s
|
|
</select>
|
|
|
|
<!-- 保存层级 -->
|
|
<update id="updateLevelNo">
|
|
UPDATE sys_dict_info s SET
|
|
s.level_no = #{levelNo}
|
|
WHERE s.sys_dict_id = #{sysDictId}
|
|
</update>
|
|
<!-- 获取增强字符串配置district -->
|
|
<select id="getDistrictDict" resultType="com.nis.domain.basics.SysDictInfo" >
|
|
SELECT
|
|
<include refid="sysDictInfoColumns"/>
|
|
FROM sys_dict_info s
|
|
WHERE s.is_valid = 1 AND item_type = 3 AND item_code like concat(#{itemCode,jdbcType=VARCHAR},'%')
|
|
</select>
|
|
</mapper> |