<?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.liquidnet.service.account.wallet.mapper.FinWalletMapper" >
  <resultMap id="BaseResultMap" type="com.liquidnet.service.account.wallet.entity.FinWallet" >
    <result column="FW0" property="walletNo" jdbcType="VARCHAR" />
    <result column="FW1" property="currency" jdbcType="VARCHAR" />
    <result column="FW2" property="alias" jdbcType="VARCHAR" />
    <result column="FW3" property="status" jdbcType="INTEGER" />
    <result column="FW4" property="payStatus" jdbcType="INTEGER" />
    <result column="FW5" property="finId" jdbcType="VARCHAR" />
    <result column="FW6" property="userExtId" jdbcType="VARCHAR" />
    <result column="FW7" property="userExtName" jdbcType="VARCHAR" />
    <result column="FW8" property="createTime" jdbcType="TIMESTAMP" />
    <result column="FW9" property="createOperator" jdbcType="VARCHAR" />
    <result column="FW10" property="updateTime" jdbcType="TIMESTAMP" />
    <result column="FW11" property="updateOperator" jdbcType="VARCHAR" />
    <result column="FW12" property="closingTime" jdbcType="TIMESTAMP" />
    <result column="FW13" property="closingOperator" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Example_Where_Clause" >
    <where >
      <foreach collection="oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.noValue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause" >
    <where >
      <foreach collection="example.oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.noValue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List" >
    FW0, FW1, FW2, FW3, FW4, FW5, FW6, FW7,
    FW8, FW9, FW10, FW11, FW12, FW13
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.liquidnet.service.account.wallet.entity.FinWalletExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from FIN_WL_N05
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select
    <include refid="Base_Column_List" />
    from FIN_WL_N05
    where FW0 = #{walletNo,jdbcType=VARCHAR}
  </select>
  <insert id="insert" parameterType="com.liquidnet.service.account.wallet.entity.FinWallet" >
    insert into fin_wallet (FW0, FW1, FW2,
      FW3, FW4, FW5,
      FW6, FW7, FW8,
      FW9, FW10, FW11,
      FW12, FW13)
    values (#{walletNo,jdbcType=VARCHAR}, #{currency,jdbcType=VARCHAR}, #{alias,jdbcType=VARCHAR},
      #{status,jdbcType=INTEGER}, #{payStatus,jdbcType=INTEGER}, #{finId,jdbcType=VARCHAR},
      #{userExtId,jdbcType=VARCHAR}, #{userExtName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
      #{createOperator,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{updateOperator,jdbcType=VARCHAR},
      #{closingTime,jdbcType=TIMESTAMP}, #{closingOperator,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.liquidnet.service.account.wallet.entity.FinWallet" >
    insert into FIN_WL_N05
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="walletNo != null" >
        FW0,
      </if>
      <if test="currency != null" >
        FW1,
      </if>
      <if test="alias != null" >
        FW2,
      </if>
      <if test="status != null" >
        FW3,
      </if>
      <if test="payStatus != null" >
        FW4,
      </if>
      <if test="finId != null" >
        FW5,
      </if>
      <if test="userExtId != null" >
        FW6,
      </if>
      <if test="userExtName != null" >
        FW7,
      </if>
      <if test="createTime != null" >
        FW8,
      </if>
      <if test="createOperator != null" >
        FW9,
      </if>
      <if test="updateTime != null" >
        FW10,
      </if>
      <if test="updateOperator != null" >
        FW11,
      </if>
      <if test="closingTime != null" >
        FW12,
      </if>
      <if test="closingOperator != null" >
        FW13,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="walletNo != null" >
        #{walletNo,jdbcType=VARCHAR},
      </if>
      <if test="currency != null" >
        #{currency,jdbcType=VARCHAR},
      </if>
      <if test="alias != null" >
        #{alias,jdbcType=VARCHAR},
      </if>
      <if test="status != null" >
        #{status,jdbcType=INTEGER},
      </if>
      <if test="payStatus != null" >
        #{payStatus,jdbcType=INTEGER},
      </if>
      <if test="finId != null" >
        #{finId,jdbcType=VARCHAR},
      </if>
      <if test="userExtId != null" >
        #{userExtId,jdbcType=VARCHAR},
      </if>
      <if test="userExtName != null" >
        #{userExtName,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createOperator != null" >
        #{createOperator,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null" >
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateOperator != null" >
        #{updateOperator,jdbcType=VARCHAR},
      </if>
      <if test="closingTime != null" >
        #{closingTime,jdbcType=TIMESTAMP},
      </if>
      <if test="closingOperator != null" >
        #{closingOperator,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.liquidnet.service.account.wallet.entity.FinWalletExample" resultType="java.lang.Integer" >
    select count(*) from FIN_WL_N05
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update FIN_WL_N05
    <set >
      <if test="record.walletNo != null" >
        FW0 = #{record.walletNo,jdbcType=VARCHAR},
      </if>
      <if test="record.currency != null" >
        FW1 = #{record.currency,jdbcType=VARCHAR},
      </if>
      <if test="record.alias != null" >
        FW2 = #{record.alias,jdbcType=VARCHAR},
      </if>
      <if test="record.status != null" >
        FW3 = #{record.status,jdbcType=INTEGER},
      </if>
      <if test="record.payStatus != null" >
        FW4 = #{record.payStatus,jdbcType=INTEGER},
      </if>
      <if test="record.finId != null" >
        FW5 = #{record.finId,jdbcType=VARCHAR},
      </if>
      <if test="record.userExtId != null" >
        FW6 = #{record.userExtId,jdbcType=VARCHAR},
      </if>
      <if test="record.userExtName != null" >
        FW7 = #{record.userExtName,jdbcType=VARCHAR},
      </if>
      <if test="record.createTime != null" >
        FW8 = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createOperator != null" >
        FW9 = #{record.createOperator,jdbcType=VARCHAR},
      </if>
      <if test="record.updateTime != null" >
        FW10 = #{record.updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.updateOperator != null" >
        FW11 = #{record.updateOperator,jdbcType=VARCHAR},
      </if>
      <if test="record.closingTime != null" >
        FW12 = #{record.closingTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.closingOperator != null" >
        FW13 = #{record.closingOperator,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map" >
    update FIN_WL_N05
    set FW0 = #{record.walletNo,jdbcType=VARCHAR},
      FW1 = #{record.currency,jdbcType=VARCHAR},
      FW2 = #{record.alias,jdbcType=VARCHAR},
      FW3 = #{record.status,jdbcType=INTEGER},
      FW4 = #{record.payStatus,jdbcType=INTEGER},
      FW5 = #{record.finId,jdbcType=VARCHAR},
      FW6 = #{record.userExtId,jdbcType=VARCHAR},
      FW7 = #{record.userExtName,jdbcType=VARCHAR},
      FW8 = #{record.createTime,jdbcType=TIMESTAMP},
      FW9 = #{record.createOperator,jdbcType=VARCHAR},
      FW10 = #{record.updateTime,jdbcType=TIMESTAMP},
      FW11 = #{record.updateOperator,jdbcType=VARCHAR},
      FW12 = #{record.closingTime,jdbcType=TIMESTAMP},
      FW13 = #{record.closingOperator,jdbcType=VARCHAR}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.liquidnet.service.account.wallet.entity.FinWallet" >
    update FIN_WL_N05
    <set >
      <if test="currency != null" >
        FW1 = #{currency,jdbcType=VARCHAR},
      </if>
      <if test="alias != null" >
        FW2 = #{alias,jdbcType=VARCHAR},
      </if>
      <if test="status != null" >
        FW3 = #{status,jdbcType=INTEGER},
      </if>
      <if test="payStatus != null" >
        FW4 = #{payStatus,jdbcType=INTEGER},
      </if>
      <if test="finId != null" >
        FW5 = #{finId,jdbcType=VARCHAR},
      </if>
      <if test="userExtId != null" >
        FW6 = #{userExtId,jdbcType=VARCHAR},
      </if>
      <if test="userExtName != null" >
        FW7 = #{userExtName,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null" >
        FW8 = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createOperator != null" >
        FW9 = #{createOperator,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null" >
        FW10 = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateOperator != null" >
        FW11 = #{updateOperator,jdbcType=VARCHAR},
      </if>
      <if test="closingTime != null" >
        FW12 = #{closingTime,jdbcType=TIMESTAMP},
      </if>
      <if test="closingOperator != null" >
        FW13 = #{closingOperator,jdbcType=VARCHAR},
      </if>
    </set>
    where FW0 = #{walletNo,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.liquidnet.service.account.wallet.entity.FinWallet" >
    update FIN_WL_N05
    set FW1 = #{currency,jdbcType=VARCHAR},
      FW2 = #{alias,jdbcType=VARCHAR},
      FW3 = #{status,jdbcType=INTEGER},
      FW4 = #{payStatus,jdbcType=INTEGER},
      FW5 = #{finId,jdbcType=VARCHAR},
      FW6 = #{finId,jdbcType=VARCHAR},
      FW7 = #{finId,jdbcType=VARCHAR},
      FW8 = #{createTime,jdbcType=TIMESTAMP},
      FW9 = #{createOperator,jdbcType=VARCHAR},
      FW10 = #{updateTime,jdbcType=TIMESTAMP},
      FW11 = #{updateOperator,jdbcType=VARCHAR},
      FW12 = #{closingTime,jdbcType=TIMESTAMP},
      FW13 = #{closingOperator,jdbcType=VARCHAR}
    where FW0 = #{walletNo,jdbcType=VARCHAR}
  </update>


  <select id="generateSeqNo" resultType="java.lang.Long">
    select _nextval(#{sequenceName,jdbcType=VARCHAR})
  </select>
  <select id="select" resultMap="BaseResultMap" parameterType="java.util.Map">
    select
    <include refid="Base_Column_List" />
    from FIN_WL_N05
    <if test="parameter != null">
      <where>
        <if test="parameter.strList != null and parameter.strList.size > 0" >
          AND FW0 IN
          <foreach collection="parameter.strList" item="obj" open="(" close=")" separator=",">
            #{obj,jdbcType=VARCHAR}
          </foreach>
        </if>
        <if test="parameter.walletNo != null and parameter.walletNo != ''" >
          AND FW0 = #{parameter.walletNo,jdbcType=VARCHAR}
        </if>
        <if test="parameter.currency != null and parameter.currency != ''" >
          AND FW1 = #{parameter.currency,jdbcType=VARCHAR}
        </if>
        <if test="parameter.alias != null and parameter.alias != ''" >
          AND FW2 = #{parameter.alias,jdbcType=VARCHAR}
        </if>
        <if test="parameter.status != null and parameter.status != ''" >
          AND FW3 = #{parameter.status,jdbcType=INTEGER}
        </if>
        <if test="parameter.payStatus != null and parameter.payStatus != ''" >
          AND FW4 = #{parameter.payStatus,jdbcType=INTEGER}
        </if>
        <if test="parameter.userExtId != null and parameter.userExtId != ''" >
          AND FW6 = #{parameter.userExtId,jdbcType=VARCHAR}
        </if>
        <if test="parameter.userExtName != null and parameter.userExtName != ''" >
          AND FW7 = #{parameter.userExtName,jdbcType=VARCHAR}
        </if>
        <if test="parameter.startTime != null" >
          AND FW8 <![CDATA[>=]]> #{parameter.startTime,jdbcType=TIMESTAMP}
        </if>
        <if test="parameter.endTime != null" >
          AND FW8 <![CDATA[<=]]> #{parameter.endTime,jdbcType=TIMESTAMP}
        </if>
          <if test="parameter.fuzzySearch != null and parameter.fuzzySearch != ''" >
              <choose>
                  <when test="parameter.fuzzyField == 1">
                      AND INSTR(FW1, #{parameter.fuzzySearch,jdbcType=VARCHAR})
                  </when>
                  <otherwise>
                      AND (
                      INSTR(FW0, #{parameter.fuzzySearch,jdbcType=VARCHAR})
                      OR INSTR(FW1, #{parameter.fuzzySearch,jdbcType=VARCHAR})
                      OR INSTR(FW2, #{parameter.fuzzySearch,jdbcType=VARCHAR})
                      )
                  </otherwise>
              </choose>
          </if>
      </where>
    </if>
    order by FW1, FW0
  </select>
<!--  <select id="selectByWalletNoAndAliasAndCurrencyForFuzzy" resultMap="BaseResultMap" parameterType="java.lang.String">-->
<!--    select-->
<!--    <include refid="Base_Column_List" />-->
<!--    from FIN_WL_N05-->
<!--    <where>-->
<!--      <if test="fuzzySearch != null and fuzzySearch != ''" >-->
<!--        AND (-->
<!--            FW0 LIKE CONCAT(#{fuzzySearch,jdbcType=VARCHAR},'%')-->
<!--            OR FW1 LIKE CONCAT(#{fuzzySearch,jdbcType=VARCHAR},'%')-->
<!--            OR FW2 LIKE CONCAT(#{fuzzySearch,jdbcType=VARCHAR},'%')-->
<!--        )-->
<!--      </if>-->
<!--      <if test="finId != null and finId != ''" >-->
<!--        AND FW5 = #{finId,jdbcType=VARCHAR}-->
<!--      </if>-->
<!--    </where>-->
<!--    order by FW1, FW0-->
<!--  </select>-->
</mapper>
