MonthAwardMapper.xml 4 KB
<?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"/>
        <result column="year_month" property="yearMonth"/>
        <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">
        year_month,month_manure_total,month_award_pool,month_manure_award,month_gold_award,month_farmer_award,
        month_forest_start_award,month_partner_award,create_time,update_time
    </sql>

    <sql id="vals">
        #{yearMonth},#{monthManureTotal},#{monthAwardPool},#{monthManureAward},#{monthGoldAward},#{monthFarmerAward},
        #{monthForestStartAward}, #{monthPartnerAward},now(),now()
    </sql>

    <sql id="updateCondition">
        <if test="yearMonth != null">year_month =#{yearMonth},</if>
        <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>
        <if test="yearMonth != null">and year_month =#{yearMonth}</if>
        <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>