<?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.ruoyi.system.mapper.projectV2.ZsyzSkDzjeMapper">
    
    <resultMap type="ZsyzSkDzje" id="ZsyzSkDzjeResult">
        <result property="id"    column="id"    />
        <result property="skId"    column="sk_id"    />
        <result property="xmmc"    column="xmmc"    />
        <result property="dwmc"    column="dwmc"    />
        <result property="zzje"    column="zzje"    />
        <result property="dwrq"    column="dwrq"    />
        <result property="isSh"    column="is_sh"    />
        <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>

    <sql id="selectZsyzSkDzjeVo">
        select id, sk_id, xmmc, dwmc, zzje, dwrq, is_sh, create_by, create_time, update_by, update_time, remark from zsyz_sk_dzje
    </sql>

    <select id="selectZsyzSkDzjeList" parameterType="ZsyzSkDzje" resultMap="ZsyzSkDzjeResult">
        <include refid="selectZsyzSkDzjeVo"/>
        <where>  
            <if test="skId != null "> and sk_id = #{skId}</if>
            <if test="xmmc != null  and xmmc != ''"> and xmmc = #{xmmc}</if>
            <if test="dwmc != null  and dwmc != ''"> and dwmc = #{dwmc}</if>
            <if test="zzje != null  and zzje != ''"> and zzje = #{zzje}</if>
            <if test="dwrq != null "> and dwrq = #{dwrq}</if>
            <if test="isSh != null  and isSh != ''"> and is_sh = #{isSh}</if>
        </where>
    </select>
    
    <select id="selectZsyzSkDzjeById" parameterType="Long" resultMap="ZsyzSkDzjeResult">
        <include refid="selectZsyzSkDzjeVo"/>
        where id = #{id}
    </select>
    <select id="selectCountBySkId" parameterType="Long" resultType="java.lang.Long">

        select ifnull(sum(zzje),0) from zsyz_sk_dzje where sk_id = #{id}
    </select>

    <insert id="insertZsyzSkDzje" parameterType="ZsyzSkDzje" useGeneratedKeys="true" keyProperty="id">
        insert into zsyz_sk_dzje
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="skId != null">sk_id,</if>
            <if test="xmmc != null and xmmc != ''">xmmc,</if>
            <if test="dwmc != null">dwmc,</if>
            <if test="zzje != null">zzje,</if>
            <if test="dwrq != null">dwrq,</if>
            <if test="isSh != null">is_sh,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="skId != null">#{skId},</if>
            <if test="xmmc != null and xmmc != ''">#{xmmc},</if>
            <if test="dwmc != null">#{dwmc},</if>
            <if test="zzje != null">#{zzje},</if>
            <if test="dwrq != null">#{dwrq},</if>
            <if test="isSh != null">#{isSh},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateZsyzSkDzje" parameterType="ZsyzSkDzje">
        update zsyz_sk_dzje
        <trim prefix="SET" suffixOverrides=",">
            <if test="skId != null">sk_id = #{skId},</if>
            <if test="xmmc != null and xmmc != ''">xmmc = #{xmmc},</if>
            <if test="dwmc != null">dwmc = #{dwmc},</if>
            <if test="zzje != null">zzje = #{zzje},</if>
            <if test="dwrq != null">dwrq = #{dwrq},</if>
            <if test="isSh != null">is_sh = #{isSh},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="updateZsyzSkDzjeSkId" parameterType="ZsyzSkDzje">
        update zsyz_sk_dzje
        <trim prefix="SET" suffixOverrides=",">
            <if test="xmmc != null and xmmc != ''">xmmc = #{xmmc},</if>
            <if test="dwmc != null">dwmc = #{dwmc},</if>
            <if test="zzje != null">zzje = #{zzje},</if>
            <if test="dwrq != null">dwrq = #{dwrq},</if>
            <if test="isSh != null">is_sh = #{isSh},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where sk_id = #{skId}
    </update>

    <delete id="deleteZsyzSkDzjeById" parameterType="Long">
        delete from zsyz_sk_dzje where id = #{id}
    </delete>

    <delete id="deleteZsyzSkDzjeByIds" parameterType="String">
        delete from zsyz_sk_dzje where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <delete id="deleteZsyzSkDzjeBySkId">
                delete from zsyz_sk_dzje where sk_id = #{id}
    </delete>
</mapper>