<?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="org.springblade.business.mapper.UserOpinionFlowMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="userOpinionFlowResultMap" type="org.springblade.business.entity.UserOpinionFlow">
        <result column="id" property="id"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="user_opinion_id" property="userOpinionId"/>
        <result column="is_current" property="isCurrent"/>
        <result column="number" property="number"/>
        <result column="sort" property="sort"/>
        <result column="manage_user" property="manageUser"/>
        <result column="manage_user_name" property="manageUserName"/>
        <result column="manage_user_phone" property="manageUserPhone"/>
        <result column="evaluation" property="evaluation"/>
        <result column="reply_name" property="replyName"/>
        <result column="reply_content" property="replyContent"/>
        <result column="manage_time" property="manageTime"/>
    </resultMap>

    <select id="queryLeftFlowManageUser" resultMap="userOpinionFlowResultMap">
        select id,manage_user,manage_user_name,manage_user_phone from u_user_opinion_flow where is_deleted = 0 and number = #{number} and sort = 2 and user_opinion_id = #{userOpinionId}
    </select>

    <select id="queryCurrentUserOpinionFlowByUserOpinionId" resultMap="userOpinionFlowResultMap">
        select
            id,
            user_opinion_id,
            evaluation,
            manage_user,
            manage_user_name,
            manage_user_phone,
            sort,
            manage_time,
            reply_name,
            reply_content,
            is_current
        from u_user_opinion_flow where is_deleted = 0 and user_opinion_id = #{key} and number = #{number} order by sort ASC
    </select>

    <select id="selectIsSolveByUserOpinionKey" resultType="java.lang.Integer">
        select is_current from u_user_opinion_flow where is_deleted = 0 and user_opinion_id = #{key} order by number DESC,sort DESC limit 1
    </select>

    <select id="selectUserOpinionFlowPage" resultMap="userOpinionFlowResultMap">
        select * from u_user_opinion_flow where is_deleted = 0
    </select>

</mapper>
