<?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.th.demo.mapping.maint.TransportMapper" >
  <resultMap id="BaseResultMap" type="com.th.demo.model.maint.Transport" >
    <id column="id" property="id" jdbcType="VARCHAR" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="cancel_flag" property="cancelFlag" jdbcType="VARCHAR" />
    <result column="belong_id" property="belongId" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, name, cancel_flag, belong_id
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from t_maint_transport
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <update id="deleteByPrimaryKey" parameterType="java.lang.String" >
    update t_maint_transport set cancel_flag = '9'
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <insert id="insert" parameterType="com.th.demo.model.maint.Transport" >

    <selectKey keyProperty="id" order="BEFORE" resultType="java.lang.String">
      SELECT  REPLACE(UUID(),'-','') as id from dual
    </selectKey>


    insert into t_maint_transport (id, name, cancel_flag, belong_id)
    values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
      #{cancelFlag,jdbcType=VARCHAR}, #{belongId,jdbcType=VARCHAR})
  </insert>

  <update id="updateByPrimaryKey" parameterType="com.th.demo.model.maint.Customer" >
    update t_maint_transport
    set name = #{name,jdbcType=VARCHAR}
    where id = #{id,jdbcType=VARCHAR}
  </update>


  <select id="selectByName" resultMap="BaseResultMap" >
    select *
    from t_maint_transport
    where name like concat('%',#{param1,jdbcType=VARCHAR},'%')
    and   belong_id = #{param2,jdbcType=VARCHAR}
    and ifnull(cancel_flag,'0') = '0'
  </select>


</mapper>