<?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.MonthManureMapper"> <resultMap id="monthMap" type="cn.wisenergy.model.app.MonthManure"> <id column="id" property="id"/> <result column="year_month" property="yearMonth"/> <result column="manure_award" property="manureAward"/> <result column="create_time" property="createTime"/> <result column="update_time" property="updateTime"/> </resultMap> <sql id="table"> month_manure </sql> <sql id="cols_all"> id, <include refid="cols_exclude_id"/> </sql> <sql id="cols_exclude_id"> `year_month`,manure_award,create_time,update_time </sql> <sql id="vals"> #{yearMonth},#{manureAward},now(),now() </sql> <sql id="updateCondition"> <if test="yearMonth != null">`year_month` =#{yearMonth},</if> <if test="manureAward != null">manure_award = #{manureAward},</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="manureAward != null">and manure_award = #{manureAward}</if> <if test="createTime != null">and create_time >= #{createTime}</if> <if test="updateTime != null">and #{updateTime} >= update_time</if> </sql> <insert id="add" parameterType="cn.wisenergy.model.app.MonthManure" 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.MonthManure"> UPDATE <include refid="table"/> <set> <include refid="updateCondition"/> </set> <where> id = #{id} </where> </update> <select id="queryByTime" resultType="cn.wisenergy.model.app.MonthManure"> SELECT <include refid="cols_all"/> FROM <include refid="table"/> <where> <if test="yearMonth != null and yearMonth != ''"> `year_month`=#{yearMonth} </if> </where> </select> </mapper>