<?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.hc.business.mapper.ZccmUserAdviseMapper">

    <resultMap type="zccmuserAdvise" id="UserAdviseMap">
        <result property="adviceId" column="advice_id" jdbcType="INTEGER"/>
        <result property="userId" column="user_id" jdbcType="INTEGER"/>
        <result property="email" column="email" jdbcType="VARCHAR"/>
        <result property="title" column="title" jdbcType="VARCHAR"/>
        <result property="advise" column="advise" jdbcType="VARCHAR"/>
        <result property="createTime" column="create_time" jdbcType="BIGINT"/>
        <result property="adviceLogo" column="advice_logo" jdbcType="VARCHAR"/>
        <result property="adviceType" column="advice_type" jdbcType="INTEGER"/>
        <result property="isReply" column="is_reply" jdbcType="INTEGER"/>
    </resultMap>

    <sql id="Base_Column_List">
        advice_id,
           user_id,
           email,
           title,
           advise,
           advice_logo,
           advice_type,
           is_reply,
           create_time
    </sql>

    <select id="queryAllByUserId" resultMap="UserAdviseMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM zccm_user_advise
        WHERE user_id = #{userId}
        ORDER BY advice_id DESC
    </select>

    <select id="queryAllByAdviceType" resultMap="UserAdviseMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM zccm_user_advise
        WHERE advice_type = #{adviceType}
        ORDER BY advice_id DESC
    </select>

    <select id="queryAll" resultMap="UserAdviseMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM zccm_user_advise
        ORDER BY advice_id DESC
    </select>

</mapper>