<?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.slodon.b2b2c.dao.write.member.MemberBankAccountWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.member.pojo.MemberBankAccount">
    <id column="account_id" property="accountId" />
    <result column="member_id" property="memberId" />
    <result column="member_name" property="memberName" />
    <result column="account_code" property="accountCode" />
    <result column="account_name" property="accountName" />
    <result column="account_number" property="accountNumber" />
    <result column="bank_name" property="bankName" />
    <result column="wx_type" property="wxType" />
    <result column="is_last" property="isLast" />
    <result column="create_time" property="createTime" />
    <result column="update_time" property="updateTime" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="memberId != null">
        `member_id`,
      </if>
      <if test="memberName != null">
        `member_name`,
      </if>
      <if test="accountCode != null">
        `account_code`,
      </if>
      <if test="accountName != null">
        `account_name`,
      </if>
      <if test="accountNumber != null">
        `account_number`,
      </if>
      <if test="bankName != null">
        `bank_name`,
      </if>
      <if test="wxType != null">
        `wx_type`,
      </if>
      <if test="isLast != null">
        `is_last`,
      </if>
      <if test="createTime != null">
        `create_time`,
      </if>
      <if test="updateTime != null">
        `update_time`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `account_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.accountIdNotEquals != null">
          AND `account_id` != #{example.accountIdNotEquals}
        </if>
        <if test="example.accountIdIn != null">
          AND `account_id` in (${example.accountIdIn})
        </if>
        <if test="example.memberId != null">
          AND `member_id` = #{example.memberId}
        </if>
        <if test="example.memberName != null">
          AND `member_name` = #{example.memberName}
        </if>
        <if test="example.memberNameLike != null">
          AND `member_name` like concat('%',#{example.memberNameLike},'%')
        </if>
        <if test="example.accountCode != null">
          AND `account_code` = #{example.accountCode}
        </if>
        <if test="example.accountName != null">
          AND `account_name` = #{example.accountName}
        </if>
        <if test="example.accountNameLike != null">
          AND `account_name` like concat('%',#{example.accountNameLike},'%')
        </if>
        <if test="example.accountNumber != null">
          AND `account_number` = #{example.accountNumber}
        </if>
        <if test="example.bankName != null">
          AND `bank_name` = #{example.bankName}
        </if>
        <if test="example.bankNameLike != null">
          AND `bank_name` like concat('%',#{example.bankNameLike},'%')
        </if>
        <if test="example.wxType != null">
          AND `wx_type` = #{example.wxType}
        </if>
        <if test="example.isLast != null">
          AND `is_last` = #{example.isLast}
        </if>
        <if test="example.createTimeAfter != null">
          AND `create_time` <![CDATA[ >= ]]> #{example.createTimeAfter}
        </if>
        <if test="example.createTimeBefore != null">
          AND `create_time` <![CDATA[ <= ]]> #{example.createTimeBefore}
        </if>
        <if test="example.updateTimeAfter != null">
          AND `update_time` <![CDATA[ >= ]]> #{example.updateTimeAfter}
        </if>
        <if test="example.updateTimeBefore != null">
          AND `update_time` <![CDATA[ <= ]]> #{example.updateTimeBefore}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `account_id` DESC
  </sql>
  <sql id="orderByOther">
    order by ${example.orderBy}
  </sql>
  <!--分组条件-->
  <sql id="groupBy">
    group by ${example.groupBy}
  </sql>
  <!--分页条件-->
  <sql id="limit">
    <if test="size != null and size &gt; 0">
      limit #{startRow},#{size}
    </if>
  </sql>
  <!--查询符合条件的记录数-->
  <select id="countByExample" parameterType="com.slodon.b2b2c.member.example.MemberBankAccountExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `member_bank_account`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `member_bank_account`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `member_bank_account`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(所有字段)-->
  <select id="listPageByExample" resultMap="resultMap">
    SELECT
      *
    FROM `member_bank_account`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
  <!--查询符合条件的记录(指定字段)-->
  <select id="listFieldsByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `member_bank_account`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(指定字段)-->
  <select id="listFieldsPageByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `member_bank_account`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
  <!--根据条件删除记录，可多条删除-->
  <delete id="deleteByExample">
    DELETE FROM `member_bank_account`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `member_bank_account`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="account_id" keyProperty="accountId" parameterType="com.slodon.b2b2c.member.pojo.MemberBankAccount" useGeneratedKeys="true">
    INSERT INTO `member_bank_account`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="memberId != null">
        #{memberId},
      </if>
      <if test="memberName != null">
        #{memberName},
      </if>
      <if test="accountCode != null">
        #{accountCode},
      </if>
      <if test="accountName != null">
        #{accountName},
      </if>
      <if test="accountNumber != null">
        #{accountNumber},
      </if>
      <if test="bankName != null">
        #{bankName},
      </if>
      <if test="wxType != null">
        #{wxType},
      </if>
      <if test="isLast != null">
        #{isLast},
      </if>
      <if test="createTime != null">
        #{createTime},
      </if>
      <if test="updateTime != null">
        #{updateTime},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `member_bank_account`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.memberId != null">
        `member_id` = #{record.memberId},
      </if>
      <if test="record.memberName != null">
        `member_name` = #{record.memberName},
      </if>
      <if test="record.accountCode != null">
        `account_code` = #{record.accountCode},
      </if>
      <if test="record.accountName != null">
        `account_name` = #{record.accountName},
      </if>
      <if test="record.accountNumber != null">
        `account_number` = #{record.accountNumber},
      </if>
      <if test="record.bankName != null">
        `bank_name` = #{record.bankName},
      </if>
      <if test="record.wxType != null">
        `wx_type` = #{record.wxType},
      </if>
      <if test="record.isLast != null">
        `is_last` = #{record.isLast},
      </if>
      <if test="record.createTime != null">
        `create_time` = #{record.createTime},
      </if>
      <if test="record.updateTime != null">
        `update_time` = #{record.updateTime},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `member_bank_account`
    <trim prefix="SET" suffixOverrides=",">
      <if test="memberId != null">
        `member_id` = #{memberId},
      </if>
      <if test="memberName != null">
        `member_name` = #{memberName},
      </if>
      <if test="accountCode != null">
        `account_code` = #{accountCode},
      </if>
      <if test="accountName != null">
        `account_name` = #{accountName},
      </if>
      <if test="accountNumber != null">
        `account_number` = #{accountNumber},
      </if>
      <if test="bankName != null">
        `bank_name` = #{bankName},
      </if>
      <if test="wxType != null">
        `wx_type` = #{wxType},
      </if>
      <if test="isLast != null">
        `is_last` = #{isLast},
      </if>
      <if test="createTime != null">
        `create_time` = #{createTime},
      </if>
      <if test="updateTime != null">
        `update_time` = #{updateTime},
      </if>
    </trim>
    WHERE `account_id` = #{accountId}
  </update>
</mapper>