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
c9c74580
Commit
c9c74580
authored
Jul 30, 2021
by
giaogiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增单向删除(隐藏)会话: 云端聊天记录不删除;假设有A和B两个用户,A删会话,B还能发; 如果B发了消息,A这边要重新把会话显示出来,并能显示之前的聊天记录;
优化查询会话列表 不展示隐藏会话
parent
c25827f8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
55 additions
and
107 deletions
+55
-107
README-zh.md
+10
-99
common/src/main/java/com/wecloud/im/controller/ImConversationController.java
+11
-0
common/src/main/java/com/wecloud/im/entity/ImApplication.java
+3
-0
common/src/main/java/com/wecloud/im/entity/ImConversationMembers.java
+3
-0
common/src/main/java/com/wecloud/im/service/ImConversationService.java
+1
-1
common/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
+21
-2
common/src/main/resources/mapper/ImApplicationMapper.xml
+1
-1
common/src/main/resources/mapper/ImConversationMapper.xml
+5
-4
No files found.
README-zh.md
View file @
c9c74580
...
...
@@ -7,7 +7,7 @@
## 项目结构
```
text
└── spring-boot-plus
├── admin SpringBootAdmin Server服务监控模块
├── admin
(暂时没用)
SpringBootAdmin Server服务监控模块
├── bootstrap spring-boot-plus 启动模块
├── config 配置模块
├── distribution 打包模块
...
...
@@ -15,124 +15,36 @@
├── framework 框架核心模块
├── generator 代码生成模块
├── scheduled 任务调度模块
└── api-system 平台管理系统api模块
└── api-app app的api模块
└── api-merchant 商家api服务模块
└── common 通用模块(包含service dao mapper)
└── common 通用模块(包含Api service dao mapper)
```
McPlainTypeController
---
## 安装中间件
redis
(必须本地开启)
##redis6
(必须本地开启)
mysql5.7 (你本地可以不开,在本地配置中已经连上了测试环境)
### docker安装redis
docker run -p 6379:6379 -d --restart=always --name redis6 -v $PWD/dockerData/redis6:/data redis:6 --appendonly yes
##mysql5.7(如果本地不开,可以连上测试环境)
### docker 安装mysql
docker run -p 3306:3306 --name mysql57 -v $PWD/dockerData/mysql57/data:/var/lib/mysql --restart always -e MYSQL_ROOT_PASSWORD=aillo123 -d mysql:5.7
---
## 开发规范
### 关于模块
api-system api-app api-merchant
三个模块是各自针对不同后端模块的api接口,都包含common模块的依赖,
你只能在其中开发模块属于自己的controller和service,
并且可以实现当前模块的service业务逻辑层,但对数据库操作,请一定调用common模块的service,不要在api-XXX的模块下写数据库的操作.
如果业务流程没有很复杂, 在controller类中你可以直接调用common模块的service
### 例如:
#### 商户注册
在api-merchant模块中的controller包下新建一个Register控制器,
模块下每个控制器url路径必须要加上前缀
```"/merchant/"```
,这样为了方便权限控制
像这样:
```
@RequestMapping("/merchant/register/")
```
注册业务逻辑要调用common模块中的service去操作
#### app注册
在api-app模块中的controller包下新建一个Register控制器,
模块下每个控制器url路径必须要加上前缀
```"/app/"```
,这样为了方便权限控制
像这样:
```
@RequestMapping("/app/register/")
```
注册业务逻辑要调用common模块中的service去操作
---
### 数据库规范
-
主键id使用
自增
ID
-
主键id使用
雪花算法
ID
-
时间类型使用时间戳timestamp
---
### 分支管理
> 请看此文章:https://www.jianshu.com/p/780aa5c4c7fe
---
##
swagger
文档
##
api
文档
http://127.0.0.1:8889/api/doc.html#/home
左上角可以切换到不同的模块
---
## 配置接口权限
*例如:*
```
/**
* 获取获取菜单树形列表
*/
@PostMapping("/getAllMenuTree")
@RequiresPermissions("sys:permission:all:menu:tree")
public ApiResult<List<SysPermissionTreeVo>> getAllMenuTree() throws Exception {
List<SysPermissionTreeVo> treeVos = sysPermissionService.getAllMenuTree();
return ApiResult.ok(treeVos);
}
```
>其中注解@RequiresPermissions表示访问此接口需要的权限,
权限可以在数据库表中先分配给角色, 再将角色与用户进行关联
**系统平台权限相关表:**
系统角色sys_role,
系统用户sys_user,
系统权限sys_permission,
角色权限关系sys_role_permission
---
## shiro理论知识
Subject(主体): 用于记录当前的操作用户,Subject在shiro中是一个接口,接口中定义了很多认证授相关的方法,外部程序通过subject进行认证授权,而subject是通过SecurityManager安全管理器进行认证授权
SecurityManager(安全管理器):对Subject 进行管理,他是shiro的核心SecurityManager是一个接口,继承了Authenticator, Authorizer, SessionManager这三个接口。
Authenticator(认证器):对用户身份进行认证
Authorizer(授权器):用户通过认证后,来判断时候拥有该权限
realm:获取用户权限数据
sessionManager(会话管理):shiro框架定义了一套会话管理,它不依赖web容器的session,所以shiro可以使用在非web应用上,也可以将分布式应用的会话集中在一点管理,此特性可使它实现单点登录。
CacheManager(缓存管理器):将用户权限数据存储在缓存,这样可以提高性能。
authc:所有url都必须认证通过才可以访问;
anon:所有url都都可以匿名访问;
过滤链定义,从上向下顺序执行,一般将/
**
放在最为下边
\ No newline at end of file
common/src/main/java/com/wecloud/im/controller/ImConversationController.java
View file @
c9c74580
...
...
@@ -10,6 +10,7 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -52,6 +53,16 @@ public class ImConversationController extends BaseController {
return
ApiResult
.
ok
(
conversationList
);
}
/**
* 单向删除(隐藏)会话
*/
@PostMapping
(
"/display/{id}"
)
@ApiOperation
(
value
=
"单向删除(隐藏)会话"
,
notes
=
"云端聊天记录不删除;假设有A和B两个用户,A删会话,B还能发; 如果B发了消息,A这边要重新把会话显示出来,并能显示之前的聊天记录"
)
public
ApiResult
<
Boolean
>
displayConversation
(
@PathVariable
(
"id"
)
Long
id
)
throws
Exception
{
boolean
flag
=
imConversationService
.
displayConversation
(
id
);
return
ApiResult
.
result
(
flag
);
}
// /**
// * 添加会话表
// */
...
...
common/src/main/java/com/wecloud/im/entity/ImApplication.java
View file @
c9c74580
...
...
@@ -59,4 +59,7 @@ public class ImApplication extends BaseEntity {
@ApiModelProperty
(
"firebase推送密钥"
)
private
String
firebaseSecret
;
@ApiModelProperty
(
"是否允许创建重复会话 0不允许 1允许"
)
private
Integer
repeatSessionStatus
;
}
common/src/main/java/com/wecloud/im/entity/ImConversationMembers.java
View file @
c9c74580
...
...
@@ -48,4 +48,7 @@ public class ImConversationMembers extends BaseEntity {
@ApiModelProperty
(
"客户端id"
)
private
Long
fkClientId
;
@NotNull
(
message
=
"单向删除(隐藏)会话, 0不显示, 1显示不能为空"
)
@ApiModelProperty
(
"单向删除(隐藏)会话, 0不显示, 1显示"
)
private
Long
displayStatus
;
}
common/src/main/java/com/wecloud/im/service/ImConversationService.java
View file @
c9c74580
...
...
@@ -54,7 +54,7 @@ public interface ImConversationService extends BaseService<ImConversation> {
* @return
* @throws Exception
*/
boolean
d
eleteIm
Conversation
(
Long
id
)
throws
Exception
;
boolean
d
isplay
Conversation
(
Long
id
)
throws
Exception
;
/**
* 根据ID获取查询对象
...
...
common/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
View file @
c9c74580
package
com
.
wecloud
.
im
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.OrderItem
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
...
...
@@ -114,6 +115,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
// 会话id
Long
imConversationId
=
SnowflakeUtil
.
getId
();
// 创建者
Long
creator
=
client
.
getId
();
// 创建会话
...
...
@@ -173,10 +175,27 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
return
super
.
updateById
(
imConversation
);
}
/**
* 单向删除(隐藏)会话","云端聊天记录不删除;假设有A和B两个用户,A删会话,B还能发; 如果B发了消息,A这边要重新把会话显示出来,并能显示之前的聊天记录"
*
* @param id
* @return
* @throws Exception
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
boolean
deleteImConversation
(
Long
id
)
throws
Exception
{
return
super
.
removeById
(
id
);
public
boolean
displayConversation
(
Long
id
)
throws
Exception
{
ImClient
curentClient
=
imClientService
.
getCurentClient
();
// 修改为删除隐藏状态
boolean
update
=
imConversationMembersService
.
update
(
new
UpdateWrapper
<
ImConversationMembers
>()
.
set
(
"display_status"
,
"0"
)
.
eq
(
"fk_client_id"
,
curentClient
.
getId
())
.
eq
(
"fk_conversation_id"
,
"id"
)
.
eq
(
"fk_appid"
,
curentClient
.
getFkAppid
())
);
return
update
;
}
@Override
...
...
common/src/main/resources/mapper/ImApplicationMapper.xml
View file @
c9c74580
...
...
@@ -5,7 +5,7 @@
<!-- 通用查询结果列 -->
<sql
id=
"Base_Column_List"
>
id
, create_time, update_time, app_key, app_secret, app_name, ios_push_channel, android_push_channel,umeng_key,umeng_secret,firebase_secret
, create_time, update_time, app_key, app_secret, app_name, ios_push_channel, android_push_channel,umeng_key,umeng_secret,firebase_secret
,repeat_session_status
</sql>
...
...
common/src/main/resources/mapper/ImConversationMapper.xml
View file @
c9c74580
...
...
@@ -24,25 +24,26 @@
SELECT imConversation.id,
imConversation.create_time,
imConversation.`name`,
imConversation.attributes as attribute,
imConversation.attributes
as attribute,
imConversation.system,
im_client.client_id AS creator,
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.re
ad_msg
= 0) AS msg_not_read_count,
AND im_inbox.re
ceiver_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
)
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}
AND imConversationMembers.display_status = 1
GROUP BY imConversation.id
</select>
...
...
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