优化查询条件
This commit is contained in:
parent
13e75b5b5e
commit
a116c6276c
@ -216,10 +216,8 @@ public class AuthApi {
|
||||
@OperLog(operModule = "获取关注目标作者的所有粉丝",operType = OperType.QUERY,operDesc = "获取关注目标作者的所有粉丝")
|
||||
public ResultBean getFollowMes(String authorId) {
|
||||
String myId = String.valueOf(request.getAttribute("authorId"));
|
||||
|
||||
//关注我的列表
|
||||
List<FollowVo> followMes = followService.selectFollowMeList(authorId,myId);
|
||||
|
||||
return ResultBean.success(followMes);
|
||||
}
|
||||
|
||||
@ -229,7 +227,6 @@ public class AuthApi {
|
||||
@OperLog(operModule = "getMyFollows",operType = OperType.QUERY,operDesc = "获取关注目标作者的所有粉丝")
|
||||
public ResultBean getMyFollows(String authorId) {
|
||||
String myId = String.valueOf(request.getAttribute("authorId"));
|
||||
|
||||
//关注我的列表
|
||||
List<FollowVo> myFollows = followService.selectMyFollowList(authorId,myId);
|
||||
return ResultBean.success(myFollows);
|
||||
|
@ -15,6 +15,7 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
@ -73,4 +74,8 @@ public class ChatVo {
|
||||
|
||||
private String fromAvatar;
|
||||
private String toAvatar;
|
||||
|
||||
private String authorId;
|
||||
private String authorName;
|
||||
private String authorAvatar;
|
||||
}
|
||||
|
@ -25,5 +25,6 @@ public interface ChatMapper extends BaseMapper<Chat> {
|
||||
IPage<ChatVo> selectChatPage(Page<ChatVo> page, @Param("chatDto") ChatDto chatDto);
|
||||
ChatVo selectChat(@Param("chatId") String chatId);
|
||||
List<ChatVo> selectChatDetail(@Param("chatDto") ChatDto chatDto);
|
||||
List<ChatVo> selectChatList(@Param("toId")String toId);
|
||||
//查询我的聊天记录列表 当我作为收发方都需要考虑
|
||||
List<ChatVo> selectChatList(@Param("authorId")String authorId);
|
||||
}
|
||||
|
@ -60,35 +60,36 @@
|
||||
</select>
|
||||
<select id="selectChatList" resultType="com.dd.admin.business.chat.domain.ChatVo"
|
||||
parameterType="java.lang.String">
|
||||
select * from (
|
||||
SELECT
|
||||
c.*
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
DISTINCT a.FROM_ID,
|
||||
a.CHAT_ID,
|
||||
a.FROM_NAME,
|
||||
a.TO_ID,
|
||||
a.TO_NAME,
|
||||
a.MESSAGE_TYPE,
|
||||
a.MESSAGE_STATUS,
|
||||
a.CONTENT,
|
||||
a.RESOURCE_URL,
|
||||
a.DELETED,
|
||||
a.CREATE_TIME,
|
||||
a.IP_ADDRESS,
|
||||
a.IP_REAL_ADDRESS,
|
||||
b.AVATAR_URL
|
||||
AS fromAvatar
|
||||
a.FROM_ID AS authorId,
|
||||
a.FROM_NAME AS authorName,
|
||||
b.AVATAR_URL AS authorAvatar,
|
||||
a.content,
|
||||
a.create_time
|
||||
FROM
|
||||
business_chat a
|
||||
LEFT JOIN business_author b ON a.FROM_ID = b.AUTHOR_ID
|
||||
LEFT JOIN
|
||||
business_author b ON a.FROM_ID = b.AUTHOR_ID
|
||||
WHERE
|
||||
a.TO_ID = #{toId}
|
||||
a.TO_ID = #{authorId}
|
||||
UNION ALL
|
||||
SELECT
|
||||
a.TO_ID AS authorId,
|
||||
a.TO_NAME AS authorName,
|
||||
b.AVATAR_URL AS authorAvatar,
|
||||
a.content,
|
||||
a.create_time
|
||||
FROM
|
||||
business_chat a
|
||||
LEFT JOIN
|
||||
business_author b ON a.TO_ID = b.AUTHOR_ID
|
||||
WHERE
|
||||
a.FROM_ID = #{authorId}
|
||||
ORDER BY
|
||||
a.create_time DESC
|
||||
) c
|
||||
GROUP BY
|
||||
c.TO_ID = #{toId}
|
||||
create_time DESC
|
||||
) a1
|
||||
GROUP BY a1.authorId
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -24,6 +24,6 @@ public interface ChatService extends IService<Chat> {
|
||||
ChatVo selectChat(String chatId);
|
||||
//-列表
|
||||
List<ChatVo> selectChatDetail(ChatDto chatDto);
|
||||
List<ChatVo> selectChatList(String toId);
|
||||
List<ChatVo> selectChatList(String authorId);
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class ChatServiceImpl extends ServiceImpl<ChatMapper, Chat> implements Ch
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ChatVo> selectChatList(String toId) {
|
||||
return baseMapper.selectChatList(toId);
|
||||
public List<ChatVo> selectChatList(String authorId) {
|
||||
return baseMapper.selectChatList(authorId);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user