<?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.bonus.zlpt.company.mapper.BmCoBankMapper">
  <resultMap id="BaseResultMap" type="com.bonus.zlpt.company.domain.BmCoBank">
    <!--@mbg.generated-->
    <!--@Table bm_co_bank-->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="bank_name" jdbcType="VARCHAR" property="bankName" />
    <result column="account_name" jdbcType="VARCHAR" property="accountName" />
    <result column="bank_account" jdbcType="VARCHAR" property="bankAccount" />
    <result column="bank_address" jdbcType="VARCHAR" property="bankAddress" />
    <result column="permit_number" jdbcType="VARCHAR" property="permitNumber" />
    <result column="permit_url" jdbcType="VARCHAR" property="permitUrl" />
    <result column="co_id" jdbcType="INTEGER" property="coId" />
  </resultMap>

  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, bank_name, account_name, bank_account, bank_address, permit_number, permit_url, co_id
  </sql>

  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from bm_co_bank
    where id = #{id,jdbcType=INTEGER}
  </select>

  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    <!--@mbg.generated-->
    delete from bm_co_bank
    where id = #{id,jdbcType=INTEGER}
  </delete>

  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.bonus.zlpt.company.domain.BmCoBank" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into bm_co_bank (bank_name, account_name, bank_account,
      bank_address, permit_number, permit_url, 
      co_id)
    values (#{bankName,jdbcType=VARCHAR}, #{accountName,jdbcType=VARCHAR}, #{bankAccount,jdbcType=VARCHAR}, 
      #{bankAddress,jdbcType=VARCHAR}, #{permitNumber,jdbcType=VARCHAR}, #{permitUrl,jdbcType=VARCHAR}, 
      #{coId,jdbcType=INTEGER})
  </insert>

  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bonus.zlpt.company.domain.BmCoBank" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into bm_co_bank
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="bankName != null and bankName != ''">
        bank_name,
      </if>
      <if test="accountName != null and accountName != ''">
        account_name,
      </if>
      <if test="bankAccount != null and bankAccount != ''">
        bank_account,
      </if>
      <if test="bankAddress != null and bankAddress != ''">
        bank_address,
      </if>
      <if test="permitNumber != null and permitNumber != ''">
        permit_number,
      </if>
      <if test="permitUrl != null and permitUrl != ''">
        permit_url,
      </if>
      <if test="coId != null">
        co_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="bankName != null and bankName != ''">
        #{bankName,jdbcType=VARCHAR},
      </if>
      <if test="accountName != null and accountName != ''">
        #{accountName,jdbcType=VARCHAR},
      </if>
      <if test="bankAccount != null and bankAccount != ''">
        #{bankAccount,jdbcType=VARCHAR},
      </if>
      <if test="bankAddress != null and bankAddress != ''">
        #{bankAddress,jdbcType=VARCHAR},
      </if>
      <if test="permitNumber != null and permitNumber != ''">
        #{permitNumber,jdbcType=VARCHAR},
      </if>
      <if test="permitUrl != null and permitUrl != ''">
        #{permitUrl,jdbcType=VARCHAR},
      </if>
      <if test="coId != null">
        #{coId,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>

  <update id="updateByPrimaryKeySelective" parameterType="com.bonus.zlpt.company.domain.BmCoBank">
    <!--@mbg.generated-->
    update bm_co_bank
    <set>
      <if test="bankName != null and bankName != ''">
        bank_name = #{bankName,jdbcType=VARCHAR},
      </if>
      <if test="accountName != null and accountName != ''">
        account_name = #{accountName,jdbcType=VARCHAR},
      </if>
      <if test="bankAccount != null and bankAccount != ''">
        bank_account = #{bankAccount,jdbcType=VARCHAR},
      </if>
      <if test="bankAddress != null and bankAddress != ''">
        bank_address = #{bankAddress,jdbcType=VARCHAR},
      </if>
      <if test="permitNumber != null and permitNumber != ''">
        permit_number = #{permitNumber,jdbcType=VARCHAR},
      </if>
      <if test="permitUrl != null and permitUrl != ''">
        permit_url = #{permitUrl,jdbcType=VARCHAR},
      </if>
      <if test="coId != null">
        co_id = #{coId,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>

  <update id="updateByPrimaryKey" parameterType="com.bonus.zlpt.company.domain.BmCoBank">
    <!--@mbg.generated-->
    update bm_co_bank
    set bank_name = #{bankName,jdbcType=VARCHAR},
      account_name = #{accountName,jdbcType=VARCHAR},
      bank_account = #{bankAccount,jdbcType=VARCHAR},
      bank_address = #{bankAddress,jdbcType=VARCHAR},
      permit_number = #{permitNumber,jdbcType=VARCHAR},
      permit_url = #{permitUrl,jdbcType=VARCHAR},
      co_id = #{coId,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="selectByCompanyId" resultType="com.bonus.zlpt.company.domain.BmCoBank">
    select * from bm_co_bank where co_id = #{companyId}
  </select>


</mapper>