<?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)
values(#{dicTypeIndex},#{dicTypeName},#{dicTypeNumber},#{dicTypeDiscribe},#{userIndex},#{updateTime},#{state})
</insert>
    <!-- 删除 -->
    <update id="deleteType">
update pqs_dicType set state=0 where DICTYPE_INDEX=#{dicTypeIndex,jdbcType=VARCHAR}
</update>
    <!-- 修改 -->
    <update id="updateType">
update pqs_dicType set DICTYPE_NAME=#{dicTypeName},DICTYPE_DESCRIBE=#{dicTypeDiscribe},UPDATETIME=#{updateTime} where DICTYPE_INDEX=#{dicTypeIndex,jdbcType=VARCHAR}
</update>
    <!-- 查询排序最大 -->
    <select id="selNumMax" resultType="int">
select  NVL(max(dictype_number),0)  from pqs_dictype where state=1 order by dictype_number desc
</select>
    <select id="selectIndexAll" resultMap="DicDataTypeMapperMap">
select  * from pqs_dictype dt  where  dt.state=1 order by dt.updatetime desc
</select>
    <!-- 查询 -->
    <select id="All" resultMap="DicDataTypeMapperMap">
select  * from pqs_dictype dt  where dt.dictype_index  <![CDATA[ <> ]]>#{typeId}  and dt.state=1 order by dt.updatetime desc
</select>
    <!-- 查询 -->
    <select id="selectTypeName" resultMap="DicDataTypeMapperMap">
select  * from pqs_dictype dt  where dt.dictype_index =#{typeId} and dt.state=1 order by dt.updatetime desc
</select>
    <select id="getLog" resultMap="DicDataTypeMapperMap">
select * from pqs_dictype where state=1 and  dictype_name in
        <foreach collection="list" item="item" index="index" open="("
                 separator="," close=")">
            #{item}
        </foreach>
</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 state=1) and state = 1
</select>

    <select id="selectAllExcelData" resultType="DicTypeExcelBody">
		select * from PQS_DICTYPE where STATE =1
	</select>
</mapper>