<?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="io.renren.modules.app.dao.SysDictDao">

    <!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="io.renren.modules.app.entity.SysDictEntity" id="sysDictMap">
                    <result property="id" column="id"/>
                    <result property="name" column="name"/>
                    <result property="type" column="type"/>
                    <result property="code" column="code"/>
                    <result property="value" column="value"/>
                    <result property="orderNum" column="order_num"/>
                    <result property="remark" column="remark"/>
                    <result property="delFlag" column="del_flag"/>
            </resultMap>

    <select id="queryByPage" parameterType="io.renren.modules.app.entity.SysDictEntity"
            resultType="io.renren.modules.app.entity.SysDictEntity">

        select * from sys_dict where 1=1

                    <if test=" id!=null and id!='' ">
                and id like CONCAT(#{id},"%")
            </if>
                    <if test=" name!=null and name!='' ">
                and name like CONCAT(#{name},"%")
            </if>
                    <if test=" type!=null and type!='' ">
                and type like CONCAT(#{type},"%")
            </if>
                    <if test=" code!=null and code!='' ">
                and code like CONCAT(#{code},"%")
            </if>
                    <if test=" value!=null and value!='' ">
                and value like CONCAT(#{value},"%")
            </if>
                    <if test=" orderNum!=null and orderNum!='' ">
                and order_num like CONCAT(#{orderNum},"%")
            </if>
                    <if test=" remark!=null and remark!='' ">
                and remark like CONCAT(#{remark},"%")
            </if>
                    <if test=" delFlag!=null and delFlag!='' ">
                and del_flag like CONCAT(#{delFlag},"%")
            </if>
        
    </select>

    <select id="queryList" parameterType="io.renren.modules.app.entity.SysDictEntity"
            resultType="io.renren.modules.app.entity.SysDictEntity">

       SELECT value,id FROM sys_dict where type=#{type} order by order_num

    </select>



    <select id="queryListLocal" parameterType="io.renren.modules.app.entity.SysDictEntity"
            resultType="io.renren.modules.app.entity.SysDictEntity">

      SELECT id,name,type FROM sys_dict  GROUP BY type ORDER BY type DESC
    </select>

	<select id="zdxlk" resultType="io.renren.modules.app.entity.SysDictEntity">
		SELECT name , type  from sys_dict group by type
	</select>
	
	<select id="selectCode" resultType="int" parameterType="io.renren.modules.app.entity.SysDictEntity">
		select count(*) from sys_dict a where a.`code` = #{code} and type = #{type}
	</select>
	
	<insert id="insertZDInfo" parameterType="io.renren.modules.app.entity.SysDictEntity" >
		insert into sys_dict(id,name,type,code,value,order_num,remark,del_flag) values(#{id},#{name},#{type},#{code},#{value},#{orderNum},#{remark},0)
	</insert>
	
	<select id="selectMaxID" resultType="String">
		select max(id) from sys_dict where type = #{type}
	</select>
</mapper>