RefillCardMapper.xml 3.68 KB
Newer Older
liaoanyuan's avatar
liaoanyuan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 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
<?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.wisenergy.mapper.RefillCardMapper">
    <resultMap id="refillCardMap" type="cn.wisenergy.model.app.RefillCard">
        <id column="id" property="id"/>
        <result column="batch_number" property="batchNumber"/>
        <result column="is_make_card" property="isMakeCard"/>
        <result column="card_number" property="cardNumber"/>
        <result column="is_activite" property="isActivite"/>
        <result column="is_delete" property="isDelete"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <sql id="table">
        refill_card
    </sql>

    <sql id="cols_all">
        id,
        <include refid="cols_exclude_id"/>
    </sql>

    <sql id="cols_exclude_id">
        card_number,batch_number,is_make_card, is_activite,is_delete,create_time,update_time
    </sql>

    <sql id="vals">
        #{cardNumber},#{batchNumber},#{isMakeCard},#{isActivite},
        #{isDelete},now(),now()
    </sql>

    <sql id="updateCondition">
        <if test="userName != null">card_number = #{cardNumber},</if>
        <if test="password != null">batch_number =#{batchNumber},</if>
        <if test="phone != null">is_make_card =#{isMakeCard},</if>
        <if test="headImage != null">is_activite =#{isMakeCard},</if>
        <if test="examType != null">is_delete = #{isDelete},</if>
        update_time =now()
    </sql>

    <sql id="criteria">
        <if test="userName != null">and card_number = #{cardNumber}</if>
        <if test="password != null"> and batch_number =#{batchNumber}</if>
        <if test="phone != null">and is_make_card =#{isMakeCard}</if>
        <if test="headImage != null"> and is_activite =#{isMakeCard}</if>
        <if test="examType != null">and is_delete = #{isDelete}</if>
        <if test="createTime != null">and create_time &gt;= #{createTime}</if>
        <if test="updateTime != null">and #{updateTime} &gt;= update_time</if>
    </sql>

licc's avatar
licc committed
53
    <insert id="add" parameterType="cn.wisenergy.model.app.User" keyProperty="id" useGeneratedKeys="true">
liaoanyuan's avatar
liaoanyuan committed
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
        insert into
        <include refid="table"/>
        (<include refid="cols_exclude_id"/>)
        value(
        <include refid="vals"/>
        )
    </insert>

    <update id="update" parameterType="java.lang.String">
        UPDATE
        <include refid="table"/>
        <set>
            is_activite =0
        </set>
        <where>
            batch_number =#{batchNumber}
        </where>
    </update>

    <select id="getList" resultMap="refillCardMap" parameterType="map">
    select
    <include refid="cols_all"/>
    from
    <include refid="table"/>
    <where>
        is_delete=0

        order by create_time desc
        limit #{pageNo},#{pageSize}
    </where>
    </select>

liaoanyuan's avatar
liaoanyuan committed
86

liaoanyuan's avatar
liaoanyuan committed
87 88 89 90 91 92 93
    <select id="getUserNumbers" resultType="java.lang.Integer">
        SELECT COUNT(id)
        FROM
        <include refid="table"/>
        where is_delete=0
    </select>

liaoanyuan's avatar
liaoanyuan committed
94 95 96 97 98 99 100 101
    <select id="getById" resultMap="refillCardMap">
        select
        <include refid="cols_all"/>
        from
        <include refid="table"/>
        where id=#{id}
    </select>

licc's avatar
licc committed
102 103 104 105 106 107 108 109
    <select id="getByBatchNumber" resultType="cn.wisenergy.model.app.RefillCard">
        select
        <include refid="cols_all"/>
        from
        <include refid="table"/>
        where batch_number=#{batchNumber}
    </select>

liaoanyuan's avatar
liaoanyuan committed
110 111 112 113 114 115 116 117 118 119
    <update id="setIsMakeCard">
        UPDATE
        <include refid="table"/>
        <set>
            is_make_card =0
        </set>
        <where>
             id=#{id}
        </where>
    </update>
liaoanyuan's avatar
liaoanyuan committed
120
</mapper>