<?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.leromro.core.mapper.ClientAccountMapper">
     <update id="updateClientBalance">
        update l_client_account
        <trim prefix="SET" suffixOverrides=",">
            <if test="balance != null">balance = #{balance},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_time = #{updateTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where client_account_id = #{clientAccountId}
    </update>

    <!--  <resultMap type="LUserBalance" id="LUserBalanceResult">
          <result property="balanceId"    column="balance_id"    />
          <result property="userId"    column="user_id"    />
          <result property="balance"    column="balance"    />
          <result property="updateTime"    column="update_time"    />
      </resultMap>

      <sql id="selectLUserBalanceVo">
          select balance_id, user_id, balance, update_time from l_user_balance
      </sql>

      <select id="selectLUserBalanceList" parameterType="LUserBalance" resultMap="LUserBalanceResult">
          <include refid="selectLUserBalanceVo"/>
          <where>
              <if test="userId != null "> and user_id = #{userId}</if>
              <if test="balance != null "> and balance = #{balance}</if>
          </where>
      </select>

      <select id="selectLUserBalanceByBalanceId" parameterType="Long" resultMap="LUserBalanceResult">
          <include refid="selectLUserBalanceVo"/>
          where balance_id = #{balanceId}
      </select>

      <insert id="insertLUserBalance" parameterType="LUserBalance" useGeneratedKeys="true" keyProperty="balanceId">
          insert into l_user_balance
          <trim prefix="(" suffix=")" suffixOverrides=",">
              <if test="userId != null">user_id,</if>
              <if test="balance != null">balance,</if>
              <if test="updateTime != null">update_time,</if>
           </trim>
          <trim prefix="values (" suffix=")" suffixOverrides=",">
              <if test="userId != null">#{userId},</if>
              <if test="balance != null">#{balance},</if>
              <if test="updateTime != null">#{updateTime},</if>
           </trim>
      </insert>
  -->

    <select id="selectBalanceByuserID" resultType="com.leromro.core.domain.ClientAccount">
        select * from l_client_account where user_id = #{userId}
    </select>


    <!--<delete id="deleteLUserBalanceByBalanceId" parameterType="Long">
        delete from l_user_balance where balance_id = #{balanceId}
    </delete>

    <delete id="deleteLUserBalanceByBalanceIds" parameterType="String">
        delete from l_user_balance where balance_id in 
        <foreach item="balanceId" collection="array" open="(" separator="," close=")">
            #{balanceId}
        </foreach>
    </delete>-->
</mapper>