Commit 246811fc by hweeeeeei

完成:获取会话详情接口

parent 3003b9e8
...@@ -15,9 +15,11 @@ import io.swagger.annotations.Api; ...@@ -15,9 +15,11 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
...@@ -37,6 +39,15 @@ public class ImConversationController extends BaseController { ...@@ -37,6 +39,15 @@ public class ImConversationController extends BaseController {
@Autowired @Autowired
private ImConversationService imConversationService; private ImConversationService imConversationService;
/**
* 获取会话表详情
*/
@GetMapping("/info")
@ApiOperation(value = "会话表详情")
public ApiResult<MyConversationListVo> getImConversation(@RequestParam("id") Long id) throws Exception {
MyConversationListVo imConversationQueryVo = imConversationService.getImConversationInfoById(id);
return ApiResult.ok(imConversationQueryVo);
}
/** /**
* 添加或修改会话名称 * 添加或修改会话名称
......
...@@ -48,6 +48,8 @@ public interface ImConversationMapper extends BaseMapper<ImConversation> { ...@@ -48,6 +48,8 @@ public interface ImConversationMapper extends BaseMapper<ImConversation> {
*/ */
List<MyConversationListVo> getMyImConversationListAndMsgCount(@Param("clientId") Long clientId); List<MyConversationListVo> getMyImConversationListAndMsgCount(@Param("clientId") Long clientId);
MyConversationListVo getImConversationAndMsgCountById(@Param("clientId") Long clientId, @Param("conversationId") Long conversationId);
/** /**
* 查询用户加入的所有会话 * 查询用户加入的所有会话
* *
......
...@@ -103,6 +103,11 @@ public interface ImConversationService extends BaseService<ImConversation> { ...@@ -103,6 +103,11 @@ public interface ImConversationService extends BaseService<ImConversation> {
*/ */
ImConversationQueryVo getImConversationById(Long id) throws Exception; ImConversationQueryVo getImConversationById(Long id) throws Exception;
MyConversationListVo getImConversationAndMsgCountById(Long clientId, Long conversationId);
MyConversationListVo getImConversationInfoById(Long id) throws Exception;
/** /**
* 获取分页对象 * 获取分页对象
* *
...@@ -110,7 +115,8 @@ public interface ImConversationService extends BaseService<ImConversation> { ...@@ -110,7 +115,8 @@ public interface ImConversationService extends BaseService<ImConversation> {
* @return * @return
* @throws Exception * @throws Exception
*/ */
Paging<ImConversationQueryVo> getImConversationPageList(ImConversationPageParam imConversationPageParam) throws Exception; Paging<ImConversationQueryVo> getImConversationPageList(ImConversationPageParam imConversationPageParam) throws
Exception;
/** /**
......
...@@ -786,6 +786,21 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -786,6 +786,21 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
return imConversationMapper.getImConversationById(id); return imConversationMapper.getImConversationById(id);
} }
@Override
public MyConversationListVo getImConversationAndMsgCountById(Long clientId, Long conversationId) {
return imConversationMapper.getImConversationAndMsgCountById(clientId, conversationId);
}
@Override
public MyConversationListVo getImConversationInfoById(Long id) throws Exception {
ImClient client = imClientService.getCurentClient();
return this.getImConversationAndMsgCountById(client.getId(), id);
}
@Override @Override
public Paging<ImConversationQueryVo> getImConversationPageList(ImConversationPageParam imConversationPageParam) throws Exception { public Paging<ImConversationQueryVo> getImConversationPageList(ImConversationPageParam imConversationPageParam) throws Exception {
Page<ImConversationQueryVo> page = new PageInfo<>(imConversationPageParam, OrderItem.desc(getLambdaColumn(ImConversation::getCreateTime))); Page<ImConversationQueryVo> page = new PageInfo<>(imConversationPageParam, OrderItem.desc(getLambdaColumn(ImConversation::getCreateTime)));
......
...@@ -24,20 +24,20 @@ ...@@ -24,20 +24,20 @@
SELECT imConversation.id, SELECT imConversation.id,
imConversation.create_time, imConversation.create_time,
imConversation.`name`, imConversation.`name`,
imConversation.attributes as attribute, imConversation.attributes as attribute,
imConversation.system, imConversation.system,
im_client.client_id AS creator, im_client.client_id AS creator,
(SELECT COUNT(im_inbox.id) (SELECT COUNT(im_inbox.id)
FROM im_inbox FROM im_inbox
WHERE im_inbox.fk_conversation_id = imConversation.id WHERE im_inbox.fk_conversation_id = imConversation.id
AND im_inbox.receiver = #{clientId} AND im_inbox.receiver = #{clientId}
AND im_inbox.read_msg_status = 0) AS msg_not_read_count, AND im_inbox.read_msg_status = 0) AS msg_not_read_count,
( (
SELECT GROUP_CONCAT(im_client.client_id) SELECT GROUP_CONCAT(im_client.client_id)
FROM im_conversation_members AS im_conversation_members FROM im_conversation_members AS im_conversation_members
INNER JOIN im_client AS im_client ON im_client.id = im_conversation_members.fk_client_id INNER JOIN im_client AS im_client ON im_client.id = im_conversation_members.fk_client_id
WHERE im_conversation_members.fk_conversation_id = imConversation.id WHERE im_conversation_members.fk_conversation_id = imConversation.id
) AS members, ) AS members,
(SELECT COUNT(*) (SELECT COUNT(*)
FROM im_conversation_members FROM im_conversation_members
WHERE fk_conversation_id = imConversation.id) AS memberCount WHERE fk_conversation_id = imConversation.id) AS memberCount
...@@ -109,5 +109,32 @@ ...@@ -109,5 +109,32 @@
WHERE im_conversation_members.fk_client_id = #{clientId1} WHERE im_conversation_members.fk_client_id = #{clientId1}
HAVING members_count = 2 LIMIT 1 HAVING members_count = 2 LIMIT 1
</select> </select>
<select id="getImConversationAndMsgCountById" resultType="com.wecloud.im.vo.MyConversationListVo">
SELECT imConversation.id,
imConversation.create_time,
imConversation.`name`,
imConversation.attributes AS attribute,
imConversation.system,
im_client.client_id AS creator,
(SELECT COUNT(im_inbox.id)
FROM im_inbox
WHERE im_inbox.fk_conversation_id = imConversation.id
AND im_inbox.receiver = #{clientId}
AND im_inbox.read_msg_status = 0) AS msg_not_read_count,
(
SELECT GROUP_CONCAT(im_client.client_id)
FROM im_conversation_members AS im_conversation_members
INNER JOIN im_client AS im_client ON im_client.id = im_conversation_members.fk_client_id
WHERE im_conversation_members.fk_conversation_id = imConversation.id
) AS members,
(SELECT COUNT(*)
FROM im_conversation_members
WHERE fk_conversation_id = imConversation.id) AS memberCount
FROM im_conversation AS imConversation
INNER JOIN im_client AS im_client ON im_client.id = imConversation.creator
WHERE imConversation.id = #{conversationId}
GROUP BY imConversation.id
</select>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment