<?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.TaskAttributionLogMapper">
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.TaskAttributionLog">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri May 14 13:44:50 CST 2021.
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="tid" jdbcType="INTEGER" property="tid" />
    <result column="aid" jdbcType="VARCHAR" property="aid" />
    <result column="receive_id" jdbcType="VARCHAR" property="receiveId" />
    <result column="remarks" jdbcType="VARCHAR" property="remarks" />
    <result column="status" jdbcType="INTEGER" property="status" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri May 14 13:44:50 CST 2021.
    -->
    id, tid, aid, receive_id, remarks, `status`, create_time
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri May 14 13:44:50 CST 2021.
    -->
    select 
    <include refid="Base_Column_List" />
    from task_attribution_log
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri May 14 13:44:50 CST 2021.
    -->
    delete from task_attribution_log
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.TaskAttributionLog">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri May 14 13:44:50 CST 2021.
    -->
    insert into task_attribution_log (id, tid, aid, 
      receive_id, remarks, `status`, 
      create_time)
    values (#{id,jdbcType=INTEGER}, #{tid,jdbcType=INTEGER}, #{aid,jdbcType=VARCHAR}, 
      #{receiveId,jdbcType=VARCHAR}, #{remarks,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, 
      #{createTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.TaskAttributionLog">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri May 14 13:44:50 CST 2021.
    -->
    insert into task_attribution_log
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="tid != null">
        tid,
      </if>
      <if test="aid != null">
        aid,
      </if>
      <if test="receiveId != null">
        receive_id,
      </if>
      <if test="remarks != null">
        remarks,
      </if>
      <if test="status != null">
        `status`,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="tid != null">
        #{tid,jdbcType=INTEGER},
      </if>
      <if test="aid != null">
        #{aid,jdbcType=VARCHAR},
      </if>
      <if test="receiveId != null">
        #{receiveId,jdbcType=VARCHAR},
      </if>
      <if test="remarks != null">
        #{remarks,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        #{status,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.TaskAttributionLog">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri May 14 13:44:50 CST 2021.
    -->
    update task_attribution_log
    <set>
      <if test="tid != null">
        tid = #{tid,jdbcType=INTEGER},
      </if>
      <if test="aid != null">
        aid = #{aid,jdbcType=VARCHAR},
      </if>
      <if test="receiveId != null">
        receive_id = #{receiveId,jdbcType=VARCHAR},
      </if>
      <if test="remarks != null">
        remarks = #{remarks,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        `status` = #{status,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.TaskAttributionLog">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri May 14 13:44:50 CST 2021.
    -->
    update task_attribution_log
    set tid = #{tid,jdbcType=INTEGER},
      aid = #{aid,jdbcType=VARCHAR},
      receive_id = #{receiveId,jdbcType=VARCHAR},
      remarks = #{remarks,jdbcType=VARCHAR},
      `status` = #{status,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
  
  <select id="selectByTid" resultType="com.goafanti.order.bo.taskAttributionLogBo">
  select a.id,a.tid,b.name aName ,c.name receiveName,a.status ,a.remarks,date_format(a.create_time ,'%Y-%m-%d %H:%i:%S') createTimes 
   	from task_attribution_log a left join admin b on a.aid =b.id
   	left join admin c on a.receive_id =c.id  
   	where tid= #{tid} order by a.create_time 
  </select>
  <insert id="insertList">
  INSERT INTO task_attribution_log
(tid, aid, receive_id, status, create_time)
select id,task_receiver ,#{transferId},5, #{date} from t_order_task where task_receiver = #{aid};
  </insert>
</mapper>