<?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.kmall.api.dao.ApiHelpIssueMapper">

    <resultMap type="com.kmall.api.entity.HelpIssueVo" id="helpIssueMap">
        <result property="id" column="id"/>
        <result property="typeId" column="type_id"/>
        <result property="question" column="question"/>
        <result property="answer" column="answer"/>
        <result property="sort" column="sort"/>
    </resultMap>

    <select id="queryObject" resultType="com.kmall.api.entity.HelpIssueVo">
		select
			`id`,
			`type_id`,
			`question`,
			`answer`,
			`sort`
		from mall_help_issue
		where id = #{id}
	</select>

    <select id="queryList" resultType="com.kmall.api.entity.HelpIssueVo">
        select
        `id`,
        `type_id`,
        `question`,
        `answer`,
        `sort`
        from mall_help_issue
        WHERE 1=1
        <if test="type_id != null and type_id != ''">
            AND type_id = #{type_id}
        </if>
        <choose>
            <when test="sidx != null and sidx.trim() != ''">
                order by ${sidx} ${order}
            </when>
            <otherwise>
                order by sort asc
            </otherwise>
        </choose>
        <if test="offset != null and limit != null">
            limit #{offset}, #{limit}
        </if>
    </select>

    <select id="queryTotal" resultType="int">
        select count(*) from mall_help_issue
        WHERE 1=1
        <if test="name != null and name.trim() != ''">
            AND name LIKE concat('%',#{name},'%')
        </if>
    </select>
</mapper>