<?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.corewing.app.mapper.FeedbackMapper">

    <!-- 结果映射 -->
    <resultMap id="VOResultMap" type="com.corewing.app.entity.Feedback">
        <id column="id" property="id"/>
        <result column="feedback_type" property="feedbackType"/>
        <result column="title" property="title"/>
        <result column="content" property="content"/>
        <result column="contact" property="contact"/>
        <result column="status" property="status"/>
        <result column="nick_name" property="nickName"/>
        <result column="username" property="username"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <!-- 基础查询SQL片段 -->
    <sql id="selectVOSql">
        select f.*,u.nick_name, u.username
            from app_feedback f
        left join app_user u on f.user_id = u.id
    </sql>

    <!-- 分页查询 -->
    <select id="page" resultMap="VOResultMap">
        <include refid="selectVOSql"/>
        <where>
            <if test="feedback.status != null">
                AND f.status = #{feedback.status}
            </if>
            <if test="feedback.title != null and feedback.title != ''">
                AND f.title like CONCAT('%', #{feedback.title}, '%')
            </if>
            <if test="feedback.feedbackType != null and feedback.feedbackType != ''">
                AND f.feedbackType like CONCAT('%', #{feedback.feedbackType}, '%')
            </if>
        </where>
    </select>

</mapper>
