<?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.AccountMapper"> <resultMap id="AccountMap" type="cn.wisenergy.model.app.AccountInfo"> <id column="id" property="id"/> <result column="user_id" property="userId"/> <result column="user_level" property="userLevel"/> <result column="year_month" property="yearMonth"/> <result column="extract_money" property="extractMoney"/> <result column="earnings_month" property="earningsMonth"/> <result column="frozen_money" property="frozenMoney"/> <result column="earnings_total" property="earningsTotal"/> <result column="frozen_status" property="frozenStatus"/> <result column="create_time" property="createTime"/> <result column="update_time" property="updateTime"/> </resultMap> <sql id="table"> account_info </sql> <sql id="cols_all"> id, <include refid="cols_exclude_id"/> </sql> <sql id="cols_exclude_id"> user_id,user_level,`year_month`,extract_money,earnings_month,frozen_money,earnings_total,frozen_status, create_time,update_time </sql> <sql id="vals"> #{userId},#{userLevel},#{yearMonth},#{extractMoney},#{earningsMonth},#{frozenMoney}, #{earningsTotal},#{frozenStatus},now(),now() </sql> <sql id="updateCondition"> <if test="userId != null">user_id = #{userId},</if> <if test="userLevel != null">user_level = #{userLevel},</if> <if test="yearMonth != null">`year_month` =#{yearMonth},</if> <if test="extractMoney != null">extract_money =#{extractMoney},</if> <if test="earningsMonth != null">earnings_month =#{earningsMonth},</if> <if test="frozenMoney != null">frozen_money =#{frozenMoney},</if> <if test="earningsTotal != null">earnings_total =#{earningsTotal},</if> <if test="frozenStatus != null">frozen_status =#{frozenStatus},</if> update_time =now() </sql> <sql id="criteria"> <if test="id != null">id = #{id}</if> <if test="userId != null">and user_id = #{userId}</if> <if test="userLevel != null">and user_level = #{userLevel}</if> <if test="yearMonth != null">and `year_month` =#{yearMonth}</if> <if test="extractMoney != null">and extract_money =#{extractMoney}</if> <if test="earningsMonth != null">and earnings_month =#{earningsMonth}</if> <if test="frozenMoney != null">and frozen_money =#{frozenMoney}</if> <if test="earningsTotal != null">and earnings_total =#{earningsTotal}</if> <if test="frozenStatus != null">and frozen_status =#{frozenStatus}</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.AccountInfo" 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.AccountInfo"> 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> <select id="getByUserId" resultType="cn.wisenergy.model.app.AccountInfo"> select <include refid="cols_all"/> from <include refid="table"/> <where> user_id=#{userId} </where> </select> <select id="getByUserIdAndTime" resultType="cn.wisenergy.model.app.AccountInfo"> select <include refid="cols_all"/> from <include refid="table"/> <where> user_id=#{userId} and `year_month`=#{yearMonth} </where> </select> <select id="count" resultType="java.lang.Integer"> select count(1) from <include refid="table"/> </select> <select id="getList" resultType="cn.wisenergy.model.app.AccountInfo"> select <include refid="cols_all"/> from <include refid="table"/> order by create_time desc limit #{startNum},#{endNum} </select> <update id="updateEarningsMonthAndEarningsTotalByid" parameterType="cn.wisenergy.model.app.AccountInfo"> UPDATE <include refid="table"/> <set> <include refid="updateCondition"/> </set> <where> id = #{id} </where> </update> </mapper>