Files
foton-slrs-system-rest/adc-da-sys/src/main/resources/mybatis/mapper/sys/DictionaryEOMapper.xml
T

320 lines
11 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.adc.da.sys.dao.DicEODao">
<!-- Result Map -->
<resultMap id="BaseResultMap" type="com.adc.da.sys.entity.DictionaryEO">
<id column="id" property="id" />
<result column="dictionary_code" property="dictionaryCode" />
<result column="dictionary_name" property="dictionaryName" />
<result column="order_num" property="orderNum" />
<result column="enable" property="enable" />
<result column="diction_type" property="dictionType" />
<result column="is_relate" property="isRelate" />
<result column="relate_dic_id" property="relateDicId" />
<result column="creation_user" property="creationUser" />
<result column="valid_flag" property="validFlag" />
<result column="creation_time" property="creationTime" />
<result column="modify_time" property="modifyTime" />
</resultMap>
<!-- TS_DICTIONARY table all fields -->
<sql id="Base_Column_List">
modify_time, creation_time, valid_flag, dictionary_name, dictionary_code, id, order_num, enable, diction_type,
is_relate,relate_dic_id,creation_user
</sql>
<resultMap id="DicTypeMap" extends="BaseResultMap" type="com.adc.da.sys.entity.DictionaryEO">
<collection property="dicTypeEOList" ofType="com.adc.da.sys.entity.DicTypeEO" javaType="java.util.List">
<id column="type_id" property="id" />
<result column="dic_type_code" property="dicTypeCode" />
<result column="dic_type_name" property="dicTypeName" />
<result column="dic_id" property="dicId" />
<result column="parent_id" property="parentId" />
<result column="type_valid_flag" property="validFlag" />
</collection>
</resultMap>
<!--gaoyan -->
<resultMap id="ListMap" type="com.adc.da.sys.entity.DictionaryEO">
<id column="id" property="id" />
<result column="dictionary_code" property="dictionaryCode" />
<result column="dictionary_name" property="dictionaryName" />
<result column="valid_flag" property="validFlag" />
<result column="creation_time" property="creationTime" />
<result column="modify_time" property="modifyTime" />
</resultMap>
<sql id="Dic_Type_List">
u.*, ur.id as type_id,
ur.dic_type_code as dic_type_code,
ur.dic_type_name as dic_type_name,
ur.dic_id as dic_id,
ur.parent_id as parent_id,
ur.valid_flag as type_valid_flag
</sql>
<!-- 查询条件 -->
<sql id="Base_Where_Clause">
where 1=1 and u0.valid_flag='0'
<trim suffixOverrides=",">
<if test="id != null and id != ''">
and u0.id ${idOperator} #{id}
</if>
<if test="dictionaryCode != null and dictionaryCode != ''">
and u0.dictionary_code ${dictionaryCodeOperator} '%${dictionaryCode}%'
</if>
<if test="dictionaryName != null and dictionaryName != ''">
and u0.dictionary_name ${dictionaryNameOperator} '%${dictionaryName}%'
</if>
<if test="validFlag != null" >
and u0.valid_flag ${validFlagOperator} #{validFlag}
</if>
<if test="modifyTime != null" >
and u0.modify_time ${modifyTimeOperator} #{modifyTime}
</if>
<if test="modifyTime1 != null" >
and u0.modify_time &gt;= #{modifyTime1}
</if>
<if test="modifyTime2 != null" >
and u0.modify_time &lt;= #{modifyTime2}
</if>
<if test="creationTime != null" >
and u0.creation_time ${creationTimeOperator} #{creationTime}
</if>
<if test="creationTime1 != null" >
and u0.creation_time &gt;= #{creationTime1}
</if>
<if test="creationTime2 != null" >
and u0.creation_time &lt;= #{creationTime2}
</if>
</trim>
</sql>
<update id="updateByPrimaryKeySelective" parameterType="com.adc.da.sys.entity.DictionaryEO" >
update TS_DICTIONARY
<set >
<if test="validFlag != null" >
valid_flag = #{validFlag},
</if>
<if test="creationTime != null" >
creation_time = #{creationTime},
</if>
<if test="modifyTime != null" >
modify_time = #{modifyTime},
</if>
<if test="dictionaryCode != null" >
dictionary_code = #{dictionaryCode},
</if>
<if test="dictionaryName != null" >
dictionary_name = #{dictionaryName},
</if>
<if test="orderNum != null" >
order_num = #{orderNum},
</if>
<if test="enable != null" >
enable = #{enable},
</if>
<if test="dictionType != null" >
diction_type = #{dictionType},
</if>
<if test="isRelate != null" >
is_relate = #{isRelate},
</if>
<if test="relateDicId != null" >
relate_dic_id = #{relateDicId},
</if>
<if test="creationUser != null" >
creation_user = #{creationUser},
</if>
</set>
where id = #{id}
</update>
<select id="getDictionaryEOById" resultMap="BaseResultMap"
parameterType="java.lang.String">
select
<include refid="Base_Column_List" />
from TS_DICTIONARY
where id = #{id}
</select>
<select id="getDictionaryEOByDicCode" resultMap="BaseResultMap"
parameterType="java.lang.String">
select
<include refid="Base_Column_List" />
from TS_DICTIONARY
where dictionary_code = #{dictionaryCode} AND valid_flag = 0
</select>
<!--杜云宝: 根据字典代码查询其详情(俩表)-->
<select id="getDicEOAndTypeEoByDicCode" resultMap="DicTypeMap"
parameterType="java.lang.String">
select
<include refid="Dic_Type_List" />
from TS_DICTIONARY u LEFT JOIN TS_DICTYPE ur ON u.ID = ur.DIC_ID
where dictionary_code = #{dictionaryCode} AND u.valid_flag = 0 AND ur.valid_flag = 0
</select>
<select id="getDictionaryEOByDicName" resultMap="BaseResultMap"
parameterType="java.lang.String">
select
<include refid="Base_Column_List" />
from TS_DICTIONARY
where dictionary_name = #{dictionaryName}
</select>
<insert id="insertSelective" parameterType="com.adc.da.sys.entity.DictionaryEO" >
<!-- <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
SELECT SEQ_TS_DICTIONARY.NEXTVAL FROM DUAL
</selectKey> -->
insert into TS_DICTIONARY
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="validFlag != null" >valid_flag,</if>
<if test="creationTime != null" >creation_time,</if>
<if test="modifyTime != null" >modify_time,</if>
<if test="id != null" >id,</if>
<if test="dictionaryCode != null" >dictionary_code,</if>
<if test="dictionaryName != null" >dictionary_name,</if>
<if test="orderNum != null" >order_num,</if>
<if test="enable != null" >enable,</if>
<if test="dictionType != null" >diction_type,</if>
<if test="isRelate != null" >is_relate,</if>
<if test="relateDicId != null" >relate_dic_id,</if>
<if test="creationUser != null" >creation_user,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="validFlag != null" >#{validFlag, jdbcType=VARCHAR},</if>
<if test="creationTime != null" >#{creationTime, jdbcType=TIMESTAMP},</if>
<if test="modifyTime != null" >#{modifyTime, jdbcType=TIMESTAMP},</if>
<if test="id != null" >#{id, jdbcType=VARCHAR},</if>
<if test="dictionaryCode != null" >#{dictionaryCode, jdbcType=VARCHAR},</if>
<if test="dictionaryName != null" >#{dictionaryName, jdbcType=VARCHAR},</if>
<if test="orderNum != null" >#{orderNum, jdbcType=INTEGER},</if>
<if test="enable != null" >#{enable, jdbcType=VARCHAR},</if>
<if test="dictionType != null" >#{dictionType, jdbcType=VARCHAR},</if>
<if test="isRelate != null" >#{isRelate, jdbcType=VARCHAR},</if>
<if test="relateDicId != null" >#{relateDicId, jdbcType=VARCHAR},</if>
<if test="creationUser != null" >#{creationUser, jdbcType=VARCHAR},</if>
</trim>
</insert>
<!-- 删除记录 -->
<update id="deleteDic" parameterType="java.lang.String">
update TS_DICTIONARY
set valid_flag = 1
where id = #{id}
</update>
<!-- TS_DICTIONARY 列表总数 -->
<select id="queryByCount" resultType="java.lang.Integer"
parameterType="com.adc.da.base.page.BasePage">
select count(distinct u0.id) from TS_DICTIONARY u0
left join TS_DICTYPE ur0 on u0.id = ur0.dic_id
<include refid="Base_Where_Clause" />
and u0.valid_flag != 1
</select>
<select id="queryByPage" resultMap="DicTypeMap" parameterType="com.adc.da.base.page.BasePage">
select <include refid="Dic_Type_List" /> from
(select tmp_tb.* , rownum rn from
(select distinct u0.* from TS_DICTIONARY u0
left join TS_DICTYPE ur0 on u0.id = ur0.dic_id
<include refid="Base_Where_Clause"/>
and u0.valid_flag != 1
order by order_num,u0.id
) tmp_tb where rownum &lt;= ${pager.endIndex}) u
left join TS_DICTYPE ur on u.id = ur.dic_id
where rn &gt;= ${pager.startIndex}
</select>
<select id="queryByList" resultMap="BaseResultMap" parameterType="com.adc.da.base.page.BasePage">
select <include refid="Base_Column_List"/> from TS_USER
<include refid="Base_Where_Clause"/>
order by order_num,id
</select>
<select id="getDictionaryEO" parameterType="java.lang.String" resultMap="ListMap">
select
*
from TS_DICTIONARY dn
where dn.VALID_FLAG = 0
</select>
<select id="getDictionaryEOByType" parameterType="java.lang.String" resultMap="ListMap">
select
*
from TS_DICTIONARY dn
where dn.VALID_FLAG = 0
<if test="null!=types and types.size()>0">
and dn.DICTIONARY_CODE in
<foreach item="msgId" collection="types" open="(" separator="," close=")" index="index">
#{msgId}
</foreach>
</if>
</select>
<select id="countByCodeOrName" resultType="java.lang.Integer" parameterType="com.adc.da.base.page.BasePage">
select count(1) from TS_DICTIONARY
where valid_flag='0'
<if test="dictionaryCode != null" >
and dictionary_code = #{dictionaryCode}
</if>
<if test="dictionaryName != null" >
and dictionary_name = #{dictionaryName}
</if>
<if test="notId != null" >
and id != #{notId}
</if>
</select>
<!-- TS_DICTIONARY 列表总数-->
<select id="queryAllDicByCount" resultType="java.lang.Integer" parameterType="com.adc.da.base.page.BasePage">
select count(1) from TS_DICTIONARY u0
<include refid="Base_Where_Clause"/>
</select>
<!-- 查询TS_DICTIONARY列表 -->
<select id="queryAllDicByPage" resultMap="BaseResultMap" parameterType="com.adc.da.base.page.BasePage">
select <include refid="Base_Column_List" /> from
(select tmp_tb.* from
(select <include refid="Base_Column_List" /> from TS_DICTIONARY u0
<include refid="Base_Where_Clause"/>
<if test="sql != null">
ORDER BY ${sql}
</if>
) tmp_tb limit ${pager.startIndex-1},${pageSize}) a
</select>
<select id="getDictionarySelList" parameterType="java.lang.String" resultType="com.adc.da.sys.common.SelectionResult">
select ID as value,DICTIONARY_NAME as label
from TS_DICTIONARY
where VALID_FLAG = '0'
<if test="id != null" >
and id != #{id}
</if>
order by order_num,id
</select>
<select id="getDictionaryCodeSelList" parameterType="java.lang.String" resultType="com.adc.da.sys.common.SelectionResult">
select dictionary_code as value,DICTIONARY_NAME as label
from TS_DICTIONARY
where VALID_FLAG = '0'
<if test="id != null" >
and id != #{id}
</if>
order by order_num,id
</select>
<select id="queryUseByCount" resultType="java.lang.Integer"
parameterType="java.lang.String">
select count(*) from SAR_STAND_ATTR_DETAILS
left join TS_DICTIONARY on TS_DICTIONARY.dictionary_code=SAR_STAND_ATTR_DETAILS.sel_val
where SAR_STAND_ATTR_DETAILS.valid_flag =0 and TS_DICTIONARY.id=#{id}
</select>
</mapper>