<?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.TDunLogMapper">
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.TDunLog">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Nov 20 11:50:41 CST 2018.
    -->
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="dun_id" jdbcType="VARCHAR" property="dunId" />
    <result column="dum_by" jdbcType="VARCHAR" property="dumBy" />
    <result column="dum_time" jdbcType="DATE" property="dumTime" />
    <result column="remarks" jdbcType="VARCHAR" property="remarks" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Nov 20 11:50:41 CST 2018.
    -->
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Nov 20 11:50:41 CST 2018.
    -->
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Nov 20 11:50:41 CST 2018.
    -->
    id, dun_id, dum_by, dum_time, remarks
  </sql>
  <select id="selectByExample" parameterType="com.goafanti.common.model.TDunLogExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Nov 20 11:50:41 CST 2018.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from t_dun_log
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Nov 20 11:50:41 CST 2018.
    -->
    select 
    <include refid="Base_Column_List" />
    from t_dun_log
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Nov 20 11:50:41 CST 2018.
    -->
    delete from t_dun_log
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.goafanti.common.model.TDunLogExample">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Nov 20 11:50:41 CST 2018.
    -->
    delete from t_dun_log
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.TDunLog">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Nov 20 11:50:41 CST 2018.
    -->
    insert into t_dun_log (id, dun_id, dum_by, 
      dum_time, remarks)
    values (#{id,jdbcType=VARCHAR}, #{dunId,jdbcType=VARCHAR}, #{dumBy,jdbcType=VARCHAR}, 
      #{dumTime,jdbcType=DATE}, #{remarks,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.TDunLog">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Nov 20 11:50:41 CST 2018.
    -->
    insert into t_dun_log
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="dunId != null">
        dun_id,
      </if>
      <if test="dumBy != null">
        dum_by,
      </if>
      <if test="dumTime != null">
        dum_time,
      </if>
      <if test="remarks != null">
        remarks,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="dunId != null">
        #{dunId,jdbcType=VARCHAR},
      </if>
      <if test="dumBy != null">
        #{dumBy,jdbcType=VARCHAR},
      </if>
      <if test="dumTime != null">
        #{dumTime,jdbcType=DATE},
      </if>
      <if test="remarks != null">
        #{remarks,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.goafanti.common.model.TDunLogExample" resultType="java.lang.Long">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Nov 20 11:50:41 CST 2018.
    -->
    select count(*) from t_dun_log
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Nov 20 11:50:41 CST 2018.
    -->
    update t_dun_log
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.dunId != null">
        dun_id = #{record.dunId,jdbcType=VARCHAR},
      </if>
      <if test="record.dumBy != null">
        dum_by = #{record.dumBy,jdbcType=VARCHAR},
      </if>
      <if test="record.dumTime != null">
        dum_time = #{record.dumTime,jdbcType=DATE},
      </if>
      <if test="record.remarks != null">
        remarks = #{record.remarks,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Nov 20 11:50:41 CST 2018.
    -->
    update t_dun_log
    set id = #{record.id,jdbcType=VARCHAR},
      dun_id = #{record.dunId,jdbcType=VARCHAR},
      dum_by = #{record.dumBy,jdbcType=VARCHAR},
      dum_time = #{record.dumTime,jdbcType=DATE},
      remarks = #{record.remarks,jdbcType=VARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.TDunLog">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Nov 20 11:50:41 CST 2018.
    -->
    update t_dun_log
    <set>
      <if test="dunId != null">
        dun_id = #{dunId,jdbcType=VARCHAR},
      </if>
      <if test="dumBy != null">
        dum_by = #{dumBy,jdbcType=VARCHAR},
      </if>
      <if test="dumTime != null">
        dum_time = #{dumTime,jdbcType=DATE},
      </if>
      <if test="remarks != null">
        remarks = #{remarks,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.TDunLog">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Nov 20 11:50:41 CST 2018.
    -->
    update t_dun_log
    set dun_id = #{dunId,jdbcType=VARCHAR},
      dum_by = #{dumBy,jdbcType=VARCHAR},
      dum_time = #{dumTime,jdbcType=DATE},
      remarks = #{remarks,jdbcType=VARCHAR}
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <select id="selectByDunId" parameterType="java.lang.String" resultType="com.goafanti.order.bo.TDunLogListBo">
   select 
    a.id, a.dun_id as dunId, b.name as dumBy, a.dum_time as dumTime, a.remarks
    from t_dun_log a left join admin b on a.dum_by=b.id
    where dun_id = #{dunId,jdbcType=VARCHAR}
  </select>
</mapper>