<?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="com.chaozhanggui.dao.system.dao.TbPlussCashAccountMapper">
  <resultMap id="BaseResultMap" type="com.chaozhanggui.dao.system.entity.TbPlussCashAccount">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="userId" jdbcType="INTEGER" property="userid" />
    <result column="accountNo" jdbcType="VARCHAR" property="accountno" />
    <result column="accountName" jdbcType="VARCHAR" property="accountname" />
    <result column="status" jdbcType="INTEGER" property="status" />
    <result column="createTime" jdbcType="TIMESTAMP" property="createtime" />
  </resultMap>
  <sql id="Base_Column_List">
    id, userId, accountNo, accountName, status, createTime
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from tb_pluss_cash_account
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from tb_pluss_cash_account
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.chaozhanggui.dao.system.entity.TbPlussCashAccount">
    insert into tb_pluss_cash_account (id, userId, accountNo, 
      accountName, status, createTime
      )
    values (#{id,jdbcType=INTEGER}, #{userid,jdbcType=INTEGER}, #{accountno,jdbcType=VARCHAR}, 
      #{accountname,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{createtime,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.chaozhanggui.dao.system.entity.TbPlussCashAccount">
    insert into tb_pluss_cash_account
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="userid != null">
        userId,
      </if>
      <if test="accountno != null">
        accountNo,
      </if>
      <if test="accountname != null">
        accountName,
      </if>
      <if test="status != null">
        status,
      </if>
      <if test="createtime != null">
        createTime,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="userid != null">
        #{userid,jdbcType=INTEGER},
      </if>
      <if test="accountno != null">
        #{accountno,jdbcType=VARCHAR},
      </if>
      <if test="accountname != null">
        #{accountname,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        #{status,jdbcType=INTEGER},
      </if>
      <if test="createtime != null">
        #{createtime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.dao.system.entity.TbPlussCashAccount">
    update tb_pluss_cash_account
    <set>
      <if test="userid != null">
        userId = #{userid,jdbcType=INTEGER},
      </if>
      <if test="accountno != null">
        accountNo = #{accountno,jdbcType=VARCHAR},
      </if>
      <if test="accountname != null">
        accountName = #{accountname,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=INTEGER},
      </if>
      <if test="createtime != null">
        createTime = #{createtime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.chaozhanggui.dao.system.entity.TbPlussCashAccount">
    update tb_pluss_cash_account
    set userId = #{userid,jdbcType=INTEGER},
      accountNo = #{accountno,jdbcType=VARCHAR},
      accountName = #{accountname,jdbcType=VARCHAR},
      status = #{status,jdbcType=INTEGER},
      createTime = #{createtime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="selectByUserId" resultMap="BaseResultMap">

    select * from tb_pluss_cash_account where userId=#{userId} group by id desc limit 1
    </select>
</mapper>