InsureProductMapper.xml 5.59 KB
Newer Older
翁国栋 committed
1 2 3
<?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">

翁国栋 committed
4
<mapper namespace="cn.timer.api.dao.insure.InsureProductMapper">
翁国栋 committed
5 6 7 8 9 10 11 12 13 14

    <!-- 可根据自己的需求,是否要使用 -->
    <resultMap type="cn.timer.api.bean.insure.InsureProduct" id="insureProductMap">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="planCodeId" column="plan_code_id"/>
        <result property="productCodeId" column="product_code_id"/>
        <result property="type" column="type"/>
        <result property="createTime" column="create_time"/>
        <result property="isDel" column="is_del"/>
翁国栋 committed
15
        <result property="payType" column="pay_type"/>
翁国栋 committed
16
        <result property="tmpUrl" column="tmp_url"/>
翁国栋 committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
    </resultMap>

    <select id="queryObject" resultType="cn.timer.api.bean.insure.InsureProduct">
        select *
        from insure_product
        where id = #{value}
    </select>

    <select id="queryList" resultType="cn.timer.api.bean.insure.InsureProduct">
        select * from insure_product
        <where>
            <if test="name != null and name != ''">AND `name` = #{name}</if>
            <if test="planCodeId != null and planCodeId != ''">AND `plan_code_id` = #{planCodeId}</if>
            <if test="productCodeId != null and productCodeId != ''">AND `product_code_id` = #{productCodeId}</if>
            <if test="type != null and type != ''">AND `type` = #{type}</if>
            <if test="createTime != null and createTime != ''">AND `create_time` = #{createTime}</if>
            <if test="isDel != null and isDel != ''">AND `is_del` = #{isDel}</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 insure_product
        <where>
            <if test="name != null and name != ''">AND `name` = #{name}</if>
            <if test="planCodeId != null and planCodeId != ''">AND `plan_code_id` = #{planCodeId}</if>
            <if test="productCodeId != null and productCodeId != ''">AND `product_code_id` = #{productCodeId}</if>
            <if test="type != null and type != ''">AND `type` = #{type}</if>
            <if test="createTime != null and createTime != ''">AND `create_time` = #{createTime}</if>
            <if test="isDel != null and isDel != ''">AND `is_del` = #{isDel}</if>
        </where>
    </select>

    <insert id="save" parameterType="cn.timer.api.bean.insure.InsureProduct" useGeneratedKeys="true" keyProperty="id">
        insert into insure_product
        (`name`,
         `plan_code_id`,
         `product_code_id`,
         `type`,
         `create_time`,
         `is_del`)
        values (#{name},
                #{planCodeId},
                #{productCodeId},
                #{type},
                #{createTime},
                #{isDel})
    </insert>

    <insert id="saveSelective" parameterType="cn.timer.api.bean.insure.InsureProduct" useGeneratedKeys="true"
            keyProperty="id">
        insert into insure_product
        (
        <if test="name != null">,`name`</if>
        <if test="planCodeId != null">,`plan_code_id`</if>
        <if test="productCodeId != null">,`product_code_id`</if>
        <if test="type != null">,`type`</if>
        <if test="createTime != null">,`create_time`</if>
        <if test="isDel != null">,`is_del`</if>
        )
        values
        (
        <if test="name != null">,#{name}</if>
        <if test="planCodeId != null">,#{planCodeId}</if>
        <if test="productCodeId != null">,#{productCodeId}</if>
        <if test="type != null">,#{type}</if>
        <if test="createTime != null">,#{createTime}</if>
        <if test="isDel != null">,#{isDel}</if>
        )
    </insert>


    <insert id="saveList" parameterType="cn.timer.api.bean.insure.InsureProduct" useGeneratedKeys="true"
            keyProperty="id">
        insert into insure_product
        (
        `name`,
        `plan_code_id`,
        `product_code_id`,
        `type`,
        `create_time`,
        `is_del`
        )
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (
            #{item.name},
            #{item.planCodeId},
            #{item.productCodeId},
            #{item.type},
            #{item.createTime},
            #{item.isDel}
            )
        </foreach>
    </insert>


    <update id="update" parameterType="cn.timer.api.bean.insure.InsureProduct">
        update insure_product
        <set>
            <if test="name != null">`name` = #{name},</if>
            <if test="planCodeId != null">`plan_code_id` = #{planCodeId},</if>
            <if test="productCodeId != null">`product_code_id` = #{productCodeId},</if>
            <if test="type != null">`type` = #{type},</if>
            <if test="createTime != null">`create_time` = #{createTime},</if>
            <if test="isDel != null">`is_del` = #{isDel}</if>
        </set>
        where id = #{id}
    </update>

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

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

</mapper>