<?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.qianhe.zqcz.jcdw.mapper.ZqczJcdwMapper">
    <!--  返回实体  -->
    <resultMap id="ZqczJcdwResult" type="com.qianhe.zqcz.jcdw.domain.ZqczJcdwVo">
        <id property="jcdwid" column="jcdwid"/>
        <result property="zsrwid" column="zsrwid"/>
        <result property="jcdwmc" column="jcdwmc"/>
        <result property="jczzlx" column="jczzlx"/>
    </resultMap>
    <!--  通用查询  -->
    <sql id="selectCommon">
        SELECT
            jcdw.jcdwid,
            jcdw.zsrwid,
            jcdw.jcdwmc,
            jcdw.jczzlx
        FROM
            zqcz_jcdw jcdw
    </sql>
    <!--  条件查询  -->
    <select id="list" parameterType="com.qianhe.zqcz.jcdw.domain.ZqczJcdwQuery" resultMap="ZqczJcdwResult">
        <include refid="selectCommon"></include>
        <where>
            <if test="zsrwid != null">AND jcdw.zsrwid = #{zsrwid}</if>
            <if test="jcdwmc != null and jcdwmc != ''">AND jcdw.jcdwmc like concat('%', #{jcdwmc}, '%')</if>
            <if test="jczzlx != null and jczzlx != ''">AND jcdw.jczzlx = #{jczzlx}</if>
        </where>
        ORDER BY jcdw.jczzlx ASC, jcdw.jcdwid DESC
    </select>
    <!--  查询详情  -->
    <select id="info" parameterType="long" resultMap="ZqczJcdwResult">
        <include refid="selectCommon"></include> WHERE jcdw.jcdwid = #{jcdwid}
    </select>
    <!--  新增  -->
    <insert id="add" parameterType="com.qianhe.zqcz.jcdw.domain.ZqczJcdw">
        INSERT INTO zqcz_jcdw
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="zsrwid != null">zsrwid,</if>
            <if test="jcdwmc != null and jcdwmc != ''">jcdwmc,</if>
            <if test="jczzlx != null and jczzlx != ''">jczzlx,</if>
            <if test="yl1 != null and yl1 != ''">yl1,</if>
            <if test="yl2 != null and yl2 != ''">yl2,</if>
            <if test="yl3 != null and yl3 != ''">yl3,</if>
            <if test="yl4 != null and yl4 != ''">yl4,</if>
            <if test="yl5 != null and yl5 != ''">yl5,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="zsrwid != null">#{zsrwid},</if>
            <if test="jcdwmc != null and jcdwmc != ''">#{jcdwmc},</if>
            <if test="jczzlx != null and jczzlx != ''">#{jczzlx},</if>
            <if test="yl1 != null and yl1 != ''">#{yl1},</if>
            <if test="yl2 != null and yl2 != ''">#{yl2},</if>
            <if test="yl3 != null and yl3 != ''">#{yl3},</if>
            <if test="yl4 != null and yl4 != ''">#{yl4},</if>
            <if test="yl5 != null and yl5 != ''">#{yl5},</if>
        </trim>
    </insert>
    <!--  修改  -->
    <update id="edit" parameterType="com.qianhe.zqcz.jcdw.domain.ZqczJcdw">
        UPDATE zqcz_jcdw
        <set>
            <if test="zsrwid != null">zsrwid=#{zsrwid},</if>
            <if test="jcdwmc != null and jcdwmc != ''">jcdwmc=#{jcdwmc},</if>
            <if test="jczzlx != null and jczzlx != ''">jczzlx=#{jczzlx},</if>
            <if test="yl1 != null and yl1 != ''">yl1=#{yl1},</if>
            <if test="yl2 != null and yl2 != ''">yl2=#{yl2},</if>
            <if test="yl3 != null and yl3 != ''">yl3=#{yl3},</if>
            <if test="yl4 != null and yl4 != ''">yl4=#{yl4},</if>
            <if test="yl5 != null and yl5 != ''">yl5=#{yl5},</if>
        </set>
        WHERE jcdwid=#{jcdwid}
    </update>
    <!--  删除  -->
    <delete id="delete" parameterType="long">
        DELETE FROM zqcz_jcdw WHERE jcdwid IN
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <!--  批量新增  -->
    <insert id="batchAdd" parameterType="java.util.List">
        INSERT INTO zqcz_jcdw (zsrwid, jcdwmc, jczzlx) VALUES
        <foreach collection="list" item="item" separator=",">
            (#{item.zsrwid}, #{item.jcdwmc}, #{item.jczzlx})
        </foreach>
    </insert>
    <!--  删除  -->
    <delete id="deleteByZsrwid" parameterType="long">
        DELETE FROM zqcz_jcdw WHERE zsrwid = #{zsrwid}
    </delete>
</mapper>
