<?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.CultivatingPrizeInfoMapper">
    <resultMap id="bankMap" type="cn.wisenergy.model.app.CultivatingPrizeInfo">
        <id column="id" property="id"/>
        <result column="user_id" property="userId"/>
        <result column="seedling" property="seedling"/>
        <result column="bronze_tree" property="bronzeTree"/>
        <result column="silver_tree" property="silverTree"/>
        <result column="gold_tree" property="goldTree"/>
        <result column="farmer" property="farmer"/>
        <result column="forest_start" property="forestStart"/>
        <result column="partner" property="partner"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

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

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

    <sql id="cols_exclude_id">
        user_id,seedling,bronze_tree,silver_tree,gold_tree,farmer,forest_start,partner,create_time,update_time
    </sql>

    <sql id="vals">
        #{userId},#{seedling},#{bronzeTree},#{silverTree},#{goldTree},#{farmer},#{forestStart},#{partner},now(),now()
    </sql>

    <sql id="updateCondition">
        <if test="userId != null">user_id = #{userId},</if>
        <if test="seedling != null">seedling = #{seedling},</if>
        <if test="bronzeTree != null">bronze_tree = #{bronzeTree},</if>
        <if test="silverTree != null">silver_tree = #{silverTree},</if>
        <if test="goldTree != null">gold_tree = #{goldTree},</if>
        <if test="farmer != null">farmer = #{farmer},</if>
        <if test="forestStart != null">forest_start = #{forestStart},</if>
        <if test="partner != null">partner = #{partner},</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="seedling != null">and seedling = #{seedling}</if>
        <if test="bronzeTree != null">and bronze_tree = #{bronzeTree}</if>
        <if test="silverTree != null">and silver_tree = #{silverTree}</if>
        <if test="goldTree != null">and gold_tree = #{goldTree}</if>
        <if test="farmer != null">and farmer = #{farmer}</if>
        <if test="forestStart != null">and forest_start = #{forestStart}</if>
        <if test="partner != null">and partner = #{partner}</if>
        <if test="createTime != null">and create_time &gt;= #{createTime}</if>
        <if test="updateTime != null">and #{updateTime} &gt;= update_time</if>
    </sql>

    <select id="getOneByUserId" resultType="cn.wisenergy.model.app.CultivatingPrizeInfo">
        select
        <include refid="cols_all"/>
        from
        <include refid="table"/>
        <where>
            user_id = #{userId}
        </where>
    </select>

</mapper>