<?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.railway.business.app.mapper.AppTaskMapper">

  <resultMap id="BaseResultMap" type="com.railway.business.app.domain.AppTask">
    <result column="id" property="id"/>
    <result column="apk_id" property="apkId"/>
    <result column="apk_version" property="apkVersion"/>
    <result column="task_type" property="taskType"/>
    <result column="user_id" property="userId"/>
    <result column="dept_id" property="deptId"/>
    <result column="enable_date" property="enableDate"/>
    <result column="del_flag" property="delFlag"/>
    <result column="create_by" property="createBy"/>
    <result column="create_time" property="createTime"/>
    <result column="update_by" property="updateBy"/>
    <result column="update_time" property="updateTime"/>
  </resultMap>

  <sql id="Base_Column_List">
    id,
    apk_id,
    apk_version,
    task_type,
    user_id,
    dept_id,
    enable_date,
    del_flag,
    create_by,
    create_time,
    update_by,
    update_time
  </sql>

  <insert id="insert" parameterType="com.railway.business.app.domain.AppTask">
    <selectKey keyProperty="id" order="BEFORE" resultType="String">
      select replace(uuid(), '-', '') from dual
    </selectKey>
    INSERT INTO app_task
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test='null != apkId'>
        apk_id,
      </if>
      <if test='null != apkVersion'>
        apk_version,
      </if>
      <if test='null != taskType'>
        task_type,
      </if>
      <if test='null != userId'>
        user_id,
      </if>
      <if test='null != deptId'>
        dept_id,
      </if>
      <if test='null != enableDate'>
        enable_date,
      </if>
      <if test='null != delFlag'>
        del_flag,
      </if>
      <if test='null != createBy'>
        create_by,
      </if>
      <if test='null != createTime'>
        create_time,
      </if>
      <if test='null != updateBy'>
        update_by,
      </if>
      <if test='null != updateTime'>
        update_time
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test='null != apkId'>
        #{apkId},
      </if>
      <if test='null != apkVersion'>
        #{apkVersion},
      </if>
      <if test='null != taskType'>
        #{taskType},
      </if>
      <if test='null != userId'>
        #{userId},
      </if>
      <if test='null != deptId'>
        #{deptId},
      </if>
      <if test='null != enableDate'>
        #{enableDate},
      </if>
      <if test='null != delFlag'>
        #{delFlag},
      </if>
      <if test='null != createBy'>
        #{createBy},
      </if>
      <if test='null != createTime'>
        #{createTime},
      </if>
      <if test='null != updateBy'>
        #{updateBy},
      </if>
      <if test='null != updateTime'>
        #{updateTime}
      </if>
    </trim>
  </insert>

  <delete id="delete">
    UPDATE app_task
    set del_flag='1'
    WHERE id = #{id}
  </delete>

  <update id="update" parameterType="com.railway.business.app.domain.AppTask">
    UPDATE app_task
    <set>
      <if test='null != apkId'>apk_id = #{apkId},</if>
      <if test='null != apkVersion'>apk_version = #{apkVersion},</if>
      <if test='null != taskType'>task_type = #{taskType},</if>
      <if test='null != userId'>user_id = #{userId},</if>
      <if test='null != deptId'>dept_id = #{deptId},</if>
      <if test='null != enableDate'>enable_date = #{enableDate},</if>
      <if test='null != delFlag'>del_flag = #{delFlag},</if>
      <if test='null != createBy'>create_by = #{createBy},</if>
      <if test='null != createTime'>create_time = #{createTime},</if>
      <if test='null != updateBy'>update_by = #{updateBy},</if>
      <if test='null != updateTime'>update_time = #{updateTime}</if>
    </set>
    WHERE id = #{id}
  </update>


  <select id="getInfo" resultMap="BaseResultMap">
    SELECT
    <include refid="Base_Column_List"/>
    FROM app_task
    WHERE del_flag='0' and id = #{id}

  </select>

  <select id="getList" resultMap="BaseResultMap">
    SELECT
    <include refid="Base_Column_List"/>
    FROM app_task
    <where>
      del_flag='0'
      <if test="apkId!=null and apkId!=''">
        and apk_id=#{apkId}
      </if>
      <if test="apkVersion!=null and apkVersion!=''">
        and apk_version=#{apkVersion}
      </if>
      <if test="taskType!=null and taskType!=''">
        and task_type=#{taskType}
      </if>
      <if test="userId!=null and userId!=''">
        and user_id=#{userId}
      </if>
      <if test="deptId!=null and deptId!=''">
        and dept_id=#{deptId}
      </if>
      <if test="enableDate!=null and enableDate!=''">
        and enable_date=#{enableDate}
      </if>
      <if test="delFlag!=null and delFlag!=''">
        and del_flag=#{delFlag}
      </if>
      <if test="createBy!=null and createBy!=''">
        and create_by=#{createBy}
      </if>
      <if test="createTime!=null and createTime!=''">
        and create_time=#{createTime}
      </if>
      <if test="updateBy!=null and updateBy!=''">
        and update_by=#{updateBy}
      </if>
      <if test="updateTime!=null and updateTime!=''">
        and update_time=#{updateTime}
      </if>
    </where>
  </select>

</mapper>