<?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.willalp.apply.mapper.HsSysApplyMapper">

    <resultMap type="HsSysApply" id="HsSysApplyResult">
                    <result property="id"    column="id"    />
                    <result property="jgid"    column="jgid"    />
                    <result property="codeid"    column="codeid"    />
                    <result property="codevalue"    column="codevalue"    />
                    <result property="codeapply"    column="codeapply"    />
                    <result property="createBy"    column="create_by"    />
                    <result property="createTime"    column="create_time"    />
                    <result property="updateBy"    column="update_by"    />
                    <result property="updateTime"    column="update_time"    />
                    <result property="remark"    column="remark"    />
            </resultMap>

    <resultMap type="HsSysCode" id="HsSysCodeResult">
        <id     property="id"     column="id"     />
        <result property="jgid"   column="jgid"   />
        <result property="levelid"  column="levelid"   />
        <result property="codeid1"   column="codeid1"   />
        <result property="length1"   column="length1"   />
        <result property="name1"   column="name1"   />
        <result property="codeid2"   column="codeid2"   />
        <result property="length2"   column="length2"   />
        <result property="name2"   column="name2"   />
        <result property="codeid3"   column="codeid3"   />
        <result property="length3"   column="length3"   />
        <result property="name3"   column="name3"   />
        <result property="codeid4"   column="codeid4"   />
        <result property="length4"   column="length4"   />
        <result property="name4"   column="name4"   />
        <result property="codeid5"   column="codeid5"   />
        <result property="length5"   column="length5"   />
        <result property="name5"   column="name5"   />
        <result property="codeid6"   column="codeid6"   />
        <result property="length6"   column="length6"   />
        <result property="name6"   column="name6"   />
        <result property="codeid7"   column="codeid7"   />
        <result property="length7"   column="length7"   />
        <result property="name7"   column="name7"   />
        <result property="codeid8"   column="codeid8"   />
        <result property="length8"   column="length8"   />
        <result property="name8"   column="name8"   />
        <result property="codeid9"   column="codeid9"   />
        <result property="length9"   column="length9"   />
        <result property="name9"   column="name9"   />
        <result property="summary"   column="summary"   />
        <result property="approved"   column="approved"   />
        <result property="createBy"   column="create_by"   />
        <result property="createTime" column="create_time" />
        <result property="updateBy"   column="update_by"   />
        <result property="updateTime" column="update_time" />
    </resultMap>

    <sql id="selectHsSysApplyVo">
        select id, jgid, codeid, codevalue, codeapply,create_by, create_time, update_by, update_time, remark from hs_sys_apply
    </sql>

    <select id="selectHsSysApplyList" parameterType="HsSysApply" resultMap="HsSysApplyResult">
        <include refid="selectHsSysApplyVo"/>
        <where>
            is_delete = 0
            <if test="jgid != null  and jgid != ''"> and jgid = #{jgid}</if>
            <if test="codeid != null  and codeid != ''"> and codeid = #{codeid}</if>
            <if test="codevalue != null  and codevalue != ''"> and codevalue = #{codevalue}</if>
            <if test="codeapply != null  and codeapply != ''"> and codeapply = #{codeapply}</if>
                                                                                                                                                                                                    </where>
        order by create_time desc
    </select>

    <select id="selectCodeById" parameterType="Long" resultType="java.util.Map">
		select *   from hs_sys_code u
		where u.levelid = #{id}
	</select>

    <select id="selectHsSysLevelList" parameterType="String" resultType="java.util.Map">
        select levelcode,levelname,parent_id from hs_sys_level where id=#{id}
    </select>

    <update id="updateSysCodename">
        update hs_sys_code set
        <if test="i == 1">  name1 =  #{value} </if>
        <if test="i == 2">  name2 =  #{value} </if>
        <if test="i == 3">  name3 =  #{value} </if>
        <if test="i == 4">  name4 =  #{value} </if>
        <if test="i == 5">  name5 =  #{value} </if>
        <if test="i == 6">  name6 =  #{value} </if>
        <if test="i == 7">  name7 =  #{value} </if>
        <if test="i == 8">  name8 =  #{value} </if>
        <if test="i == 9">  name9 =  #{value} </if>
            where levelid=#{levelid}
    </update>

    <select id="checkApplyData" parameterType="String" resultType="java.util.Map">
        select codeapply from hs_sys_apply where codeapply=#{codeapply}
    </select>

</mapper>
