Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wecloud_im_server
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewei
wecloud_im_server
Commits
df551751
Commit
df551751
authored
May 19, 2021
by
giaogiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
查询用户加入的所有会话 与每个会话的未读条数 成员
parent
03595a6f
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
184 additions
and
12 deletions
+184
-12
bootstrap/src/test/java/io/geekidea/springbootplus/test/ImConversationTest.java
+27
-0
common/src/main/java/com/wecloud/im/controller/ImConversationController.java
+13
-0
common/src/main/java/com/wecloud/im/mapper/ImConversationMapper.java
+10
-0
common/src/main/java/com/wecloud/im/service/ImClientService.java
+3
-0
common/src/main/java/com/wecloud/im/service/ImConversationService.java
+12
-0
common/src/main/java/com/wecloud/im/service/impl/ImClientServiceImpl.java
+23
-0
common/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
+12
-0
common/src/main/java/com/wecloud/im/tillo/app_ws/strategy/concrete/ImConcreteReceiveStrategy.java
+0
-1
common/src/main/java/com/wecloud/im/vo/MyConversationListVo.java
+10
-11
common/src/main/java/com/wecloud/im/vo/MyConversationMembersVo.java
+36
-0
common/src/main/resources/mapper/ImConversationMapper.xml
+24
-0
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/util/JwtUtil.java
+14
-0
No files found.
bootstrap/src/test/java/io/geekidea/springbootplus/test/ImConversationTest.java
0 → 100644
View file @
df551751
package
io
.
geekidea
.
springbootplus
.
test
;
import
com.wecloud.im.mapper.ImConversationMapper
;
import
com.wecloud.im.vo.MyConversationListVo
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
java.util.List
;
/**
* imConversation 单元测试
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
public
class
ImConversationTest
{
@Autowired
private
ImConversationMapper
imConversationMapper
;
@Test
public
void
listConversation
()
{
List
<
MyConversationListVo
>
myImConversationList
=
imConversationMapper
.
getMyImConversationList
(
1394579719625773056L
);
}
}
common/src/main/java/com/wecloud/im/controller/ImConversationController.java
View file @
df551751
...
...
@@ -3,6 +3,7 @@ package com.wecloud.im.controller;
import
com.wecloud.im.entity.ImConversation
;
import
com.wecloud.im.param.add.ImConversationCreate
;
import
com.wecloud.im.service.ImConversationService
;
import
com.wecloud.im.vo.MyConversationListVo
;
import
io.geekidea.springbootplus.framework.common.api.ApiResult
;
import
io.geekidea.springbootplus.framework.common.controller.BaseController
;
import
io.geekidea.springbootplus.framework.log.annotation.OperationLog
;
...
...
@@ -16,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
/**
* 会话表 控制器
*
...
...
@@ -42,6 +45,16 @@ public class ImConversationController extends BaseController {
return
imConversation
;
}
/**
* 查询用户加入的所有会话 与每个会话的未读条数 成员
*/
@PostMapping
(
"/getList"
)
@ApiOperation
(
value
=
"查询用户加入的所有会话 与每个会话的未读条数 成员"
)
public
ApiResult
<
List
<
MyConversationListVo
>>
getImConversationPageList
()
throws
Exception
{
List
<
MyConversationListVo
>
conversationList
=
imConversationService
.
getMyImConversationList
();
return
ApiResult
.
ok
(
conversationList
);
}
// /**
// * 添加会话表
// */
...
...
common/src/main/java/com/wecloud/im/mapper/ImConversationMapper.java
View file @
df551751
...
...
@@ -6,10 +6,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.wecloud.im.entity.ImConversation
;
import
com.wecloud.im.param.ImConversationPageParam
;
import
com.wecloud.im.param.ImConversationQueryVo
;
import
com.wecloud.im.vo.MyConversationListVo
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Repository
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* 会话表 Mapper 接口
...
...
@@ -37,4 +39,12 @@ public interface ImConversationMapper extends BaseMapper<ImConversation> {
*/
IPage
<
ImConversationQueryVo
>
getImConversationPageList
(
@Param
(
"page"
)
Page
page
,
@Param
(
"param"
)
ImConversationPageParam
imConversationPageParam
);
/**
* 查询用户加入的所有会话 与每个会话的未读条数 成员
*
* @param clientId
* @return
*/
List
<
MyConversationListVo
>
getMyImConversationList
(
@Param
(
"clientId"
)
Long
clientId
);
}
common/src/main/java/com/wecloud/im/service/ImClientService.java
View file @
df551751
...
...
@@ -59,4 +59,7 @@ public interface ImClientService extends BaseService<ImClient> {
*/
Paging
<
ImClientQueryVo
>
getImClientPageList
(
ImClientPageParam
imClientPageParam
)
throws
Exception
;
ImClient
getClient
();
}
common/src/main/java/com/wecloud/im/service/ImConversationService.java
View file @
df551751
...
...
@@ -4,10 +4,13 @@ import com.wecloud.im.entity.ImConversation;
import
com.wecloud.im.param.ImConversationPageParam
;
import
com.wecloud.im.param.ImConversationQueryVo
;
import
com.wecloud.im.param.add.ImConversationCreate
;
import
com.wecloud.im.vo.MyConversationListVo
;
import
io.geekidea.springbootplus.framework.common.api.ApiResult
;
import
io.geekidea.springbootplus.framework.common.service.BaseService
;
import
io.geekidea.springbootplus.framework.core.pagination.Paging
;
import
java.util.List
;
/**
* 会话表 服务类
*
...
...
@@ -64,4 +67,13 @@ public interface ImConversationService extends BaseService<ImConversation> {
*/
Paging
<
ImConversationQueryVo
>
getImConversationPageList
(
ImConversationPageParam
imConversationPageParam
)
throws
Exception
;
/**
* 查询用户加入的所有会话 与每个会话的未读条数
*
* @return
* @throws Exception
*/
List
<
MyConversationListVo
>
getMyImConversationList
()
throws
Exception
;
}
common/src/main/java/com/wecloud/im/service/impl/ImClientServiceImpl.java
View file @
df551751
package
com
.
wecloud
.
im
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.OrderItem
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.entity.ImClient
;
import
com.wecloud.im.mapper.ImClientMapper
;
import
com.wecloud.im.param.ImClientPageParam
;
import
com.wecloud.im.param.ImClientQueryVo
;
import
com.wecloud.im.service.ImApplicationService
;
import
com.wecloud.im.service.ImClientService
;
import
io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl
;
import
io.geekidea.springbootplus.framework.core.pagination.PageInfo
;
import
io.geekidea.springbootplus.framework.core.pagination.Paging
;
import
io.geekidea.springbootplus.framework.shiro.jwt.JwtToken
;
import
io.geekidea.springbootplus.framework.shiro.util.JwtUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -28,6 +33,8 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
@Autowired
private
ImClientMapper
imClientMapper
;
@Autowired
private
ImApplicationService
imApplicationService
;
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
...
...
@@ -59,4 +66,20 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
return
new
Paging
<
ImClientQueryVo
>(
iPage
);
}
@Override
public
ImClient
getClient
()
{
JwtToken
curentJwtToken
=
JwtUtil
.
getCurentJwtToken
();
// 根据appKey查询appid
ImApplication
imApplication
=
imApplicationService
.
getOne
(
new
QueryWrapper
<
ImApplication
>().
lambda
().
eq
(
ImApplication:
:
getAppKey
,
curentJwtToken
.
getAppKey
())
);
ImClient
client
=
this
.
getOne
(
new
QueryWrapper
<
ImClient
>().
lambda
()
.
eq
(
ImClient:
:
getFkAppid
,
imApplication
.
getId
())
.
eq
(
ImClient:
:
getClientId
,
curentJwtToken
.
getClientId
()));
return
client
;
}
}
common/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
View file @
df551751
...
...
@@ -16,6 +16,7 @@ import com.wecloud.im.service.ImApplicationService;
import
com.wecloud.im.service.ImClientService
;
import
com.wecloud.im.service.ImConversationMembersService
;
import
com.wecloud.im.service.ImConversationService
;
import
com.wecloud.im.vo.MyConversationListVo
;
import
io.geekidea.springbootplus.framework.common.api.ApiResult
;
import
io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl
;
import
io.geekidea.springbootplus.framework.core.pagination.PageInfo
;
...
...
@@ -29,6 +30,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Date
;
import
java.util.List
;
/**
* 会话表 服务实现类
...
...
@@ -48,6 +50,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
@Autowired
private
ImConversationService
imConversationService
;
@Autowired
private
ImClientService
imClientService
;
...
...
@@ -142,4 +145,13 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
return
new
Paging
<
ImConversationQueryVo
>(
iPage
);
}
@Override
public
List
<
MyConversationListVo
>
getMyImConversationList
()
throws
Exception
{
ImClient
client
=
imClientService
.
getClient
();
return
imConversationMapper
.
getMyImConversationList
(
client
.
getId
());
}
}
common/src/main/java/com/wecloud/im/tillo/app_ws/strategy/concrete/ImConcreteReceiveStrategy.java
View file @
df551751
...
...
@@ -53,7 +53,6 @@ public class ImConcreteReceiveStrategy extends AbstractReceiveStrategy {
@Autowired
private
ImApplicationService
imApplicationService
;
@Autowired
private
ImConversationMembersService
imConversationMembersService
;
...
...
common/src/main/java/com/wecloud/im/vo/MyConversationListVo.java
View file @
df551751
...
...
@@ -28,24 +28,22 @@ public class MyConversationListVo implements Serializable {
@ApiModelProperty
(
"创建时间"
)
private
Date
createTime
;
@ApiModelProperty
(
"修改时间"
)
private
Date
updateTime
;
@ApiModelProperty
(
"对话中最后一条消息的发送或接收时间"
)
private
Date
lastMessage
;
@ApiModelProperty
(
"应用appid"
)
private
Long
fkAppid
;
@ApiModelProperty
(
"创建者客户端id"
)
private
Lo
ng
creator
;
private
Stri
ng
creator
;
@ApiModelProperty
(
"可选 对话的名字,可为群组命名。"
)
private
String
name
;
@ApiModelProperty
(
"可选 自定义属性,供开发者扩展使用。"
)
private
String
attributes
;
private
Object
attributes
;
@ApiModelProperty
(
"可选 对话类型标志,是否是系统对话,后面会说明。"
)
private
Boolean
system
;
@ApiModelProperty
(
"未读消息条数"
)
private
Long
msgNotReadCount
;
@ApiModelProperty
(
"成员"
)
private
String
members
;
}
\ No newline at end of file
common/src/main/java/com/wecloud/im/vo/MyConversationMembersVo.java
0 → 100644
View file @
df551751
package
com
.
wecloud
.
im
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* <pre>
* 会话表 查询结果对象
* </pre>
*
* @author wei
* @date 2021-05-07
*/
@Data
@Accessors
(
chain
=
true
)
@ApiModel
(
value
=
"MyConversationMemberVo"
)
public
class
MyConversationMembersVo
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
"加入时间"
)
private
Date
joinTime
;
@ApiModelProperty
(
"客户端id"
)
private
String
clientId
;
@ApiModelProperty
(
"名字"
)
private
String
name
;
}
\ No newline at end of file
common/src/main/resources/mapper/ImConversationMapper.xml
View file @
df551751
...
...
@@ -20,5 +20,29 @@
<include
refid=
"Base_Column_List"
/>
from im_conversation
</select>
<select
id=
"getMyImConversationList"
resultType=
"com.wecloud.im.vo.MyConversationListVo"
>
SELECT imConversation.id,
imConversation.create_time,
imConversation.`name`,
imConversation.attributes,
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}) 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
FROM im_conversation_members AS imConversationMembers
INNER JOIN im_conversation AS imConversation
ON imConversation.id = imConversationMembers.fk_conversation_id
INNER JOIN im_client AS im_client ON im_client.id = imConversation.creator
WHERE imConversationMembers.fk_client_id = #{clientId}
GROUP BY imConversation.id
</select>
</mapper>
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/util/JwtUtil.java
View file @
df551751
...
...
@@ -23,10 +23,12 @@ import com.auth0.jwt.algorithms.Algorithm;
import
com.auth0.jwt.interfaces.DecodedJWT
;
import
io.geekidea.springbootplus.config.constant.CommonConstant
;
import
io.geekidea.springbootplus.config.properties.JwtProperties
;
import
io.geekidea.springbootplus.framework.shiro.jwt.JwtToken
;
import
io.geekidea.springbootplus.framework.util.UUIDUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.time.DateUtils
;
import
org.apache.shiro.SecurityUtils
;
import
org.springframework.stereotype.Component
;
import
java.time.Duration
;
...
...
@@ -51,6 +53,18 @@ public class JwtUtil {
log
.
info
(
JSON
.
toJSONString
(
JwtUtil
.
jwtProperties
));
}
/**
* 获取当前JwtToken
*
* @return
*/
public
static
JwtToken
getCurentJwtToken
()
{
JwtToken
jwtToken
=
(
JwtToken
)
SecurityUtils
.
getSubject
().
getPrincipal
();
return
jwtToken
;
}
/**
* 生成JWT Token
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment