<?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.ichangzuo.system.mapper.QnAMapper">
    <!-- 提现分页列表 -->
    <select id="listByType" resultType="com.ichangzuo.system.model.bo.QnABO">
        SELECT
            help_id,
            question,
            answer
        FROM
            mc_help_qa
        WHERE
            help_type_id like CONCAT('%',#{typeId},'%') AND state=6
    </select>

    <!-- 用户分页列表 -->
    <select id="listPage" resultType="com.ichangzuo.system.model.bo.QnAFullBO">
        SELECT
            h.*,
            u.user_name,
            u.nickname
        FROM mc_help_qa h
        LEFT JOIN mc_user u ON h.user_id = u.user_id
        <where>
            <if test="queryParams.typeIds!=null and queryParams.typeIds.trim() neq ''" >
                AND
                <foreach collection="queryParams.typeIds.split(',')" item="id" separator="AND" open="(" close=")" >
                    FIND_IN_SET(#{id}, help_type_id)
                </foreach>
            </if>
            <if test="queryParams.userId!=null">
                AND h.user_id = #{queryParams.userId}
            </if>
            <if test="queryParams.state!=null">
                AND h.state = #{queryParams.state}
            </if>
        </where>
        ORDER BY help_id DESC
    </select>
</mapper>
