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
51116217
Commit
51116217
authored
Feb 25, 2022
by
hewei
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'upay-test' into 'upay-prod'
Upay test See merge request
!29
parents
bcbb68a2
1a8cfb67
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
202 additions
and
48 deletions
+202
-48
common/src/main/java/com/wecloud/im/controller/ImConversationController.java
+11
-0
common/src/main/java/com/wecloud/im/controller/serverapi/ApiImMessageController.java
+29
-4
common/src/main/java/com/wecloud/im/mapper/ImConversationMapper.java
+2
-0
common/src/main/java/com/wecloud/im/param/add/ImMsgSendRestApi.java
+6
-8
common/src/main/java/com/wecloud/im/param/add/ImMsgSendRestResult.java
+27
-0
common/src/main/java/com/wecloud/im/service/ImConversationService.java
+7
-1
common/src/main/java/com/wecloud/im/service/ImMessageService.java
+6
-3
common/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
+21
-0
common/src/main/java/com/wecloud/im/service/impl/ImMessageServiceImpl.java
+0
-0
common/src/main/resources/mapper/ImConversationMapper.xml
+31
-4
docs/md/内部/wecloud-im服务端REST API对接文档.md
+62
-28
No files found.
common/src/main/java/com/wecloud/im/controller/ImConversationController.java
View file @
51116217
...
...
@@ -15,9 +15,11 @@ 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.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
...
...
@@ -37,6 +39,15 @@ public class ImConversationController extends BaseController {
@Autowired
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
);
}
/**
* 添加或修改会话名称
...
...
common/src/main/java/com/wecloud/im/controller/serverapi/ApiImMessageController.java
View file @
51116217
package
com
.
wecloud
.
im
.
controller
.
serverapi
;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.param.add.ImMsgSendToOnlineClient
;
import
com.wecloud.im.param.add.ImMsgSendRestApi
;
import
com.wecloud.im.param.add.ImMsgSendRestResult
;
import
com.wecloud.im.service.ImApplicationService
;
import
com.wecloud.im.service.ImMessageService
;
import
io.geekidea.springbootplus.framework.common.api.ApiCode
;
...
...
@@ -34,12 +35,36 @@ public class ApiImMessageController extends BaseController {
@Autowired
private
ImMessageService
imMessageService
;
/**
* 向会话中的client下发消息
*/
@PostMapping
(
"/send"
)
@ApiOperation
(
value
=
"向会话中的client下发消息"
,
notes
=
"应用服务端向某会话中所有client下发消息, 会保存进离线消息, 在线和离线client能收到,离线有系统推送"
)
public
ApiResult
<
ImMsgSendRestResult
>
restApiImMessageSendChat
(
@RequestBody
ImMsgSendRestApi
imMsgSendRestApi
,
@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
imMessageService
.
restApiImMessageSend
(
imMsgSendRestApi
,
imApplication
);
}
/**
* 向会话中在线client,下发透传消息
*/
@PostMapping
(
"/sendToOnline
Client
"
)
@PostMapping
(
"/sendToOnline"
)
@ApiOperation
(
value
=
"向会话中在线client,下发透传消息"
,
notes
=
"应用服务端向某会话中所有client下发透传消息, 不会保存进离线消息, 仅在线client能收到"
)
public
ApiResult
<
Boolean
>
restApiImMessageSend
(
@RequestBody
ImMsgSendToOnlineClient
imMsgSendToOnlineClient
,
@RequestHeader
String
appkey
,
@RequestHeader
String
appSecret
)
throws
Exception
{
public
ApiResult
<
ImMsgSendRestResult
>
restApiImMessageSend
(
@RequestBody
ImMsgSendRestApi
imMsgSendRestApi
,
@RequestHeader
String
appkey
,
@RequestHeader
String
appSecret
)
throws
Exception
{
// return imMessageService.updateMsgWithdrawById(imMsgRecall);
...
...
@@ -55,7 +80,7 @@ public class ApiImMessageController extends BaseController {
return
ApiResult
.
result
(
ApiCode
.
FAIL
,
null
);
}
return
imMessageService
.
restApiImMessageSend
(
imMsgSendToOnlineClient
,
imApplication
);
return
imMessageService
.
restApiImMessageSend
Online
(
imMsgSendRestApi
,
imApplication
);
}
...
...
common/src/main/java/com/wecloud/im/mapper/ImConversationMapper.java
View file @
51116217
...
...
@@ -48,6 +48,8 @@ public interface ImConversationMapper extends BaseMapper<ImConversation> {
*/
List
<
MyConversationListVo
>
getMyImConversationListAndMsgCount
(
@Param
(
"clientId"
)
Long
clientId
);
MyConversationListVo
getImConversationAndMsgCountById
(
@Param
(
"clientId"
)
Long
clientId
,
@Param
(
"conversationId"
)
Long
conversationId
);
/**
* 查询用户加入的所有会话
*
...
...
common/src/main/java/com/wecloud/im/param/add/ImMsgSend
ToOnlineClient
.java
→
common/src/main/java/com/wecloud/im/param/add/ImMsgSend
RestApi
.java
View file @
51116217
...
...
@@ -18,19 +18,17 @@ import java.util.HashMap;
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
value
=
"ImMsgSendToOnlineClient"
)
public
class
ImMsgSend
ToOnlineClient
extends
BaseEntity
{
public
class
ImMsgSend
RestApi
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
// @ApiModelProperty(value = "自定义透传内容
", required = true)
// private String cont
ent;
@ApiModelProperty
(
value
=
"发送者id
"
,
required
=
true
)
private
String
senderCli
ent
;
@ApiModelProperty
(
value
=
"自定义透传内容 ,为任意参数名称和类型的对象,供开发者扩展使用。"
,
required
=
true
)
@ApiModelProperty
(
value
=
"自定义内容 ,为任意参数名称和类型的对象,供开发者扩展使用。"
,
required
=
true
)
private
HashMap
content
;
@ApiModelProperty
(
value
=
"会话id"
,
required
=
true
)
private
Long
conversationId
;
// @ApiModelProperty(value = "会话id", required = true)
// private Long conversationId;
}
common/src/main/java/com/wecloud/im/param/add/ImMsgSendRestResult.java
0 → 100644
View file @
51116217
package
com
.
wecloud
.
im
.
param
.
add
;
import
io.geekidea.springbootplus.framework.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
/**
* 服务端api消息下发
*
* @author wei
*/
@Data
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
value
=
"ImMsgSendRestResult"
)
public
class
ImMsgSendRestResult
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"消息id"
,
required
=
true
)
private
Long
msgId
;
}
common/src/main/java/com/wecloud/im/service/ImConversationService.java
View file @
51116217
...
...
@@ -103,6 +103,11 @@ public interface ImConversationService extends BaseService<ImConversation> {
*/
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> {
* @return
* @throws Exception
*/
Paging
<
ImConversationQueryVo
>
getImConversationPageList
(
ImConversationPageParam
imConversationPageParam
)
throws
Exception
;
Paging
<
ImConversationQueryVo
>
getImConversationPageList
(
ImConversationPageParam
imConversationPageParam
)
throws
Exception
;
/**
...
...
common/src/main/java/com/wecloud/im/service/ImMessageService.java
View file @
51116217
...
...
@@ -5,7 +5,8 @@ import com.wecloud.im.entity.ImClient;
import
com.wecloud.im.entity.ImMessage
;
import
com.wecloud.im.param.ImHistoryMessagePageParam
;
import
com.wecloud.im.param.add.ImMsgRecall
;
import
com.wecloud.im.param.add.ImMsgSendToOnlineClient
;
import
com.wecloud.im.param.add.ImMsgSendRestApi
;
import
com.wecloud.im.param.add.ImMsgSendRestResult
;
import
com.wecloud.im.param.add.ImMsgUpdate
;
import
com.wecloud.im.vo.ImMessageOfflineListVo
;
import
com.wecloud.im.vo.OfflineMsgDto
;
...
...
@@ -27,10 +28,12 @@ public interface ImMessageService extends BaseService<ImMessage> {
/**
* 下发透传消息
*
* @param imMsgSend
ToOnlineClient
* @param imMsgSend
RestApi
* @return
*/
ApiResult
<
Boolean
>
restApiImMessageSend
(
ImMsgSendToOnlineClient
imMsgSendToOnlineClient
,
ImApplication
imApplication
);
ApiResult
<
ImMsgSendRestResult
>
restApiImMessageSendOnline
(
ImMsgSendRestApi
imMsgSendRestApi
,
ImApplication
imApplication
);
ApiResult
<
ImMsgSendRestResult
>
restApiImMessageSend
(
ImMsgSendRestApi
imMsgSendRestApi
,
ImApplication
imApplication
);
ImMessage
saveImMessage
(
ImApplication
imApplication
,
ImClient
imClientSender
,
Long
toConversationId
,
long
messageId
,
String
content
);
...
...
common/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
View file @
51116217
...
...
@@ -786,6 +786,27 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
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
();
MyConversationListVo
imConversationAndMsgCountById
=
this
.
getImConversationAndMsgCountById
(
client
.
getId
(),
id
);
JsonMapper
jsonMapper
=
new
JsonMapper
();
HashMap
attributess
=
jsonMapper
.
readValue
(
imConversationAndMsgCountById
.
getAttribute
(),
HashMap
.
class
);
imConversationAndMsgCountById
.
setAttributes
(
attributess
);
return
imConversationAndMsgCountById
;
}
@Override
public
Paging
<
ImConversationQueryVo
>
getImConversationPageList
(
ImConversationPageParam
imConversationPageParam
)
throws
Exception
{
Page
<
ImConversationQueryVo
>
page
=
new
PageInfo
<>(
imConversationPageParam
,
OrderItem
.
desc
(
getLambdaColumn
(
ImConversation:
:
getCreateTime
)));
...
...
common/src/main/java/com/wecloud/im/service/impl/ImMessageServiceImpl.java
View file @
51116217
This diff is collapsed.
Click to expand it.
common/src/main/resources/mapper/ImConversationMapper.xml
View file @
51116217
...
...
@@ -24,20 +24,20 @@
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.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)
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,
(SELECT COUNT(*)
FROM im_conversation_members
WHERE fk_conversation_id = imConversation.id) AS memberCount
...
...
@@ -109,5 +109,32 @@
WHERE im_conversation_members.fk_client_id = #{clientId1}
HAVING members_count = 2 LIMIT 1
</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>
docs/md/内部/wecloud-im服务端REST API对接文档.md
View file @
51116217
# wec
loud-im服务端REST API对接文档
# wec
loud-im服务端REST API对接文档
...
...
@@ -2,31 +2,15 @@
## 本地API文档地址
http://192.168.1.
110
:8082/api/doc.html#/home
http://192.168.1.
89
:8082/api/doc.html#/home
账号密码admin admin
以上只包含api接口文档 websocket对接说明在此文档中
## 测试外网
文档:
```
https://wstest.im199.com/api/doc.html#/home
```
__
_
测试外网请求示例:
```
https://wstest.im199.com/api/imApplication/add
```
以上只包含api接口文档 websocket对接说明在此文档中
____
__
_
## 测试外网
...
...
@@ -57,7 +41,7 @@ _______
## 鉴权方式
### 方式一(
正在开发
):
### 方式一(
开发完成
):
对于 POST 和 PUT 请求,请求的主体必须是 JSON 格式,而且 HTTP header 的 Content-Type 需要设置为
`application/json`
。
...
...
@@ -65,13 +49,15 @@ _______
**示例**
: rest-api-会话成员表分页列表
#### **示例**:
rest-api-会话成员表分页列表
-
Request URL: http://192.168.1.89:8082/api/restApi/imConversationMembers/findList
-
Request Method: POST
**请求头
部
**
**请求头
参数
**
```
appkey: D13ug9jsWbJbeVx1
...
...
@@ -81,11 +67,25 @@ appSecret: c92edcc7ba0c68b9b1da4cec6f3511876b2302faf2ab3737
**请求body**
**请求body
示例
**
```
{
"conversationId": 1442742976269914112
"senderClient": "client_2",
"content": {
"reqId":"1231223123",
"cmd":1,
"data":{
"diyAbcd":"aaaa自已定2义字段的值",
"toConversation":1495943481078714368,
"type":-1,
"text":"发给12312123213这是一123个纯文本消息,发给12312123213这是一123个纯文本消息发给12312123213这是一123个纯文本消息",
"attrs":{
"a":"attrs 阿道夫123123是用来213存储用户自定义的一些键值对,ttrs 阿道夫123123是用来213存储用户自定义的一些键值对",
"b":"attrs 阿道夫123123是用来213存储用户自定义的一些键值对,ttrs 阿道夫123123是用来213存储用户自定义的一些键值对"
}
}
}
}
```
...
...
@@ -94,7 +94,23 @@ appSecret: c92edcc7ba0c68b9b1da4cec6f3511876b2302faf2ab3737
**响应数据**
```
{"code":200,"message":"成功","data":[{"clientId":"1442742442803503105"},{"clientId":"1435497966619996162"}]}
{
"senderClient": "client_2",
"content": {
"reqId":"1231223123",
"cmd":1,
"data":{
"diyAbcd":"aaaa自已定2义字段的值",
"toConversation":1495943481078714368,
"type":-1,
"text":"发给12312123213这是一123个纯文本消息,发给12312123213这是一123个纯文本消息发给12312123213这是一123个纯文本消息",
"attrs":{
"a":"attrs 阿道夫123123是用来213存储用户自定义的一些键值对,ttrs 阿道夫123123是用来213存储用户自定义的一些键值对",
"b":"attrs 阿道夫123123是用来213存储用户自定义的一些键值对,ttrs 阿道夫123123是用来213存储用户自定义的一些键值对"
}
}
}
}
```
...
...
@@ -143,7 +159,19 @@ curl -X PUT \
一个请求是否成功是由 HTTP 状态码标明的。一个 2XX 的状态码表示成功,而一个 4XX 表示请求失败。当一个请求失败时响应的主体仍然是一个 JSON 对象,但是总是会包含
`code`
和
`error`
这两个字段,你可以用它们来进行调试。举个例子,如果尝试用非法的属性名来保存一个对象会得到如下信息:
## 单聊、群聊
### 服务端发消息
文档: 服务端rest-API-消息 - > 向会话中的client下发消息
文档地址
http://192.168.1.89:8082/api/doc.html#/app/%E6%9C%8D%E5%8A%A1%E7%AB%AFrest-API-%E6%B6%88%E6%81%AF/restApiImMessageSendChatUsingPOST
### 创建对话
...
...
@@ -159,7 +187,13 @@ curl -X PUT \
### 查询成员
### 单聊、群聊-发消息
### 查询历史消息
...
...
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