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
57d2ee59
You need to sign in or sign up before continuing.
Commit
57d2ee59
authored
Dec 01, 2021
by
hweeeeeei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加接口:服务端rest-API-会话成员表,rest-api-会话成员表分页列表
parent
4b292cab
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
239 additions
and
32 deletions
+239
-32
common/src/main/java/com/wecloud/im/controller/ImConversationController.java
+5
-5
common/src/main/java/com/wecloud/im/controller/serverapi/ApiImConversationMembersController.java
+114
-0
common/src/main/java/com/wecloud/im/mapper/ImConversationMembersMapper.java
+5
-0
common/src/main/java/com/wecloud/im/param/ApiImConversationMembersPageParam.java
+27
-0
common/src/main/java/com/wecloud/im/param/ApiImConversationMembersQueryVo.java
+44
-0
common/src/main/java/com/wecloud/im/service/ImConversationMembersService.java
+10
-0
common/src/main/java/com/wecloud/im/service/impl/ImConversationMembersServiceImpl.java
+14
-0
common/src/main/resources/mapper/ImConversationMembersMapper.xml
+9
-0
config/src/main/resources/config/application-dev.yml
+1
-1
config/src/main/resources/config/application.yml
+1
-0
docs/md/内部/wecloud-im前端Websocket对接文档.md
+1
-5
docs/md/内部/wecloud-im服务端REST API对接文档.md
+8
-21
No files found.
common/src/main/java/com/wecloud/im/controller/ImConversationController.java
View file @
57d2ee59
...
...
@@ -42,7 +42,7 @@ public class ImConversationController extends BaseController {
* 添加或修改会话名称
*/
@PostMapping
(
"/saveOrUpdateName"
)
@ApiOperation
(
value
=
"添加或修改会话名称"
,
notes
=
""
)
@ApiOperation
(
value
=
"添加或修改会话名称"
,
notes
=
"
权限:目前只有创建者有权限操作
"
)
public
ApiResult
<
Boolean
>
saveOrUpdateName
(
@RequestBody
ImConversationNameUpdate
imConversationNameUpdate
)
throws
Exception
{
return
imConversationService
.
saveOrUpdateName
(
imConversationNameUpdate
);
}
...
...
@@ -52,7 +52,7 @@ public class ImConversationController extends BaseController {
* 添加或修改会话拓展字段
*/
@PostMapping
(
"/saveOrUpdateAttr"
)
@ApiOperation
(
value
=
"添加或修改会话拓展字段"
,
notes
=
""
)
@ApiOperation
(
value
=
"添加或修改会话拓展字段"
,
notes
=
"
权限:目前只有创建者有权限操作
"
)
public
ApiResult
<
Boolean
>
saveOrUpdateAttr
(
@RequestBody
ImConversationAttrUpdate
imConversationAttrUpdate
)
throws
Exception
{
return
imConversationService
.
saveOrUpdateAttr
(
imConversationAttrUpdate
);
}
...
...
@@ -62,7 +62,7 @@ public class ImConversationController extends BaseController {
* client退出会话
*/
@PostMapping
(
"/leave"
)
@ApiOperation
(
value
=
"client退出会话"
,
notes
=
""
)
@ApiOperation
(
value
=
"client退出会话"
,
notes
=
"
若是创建者退出,[创建者]权限将会转移给按加入会话时间排序的下一个client
"
)
public
ApiResult
<
Boolean
>
leaveConversation
(
@RequestBody
ImClientLeaveConversation
imClientToConversation
)
throws
Exception
{
return
imConversationService
.
leaveConversation
(
imClientToConversation
);
}
...
...
@@ -72,7 +72,7 @@ public class ImConversationController extends BaseController {
* 将client从会话移除
*/
@PostMapping
(
"/delClient"
)
@ApiOperation
(
value
=
"将client从会话移除"
,
notes
=
""
)
@ApiOperation
(
value
=
"将client从会话移除"
,
notes
=
"
权限:目前只有创建者有权限操作
"
)
public
ApiResult
<
Boolean
>
delClientToConversation
(
@RequestBody
ImClientToConversation
imClientToConversation
)
throws
Exception
{
return
imConversationService
.
delClientToConversation
(
imClientToConversation
);
}
...
...
@@ -82,7 +82,7 @@ public class ImConversationController extends BaseController {
* 将用户添加进会话
*/
@PostMapping
(
"/addClient"
)
@ApiOperation
(
value
=
"将用户添加进会话"
,
notes
=
""
)
@ApiOperation
(
value
=
"将用户添加进会话"
,
notes
=
"
权限:会话中所有client都有权限操作
"
)
public
ApiResult
<
Boolean
>
addClientToConversation
(
@RequestBody
ImClientToConversation
imClientToConversation
)
throws
Exception
{
return
imConversationService
.
addClientToConversation
(
imClientToConversation
);
}
...
...
common/src/main/java/com/wecloud/im/controller/serverapi/ApiImConversationMembersController.java
0 → 100644
View file @
57d2ee59
package
com
.
wecloud
.
im
.
controller
.
serverapi
;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.param.ApiImConversationMembersPageParam
;
import
com.wecloud.im.param.ApiImConversationMembersQueryVo
;
import
com.wecloud.im.service.ImApplicationService
;
import
com.wecloud.im.service.ImConversationMembersService
;
import
io.geekidea.springbootplus.framework.common.api.ApiCode
;
import
io.geekidea.springbootplus.framework.common.api.ApiResult
;
import
io.geekidea.springbootplus.framework.common.controller.BaseController
;
import
io.geekidea.springbootplus.framework.log.annotation.OperationLog
;
import
io.geekidea.springbootplus.framework.log.enums.OperationLogType
;
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.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestHeader
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
/**
* 会话成员表 控制器
*
* @author wei
* @since 2021-05-07
*/
@Slf4j
@RestController
@RequestMapping
(
"/restApi/imConversationMembers"
)
@Api
(
value
=
"服务端rest-API-会话成员表"
,
tags
=
{
"服务端API-会话成员表"
})
public
class
ApiImConversationMembersController
extends
BaseController
{
@Autowired
private
ImConversationMembersService
imConversationMembersService
;
@Autowired
private
ImApplicationService
imApplicationService
;
/**
* 会话成员表分页列表
*/
@PostMapping
(
"/findList"
)
@OperationLog
(
name
=
"rest-api-会话成员表分页列表"
,
type
=
OperationLogType
.
PAGE
)
@ApiOperation
(
value
=
"rest-api-会话成员表分页列表"
)
public
ApiResult
<
List
<
ApiImConversationMembersQueryVo
>>
getApiImConversationMembersList
(
@Validated
@RequestBody
ApiImConversationMembersPageParam
apiImConversationMembersPageParam
,
@RequestHeader
String
appkey
,
@RequestHeader
String
appSecret
)
throws
Exception
{
// 根据appKey从数据库查询密钥
ImApplication
imApplication
=
imApplicationService
.
getOneByAppKey
(
appkey
);
if
(
imApplication
==
null
)
{
return
ApiResult
.
result
(
ApiCode
.
FAIL
,
null
);
}
// 校验appkey 和appSecret
if
(!
imApplication
.
getAppSecret
().
equals
(
appSecret
))
{
return
ApiResult
.
result
(
ApiCode
.
FAIL
,
null
);
}
return
imConversationMembersService
.
getRestApiImConversationMembersList
(
apiImConversationMembersPageParam
,
imApplication
);
}
// /**
// * 添加会话成员表
// */
// @PostMapping("/add")
// @OperationLog(name = "添加会话成员表", type = OperationLogType.ADD)
// @ApiOperation(value = "添加会话成员表")
// public ApiResult<Boolean> addImConversationMembers(@Validated(Add.class) @RequestBody ImConversationMembers imConversationMembers) throws Exception {
// boolean flag = imConversationMembersService.saveImConversationMembers(imConversationMembers);
// return ApiResult.result(flag);
// }
//
// /**
// * 修改会话成员表
// */
// @PostMapping("/update")
// @OperationLog(name = "修改会话成员表", type = OperationLogType.UPDATE)
// @ApiOperation(value = "修改会话成员表")
// public ApiResult<Boolean> updateImConversationMembers(@Validated(Update.class) @RequestBody ImConversationMembers imConversationMembers) throws Exception {
// boolean flag = imConversationMembersService.updateImConversationMembers(imConversationMembers);
// return ApiResult.result(flag);
// }
//
// /**
// * 删除会话成员表
// */
// @PostMapping("/delete/{id}")
// @OperationLog(name = "删除会话成员表", type = OperationLogType.DELETE)
// @ApiOperation(value = "删除会话成员表")
// public ApiResult<Boolean> deleteImConversationMembers(@PathVariable("id") Long id) throws Exception {
// boolean flag = imConversationMembersService.deleteImConversationMembers(id);
// return ApiResult.result(flag);
// }
//
// /**
// * 获取会话成员表详情
// */
// @GetMapping("/info/{id}")
// @OperationLog(name = "会话成员表详情", type = OperationLogType.INFO)
// @ApiOperation(value = "会话成员表详情")
// public ApiResult<ImConversationMembersQueryVo> getImConversationMembers(@PathVariable("id") Long id) throws Exception {
// ImConversationMembersQueryVo imConversationMembersQueryVo = imConversationMembersService.getImConversationMembersById(id);
// return ApiResult.ok(imConversationMembersQueryVo);
// }
//
}
common/src/main/java/com/wecloud/im/mapper/ImConversationMembersMapper.java
View file @
57d2ee59
...
...
@@ -4,12 +4,14 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.wecloud.im.entity.ImConversationMembers
;
import
com.wecloud.im.param.ApiImConversationMembersQueryVo
;
import
com.wecloud.im.param.ImConversationMembersPageParam
;
import
com.wecloud.im.param.ImConversationMembersQueryVo
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Repository
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* 会话成员表 Mapper 接口
...
...
@@ -28,6 +30,9 @@ public interface ImConversationMembersMapper extends BaseMapper<ImConversationMe
*/
ImConversationMembersQueryVo
getImConversationMembersById
(
Serializable
id
);
List
<
ApiImConversationMembersQueryVo
>
getRestApiImConversationMembersList
(
@Param
(
"conversationId"
)
Long
conversationId
);
/**
* 获取分页对象
*
...
...
common/src/main/java/com/wecloud/im/param/ApiImConversationMembersPageParam.java
0 → 100644
View file @
57d2ee59
package
com
.
wecloud
.
im
.
param
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
/**
* <pre>
* 会话成员表 分页参数对象
* </pre>
*
* @author wei
* @date 2021-05-07
*/
@Data
@Accessors
(
chain
=
true
)
@ApiModel
(
value
=
"ApiImConversationMembersPageParam"
)
public
class
ApiImConversationMembersPageParam
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"会话表id"
,
required
=
true
)
private
Long
conversationId
;
}
common/src/main/java/com/wecloud/im/param/ApiImConversationMembersQueryVo.java
0 → 100644
View file @
57d2ee59
package
com
.
wecloud
.
im
.
param
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
/**
* <pre>
* 会话成员表 查询结果对象
* </pre>
*
* @author wei
* @date 2021-05-07
*/
@Data
@Accessors
(
chain
=
true
)
@ApiModel
(
value
=
"ApiImConversationMembersQueryVo"
)
public
class
ApiImConversationMembersQueryVo
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
// @ApiModelProperty("唯一id")
// private Long id;
// @ApiModelProperty("加入时间")
// private Date createTime;
@ApiModelProperty
(
"客户端id"
)
private
String
clientId
;
// @ApiModelProperty("修改时间")
// private Date updateTime;
//
// @ApiModelProperty("应用appid")
// private Long fkAppid;
// @ApiModelProperty("会话表id")
// private Long fkConversationId;
}
\ No newline at end of file
common/src/main/java/com/wecloud/im/service/ImConversationMembersService.java
View file @
57d2ee59
package
com
.
wecloud
.
im
.
service
;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.entity.ImConversationMembers
;
import
com.wecloud.im.param.ApiImConversationMembersPageParam
;
import
com.wecloud.im.param.ApiImConversationMembersQueryVo
;
import
com.wecloud.im.param.ImConversationMembersPageParam
;
import
com.wecloud.im.param.ImConversationMembersQueryVo
;
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
;
/**
* 会话成员表 服务类
*
...
...
@@ -14,6 +20,10 @@ import io.geekidea.springbootplus.framework.core.pagination.Paging;
*/
public
interface
ImConversationMembersService
extends
BaseService
<
ImConversationMembers
>
{
ApiResult
<
List
<
ApiImConversationMembersQueryVo
>>
getRestApiImConversationMembersList
(
ApiImConversationMembersPageParam
apiImConversationMembersPageParam
,
ImApplication
imApplication
);
/**
* 保存
*
...
...
common/src/main/java/com/wecloud/im/service/impl/ImConversationMembersServiceImpl.java
View file @
57d2ee59
...
...
@@ -3,11 +3,15 @@ package com.wecloud.im.service.impl;
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.ImConversationMembers
;
import
com.wecloud.im.mapper.ImConversationMembersMapper
;
import
com.wecloud.im.param.ApiImConversationMembersPageParam
;
import
com.wecloud.im.param.ApiImConversationMembersQueryVo
;
import
com.wecloud.im.param.ImConversationMembersPageParam
;
import
com.wecloud.im.param.ImConversationMembersQueryVo
;
import
com.wecloud.im.service.ImConversationMembersService
;
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
;
import
io.geekidea.springbootplus.framework.core.pagination.Paging
;
...
...
@@ -16,6 +20,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
/**
* 会话成员表 服务实现类
*
...
...
@@ -29,6 +35,14 @@ public class ImConversationMembersServiceImpl extends BaseServiceImpl<ImConversa
@Autowired
private
ImConversationMembersMapper
imConversationMembersMapper
;
@Override
public
ApiResult
<
List
<
ApiImConversationMembersQueryVo
>>
getRestApiImConversationMembersList
(
ApiImConversationMembersPageParam
apiImConversationMembersPageParam
,
ImApplication
imApplication
)
{
List
<
ApiImConversationMembersQueryVo
>
restApiImConversationMembersList
=
imConversationMembersMapper
.
getRestApiImConversationMembersList
(
apiImConversationMembersPageParam
.
getConversationId
());
return
ApiResult
.
ok
(
restApiImConversationMembersList
);
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
boolean
saveImConversationMembers
(
ImConversationMembers
imConversationMembers
)
throws
Exception
{
...
...
common/src/main/resources/mapper/ImConversationMembersMapper.xml
View file @
57d2ee59
...
...
@@ -20,5 +20,14 @@
<include
refid=
"Base_Column_List"
/>
from im_conversation_members
</select>
<select
id=
"getRestApiImConversationMembersList"
resultType=
"com.wecloud.im.param.ApiImConversationMembersQueryVo"
>
SELECT im_client.client_id AS clientId
FROM im_conversation_members AS imConversationMembers
INNER JOIN im_client AS im_client ON im_client.id = imConversationMembers.fk_client_id
WHERE fk_conversation_id = #{conversationId}
</select>
</mapper>
config/src/main/resources/config/application-dev.yml
View file @
57d2ee59
...
...
@@ -15,7 +15,7 @@ spring-boot-plus:
spring
:
datasource
:
url
:
jdbc:mysql://localhost:3306/wecloud_im
_v1_3
?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
url
:
jdbc:mysql://localhost:3306/wecloud_im?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
username
:
root
password
:
123
...
...
config/src/main/resources/config/application.yml
View file @
57d2ee59
...
...
@@ -199,6 +199,7 @@ spring-boot-plus:
-
/imApplication/**
-
/signDemo/get
-
/Wecloud-IM-Websocket-Docs.html
-
/restApi/**
# 多行字符串权限配置
filter-chain-definitions
:
|
...
...
docs/md/内部/wecloud-im前端Websocket对接文档.md
View file @
57d2ee59
# wec
loud-im 前端Websocket对接文档
# wec
loud-im 前端Websocket对接文档
...
...
@@ -490,7 +490,6 @@ websocket是异步的 有可能你很快速的发送了几条消息,服务器响
| 字段名 | 字段类型 | 是否可空 | 说明 |
| ------ | -------- | -------- | ----------------- |
| sender | String | 否 | 新群主的client ID |
| | | | |
...
...
@@ -527,9 +526,6 @@ websocket是异步的 有可能你很快速的发送了几条消息,服务器响
| 字段名 | 字段类型 | 是否可空 | 说明 |
| ------ | -------- | -------- | --------------- |
| sender | String | 否 | 退出的client ID |
| | | | |
...
...
docs/md/内部/wecloud-im服务端REST API对接文档.md
View file @
57d2ee59
# wec
loud-im服务端REST API对接文档
# wec
loud-im服务端REST API对接文档
...
...
@@ -24,13 +24,7 @@ ___
https://wstest.im199.com/api/imApplication/add
```
__
_
ws连接示例
```
wss://wstest.im199.com/ws?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJ3ZWIiLCJjbGllbnRJZCI6ImFiY2QxIiwiaXNzIjoid2VjbG91ZF9pbSIsImFwcEtleSI6IkpLdE5IZnJWVXdzaGF4ek4iLCJleHAiOjE2MjgzMjMxNDMsImlhdCI6MTYyMzEzOTE0MywianRpIjoiNWU3NzU5ZjM2ODQ3NDFiMzg4MGEyYjkwMjQ0OWZjZmYifQ.CC-iuGjNwQLH4VxFI2wZEPuP4AGabOUOiRh9snp3IB4
```
____
__
_
...
...
@@ -54,13 +48,6 @@ ___
https://ws.im199.com/api/imApplication/add
```
__
_
ws连接示例
```
wss://ws.im199.com/ws?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJ3ZWIiLCJjbGllbnRJZCI6ImFiY2QxIiwiaXNzIjoid2VjbG91ZF9pbSIsImFwcEtleSI6IkpLdE5IZnJWVXdzaGF4ek4iLCJleHAiOjE2MjgzMjMxNDMsImlhdCI6MTYyMzEzOTE0MywianRpIjoiNWU3NzU5ZjM2ODQ3NDFiMzg4MGEyYjkwMjQ0OWZjZmYifQ.CC-iuGjNwQLH4VxFI2wZEPuP4AGabOUOiRh9snp3IB4
```
____
__
_
...
...
@@ -70,28 +57,28 @@ _______
## 鉴权方式
### 方式一:
### 方式一
(正在开发)
:
对于 POST 和 PUT 请求,请求的主体必须是 JSON 格式,而且 HTTP header 的 Content-Type 需要设置为
`application/json`
。
用户验证通过 HTTP header 来进行,
**
X-LC-Id**
标明正在运行的是哪个应用(应用的 App ID),
**X-LC-Key
**
用来授权鉴定 endpoint:
用户验证通过 HTTP header 来进行,
**
appkey**
标明正在运行的是哪个应用(应用的 App ID),
**appSecret
**
用来授权鉴定 endpoint:
```
json
curl -X PUT
\
-H "
X-LC-Id: {{appid
}}"
\
-H "
X-LC-Key: {{appkey
}}"
\
-H "
appkey: {{appkey
}}"
\
-H "
appSecret: {{appSecret
}}"
\
-H "Content-Type: application/json"
\
-d '{"content": "
更新一篇博客的内容
"}'
\
-d '{"content": "
你好
"}'
\
https://https://ws.im199.com/api/
```
**X-LC-Key** 通常情况下是应用的 App Key
### 方式二
### 方式二(暂时没开发)
**更安全的鉴权**
...
...
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