<?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.TOrderAssistMapper">
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.TOrderAssist">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
    <result column="aid" jdbcType="VARCHAR" property="aid" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  </resultMap>
  <sql id="Base_Column_List">
    id, order_no, aid, create_time
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from t_order_assist
    where id = #{id,jdbcType=INTEGER}
  </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from t_order_assist
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TOrderAssist" useGeneratedKeys="true">
    insert into t_order_assist (order_no, aid, create_time
      )
    values (#{orderNo,jdbcType=VARCHAR}, #{aid,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TOrderAssist" useGeneratedKeys="true">
    insert into t_order_assist
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="orderNo != null">
        order_no,
      </if>
      <if test="aid != null">
        aid,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="orderNo != null">
        #{orderNo,jdbcType=VARCHAR},
      </if>
      <if test="aid != null">
        #{aid,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.TOrderAssist">
    update t_order_assist
    <set>
      <if test="orderNo != null">
        order_no = #{orderNo,jdbcType=VARCHAR},
      </if>
      <if test="aid != null">
        aid = #{aid,jdbcType=VARCHAR},
      </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.TOrderAssist">
    update t_order_assist
    set order_no = #{orderNo,jdbcType=VARCHAR},
      aid = #{aid,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="assistList" resultType="com.goafanti.order.bo.assistListBo">
    select a.id,a.order_no orderNo,a.aid,a.create_time createTime,b.name,
           date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimes
    from t_order_assist a left join admin b on a.aid=b.id
    where order_no = #{orderNo}
    order by a.id
  </select>
</mapper>