MonthAwardMapper.xml 4 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
        <result column="year_month" property="yearMonth"/>
licc's avatar
licc committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
        <result column="month_manure_total" property="monthManureTotal"/>
        <result column="month_award_pool" property="monthAwardPool"/>
        <result column="month_manure_award" property="monthManureAward"/>
        <result column="month_gold_award" property="monthGoldAward"/>
        <result column="month_farmer_award" property="monthFarmerAward"/>
        <result column="month_forest_start_award" property="monthForestStartAward"/>
        <result column="month_partner_award" property="monthPartnerAward"/>
        <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
28
        year_month,month_manure_total,month_award_pool,month_manure_award,month_gold_award,month_farmer_award,
licc's avatar
licc committed
29 30 31 32
        month_forest_start_award,month_partner_award,create_time,update_time
    </sql>

    <sql id="vals">
licc's avatar
licc committed
33
        #{yearMonth},#{monthManureTotal},#{monthAwardPool},#{monthManureAward},#{monthGoldAward},#{monthFarmerAward},
licc's avatar
licc committed
34 35 36 37
        #{monthForestStartAward}, #{monthPartnerAward},now(),now()
    </sql>

    <sql id="updateCondition">
licc's avatar
licc committed
38
        <if test="yearMonth != null">year_month =#{yearMonth},</if>
licc's avatar
licc committed
39 40 41 42 43 44 45 46 47 48 49 50
        <if test="monthManureTotal != null">month_manure_total = #{monthManureTotal},</if>
        <if test="monthAwardPool != null">month_award_pool = #{monthAwardPool},</if>
        <if test="monthManureAward != null">month_manure_award =#{monthManureAward},</if>
        <if test="monthGoldAward != null">month_gold_award =#{monthGoldAward},</if>
        <if test="monthFarmerAward != null">month_farmer_award =#{monthFarmerAward},</if>
        <if test="monthForestStartAward != null">month_forest_start_award =#{monthForestStartAward},</if>
        <if test="monthPartnerAward != null">month_partner_award =#{monthPartnerAward},</if>
        update_time =now()
    </sql>

    <sql id="criteria">
        <if test="id != null">id = #{id}</if>
licc's avatar
licc committed
51
        <if test="yearMonth != null">and year_month =#{yearMonth}</if>
licc's avatar
licc committed
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
        <if test="monthManureTotal != null">and month_manure_total = #{monthManureTotal}</if>
        <if test="monthAwardPool != null">and month_award_pool = #{monthAwardPool}</if>
        <if test="monthManureAward != null">and month_manure_award =#{monthManureAward}</if>
        <if test="monthGoldAward != null">and month_gold_award =#{monthGoldAward}</if>
        <if test="monthFarmerAward != null">and month_farmer_award =#{monthFarmerAward}</if>
        <if test="monthForestStartAward != null">and month_forest_start_award =#{monthForestStartAward}</if>
        <if test="monthPartnerAward != null">and month_partner_award =#{monthPartnerAward}</if>
        <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>

</mapper>