<?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.TestReportMapper">
  <insert id="addTestReport" parameterType="TestReport" useGeneratedKeys="true" keyProperty="id">
    insert into test_report
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="serialNumber != null and serialNumber != ''">serial_number,</if>
      <if test="name != null and name != ''">name,</if>
      <if test="result != null and result != ''">result,</if>
      <if test="status != null and status != ''">status,</if>
      <if test="report != null">report,</if>
      <if test="updateBy != null and updateBy != ''">update_by,</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="serialNumber != null and serialNumber != ''">#{serialNumber},</if>
      <if test="name != null and name != ''">#{name},</if>
      <if test="result != null and result != ''">#{result},</if>
      <if test="status != null and status != ''">#{status},</if>
      <if test="report != null">#{report},</if>
      <if test="updateBy != null and updateBy != ''">#{updateBy},</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="selectTestReportList" parameterType="Long" resultType="TestReportVo">
    SELECT
      tr.name AS name,
      tr.result AS result,
      tr.status AS status,
      tpr.type AS type,
      tr.create_time AS createTime,
      tr.update_by AS updateBy
    FROM test_plan_report tpr
    LEFT JOIN test_report tr ON tr.id = tpr.report_id
    WHERE tpr.plan_id = #{planId}
      AND tpr.del_flag = '0'
  </select>
</mapper>