<?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.sgzb.system.mapper.BmNumLogsMapper">
  <resultMap id="BaseResultMap" type="com.bonus.sgzb.system.api.domain.BmNumLogs">
    <!--@mbg.generated-->
    <!--@Table bm_num_logs-->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="model_title" jdbcType="VARCHAR" property="modelTitle" />
    <result column="method" jdbcType="VARCHAR" property="method" />
    <result column="task" jdbcType="VARCHAR" property="task" />
    <result column="task_name" jdbcType="VARCHAR" property="taskName" />
    <result column="type_id" jdbcType="INTEGER" property="typeId" />
    <result column="type_name" jdbcType="VARCHAR" property="typeName" />
    <result column="type_parent_name" jdbcType="VARCHAR" property="typeParentName" />
    <result column="num" jdbcType="VARCHAR" property="num" />
    <result column="description" jdbcType="VARCHAR" property="description" />
    <result column="json_result" jdbcType="VARCHAR" property="jsonResult" />
    <result column="time" jdbcType="TIMESTAMP" property="time" />
    <result column="creator" jdbcType="VARCHAR" property="creator" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="status" jdbcType="TINYINT" property="status" />
  </resultMap>

  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, model_title, `method`, task, type_id, num, `description`, json_result, `time`, creator,
    remark, `status`
  </sql>

  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select
    bnl.id, bnl.model_title, bnl.`method`, bnl.task, bnl.type_id, bnl.num, bnl.`description`, bnl.json_result, bnl.`time`, bnl.creator,
    bnl.remark, bnl.`status`, mt.type_name, mt1.type_name as type_parent_name, tt.code as task_name
    from bm_num_logs bnl
    left join ma_type mt on bnl.type_id = mt.type_id
    inner join ma_type mt1 on mt.parent_id = mt1.type_id
    left join tm_task tt on bnl.task = tt.task_id
    where id = #{id,jdbcType=INTEGER}
  </select>

  <select id="selectAll" resultMap="BaseResultMap">
    select
      bnl.id, bnl.model_title, bnl.`method`, bnl.task, bnl.type_id, bnl.num, bnl.`description`, bnl.json_result, bnl.`time`, bnl.creator,
      bnl.remark, bnl.`status`, mt.type_name, mt1.type_name as type_parent_name, tt.code as task_name
    from bm_num_logs bnl
    left join ma_type mt on bnl.type_id = mt.type_id
    inner join ma_type mt1 on mt.parent_id = mt1.type_id
    left join tm_task tt on bnl.task = tt.task_id
    <where>
      <if test="modelTitle != null and modelTitle != ''">
        and bnl.model_title like concat('%', #{modelTitle}, '%')
      </if>
      <if test="typeName != null and typeName != ''">
        and mt1.type_name like concat('%', #{typeName}, '%')
      </if>
    </where>
  </select>

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

  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.system.api.domain.BmNumLogs" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into bm_num_logs (model_title, `method`, task, 
      type_id, description, json_result,
      `time`, creator, remark
      )
    values (#{modelTitle,jdbcType=VARCHAR}, #{method,jdbcType=VARCHAR}, #{task,jdbcType=VARCHAR}, 
      #{typeId,jdbcType=INTEGER}, #{description,jdbcType=VARCHAR}, #{jsonResult,jdbcType=VARCHAR},
      now(), #{creator,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}
      )
  </insert>

  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.system.api.domain.BmNumLogs" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into bm_num_logs
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="modelTitle != null and modelTitle != ''">
        model_title,
      </if>
      <if test="method != null and method != ''">
        `method`,
      </if>
      <if test="task != null and task != ''">
        task,
      </if>
      <if test="typeId != null">
        type_id,
      </if>
      <if test="num != null and num != ''">
        num,
      </if>
      <if test="description != null and description != ''">
        `description`,
      </if>
      <if test="jsonResult != null and jsonResult != ''">
        json_result,
      </if>
      <if test="time != null">
        `time`,
      </if>
      <if test="creator != null and creator != ''">
        creator,
      </if>
      <if test="remark != null and remark != ''">
        remark,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="modelTitle != null and modelTitle != ''">
        #{modelTitle,jdbcType=VARCHAR},
      </if>
      <if test="method != null and method != ''">
        #{method,jdbcType=VARCHAR},
      </if>
      <if test="task != null and task != ''">
        #{task,jdbcType=VARCHAR},
      </if>
      <if test="typeId != null">
        #{typeId,jdbcType=INTEGER},
      </if>
      <if test="num != null and num != ''">
        #{num,jdbcType=VARCHAR},
      </if>
      <if test="description != null and description != ''">
        #{description,jdbcType=VARCHAR},
      </if>
      <if test="jsonResult != null and jsonResult != ''">
        #{jsonResult,jdbcType=VARCHAR},
      </if>
      <if test="time != null">
        #{time,jdbcType=TIMESTAMP},
      </if>
      <if test="creator != null and creator != ''">
        #{creator,jdbcType=VARCHAR},
      </if>
      <if test="remark != null and remark != ''">
        #{remark,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>

  <update id="updateByPrimaryKeySelective" parameterType="com.bonus.sgzb.system.api.domain.BmNumLogs">
    <!--@mbg.generated-->
    update bm_num_logs
    <set>
      <if test="modelTitle != null and modelTitle != ''">
        model_title = #{modelTitle,jdbcType=VARCHAR},
      </if>
      <if test="method != null and method != ''">
        `method` = #{method,jdbcType=VARCHAR},
      </if>
      <if test="task != null and task != ''">
        task = #{task,jdbcType=VARCHAR},
      </if>
      <if test="typeId != null">
        type_id = #{typeId,jdbcType=INTEGER},
      </if>
      <if test="description != null and description != ''">
        description = #{description,jdbcType=VARCHAR},
      </if>
      <if test="jsonResult != null and jsonResult != ''">
        json_result = #{jsonResult,jdbcType=VARCHAR},
      </if>
      <if test="time != null">
        `time` = #{time,jdbcType=TIMESTAMP},
      </if>
      <if test="creator != null and creator != ''">
        creator = #{creator,jdbcType=VARCHAR},
      </if>
      <if test="remark != null and remark != ''">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>

  <update id="updateByPrimaryKey" parameterType="com.bonus.sgzb.system.api.domain.BmNumLogs">
    <!--@mbg.generated-->
    update bm_num_logs
    set model_title = #{modelTitle,jdbcType=VARCHAR},
      `method` = #{method,jdbcType=VARCHAR},
      task = #{task,jdbcType=VARCHAR},
      type_id = #{typeId,jdbcType=INTEGER},
      description = #{description,jdbcType=VARCHAR},
      json_result = #{jsonResult,jdbcType=VARCHAR},
      `time` = #{time,jdbcType=TIMESTAMP},
      creator = #{creator,jdbcType=VARCHAR},
      remark = #{remark,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>

</mapper>