<?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="cn.timer.api.dao.spmk.SpmkSpglMapper">
<!-- 
    <resultMap id="SpmkSpglDto" type="cn.timer.api.dto.spmk.SpmkSpglDto" >
                <id column="id" property="id" />
                <result column="org_code" property="orgCode" />
                <result column="spz_id" property="spzId" />
                <result column="mb_id" property="mbId" />
                <result column="icon_address" property="iconAddress" />
                <result column="name" property="name" />
                <result column="description" property="description" />
                <result column="is_open" property="isOpen" />
                <result column="sort" property="sort" />
                <result column="sprqc_type" property="sprqcType" />
                <result column="txts" property="txts" />
                <result column="spyj" property="spyj" />
                <result column="is_zdtg" property="isZdtg" />
                <result column="dymb_type" property="dymbType" />
                <result column="is_bxqm" property="isBxqm" />
                <result column="is_syscqm" property="isSyscqm" />
                <result column="is_mccxqm" property="isMccxqm" />
                <result column="update_time" property="updateTime" />
                <result column="create_time" property="createTime" />
                <collection column="SpmkKjpz_id" property="spmkKjpzs" ofType="cn.timer.api.bean.spmk.SpmkKjpz" javaType="java.util.ArrayList">
                	<id column="SpmkKjpz_id" property="id" />
	                <result column="SpmkKjpz_kj_id" property="kjId" />
	                <result column="SpmkKjpz_title" property="title" />
	                <result column="SpmkKjpz_titletwo" property="titletwo" />
	                <result column="SpmkKjpz_type" property="type" />
	                <result column="SpmkKjpz_tswz" property="tswz" />
	                <result column="SpmkKjpz_dzmc" property="dzmc" />
	                <result column="SpmkKjpz_is_yz" property="isYz" />
	                <result column="SpmkKjpz_is_dy" property="isDy" />
	                <result column="SpmkKjpz_time_type" property="timeType" />
	                <result column="SpmkKjpz_is_syzp" property="isSyzp" />
	                <result column="SpmkKjpz_dygs_type" property="dygsType" />
	                <result column="SpmkKjpz_is_show" property="isShow" />
	                <result column="SpmkKjpz_ljtz_url" property="ljtzUrl" />
	                <result column="SpmkKjpz_is_showup" property="isShowup" />
	                <result column="SpmkKjpz_xx_type" property="xxType" />
	                <result column="SpmkKjpz_jsgs" property="jsgs" />
	                <result column="SpmkKjpz_glspd_id" property="glspdId" />
	                <result column="SpmkKjpz_description" property="description" />
	                <collection column="SpmkXzx_id" property="spmkXzxs" ofType="cn.timer.api.bean.spmk.SpmkXzx" 
	                javaType="java.util.ArrayList" columnPrefix="SpmkXzx_" >
	                	<id column="id" property="id" />
		                <result column="kjpz_id" property="kjpzId" />
		                <result column="value" property="value" />
		                <result column="sort" property="sort" />
				    </collection>
		        </collection>
		        <collection column="SpmkLcjd_id" property="spmkLcjds" ofType="cn.timer.api.bean.spmk.SpmkLcjd" javaType="java.util.ArrayList">
		        	<id column="SpmkLcjd_id" property="id" />
	                <result column="SpmkLcjd_spgl_id" property="spglId" />
	                <result column="SpmkLcjd_name" property="name" />
	                <result column="SpmkLcjd_type" property="type" />
	                <result column="SpmkLcjd_up_id" property="upId" />
	                <result column="SpmkLcjd_dowm_id" property="dowmId" />
	                <result column="SpmkLcjd_yxj" property="yxj" />
	                <result column="SpmkLcjd_sprsz_type" property="sprszType" />
	                <result column="SpmkLcjd_is_dsp" property="isDsp" />
	                <result column="SpmkLcjd_spfs_type" property="spfsType" />
	                <result column="SpmkLcjd_sprwk_type" property="sprwkType" />
	                <collection column="SpmkSxpz_id" property="spmkSxpzs" ofType="cn.timer.api.bean.spmk.SpmkSxpz" 
	                javaType="java.util.ArrayList" columnPrefix="SpmkSxpz_" resultMap="cn.timer.api.dao.spmk.SpmkSxpzMapper.BaseResultMap">
				    </collection>
				    <collection column="SpmkLcjdEmpAsso_id" property="spmkLcjdEmpAssos" ofType="cn.timer.api.bean.spmk.SpmkLcjdEmpAsso" 
	                javaType="java.util.ArrayList" columnPrefix="SpmkLcjdEmpAsso_" resultMap="cn.timer.api.dao.spmk.SpmkLcjdEmpAssoMapper.BaseResultMap">
				    </collection>
		        </collection>
    </resultMap>
     -->
    <resultMap id="SpmkSpglMbDto" type="cn.timer.api.bean.spmk.SpmkSpgl" >
                <id column="id" property="id" />
                <result column="org_code" property="orgCode" />
                <result column="spz_id" property="spzId" />
                <result column="mb_id" property="mbId" />
                <result column="icon_address" property="iconAddress" />
                <result column="name" property="name" />
                <result column="description" property="description" />
                <result column="is_open" property="isOpen" />
                <result column="sort" property="sort" />
                <result column="sprqc_type" property="sprqcType" />
                <result column="txts" property="txts" />
                <result column="spyj" property="spyj" />
                <result column="is_zdtg" property="isZdtg" />
                <result column="dymb_type" property="dymbType" />
                <result column="is_bxqm" property="isBxqm" />
                <result column="is_syscqm" property="isSyscqm" />
                <result column="is_mccxqm" property="isMccxqm" />
                <result column="update_time" property="updateTime" />
                <result column="create_time" property="createTime" />
                <result column="lcjd" property="lcjd" />
                <association property="spmkMb" javaType="cn.timer.api.bean.spmk.SpmkMb">
			       	<id column="SpmkMb_id" property="id" />
	                <result column="SpmkMb_name" property="name" />
	                <result column="SpmkMb_type" property="type" />
	                <result column="SpmkMb_kj" property="kj" />
			    </association>
    </resultMap>
    
    <resultMap id="BaseResultMap" type="cn.timer.api.bean.spmk.SpmkSpgl" >
                <id column="id" property="id" />
                <result column="org_code" property="orgCode" />
                <result column="spz_id" property="spzId" />
                <result column="mb_id" property="mbId" />
                <result column="icon_address" property="iconAddress" />
                <result column="name" property="name" />
                <result column="description" property="description" />
                <result column="is_open" property="isOpen" />
                <result column="sort" property="sort" />
                <result column="sprqc_type" property="sprqcType" />
                <result column="txts" property="txts" />
                <result column="spyj" property="spyj" />
                <result column="is_zdtg" property="isZdtg" />
                <result column="dymb_type" property="dymbType" />
                <result column="is_bxqm" property="isBxqm" />
                <result column="is_syscqm" property="isSyscqm" />
                <result column="is_mccxqm" property="isMccxqm" />
                <result column="update_time" property="updateTime" />
                <result column="create_time" property="createTime" />
    </resultMap>

    <sql id="Base_Column_List">
                a.id,
                a.org_code,
                a.spz_id,
                a.mb_id,
                a.icon_address,
                a.name,
                a.description,
                a.is_open,
                a.sort,
                a.sprqc_type,
                a.txts,
                a.spyj,
                a.is_zdtg,
                a.dymb_type,
                a.is_bxqm,
                a.is_syscqm,
                a.is_mccxqm,
                a.lcjd,
                a.update_time,
                a.create_time
    </sql>
    
    <sql id="Base_Column_List_Alias">
                id SpmkSpgl_id,
                org_code SpmkSpgl_org_code,
                spz_id SpmkSpgl_spz_id,
                mb_id SpmkSpgl_mb_id,
                icon_address SpmkSpgl_icon_address,
                name SpmkSpgl_name,
                description SpmkSpgl_description,
                is_open SpmkSpgl_is_open,
                sort SpmkSpgl_sort,
                sprqc_type SpmkSpgl_sprqc_type,
                txts SpmkSpgl_txts,
                spyj SpmkSpgl_spyj,
                is_zdtg SpmkSpgl_is_zdtg,
                dymb_type SpmkSpgl_dymb_type,
                is_bxqm SpmkSpgl_is_bxqm,
                is_syscqm SpmkSpgl_is_syscqm,
                is_mccxqm SpmkSpgl_is_mccxqm,
                update_time SpmkSpgl_update_time,
                create_time SpmkSpgl_create_time
    </sql>
    
    <sql id="SpmkKjpz_Alias">
                c.id SpmkKjpz_id,
                c.kj_id SpmkKjpz_kj_id,
                c.title SpmkKjpz_title,
                c.titletwo SpmkKjpz_titletwo,
                c.type SpmkKjpz_type,
                c.tswz SpmkKjpz_tswz,
                c.dzmc SpmkKjpz_dzmc,
                c.is_yz SpmkKjpz_is_yz,
                c.is_dy SpmkKjpz_is_dy,
                c.time_type SpmkKjpz_time_type,
                c.is_syzp SpmkKjpz_is_syzp,
                c.dygs_type SpmkKjpz_dygs_type,
                c.is_show SpmkKjpz_is_show,
                c.ljtz_url SpmkKjpz_ljtz_url,
                c.is_showup SpmkKjpz_is_showup,
                c.xx_type SpmkKjpz_xx_type,
                c.jsgs SpmkKjpz_jsgs,
                c.glspd_id SpmkKjpz_glspd_id,
                c.description SpmkKjpz_description
    </sql>
    
    <sql id="SpmkXzx_Alias">
                d.id SpmkXzx_id,
                d.kjpz_id SpmkXzx_kjpz_id,
                d.value SpmkXzx_value,
                d.sort SpmkXzx_sort
    </sql>
    
    <sql id="SpmkLcjd_Alias">
                e.id SpmkLcjd_id,
                e.spgl_id SpmkLcjd_spgl_id,
                e.name SpmkLcjd_name,
                e.type SpmkLcjd_type,
                e.up_id SpmkLcjd_up_id,
                e.dowm_id SpmkLcjd_dowm_id,
                e.yxj SpmkLcjd_yxj,
                e.sprsz_type SpmkLcjd_sprsz_type,
                e.is_dsp SpmkLcjd_is_dsp,
                e.spfs_type SpmkLcjd_spfs_type,
                e.sprwk_type SpmkLcjd_sprwk_type
    </sql>
    
    
    <sql id="SpmkSxpz_Alias">
                f.id SpmkSxpz_id,
                f.lcjd_id SpmkSxpz_lcjd_id,
                f.kjpz_id SpmkSxpz_kjpz_id,
                f.keyz SpmkSxpz_keyz,
                f.ysf_type SpmkSxpz_ysf_type,
                f.val SpmkSxpz_val,
                f.name SpmkSxpz_name,
                f.is_valid SpmkSxpz_is_valid,
                f.type SpmkSxpz_type
    </sql>
    
    <sql id="SpmkMb_Alias">
                b.id SpmkMb_id,
                b.name SpmkMb_name,
                b.type SpmkMb_type,
                b.kj SpmkMb_kj
    </sql>
    
    <sql id="SpmkLcjdEmpAsso_Alias">
                g.id SpmkLcjdEmpAsso_id,
                g.lcjd_id SpmkLcjdEmpAsso_lcjd_id,
                g.emp_num SpmkLcjdEmpAsso_emp_num,
                g.bmgw_id SpmkLcjdEmpAsso_bmgw_id,
                g.is_editable SpmkLcjdEmpAsso_is_editable
    </sql>
    
    <select id="selectSpglById2" resultMap="SpmkSpglMbDto">
        SELECT 
        	<include refid="Base_Column_List" />,
        	<include refid="SpmkMb_Alias" />
        FROM 
        	spmk_spgl a
        	LEFT JOIN spmk_mb b ON a.mb_id = b.id
        WHERE 
        	a.id = #{id}
    </select>
    <!-- 
    <select id="selectSpglById" resultMap="SpmkSpglDto">
        SELECT 
        	<include refid="Base_Column_List" />,
        	<include refid="SpmkKjpz_Alias" />,
        	<include refid="SpmkXzx_Alias" />,
        	<include refid="SpmkLcjd_Alias" />,
        	<include refid="SpmkLcjdEmpAsso_Alias" />,
        	<include refid="SpmkSxpz_Alias" />
        FROM 
        	spmk_spgl a
        	LEFT JOIN spmk_kj_mk b ON a.mb_id = b.mb_id
        	LEFT JOIN spmk_kjpz c ON c.id = b.kjpz_id
        	LEFT JOIN spmk_xzx d ON c.id = d.kjpz_id
        	LEFT JOIN spmk_lcjd e ON a.id = e.spgl_id
        	LEFT JOIN spmk_sxpz f ON e.id = f.lcjd_id
        	LEFT JOIN spmk_lcjd_emp_asso g ON e.id = g.lcjd_id
        WHERE 
        	a.id = #{id}
    </select>
     -->
    

	<update id="updateListSortById" parameterType="list">
        <foreach item="item" index="index" collection="list" open="" separator=";" close="">
	        		UPDATE spmk_spgl
			        <set>
			                    <if test ='null != item.sort'>sort = #{item.sort},</if>
			        </set>
			        WHERE id = #{item.id}
		</foreach>
    </update>

	<!-- 

    <insert id="insert" useGeneratedKeys="true" keyColumn="id" parameterType="cn.timer.api.bean.spmk.SpmkSpgl">
        INSERT INTO spmk_spgl
        <trim prefix="(" suffix=")" suffixOverrides=",">
                        <if test ='null != orgCode'>
                        org_code,
                        </if>
                        <if test ='null != spzId'>
                        spz_id,
                        </if>
                        <if test ='null != mbId'>
                        mb_id,
                        </if>
                        <if test ='null != iconAddress'>
                        icon_address,
                        </if>
                        <if test ='null != name'>
                        name,
                        </if>
                        <if test ='null != description'>
                        description,
                        </if>
                        <if test ='null != isOpen'>
                        is_open,
                        </if>
                        <if test ='null != sort'>
                        sort,
                        </if>
                        <if test ='null != sprqcType'>
                        sprqc_type,
                        </if>
                        <if test ='null != txts'>
                        txts,
                        </if>
                        <if test ='null != spyj'>
                        spyj,
                        </if>
                        <if test ='null != isZdtg'>
                        is_zdtg,
                        </if>
                        <if test ='null != dymbType'>
                        dymb_type,
                        </if>
                        <if test ='null != isBxqm'>
                        is_bxqm,
                        </if>
                        <if test ='null != isSyscqm'>
                        is_syscqm,
                        </if>
                        <if test ='null != isMccxqm'>
                        is_mccxqm,
                        </if>
                        <if test ='null != updateTime'>
                        update_time,
                        </if>
                        <if test ='null != createTime'>
                        create_time
                        </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                        <if test ='null != orgCode'>
                        #{orgCode},
                        </if>
                        <if test ='null != spzId'>
                        #{spzId},
                        </if>
                        <if test ='null != mbId'>
                        #{mbId},
                        </if>
                        <if test ='null != iconAddress'>
                        #{iconAddress},
                        </if>
                        <if test ='null != name'>
                        #{name},
                        </if>
                        <if test ='null != description'>
                        #{description},
                        </if>
                        <if test ='null != isOpen'>
                        #{isOpen},
                        </if>
                        <if test ='null != sort'>
                        #{sort},
                        </if>
                        <if test ='null != sprqcType'>
                        #{sprqcType},
                        </if>
                        <if test ='null != txts'>
                        #{txts},
                        </if>
                        <if test ='null != spyj'>
                        #{spyj},
                        </if>
                        <if test ='null != isZdtg'>
                        #{isZdtg},
                        </if>
                        <if test ='null != dymbType'>
                        #{dymbType},
                        </if>
                        <if test ='null != isBxqm'>
                        #{isBxqm},
                        </if>
                        <if test ='null != isSyscqm'>
                        #{isSyscqm},
                        </if>
                        <if test ='null != isMccxqm'>
                        #{isMccxqm},
                        </if>
                        <if test ='null != updateTime'>
                        #{updateTime},
                        </if>
                        <if test ='null != createTime'>
                        #{createTime}
                        </if>
        </trim>
    </insert>

    <delete id="delete" >
        DELETE FROM spmk_spgl
        WHERE id = #{id}
    </delete>

    <update id="update" parameterType="cn.timer.api.bean.spmk.SpmkSpgl">
        UPDATE spmk_spgl
        <set>
                    <if test ='null != spzId'>spz_id = #{spzId},</if>
                    <if test ='null != orgCode'>org_code = #{orgCode},</if>
                    <if test ='null != mbId'>mb_id = #{mbId},</if>
                    <if test ='null != iconAddress'>icon_address = #{iconAddress},</if>
                    <if test ='null != name'>name = #{name},</if>
                    <if test ='null != description'>description = #{description},</if>
                    <if test ='null != isOpen'>is_open = #{isOpen},</if>
                    <if test ='null != sort'>sort = #{sort},</if>
                    <if test ='null != sprqcType'>sprqc_type = #{sprqcType},</if>
                    <if test ='null != txts'>txts = #{txts},</if>
                    <if test ='null != spyj'>spyj = #{spyj},</if>
                    <if test ='null != isZdtg'>is_zdtg = #{isZdtg},</if>
                    <if test ='null != dymbType'>dymb_type = #{dymbType},</if>
                    <if test ='null != isBxqm'>is_bxqm = #{isBxqm},</if>
                    <if test ='null != isSyscqm'>is_syscqm = #{isSyscqm},</if>
                    <if test ='null != isMccxqm'>is_mccxqm = #{isMccxqm},</if>
                    <if test ='null != updateTime'>update_time = #{updateTime},</if>
                    <if test ='null != createTime'>create_time = #{createTime}</if>
        </set>
        WHERE id = #{id}
    </update>


    <select id="load" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM spmk_spgl
        WHERE id = #{id}
    </select>

    <select id="pageList" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM spmk_spgl
        LIMIT #{offset}, #{pageSize}
    </select>

    <select id="pageListCount" resultType="java.lang.Integer">
        SELECT count(1)
        FROM spmk_spgl
    </select>

	 -->

</mapper>