<?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.xxfc.platform.im.mapper.ImPraiseMapper">
  <resultMap id="BaseResultMap" type="com.xxfc.platform.im.entity.ImPraise">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="question_id" jdbcType="BIGINT" property="questionId" />
    <result column="user_id" jdbcType="BIGINT" property="userId" />
    <result column="time" jdbcType="BIGINT" property="time" />
    <result column="state" jdbcType="INTEGER" property="state" />
    <result column="visible" jdbcType="INTEGER" property="visible" />
    <result column="is_del" jdbcType="BIT" property="isDel" />
  </resultMap>

  <select id="selectByQuestionId" resultType="com.xxfc.platform.im.entity.ImPraise" parameterType="java.lang.Long">
        select * from im_praise
        where question_id = #{questionId} and is_del = 0 and visible = 1
        order by time DESC
  </select>

  <select id="selectByQuestionIdAndTime" resultType="com.xxfc.platform.im.entity.ImPraise" parameterType="com.xxfc.platform.im.dto.ImPraiseDto">
        select * from im_praise
        where question_id = #{questionId} and is_del = 0 and visible = 1
        and time between #{startTime} and #{endTime}
  </select>

  <select id="selectByUserIdAndQuestionId" resultType="com.xxfc.platform.im.entity.ImPraise" parameterType="java.util.Map">
      select * from im_praise
        where question_id = #{questionId} and is_del = 0 and visible = 1
        and user_id = #{userId}
  </select>
</mapper>