<?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.goafanti.common.dao.TaskStopLogMapper">
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.TaskStopLog">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="task_stop_id" jdbcType="BIGINT" property="taskStopId" />
    <result column="status" jdbcType="INTEGER" property="status" />
    <result column="reason" jdbcType="VARCHAR" property="reason" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  </resultMap>
  <sql id="Base_Column_List">
    id, task_stop_id, `status`, reason, create_by, create_time
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from task_stop_log
    where id = #{id,jdbcType=BIGINT}
  </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from task_stop_log
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TaskStopLog" useGeneratedKeys="true">
    insert into task_stop_log (task_stop_id, `status`, reason,
      create_by, create_time)
    values (#{taskStopId,jdbcType=BIGINT}, #{status,jdbcType=INTEGER}, #{reason,jdbcType=VARCHAR},
      #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TaskStopLog" useGeneratedKeys="true">
    insert into task_stop_log
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="taskStopId != null">
        task_stop_id,
      </if>
      <if test="status != null">
        `status`,
      </if>
      <if test="reason != null">
        reason,
      </if>
      <if test="createBy != null">
        create_by,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="taskStopId != null">
        #{taskStopId,jdbcType=BIGINT},
      </if>
      <if test="status != null">
        #{status,jdbcType=INTEGER},
      </if>
      <if test="reason != null">
        #{reason,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.TaskStopLog">
    update task_stop_log
    <set>
      <if test="taskStopId != null">
        task_stop_id = #{taskStopId,jdbcType=BIGINT},
      </if>
      <if test="status != null">
        `status` = #{status,jdbcType=INTEGER},
      </if>
      <if test="reason != null">
        reason = #{reason,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        create_by = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.TaskStopLog">
    update task_stop_log
    set task_stop_id = #{taskStopId,jdbcType=BIGINT},
      `status` = #{status,jdbcType=INTEGER},
      reason = #{reason,jdbcType=VARCHAR},
      create_by = #{createBy,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=BIGINT}
  </update>

  <select id="selectListBySoptId" resultType="com.goafanti.order.bo.TaskStopLogBo">
    select a.id ,a.task_stop_id taskSoptId,a.status ,a.reason ,a.create_by createBy ,a.create_time createTime,
           b.name createName,DATE_FORMAT(a.create_time,'%Y-%m-%d %H:%i:%S') createTimes
    from task_stop_log a left join admin b on a.create_by =b.id
    where a.task_stop_id = #{taskStopId}
  </select>
</mapper>
