<?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.test.test.mapper.TestProjectPlanMapper">

  <insert id="insertTestProjectPlan" parameterType="testPlanAddQO">
    insert into test_project_plan
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="projectId != null and projectId != ''">project_id,</if>
      <if test="planId != null and planId != ''">plan_id,</if>
      <if test="createTime != null">create_time,</if>
      <if test="updateTime != null">update_time,</if>
      <if test="version != null">version,</if>
      <if test="delFlag != null and delFlag != ''">del_flag,</if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="projectId != null and projectId != ''">#{projectId},</if>
      <if test="planId != null and planId != ''">#{planId},</if>
      <if test="createTime != null">#{createTime},</if>
      <if test="updateTime != null">#{updateTime},</if>
      <if test="version != null">#{version},</if>
      <if test="delFlag != null and delFlag != ''">#{delFlag},</if>
    </trim>
  </insert>

  <select id="selectTestPlanProjectList" parameterType="Long" resultType="TestPlanProjectVo">
    SELECT
      tp.serial_number AS serialNumber,
      tp.name ,
      tp.outline,
      tp.detail,
      tp.priority,
      tp.estimated_time AS estimatedTime,
      tp.source,
      tp.type,
      tp.status,
      su.user_name AS manager,
      tp.create_time AS createTime,
      tp.version,
      tp.del_flag
    FROM test_project_plan tpp
    LEFT JOIN test_project tp ON tp.id = tpp.project_id
    LEFT JOIN sys_user su ON su.user_id = tp.manager
    WHERE tpp.plan_id = #{planId}
    AND tpp.del_flag = '0'
  </select>
</mapper>