<?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.zm.order.tool.server.cy.WmOrderNewCommentsDao">

    <resultMap id="OrderMap" type="com.zm.order.tool.server.model.WmOrderNewComments">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="comment_no" jdbcType="VARCHAR" property="commentNo"/>
        <result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
        <result column="store_id" jdbcType="INTEGER" property="storeId"/>
        <result column="multi_store_id" jdbcType="INTEGER" property="multiStoreId"/>
        <result column="user_id" jdbcType="BIGINT" property="userId"/>
        <result column="content" jdbcType="VARCHAR" property="content"/>
        <result column="image" jdbcType="LONGVARCHAR" property="image"/>
        <result column="comment_level" jdbcType="TINYINT" property="commentLevel"/>
        <result column="reply_content" jdbcType="VARCHAR" property="replyContent"/>
        <result column="comment_status" jdbcType="TINYINT" property="commentStatus"/>
        <result column="stick_status" jdbcType="TINYINT" property="stickStatus"/>
        <result column="created_at" jdbcType="TIMESTAMP" property="createdAt"/>
        <result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt"/>
    </resultMap>

    <sql id="tb">
        wm_order_new_comments
    </sql>

    <sql id="cols_all">
        id,
        <include refid="cols_exclude_id"/>
    </sql>

    <sql id="cols_exclude_id">
		comment_no,
		order_no,
		store_id,
		multi_store_id,
		user_id,
		content,
		image,
		comment_level,
		reply_content,
		comment_status,
		stick_status,
		created_at,
		updated_at
    </sql>

    <select id="selectList" parameterType="map" resultMap="OrderMap">
        select
        <include refid="cols_all"/>
        from
        <include refid="tb"/>
        <where>
            <if test="storeId != null">
                store_id = #{storeId}
            </if>
            <if test="lastId != null">
                <![CDATA[ AND id < #{lastId} ]]>
            </if>
            <if test="orderNo != null">
                AND order_no = #{orderNo}
            </if>
        </where>
        order by id desc
        <if test="size != null">
            limit ${size}
        </if>
        <if test="start != null">
            limit ${start}, ${pageSize}
        </if>
    </select>

</mapper>