<?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.zpgl.ZpglRcxxMaterialMapper">

    <!-- 可根据自己的需求,是否要使用 -->
    <resultMap type="cn.timer.api.bean.zpgl.ZpglRcxxMaterial" id="zpglRcxxMaterialMap">
        <result property="id" column="id"/>
        <result property="numId" column="num_id"/>
        <result property="url" column="url"/>
        <result property="type" column="type"/>
        <result property="createTime" column="create_time"/>
        <result property="orgCode" column="org_code"/>
        <result property="zpglRcxxId" column="zpgl_rcxx_id"/>
    </resultMap>

    <select id="queryObject" resultType="cn.timer.api.bean.zpgl.ZpglRcxxMaterial">
        select *
        from zpgl_rcxx_material
        where id = #{value}
    </select>

    <select id="queryList" resultType="cn.timer.api.bean.zpgl.ZpglRcxxMaterial">
        select * from zpgl_rcxx_material
        <where>
            <if test="id != null and id != ''">AND `id` = #{id}</if>
            <if test="numId != null and numId != ''">AND `num_id` = #{numId}</if>
            <if test="url != null and url != ''">AND `url` = #{url}</if>
            <if test="type != null and type != ''">AND `type` = #{type}</if>
            <if test="createTime != null and createTime != ''">AND `create_time` = #{createTime}</if>
            <if test="orgCode != null and orgCode != ''">AND `org_code` = #{orgCode}</if>
        </where>
        <choose>
            <when test="sidx != null and sidx.trim() != ''">
                order by ${sidx} ${order}
            </when>
            <otherwise>
                order by id desc
            </otherwise>
        </choose>
        <if test="offset != null and limit != null">
            limit #{offset}, #{limit}
        </if>
    </select>

    <select id="queryTotal" resultType="int">
        select count(*) from zpgl_rcxx_material
        <where>
            <if test="id != null and id != ''">AND `id` = #{id}</if>
            <if test="numId != null and numId != ''">AND `num_id` = #{numId}</if>
            <if test="url != null and url != ''">AND `url` = #{url}</if>
            <if test="type != null and type != ''">AND `type` = #{type}</if>
            <if test="createTime != null and createTime != ''">AND `create_time` = #{createTime}</if>
            <if test="orgCode != null and orgCode != ''">AND `org_code` = #{orgCode}</if>
        </where>
    </select>

    <insert id="save" parameterType="cn.timer.api.bean.zpgl.ZpglRcxxMaterial">
        insert into zpgl_rcxx_material
        (`id`,
         `num_id`,
         `url`,
         `type`,
         `create_time`,
         `org_code`)
        values (#{id},
                #{numId},
                #{url},
                #{type},
                #{createTime},
                #{orgCode})
    </insert>

    <insert id="saveSelective" parameterType="cn.timer.api.bean.zpgl.ZpglRcxxMaterial">
        insert into zpgl_rcxx_material
        (
        <if test="id != null">`id`</if>
        <if test="numId != null">,`num_id`</if>
        <if test="url != null">,`url`</if>
        <if test="type != null">,`type`</if>
        <if test="createTime != null">,`create_time`</if>
        <if test="orgCode != null">,`org_code`</if>
        )
        values
        (
        <if test="id != null">#{id}</if>
        <if test="numId != null">,#{numId}</if>
        <if test="url != null">,#{url}</if>
        <if test="type != null">,#{type}</if>
        <if test="createTime != null">,#{createTime}</if>
        <if test="orgCode != null">,#{orgCode}</if>
        )
    </insert>


    <insert id="saveList" parameterType="cn.timer.api.bean.zpgl.ZpglRcxxMaterial">
        insert into zpgl_rcxx_material
        (
        `id`,
        `num_id`,
        `url`,
        `type`,
        `create_time`,
        `org_code`
        )
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (
            #{item.id},
            #{item.numId},
            #{item.url},
            #{item.type},
            #{item.createTime},
            #{item.orgCode}
            )
        </foreach>
    </insert>


    <update id="update" parameterType="cn.timer.api.bean.zpgl.ZpglRcxxMaterial">
        update zpgl_rcxx_material
        <set>
            <if test="numId != null">`num_id` = #{numId},</if>
            <if test="url != null">`url` = #{url},</if>
            <if test="type != null">`type` = #{type},</if>
            <if test="createTime != null">`create_time` = #{createTime},</if>
            <if test="orgCode != null">`org_code` = #{orgCode}</if>
        </set>
        where id = #{id}
    </update>

    <delete id="delete">
        delete
        from zpgl_rcxx_material
        where id = #{value}
    </delete>

    <delete id="deleteBatch">
        delete from zpgl_rcxx_material where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

</mapper>