<?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.microservices.pms.project.mapper.PmsIssueTransformationCommentRecordMapper">
    <resultMap id="BaseResultMap" type="com.microservices.pms.project.domain.PmsIssueTransformationCommentRecord">
        <id column="id" property="id" jdbcType="INTEGER" />
        <result column="gitlink_issue_id" property="gitlinkIssueId" jdbcType="INTEGER" />
        <result column="comment_type" property="commentType" jdbcType="VARCHAR" />
        <result column="has_comment" property="hasComment" jdbcType="BIT" />
    </resultMap>
    <delete id="deleteByGitlinkIssueIdAndCommentType">
        DELETE FROM pms_issue_transformation_comment_record
        WHERE comment_type = #{commentType} AND gitlink_issue_id = #{gitlinkIssueId}
    </delete>

    <insert id="insertSelective" parameterType="com.microservices.pms.project.domain.PmsIssueTransformationCommentRecord">
        INSERT INTO pms_issue_transformation_comment_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="gitlinkIssueId != null">
                gitlink_issue_id,
            </if>
            <if test="commentType != null">
                comment_type,
            </if>
            <if test="hasComment != null">
                has_comment,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="gitlinkIssueId != null">
                #{gitlinkIssueId},
            </if>
            <if test="commentType != null">
                #{commentType},
            </if>
            <if test="hasComment != null">
                #{hasComment},
            </if>
        </trim>
    </insert>

    <select id="selectByGitlinkIssueId"
            resultMap="BaseResultMap">
        select id,
               gitlink_issue_id,
               comment_type,
               has_comment
        from pms_issue_transformation_comment_record
        where gitlink_issue_id = #{gitlinkIssueId}
    </select>

</mapper>