<?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.MaUpOffMapper">
  <resultMap id="BaseResultMap" type="com.bonus.zlpt.company.domain.MaUpOff">
    <!--@mbg.generated-->
    <!--@Table ma_up_off-->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="ma_id" jdbcType="INTEGER" property="maId" />
    <result column="apply_time" jdbcType="VARCHAR" property="applyTime" />
    <result column="apply_user" jdbcType="VARCHAR" property="applyUser" />
    <result column="apply_company" jdbcType="VARCHAR" property="applyCompany" />
    <result column="type" jdbcType="VARCHAR" property="type" />
    <result column="audit_user" jdbcType="VARCHAR" property="auditUser" />
    <result column="audit_time" jdbcType="VARCHAR" property="auditTime" />
    <result column="status" jdbcType="VARCHAR" property="status" />
  </resultMap>

  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, ma_id, apply_time, apply_user, apply_company, `type`, audit_user, audit_time, `status`
  </sql>

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

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

  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.bonus.zlpt.company.domain.MaUpOff" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into ma_up_off (ma_id, apply_time, apply_user, apply_company, `type`, audit_user, audit_time, `status`)
    values (#{maId,jdbcType=INTEGER}, #{applyTime,jdbcType=VARCHAR}, #{applyUser,jdbcType=VARCHAR}, 
      #{applyCompany,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{auditUser,jdbcType=VARCHAR}, 
      #{auditTime,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR})
  </insert>

  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bonus.zlpt.company.domain.MaUpOff" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into ma_up_off
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="maId != null">
        ma_id,
      </if>
      <if test="applyTime != null and applyTime != ''">
        apply_time,
      </if>
      <if test="applyUser != null and applyUser != ''">
        apply_user,
      </if>
      <if test="applyCompany != null and applyCompany != ''">
        apply_company,
      </if>
      <if test="type != null and type != ''">
        `type`,
      </if>
      <if test="auditUser != null and auditUser != ''">
        audit_user,
      </if>
      <if test="auditTime != null and auditTime != ''">
        audit_time,
      </if>
      <if test="status != null and status != ''">
        `status`,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="maId != null">
        #{maId,jdbcType=INTEGER},
      </if>
      <if test="applyTime != null and applyTime != ''">
        #{applyTime,jdbcType=VARCHAR},
      </if>
      <if test="applyUser != null and applyUser != ''">
        #{applyUser,jdbcType=VARCHAR},
      </if>
      <if test="applyCompany != null and applyCompany != ''">
        #{applyCompany,jdbcType=VARCHAR},
      </if>
      <if test="type != null and type != ''">
        #{type,jdbcType=VARCHAR},
      </if>
      <if test="auditUser != null and auditUser != ''">
        #{auditUser,jdbcType=VARCHAR},
      </if>
      <if test="auditTime != null and auditTime != ''">
        #{auditTime,jdbcType=VARCHAR},
      </if>
      <if test="status != null and status != ''">
        #{status,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>

  <update id="updateByPrimaryKeySelective" parameterType="com.bonus.zlpt.company.domain.MaUpOff">
    <!--@mbg.generated-->
    update ma_up_off
    <set>
      <if test="maId != null">
        ma_id = #{maId,jdbcType=INTEGER},
      </if>
      <if test="applyTime != null and applyTime != ''">
        apply_time = #{applyTime,jdbcType=VARCHAR},
      </if>
      <if test="applyUser != null and applyUser != ''">
        apply_user = #{applyUser,jdbcType=VARCHAR},
      </if>
      <if test="applyCompany != null and applyCompany != ''">
        apply_company = #{applyCompany,jdbcType=VARCHAR},
      </if>
      <if test="type != null and type != ''">
        `type` = #{type,jdbcType=VARCHAR},
      </if>
      <if test="auditUser != null and auditUser != ''">
        audit_user = #{auditUser,jdbcType=VARCHAR},
      </if>
      <if test="auditTime != null and auditTime != ''">
        audit_time = #{auditTime,jdbcType=VARCHAR},
      </if>
      <if test="status != null and status != ''">
        `status` = #{status,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>

  <update id="updateByPrimaryKey" parameterType="com.bonus.zlpt.company.domain.MaUpOff">
    <!--@mbg.generated-->
    update ma_up_off
    set ma_id = #{maId,jdbcType=INTEGER},
      apply_time = #{applyTime,jdbcType=VARCHAR},
      apply_user = #{applyUser,jdbcType=VARCHAR},
      apply_company = #{applyCompany,jdbcType=VARCHAR},
      `type` = #{type,jdbcType=VARCHAR},
      audit_user = #{auditUser,jdbcType=VARCHAR},
      audit_time = #{auditTime,jdbcType=VARCHAR},
      `status` = #{status,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="selectAll" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from ma_up_off
    <where>
      <if test="id!= null">
        id = #{id,jdbcType=INTEGER}
      </if>
      <if test="maId!= null">
        and ma_id = #{maId,jdbcType=INTEGER}
      </if>
      <if test="applyCompany!= null and applyCompany!= ''">
        and apply_company like concat('%',#{applyCompany,jdbcType=VARCHAR},'%')
      </if>
    </where>
  </select>

  <select id="batchUpOff" resultType="int">
    update ma_up_off set status = '1', type = '1', audit_time = now() where id in
    <foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
      #{item}
    </foreach>
  </select>

</mapper>