MonthAwardMapper.xml 4.31 KB
Newer Older
licc's avatar
licc committed
1 2 3 4 5
<?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.MonthAwardMapper">
    <resultMap id="monthMap" type="cn.wisenergy.model.app.MonthAward">
        <id column="id" property="id"/>
licc's avatar
licc committed
6 7 8 9 10 11 12 13
        <result column="growth_award" property="growthAward"/>
        <result column="award_total" property="awardTotal"/>
        <result column="month_award_total" property="monthAwardTotal"/>
        <result column="month_increased" property="monthIncreased"/>
        <result column="gold_award" property="goldAward"/>
        <result column="farmer_award" property="farmerAward"/>
        <result column="forest_start_award" property="forestStartAward"/>
        <result column="partner_award" property="partnerAward"/>
licc's avatar
licc committed
14
        <result column="year_month" property="yearMonth"/>
licc's avatar
licc committed
15 16 17 18 19 20 21 22 23 24 25 26 27 28
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

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

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

    <sql id="cols_exclude_id">
licc's avatar
licc committed
29
        growth_award,award_total,month_award_total,month_increased,gold_award,farmer_award, forest_start_award,
licc's avatar
licc committed
30
        partner_award,`year_month`,create_time,update_time
licc's avatar
licc committed
31 32 33
    </sql>

    <sql id="vals">
licc's avatar
licc committed
34
        #{growthAward},#{awardTotal},#{monthAwardTotal},#{monthIncreased},#{goldAward},#{farmerAward},
licc's avatar
licc committed
35
        #{forestStartAward}, #{partnerAward},#{yearMonth},now(),now()
licc's avatar
licc committed
36 37 38
    </sql>

    <sql id="updateCondition">
licc's avatar
licc committed
39 40 41 42 43 44 45 46
        <if test="growthAward != null">growth_award =#{growthAward},</if>
        <if test="awardTotal != null">award_total = #{awardTotal},</if>
        <if test="monthAwardTotal != null">month_award_total = #{monthAwardTotal},</if>
        <if test="monthIncreased != null">month_increased =#{monthIncreased},</if>
        <if test="goldAward != null">gold_award =#{goldAward},</if>
        <if test="farmerAward != null">farmer_award =#{farmerAward},</if>
        <if test="forestStartAward != null">forest_start_award =#{forestStartAward},</if>
        <if test="partnerAward != null">partner_award =#{partnerAward},</if>
licc's avatar
licc committed
47
        <if test="yearMonth != null">`year_month` =#{yearMonth},</if>
licc's avatar
licc committed
48 49 50 51 52
        update_time =now()
    </sql>

    <sql id="criteria">
        <if test="id != null">id = #{id}</if>
licc's avatar
licc committed
53 54 55 56 57 58 59 60
        <if test="growthAward != null">and growth_award =#{growthAward}</if>
        <if test="awardTotal != null">and award_total = #{awardTotal}</if>
        <if test="monthAwardTotal != null">and month_award_total = #{monthAwardTotal}</if>
        <if test="monthIncreased != null">and month_increased =#{monthIncreased}</if>
        <if test="goldAward != null">and gold_award =#{goldAward}</if>
        <if test="farmerAward != null">and farmer_award =#{farmerAward}</if>
        <if test="forestStartAward != null">and forest_start_award =#{forestStartAward}</if>
        <if test="partnerAward != null">and partner_award =#{partnerAward}</if>
licc's avatar
licc committed
61
        <if test="yearMonth != null">and `year_month` =#{yearMonth}</if>
licc's avatar
licc committed
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
        <if test="createTime != null">and create_time &gt;= #{createTime}</if>
        <if test="updateTime != null">and #{updateTime} &gt;= update_time</if>
    </sql>

    <insert id="add" parameterType="cn.wisenergy.model.app.MonthAward" keyProperty="id" useGeneratedKeys="true">
        insert into
        <include refid="table"/>
        (<include refid="cols_exclude_id"/>)
        value(
        <include refid="vals"/>
        )
    </insert>

    <update id="edit" parameterType="cn.wisenergy.model.app.MonthAward">
        UPDATE
        <include refid="table"/>
        <set>
            <include refid="updateCondition"/>
        </set>
        <where>
            id = #{id}
        </where>
    </update>

    <delete id="delById" parameterType="java.lang.Integer">
        delete from
        <include refid="table"/>
        where id = #{id}
    </delete>

licc's avatar
licc committed
92 93 94 95 96 97 98
    <select id="getByTime" resultType="cn.wisenergy.model.app.MonthAward">
        select
        <include refid="cols_all"/>
        from
        <include refid="table"/>
        <where>
            <if test="yearMonth != null">
licc's avatar
licc committed
99
                `year_month`=#{yearMonth}
licc's avatar
licc committed
100 101
            </if>
        </where>
licc's avatar
licc committed
102 103
        order by create_time desc
        limit 1
licc's avatar
licc committed
104 105
    </select>

licc's avatar
licc committed
106
</mapper>