<?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.njcn.mapper.configuration.DicDataTypeMapper">

<!-- 数据字典 -->
<resultMap type="com.njcn.pojo.configuration.DicType" id="DicDataTypeMapperMap" autoMapping="true">
	<id property="dicTypeIndex" column="DICTYPE_INDEX"/>
	<association property="uID"  autoMapping="true" javaType="User">
    <id property="userIndex" column="USER_INDEX"/>	
	</association>
</resultMap>
<!-- 增加 -->
<insert id="insertType">
insert into pqs_dictype(DICTYPE_INDEX,DICTYPE_NAME,DICTYPE_NUMBER,DICTYPE_DESCRIBE,USER_INDEX,UPDATETIME,STATE,SYSTYPE)
values(#{dicTypeIndex},#{dicTypeName},#{dicTypeNumber},#{dicTypeDiscribe},#{userIndex},#{updateTime},#{state},#{sysType})
</insert>
<!-- 删除 -->
<update id="deleteType">
update pqs_dicType set state=0 where DICTYPE_INDEX=#{dicTypeIndex,jdbcType=VARCHAR} and systype=#{sysType}
</update>
<!-- 修改 -->
<update id="updateType">
update pqs_dicType set DICTYPE_NAME=#{dicTypeName},DICTYPE_DESCRIBE=#{dicTypeDiscribe},UPDATETIME=#{updateTime},SYSTYPE=#{sysType} where DICTYPE_INDEX=#{dicTypeIndex,jdbcType=VARCHAR} 
</update>
<!-- 查询排序最大 -->
<select id="selNumMax" resultType="int">
select   max(dictype_number) from pqs_dictype where systype=#{sysType} and state=1 order by dictype_number desc
</select>
<select id="selectIndexAll" resultMap="DicDataTypeMapperMap">
select  * from pqs_dictype dt join pqs_user u on dt.USER_INDEX=u.USER_INDEX where  dt.systype=#{sysType} and dt.state=1 order by dt.updatetime desc 
</select>
<!-- 查询 -->
<select id="All" resultMap="DicDataTypeMapperMap">
select  * from pqs_dictype dt join pqs_user u on dt.USER_INDEX=u.USER_INDEX where dt.dictype_index  <![CDATA[ <> ]]>#{typeId} and dt.systype=#{sysType} and dt.state=1 order by dt.updatetime desc 
</select>
<!-- 查询 -->
<select id="selectTypeName" resultMap="DicDataTypeMapperMap">
select  * from pqs_dictype dt join pqs_user u on dt.USER_INDEX=u.USER_INDEX where dt.dictype_index =#{typeId} and dt.systype=#{sysType} and dt.state=1 order by dt.updatetime desc 
</select>
<select id="getLog" resultMap="DicDataTypeMapperMap">
select * from pqs_dictype where systype=#{sysType} and state=1 and  dictype_name like '%事件类型%'
</select>
<!-- 根据dictype_name查询 -->
<select id="querybyname" resultMap="DicDataTypeMapperMap">
select * from pqs_dictype where DICTYPE_NAME=#{dicTypename,jdbcType=VARCHAR} and state=1
</select>
<!-- 查询除此之外的名称 -->
<select id="selectName" resultMap="DicDataTypeMapperMap">
select * from pqs_dictype  where DICTYPE_NAME not in (select DICTYPE_NAME from pqs_dictype where DICTYPE_INDEX=#{dicTypeIndex} and systype=#{sysType} and state=1) and state = 1
</select>
</mapper>