pet/com.datang.pet.mapper/target/classes/mapperExtend/UserAttentionRecordMapperEx...

107 lines
5.3 KiB
XML

<?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.datang.pet.mapperExtend.UserAttentionRecordMapperExtend">
<resultMap id="GetFansListResultMap" type="com.datang.pet.vo.GetFansListResponse">
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="fans_id" jdbcType="VARCHAR" property="fansId" />
<result column="message_date" jdbcType="TIMESTAMP" property="messageDate" />
<result column="attention_date" jdbcType="TIMESTAMP" property="attentionDate" />
<result column="fans_nike_name" jdbcType="VARCHAR" property="fansNikeName" />
<result column="fans_head_portrait" jdbcType="VARCHAR" property="fansHeadPortrait" />
<result column="pet_quantity" jdbcType="INTEGER" property="petQuantity" />
<result column="fans_quantity" jdbcType="INTEGER" property="fansQuantity" />
<result column="concern_quantity" jdbcType="INTEGER" property="concernQuantity" />
</resultMap>
<resultMap id="getLikeListResultMap" type="com.datang.pet.vo.GetLikeListResponse">
<result column="message" jdbcType="VARCHAR" property="message" />
<result column="message_type" jdbcType="VARCHAR" property="messageType" />
<result column="talk_id" jdbcType="VARCHAR" property="talkId" />
<result column="message_date" jdbcType="TIMESTAMP" property="messageDate" />
<result column="nike_name" jdbcType="VARCHAR" property="nikeName" />
<result column="head_portrait" jdbcType="VARCHAR" property="headPortrait" />
<result column="talk_type" jdbcType="VARCHAR" property="talkType" />
<result column="src" jdbcType="VARCHAR" property="src" />
</resultMap>
<resultMap id="getCommentMessageListResultMap" type="com.datang.pet.vo.GetCommentMessageResponse">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="is_read" jdbcType="CHAR" property="isRead" />
<result column="message" jdbcType="VARCHAR" property="message" />
<result column="message_type" jdbcType="CHAR" property="messageType" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="model_id" jdbcType="VARCHAR" property="modelId" />
<result column="message_date" jdbcType="TIMESTAMP" property="messageDate" />
<result column="extent1" jdbcType="VARCHAR" property="extent1" />
<result column="extent2" jdbcType="VARCHAR" property="extent2" />
<result column="extent3" jdbcType="VARCHAR" property="extent3" />
<result column="extent4" jdbcType="VARCHAR" property="extent4" />
<result column="nike_name" jdbcType="VARCHAR" property="nikeName" />
<result column="head_portrait" jdbcType="VARCHAR" property="headPortrait" />
<result column="talk_type" jdbcType="VARCHAR" property="talkType" />
<result column="src" jdbcType="VARCHAR" property="src" />
</resultMap>
<select id="getFansList" resultMap="GetFansListResultMap">
SELECT m.*,u.nike_name AS fans_nike_name,u.head_portrait AS fans_head_portrait,
u.pet_quantity,u.fans_quantity,u.concern_quantity FROM
(
SELECT m.*,r.attention_date FROM
(
SELECT user_id,model_id AS fans_id,message_date FROM user_message
<where>
<if test="time!=null">
message_date &lt; #{time}
</if>
AND user_id=#{userId} AND message_type='3'
</where>
)AS m
LEFT JOIN user_attention_record AS r ON r.fans_id = m.user_id
)AS m LEFT JOIN user_info AS u ON m.fans_id=u.id
ORDER BY m.message_date DESC LIMIT 0,20
</select>
<select id="getLikeList" resultMap="getLikeListResultMap">
SELECT m.message,m.message_type,m.talk_id,m.message_date,m.nike_name,m.head_portrait,m.talk_type,r.src FROM
(
SELECT m.*,t.resource_id,t.talk_type FROM
(
SELECT m.message,m.message_type,m.talk_id,m.message_date,u.nike_name,u.head_portrait FROM
(
SELECT message,message_type,model_id AS talk_id,message_date,extent1 AS user_id FROM user_message
<where>
<if test="time!=null">
message_date &lt; #{time}
</if>
AND user_id=#{userId} AND message_type IN('2','5','8')
</where>
)AS m LEFT JOIN user_info AS u ON m.user_id = u.id
)AS m LEFT JOIN talk AS t ON m.talk_id=t.id
)AS m LEFT JOIN resource AS r ON m.resource_id = r.id WHERE r.sequence=1
ORDER BY message_date DESC LIMIT 0,20
</select>
<select id="getCommentMessageList" resultMap="getCommentMessageListResultMap">
SELECT m.*,r.src FROM
(
SELECT m.*,t.resource_id,t.talk_type FROM
(
SELECT m.*,u.nike_name,u.head_portrait FROM
(
SELECT * FROM user_message
<where>
<if test="time!=null">
message_date &lt; #{time}
</if>
AND user_id=#{userId} AND message_type IN('4','6','7')
</where>
)AS m LEFT JOIN user_info AS u ON m.extent1 = u.id
)AS m LEFT JOIN talk AS t ON m.extent2=t.id
)AS m LEFT JOIN resource AS r ON m.resource_id = r.id WHERE r.sequence=1
ORDER BY message_date DESC LIMIT 0,20
</select>
</mapper>