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
716bdd11
Commit
716bdd11
authored
Mar 21, 2022
by
李晓钟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
websocket的文档处理
parent
9a15f298
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
262 additions
and
59 deletions
+262
-59
bootstrap/src/main/java/io/geekidea/springbootplus/config/Swagger2Config.java
+4
-0
core/src/main/java/com/wecloud/dispatch/WsTestAction.java
+0
-2
core/src/main/java/com/wecloud/dispatch/annotation/ActionMapping.java
+40
-5
core/src/main/java/com/wecloud/dispatch/general/impl/GeneralMethodArgumentResolver.java
+7
-3
core/src/main/java/com/wecloud/dispatch/registry/ActionRegistry.java
+14
-14
core/src/main/java/com/wecloud/dispatch/swagger/CustomOperationPlugin.java
+51
-0
core/src/main/java/com/wecloud/dispatch/swagger/SwaggerAddtion.java
+89
-0
core/src/main/java/com/wecloud/im/action/MessageAction.java
+7
-1
core/src/main/java/com/wecloud/im/action/NormalChatAction.java
+2
-0
core/src/main/java/com/wecloud/im/thousandchat/action/ThousandChatAction.java
+33
-2
core/src/main/java/com/wecloud/im/thousandchat/controller/ThousandChatController.java
+1
-19
core/src/main/java/com/wecloud/im/thousandchat/param/LastestReceivedMsg.java
+4
-3
core/src/main/java/com/wecloud/im/ws/sender/ChannelSender.java
+1
-1
framework/pom.xml
+4
-4
pom.xml
+5
-5
No files found.
bootstrap/src/main/java/io/geekidea/springbootplus/config/Swagger2Config.java
View file @
716bdd11
...
@@ -22,6 +22,8 @@ import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
...
@@ -22,6 +22,8 @@ import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import
com.google.common.base.Function
;
import
com.google.common.base.Function
;
import
com.google.common.base.Optional
;
import
com.google.common.base.Optional
;
import
com.google.common.base.Predicate
;
import
com.google.common.base.Predicate
;
import
com.wecloud.dispatch.extend.ActionRequest
;
import
com.wecloud.dispatch.extend.ArgumentBox
;
import
io.geekidea.springbootplus.config.properties.SwaggerProperties
;
import
io.geekidea.springbootplus.config.properties.SwaggerProperties
;
import
io.geekidea.springbootplus.framework.common.exception.SpringBootPlusConfigException
;
import
io.geekidea.springbootplus.framework.common.exception.SpringBootPlusConfigException
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
...
@@ -102,6 +104,8 @@ public class Swagger2Config {
...
@@ -102,6 +104,8 @@ public class Swagger2Config {
HttpServletRequest
.
class
,
HttpServletRequest
.
class
,
HttpServletResponse
.
class
,
HttpServletResponse
.
class
,
HttpSession
.
class
,
HttpSession
.
class
,
ActionRequest
.
class
,
ArgumentBox
.
class
,
ApiIgnore
.
class
ApiIgnore
.
class
};
};
@Autowired
@Autowired
...
...
core/src/main/java/com/wecloud/dispatch/WsTestAction.java
View file @
716bdd11
...
@@ -57,7 +57,6 @@ import java.util.Set;
...
@@ -57,7 +57,6 @@ import java.util.Set;
*/
*/
@Controller
@Controller
@ActionMapping
(
value
=
"/sendtest"
)
@ActionMapping
(
value
=
"/sendtest"
)
@RequestMapping
(
"/sendtest"
)
@Api
(
value
=
"测试方法类"
,
tags
=
{
"websocket报文-全部采用json传输"
})
@Api
(
value
=
"测试方法类"
,
tags
=
{
"websocket报文-全部采用json传输"
})
@Slf4j
@Slf4j
public
class
WsTestAction
{
public
class
WsTestAction
{
...
@@ -73,7 +72,6 @@ public class WsTestAction {
...
@@ -73,7 +72,6 @@ public class WsTestAction {
*/
*/
@ActionMapping
(
value
=
"gogo"
)
@ActionMapping
(
value
=
"gogo"
)
@ApiOperation
(
value
=
"测试方法"
)
@ApiOperation
(
value
=
"测试方法"
)
@PostMapping
(
"gogo"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"reqId"
,
value
=
"请求id"
,
required
=
false
),
@ApiImplicitParam
(
name
=
"reqId"
,
value
=
"请求id"
,
required
=
false
),
@ApiImplicitParam
(
name
=
"hello"
,
value
=
"测试参数hello"
,
required
=
true
),
@ApiImplicitParam
(
name
=
"hello"
,
value
=
"测试参数hello"
,
required
=
true
),
...
...
core/src/main/java/com/wecloud/dispatch/annotation/ActionMapping.java
View file @
716bdd11
package
com
.
wecloud
.
dispatch
.
annotation
;
package
com
.
wecloud
.
dispatch
.
annotation
;
import
org.springframework.core.annotation.AliasFor
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.RetentionPolicy
;
...
@@ -10,17 +15,47 @@ import java.lang.annotation.Target;
...
@@ -10,17 +15,47 @@ import java.lang.annotation.Target;
*/
*/
@Target
({
ElementType
.
METHOD
,
ElementType
.
TYPE
})
@Target
({
ElementType
.
METHOD
,
ElementType
.
TYPE
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@RequestMapping
(
method
=
RequestMethod
.
POST
)
public
@interface
ActionMapping
{
public
@interface
ActionMapping
{
@AliasFor
(
annotation
=
RequestMapping
.
class
)
String
name
()
default
""
;
/**
* Alias for {@link RequestMapping#value}.
*/
@AliasFor
(
annotation
=
RequestMapping
.
class
)
String
[]
value
()
default
{};
/**
* Alias for {@link RequestMapping#path}.
*/
@AliasFor
(
annotation
=
RequestMapping
.
class
)
String
[]
path
()
default
{};
/**
/**
* Mapping映射字段
* Alias for {@link RequestMapping#params}.
* @return
*/
*/
String
[]
value
()
default
""
;
@AliasFor
(
annotation
=
RequestMapping
.
class
)
String
[]
params
()
default
{};
/**
/**
*
* Alias for {@link RequestMapping#headers}.
* @return
*/
*/
@AliasFor
(
annotation
=
RequestMapping
.
class
)
String
[]
headers
()
default
{};
/**
* Alias for {@link RequestMapping#consumes}.
*/
@AliasFor
(
annotation
=
RequestMapping
.
class
)
String
[]
consumes
()
default
{};
/**
* Alias for {@link RequestMapping#produces}.
*/
@AliasFor
(
annotation
=
RequestMapping
.
class
)
String
[]
produces
()
default
{};
int
order
()
default
10
;
int
order
()
default
10
;
}
}
core/src/main/java/com/wecloud/dispatch/general/impl/GeneralMethodArgumentResolver.java
View file @
716bdd11
...
@@ -6,6 +6,7 @@ import com.wecloud.dispatch.extend.ArgumentBox;
...
@@ -6,6 +6,7 @@ import com.wecloud.dispatch.extend.ArgumentBox;
import
com.wecloud.dispatch.extend.MethodArgumentResolver
;
import
com.wecloud.dispatch.extend.MethodArgumentResolver
;
import
com.wecloud.utils.JsonUtils
;
import
com.wecloud.utils.JsonUtils
;
import
org.springframework.core.MethodParameter
;
import
org.springframework.core.MethodParameter
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.lang.reflect.Array
;
import
java.lang.reflect.Array
;
...
@@ -38,15 +39,18 @@ public class GeneralMethodArgumentResolver implements MethodArgumentResolver {
...
@@ -38,15 +39,18 @@ public class GeneralMethodArgumentResolver implements MethodArgumentResolver {
ActionRequest
request
,
ActionRequest
request
,
ArgumentBox
argumentBox
)
{
ArgumentBox
argumentBox
)
{
Object
object
=
null
;
Object
object
=
null
;
RequestBody
requestBodyDefine
=
parameter
.
getParameterAnnotation
(
RequestBody
.
class
);
if
(
requestBodyDefine
!=
null
)
{
Class
<?>
clazz
=
parameter
.
getParameterType
();
object
=
JsonUtils
.
beanCopyDeep
(
request
.
getData
(),
clazz
);
return
object
;
}
RequestParam
define
=
parameter
.
getParameterAnnotation
(
RequestParam
.
class
);
RequestParam
define
=
parameter
.
getParameterAnnotation
(
RequestParam
.
class
);
// 获取属定义的名称
// 获取属定义的名称
String
name
=
null
==
define
?
parameter
.
getParameterName
()
:
define
.
value
();
String
name
=
null
==
define
?
parameter
.
getParameterName
()
:
define
.
value
();
Class
<?>
clazz
=
parameter
.
getParameterType
();
Class
<?>
clazz
=
parameter
.
getParameterType
();
Object
value
=
request
.
getData
().
get
(
name
);
Object
value
=
request
.
getData
().
get
(
name
);
if
(
ActionRequest
.
class
.
isAssignableFrom
(
clazz
))
{
if
(
ActionRequest
.
class
.
isAssignableFrom
(
clazz
))
{
object
=
request
;
object
=
request
;
}
else
if
(
ArgumentBox
.
class
.
isAssignableFrom
(
clazz
))
{
}
else
if
(
ArgumentBox
.
class
.
isAssignableFrom
(
clazz
))
{
...
...
core/src/main/java/com/wecloud/dispatch/registry/ActionRegistry.java
View file @
716bdd11
...
@@ -63,20 +63,20 @@ public class ActionRegistry {
...
@@ -63,20 +63,20 @@ public class ActionRegistry {
}
}
}
}
public
void
add
(
Method
method
)
{
//
public void add(Method method) {
if
(
null
!=
method
)
{
//
if (null != method) {
Annotation
[]
as
=
method
.
getDeclaringClass
().
getAnnotations
();
//
Annotation[] as = method.getDeclaringClass().getAnnotations();
ActionMapping
am
=
null
;
//
ActionMapping am = null;
for
(
Annotation
annotation
:
as
)
{
//
for (Annotation annotation : as) {
if
(
annotation
instanceof
ActionMapping
)
{
//
if (annotation instanceof ActionMapping) {
am
=
((
ActionMapping
)
annotation
);
//
am = ((ActionMapping) annotation);
break
;
//
break;
}
//
}
}
//
}
String
[]
codes
=
null
==
am
?
new
String
[]
{
""
}
:
am
.
value
();
//
String[] codes = null == am ? new String[] { "" } : am.value();
add
(
codes
,
method
);
//
add(codes, method);
}
//
}
}
//
}
public
void
add
(
String
[]
codes
,
Method
method
)
{
public
void
add
(
String
[]
codes
,
Method
method
)
{
if
(
null
!=
method
)
{
if
(
null
!=
method
)
{
...
...
core/src/main/java/com/wecloud/dispatch/swagger/CustomOperationPlugin.java
0 → 100644
View file @
716bdd11
package
com
.
wecloud
.
dispatch
.
swagger
;
import
com.google.common.base.Optional
;
import
com.wecloud.dispatch.annotation.ActionMapping
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.servlet.mvc.condition.NameValueExpression
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spi.service.OperationBuilderPlugin
;
import
springfox.documentation.spi.service.contexts.OperationContext
;
import
springfox.documentation.spring.web.DescriptionResolver
;
import
springfox.documentation.swagger.common.SwaggerPluginSupport
;
@Component
@Order
(
SwaggerPluginSupport
.
SWAGGER_PLUGIN_ORDER
+
1
)
public
class
CustomOperationPlugin
implements
OperationBuilderPlugin
{
private
final
DescriptionResolver
descriptions
;
@Autowired
public
CustomOperationPlugin
(
DescriptionResolver
descriptions
)
{
this
.
descriptions
=
descriptions
;
}
@Override
public
void
apply
(
OperationContext
context
)
{
Optional
<
ApiOperation
>
apiOperationOp
=
context
.
findAnnotation
(
ApiOperation
.
class
);
Optional
<
ActionMapping
>
acOp
=
context
.
findAnnotation
(
ActionMapping
.
class
);
if
(
apiOperationOp
.
isPresent
()
||
acOp
.
isPresent
())
{
String
notes
=
""
;
if
(
apiOperationOp
.
isPresent
())
{
notes
=
apiOperationOp
.
get
().
notes
();
}
Optional
<
ActionMapping
>
hasActionMapping
=
context
.
findAnnotation
(
ActionMapping
.
class
);
//添加权限码到notes中
if
(
hasActionMapping
.
isPresent
())
{
notes
=
notes
+
"需要注意的是:<br/> 1、这是websocket接口;<br/> 2、请用ws://调用 <br/> 3、请求参数外层需要包一层:"
+
"{ <br/>"
+
"\t\"reqId\": Long类型, <br/>"
+
"\t\"action\": 字符串类型(就是上面的地址) <br/>"
+
"\t\"data\": 真正的请求参数(就是下面的请求参数), <br/>"
+
"} "
;
//编辑api文档信息, notes
context
.
operationBuilder
().
notes
(
descriptions
.
resolve
(
notes
));
}
}
}
@Override
public
boolean
supports
(
DocumentationType
documentationType
)
{
return
SwaggerPluginSupport
.
pluginDoesApply
(
documentationType
);
}
}
core/src/main/java/com/wecloud/dispatch/swagger/SwaggerAddtion.java
0 → 100644
View file @
716bdd11
//package com.wecloud.dispatch.swagger;
//
//import com.fasterxml.classmate.TypeResolver;
//import com.google.common.collect.Sets;
//import org.springframework.http.HttpMethod;
//import org.springframework.http.MediaType;
//import org.springframework.stereotype.Component;
//import springfox.documentation.builders.OperationBuilder;
//import springfox.documentation.builders.ParameterBuilder;
//import springfox.documentation.schema.ModelRef;
//import springfox.documentation.service.ApiDescription;
//import springfox.documentation.service.Operation;
//import springfox.documentation.service.Parameter;
//import springfox.documentation.spi.DocumentationType;
//import springfox.documentation.spi.service.ApiListingScannerPlugin;
//import springfox.documentation.spi.service.contexts.DocumentationContext;
//import springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator;
//
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.List;
//
//@Component
//public class SwaggerAddtion implements ApiListingScannerPlugin {
// @Override
// public List<ApiDescription> apply(DocumentationContext documentationContext) {
// String path = "/oauth/token";
// String description = "UserToken";
//
// List<Parameter> parameters = new ArrayList<>();
// Parameter param1 = new ParameterBuilder()
// .description("oauth2鉴权方式,如password")//参数描述
// .type(new TypeResolver().resolve(String.class))//参数数据类型
// .name("grant_type")//参数名称
// .defaultValue("password")//参数默认值
// .parameterType("query")//参数类型
// .parameterAccess("access")
// .required(true)//是否必填
// .modelRef(new ModelRef("string")) //参数数据类型
// .build();
// parameters.add(param1);
// Parameter param2 = new ParameterBuilder()
// .description("用户名")
// .type(new TypeResolver().resolve(String.class))
// .name("username")
// .parameterType("query")
// .parameterAccess("access")
// .required(true)
// .modelRef(new ModelRef("string")) //<5>
// .build();
// parameters.add(param2);
//
// Parameter param3 = new ParameterBuilder()
// .description("密码")
// .type(new TypeResolver().resolve(String.class))
// .name("password")
// .parameterType("query")
// .parameterAccess("access")
// .required(true)
// .modelRef(new ModelRef("string")) //<5>
// .build();
// parameters.add(param3);
//
// Operation operation = new OperationBuilder(
// new CachingOperationNameGenerator())
// .method(HttpMethod.POST)//http请求类型
// .produces(Sets.newHashSet(MediaType.APPLICATION_JSON_VALUE))
// .summary("获取token")
// .notes("获取token")//方法描述
// .tags(Sets.newHashSet("归类标签"))//归类标签
// .parameters(parameters)
// .build();
//
// ApiDescription apiDescription = new ApiDescription(
// path, //url
// description, //描述
// Arrays.asList(operation),
// false);
// List<ApiDescription> descriptions = new ArrayList<>();
// descriptions.add(apiDescription);
//
// return descriptions;
// }
//
// @Override
// public boolean supports(DocumentationType documentationType) {
// return DocumentationType.SWAGGER_2.equals(documentationType);
// }
//}
core/src/main/java/com/wecloud/im/action/MessageAction.java
View file @
716bdd11
...
@@ -15,6 +15,7 @@ import com.wecloud.im.ws.model.WsResponse;
...
@@ -15,6 +15,7 @@ import com.wecloud.im.ws.model.WsResponse;
import
com.wecloud.im.ws.sender.ChannelSender
;
import
com.wecloud.im.ws.sender.ChannelSender
;
import
io.geekidea.springbootplus.framework.core.pagination.Paging
;
import
io.geekidea.springbootplus.framework.core.pagination.Paging
;
import
io.netty.channel.socket.nio.NioSocketChannel
;
import
io.netty.channel.socket.nio.NioSocketChannel
;
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.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -26,7 +27,7 @@ import org.springframework.stereotype.Component;
...
@@ -26,7 +27,7 @@ import org.springframework.stereotype.Component;
*/
*/
@Slf4j
@Slf4j
@Component
@Component
@ActionMapping
(
value
=
"/im
M
essage"
)
@ActionMapping
(
value
=
"/im
/m
essage"
)
public
class
MessageAction
{
public
class
MessageAction
{
@Autowired
@Autowired
...
@@ -42,6 +43,7 @@ public class MessageAction {
...
@@ -42,6 +43,7 @@ public class MessageAction {
* @param reqId
* @param reqId
*/
*/
@ActionMapping
(
"/withdraw"
)
@ActionMapping
(
"/withdraw"
)
@ApiOperation
(
"消息撤回"
)
public
void
withdraw
(
ActionRequest
request
,
ImMsgRecall
msgRecall
,
String
reqId
)
{
public
void
withdraw
(
ActionRequest
request
,
ImMsgRecall
msgRecall
,
String
reqId
)
{
log
.
info
(
"撤回消息内容:{}"
,
JSON
.
toJSONString
(
msgRecall
));
log
.
info
(
"撤回消息内容:{}"
,
JSON
.
toJSONString
(
msgRecall
));
WsResponse
<
Boolean
>
wsResponse
=
new
WsResponse
<>();
WsResponse
<
Boolean
>
wsResponse
=
new
WsResponse
<>();
...
@@ -56,6 +58,7 @@ public class MessageAction {
...
@@ -56,6 +58,7 @@ public class MessageAction {
* @param reqId
* @param reqId
*/
*/
@ActionMapping
(
"/delete"
)
@ActionMapping
(
"/delete"
)
@ApiOperation
(
"删除消息内容"
)
public
void
deleteMsg
(
ActionRequest
request
,
MsgDeleteParam
msgDeleteParam
,
String
reqId
)
{
public
void
deleteMsg
(
ActionRequest
request
,
MsgDeleteParam
msgDeleteParam
,
String
reqId
)
{
log
.
info
(
"删除消息内容:{}"
,
JSON
.
toJSONString
(
msgDeleteParam
));
log
.
info
(
"删除消息内容:{}"
,
JSON
.
toJSONString
(
msgDeleteParam
));
WsResponse
<
Boolean
>
wsResponse
=
new
WsResponse
<>();
WsResponse
<
Boolean
>
wsResponse
=
new
WsResponse
<>();
...
@@ -70,6 +73,7 @@ public class MessageAction {
...
@@ -70,6 +73,7 @@ public class MessageAction {
* @param reqId
* @param reqId
*/
*/
@ActionMapping
(
"/updateMsgById"
)
@ActionMapping
(
"/updateMsgById"
)
@ApiOperation
(
"修改消息体"
)
public
void
updateMsgById
(
ActionRequest
request
,
ImMsgUpdate
imMsgUpdate
,
String
reqId
)
{
public
void
updateMsgById
(
ActionRequest
request
,
ImMsgUpdate
imMsgUpdate
,
String
reqId
)
{
log
.
info
(
"修改消息内容:{}"
,
JSON
.
toJSONString
(
imMsgUpdate
));
log
.
info
(
"修改消息内容:{}"
,
JSON
.
toJSONString
(
imMsgUpdate
));
WsResponse
<
Boolean
>
wsResponse
=
new
WsResponse
<>();
WsResponse
<
Boolean
>
wsResponse
=
new
WsResponse
<>();
...
@@ -84,6 +88,7 @@ public class MessageAction {
...
@@ -84,6 +88,7 @@ public class MessageAction {
* @param reqId
* @param reqId
*/
*/
@ActionMapping
(
"/getHistoryMsg"
)
@ActionMapping
(
"/getHistoryMsg"
)
@ApiOperation
(
"查询某个会话历史消息分页列表"
)
public
void
getHistoryMsg
(
ActionRequest
request
,
ImHistoryMessagePageParam
param
,
String
reqId
)
{
public
void
getHistoryMsg
(
ActionRequest
request
,
ImHistoryMessagePageParam
param
,
String
reqId
)
{
log
.
info
(
"查询某个会话历史消息分页列表:{}"
,
JSON
.
toJSONString
(
param
));
log
.
info
(
"查询某个会话历史消息分页列表:{}"
,
JSON
.
toJSONString
(
param
));
WsResponse
<
Paging
<
OfflineMsgDto
>>
wsResponse
=
new
WsResponse
<>();
WsResponse
<
Paging
<
OfflineMsgDto
>>
wsResponse
=
new
WsResponse
<>();
...
@@ -98,6 +103,7 @@ public class MessageAction {
...
@@ -98,6 +103,7 @@ public class MessageAction {
* @param reqId
* @param reqId
*/
*/
@ActionMapping
(
"/getReaders"
)
@ActionMapping
(
"/getReaders"
)
@ApiOperation
(
"查询某个消息已读client列表和未读client"
)
public
void
getReaders
(
ActionRequest
request
,
GetReadersParam
param
,
String
reqId
)
{
public
void
getReaders
(
ActionRequest
request
,
GetReadersParam
param
,
String
reqId
)
{
log
.
info
(
"查询某个消息已读client列表和未读client:{}"
,
JSON
.
toJSONString
(
param
));
log
.
info
(
"查询某个消息已读client列表和未读client:{}"
,
JSON
.
toJSONString
(
param
));
WsResponse
<
ReaderList
>
wsResponse
=
new
WsResponse
<>();
WsResponse
<
ReaderList
>
wsResponse
=
new
WsResponse
<>();
...
...
core/src/main/java/com/wecloud/im/action/NormalChatAction.java
View file @
716bdd11
...
@@ -36,6 +36,7 @@ import io.geekidea.springbootplus.framework.common.api.ApiCode;
...
@@ -36,6 +36,7 @@ import io.geekidea.springbootplus.framework.common.api.ApiCode;
import
io.geekidea.springbootplus.framework.common.api.ApiResult
;
import
io.geekidea.springbootplus.framework.common.api.ApiResult
;
import
io.netty.channel.Channel
;
import
io.netty.channel.Channel
;
import
io.netty.channel.socket.nio.NioSocketChannel
;
import
io.netty.channel.socket.nio.NioSocketChannel
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -78,6 +79,7 @@ public class NormalChatAction {
...
@@ -78,6 +79,7 @@ public class NormalChatAction {
private
MqSender
mqSender
;
private
MqSender
mqSender
;
@ActionMapping
(
"/normal/send"
)
@ActionMapping
(
"/normal/send"
)
@ApiOperation
(
"普通消息发送"
)
public
void
sendMsg
(
ActionRequest
request
,
ChatContentVo
data
,
String
reqId
)
{
public
void
sendMsg
(
ActionRequest
request
,
ChatContentVo
data
,
String
reqId
)
{
if
(
log
.
isDebugEnabled
())
{
if
(
log
.
isDebugEnabled
())
{
log
.
debug
(
"接收到参数,reqId: {},\n data: {}, "
,
reqId
,
data
);
log
.
debug
(
"接收到参数,reqId: {},\n data: {}, "
,
reqId
,
data
);
...
...
core/src/main/java/com/wecloud/im/thousandchat/action/ThousandChatAction.java
View file @
716bdd11
...
@@ -20,6 +20,8 @@ import com.wecloud.im.service.ImConversationMembersService;
...
@@ -20,6 +20,8 @@ import com.wecloud.im.service.ImConversationMembersService;
import
com.wecloud.im.service.ImConversationService
;
import
com.wecloud.im.service.ImConversationService
;
import
com.wecloud.im.service.ImMessageService
;
import
com.wecloud.im.service.ImMessageService
;
import
com.wecloud.im.thousandchat.cache.ThousandChatCacheManager
;
import
com.wecloud.im.thousandchat.cache.ThousandChatCacheManager
;
import
com.wecloud.im.thousandchat.param.LastestReceivedMsg
;
import
com.wecloud.im.thousandchat.service.ThousandChatService
;
import
com.wecloud.im.ws.enums.WsResponseCmdEnum
;
import
com.wecloud.im.ws.enums.WsResponseCmdEnum
;
import
com.wecloud.im.ws.model.WsResponse
;
import
com.wecloud.im.ws.model.WsResponse
;
import
com.wecloud.im.ws.sender.ChannelSender
;
import
com.wecloud.im.ws.sender.ChannelSender
;
...
@@ -31,9 +33,16 @@ import io.geekidea.springbootplus.framework.common.api.ApiCode;
...
@@ -31,9 +33,16 @@ import io.geekidea.springbootplus.framework.common.api.ApiCode;
import
io.geekidea.springbootplus.framework.common.api.ApiResult
;
import
io.geekidea.springbootplus.framework.common.api.ApiResult
;
import
io.netty.channel.Channel
;
import
io.netty.channel.Channel
;
import
io.netty.channel.socket.nio.NioSocketChannel
;
import
io.netty.channel.socket.nio.NioSocketChannel
;
import
io.swagger.annotations.Api
;
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.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.validation.annotation.Validated
;
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.RestController
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -46,7 +55,8 @@ import java.util.Map;
...
@@ -46,7 +55,8 @@ import java.util.Map;
*/
*/
@Slf4j
@Slf4j
@Component
@Component
@ActionMapping
(
value
=
"/chat"
)
@ActionMapping
@Api
(
value
=
"万人群消息处理"
,
tags
=
{
"万人群消息处理"
})
public
class
ThousandChatAction
{
public
class
ThousandChatAction
{
@Autowired
@Autowired
...
@@ -63,11 +73,14 @@ public class ThousandChatAction {
...
@@ -63,11 +73,14 @@ public class ThousandChatAction {
private
ChannelSender
channelSender
;
private
ChannelSender
channelSender
;
@Autowired
@Autowired
private
ThousandChatCacheManager
thousandChatCacheManager
;
private
ThousandChatCacheManager
thousandChatCacheManager
;
@Autowired
private
ThousandChatService
thousandChatService
;
@Autowired
@Autowired
private
MqSender
mqSender
;
private
MqSender
mqSender
;
@ActionMapping
(
"/thousand/send"
)
@ActionMapping
(
"/chat/thousand/send"
)
@ApiOperation
(
value
=
"万人群消息发送"
)
public
void
sendMsg
(
ActionRequest
request
,
ChatContentVo
data
,
String
reqId
)
{
public
void
sendMsg
(
ActionRequest
request
,
ChatContentVo
data
,
String
reqId
)
{
if
(
log
.
isDebugEnabled
())
{
if
(
log
.
isDebugEnabled
())
{
log
.
debug
(
"接收到参数,reqId: {},\n data: {}, "
,
data
);
log
.
debug
(
"接收到参数,reqId: {},\n data: {}, "
,
data
);
...
@@ -132,6 +145,24 @@ public class ThousandChatAction {
...
@@ -132,6 +145,24 @@ public class ThousandChatAction {
}
}
/**
/**
* 消息修改为已接收状态
*/
@ActionMapping
(
"/imState/msgReceivedUpdate"
)
@ApiOperation
(
value
=
"万人群消息修改为已接收状态"
)
public
ApiResult
<
Boolean
>
updateImMsgReceived
(
@RequestBody
@Validated
LastestReceivedMsg
lastestReceivedMsg
)
{
return
thousandChatService
.
updateImMsgReceived
(
lastestReceivedMsg
);
}
/**
* 消息修改为已读状态
*/
@ActionMapping
(
"/imState/msgReadUpdate"
)
@ApiOperation
(
value
=
"万人群消息修改为已读状态"
)
public
ApiResult
<
Boolean
>
updateInMsgReadUpdate
(
Long
lastestMsgId
)
{
return
thousandChatService
.
updateImMsgRead
(
lastestMsgId
);
}
/**
* 发送消息给在线客户
* 发送消息给在线客户
* @param data
* @param data
* @param imMessageOnlineSend
* @param imMessageOnlineSend
...
...
core/src/main/java/com/wecloud/im/thousandchat/controller/ThousandChatController.java
View file @
716bdd11
...
@@ -20,29 +20,11 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -20,29 +20,11 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
@Slf4j
@RestController
@RestController
@RequestMapping
(
"/imState"
)
@RequestMapping
(
"/imState"
)
@Api
(
value
=
"万人群消息处理API"
,
tags
=
{
"万人群消息处理"
})
@Api
(
value
=
"万人群消息处理API"
,
tags
=
{
"万人群消息处理
API
"
})
public
class
ThousandChatController
extends
BaseController
{
public
class
ThousandChatController
extends
BaseController
{
@Autowired
@Autowired
private
ThousandChatService
thousandChatService
;
private
ThousandChatService
thousandChatService
;
/**
* 消息修改为已接收状态
*/
@PostMapping
(
"/msgReceivedUpdate"
)
@ApiOperation
(
value
=
"万人群消息修改为已接收状态"
)
public
ApiResult
<
Boolean
>
updateImMsgReceived
(
@RequestBody
@Validated
LastestReceivedMsg
lastestReceivedMsg
)
{
return
thousandChatService
.
updateImMsgReceived
(
lastestReceivedMsg
);
}
/**
* 消息修改为已读状态
*/
@PostMapping
(
"/msgReadUpdate"
)
@ApiOperation
(
value
=
"万人群消息修改为已读状态"
)
public
ApiResult
<
Boolean
>
updateInMsgReadUpdate
(
Long
lastestMsgId
)
{
return
thousandChatService
.
updateImMsgRead
(
lastestMsgId
);
}
}
}
core/src/main/java/com/wecloud/im/thousandchat/param/LastestReceivedMsg.java
View file @
716bdd11
package
com
.
wecloud
.
im
.
thousandchat
.
param
;
package
com
.
wecloud
.
im
.
thousandchat
.
param
;
import
com.wecloud.dispatch.common.BaseRequest
;
import
io.geekidea.springbootplus.framework.common.entity.BaseEntity
;
import
io.geekidea.springbootplus.framework.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
...
@@ -9,6 +10,7 @@ import lombok.experimental.Accessors;
...
@@ -9,6 +10,7 @@ import lombok.experimental.Accessors;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
/**
/**
* @author lixiaozhong
* @author lixiaozhong
...
@@ -16,9 +18,8 @@ import javax.validation.constraints.NotNull;
...
@@ -16,9 +18,8 @@ import javax.validation.constraints.NotNull;
*/
*/
@Data
@Data
@Accessors
(
chain
=
true
)
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
value
=
"LastestReceivedMsg"
)
@ApiModel
(
value
=
"ImMsgReceivedStatusUpdate"
)
public
class
LastestReceivedMsg
implements
Serializable
{
public
class
LastestReceivedMsg
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"消息id,只需要发送最新的一条已接收消息"
,
required
=
true
)
@ApiModelProperty
(
value
=
"消息id,只需要发送最新的一条已接收消息"
,
required
=
true
)
...
...
core/src/main/java/com/wecloud/im/ws/sender/ChannelSender.java
View file @
716bdd11
...
@@ -43,7 +43,7 @@ public class ChannelSender {
...
@@ -43,7 +43,7 @@ public class ChannelSender {
* 指定ip调用,router=address;
* 指定ip调用,router=address;
* injvm = false要设置成false,否则会调用到本地提供者
* injvm = false要设置成false,否则会调用到本地提供者
*/
*/
@DubboReference
(
injvm
=
false
,
interfaceClass
=
RouterSendService
.
class
,
parameters
=
{
"router"
,
"address"
})
@DubboReference
(
injvm
=
false
,
check
=
false
,
interfaceClass
=
RouterSendService
.
class
,
parameters
=
{
"router"
,
"address"
})
private
RouterSendService
routerSendService
;
private
RouterSendService
routerSendService
;
/**
/**
...
...
framework/pom.xml
View file @
716bdd11
...
@@ -68,10 +68,10 @@
...
@@ -68,10 +68,10 @@
<groupId>
io.springfox
</groupId>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
<artifactId>
springfox-swagger2
</artifactId>
</dependency>
</dependency>
<dependency
>
<!-- <dependency>--
>
<groupId>
io.springfox
</groupId
>
<!-- <groupId>io.springfox</groupId>--
>
<artifactId>
springfox-swagger-ui
</artifactId
>
<!-- <artifactId>springfox-swagger-ui</artifactId>--
>
</dependency
>
<!-- </dependency>--
>
<!-- swagger end -->
<!-- swagger end -->
<dependency>
<dependency>
<groupId>
com.github.xiaoymin
</groupId>
<groupId>
com.github.xiaoymin
</groupId>
...
...
pom.xml
View file @
716bdd11
...
@@ -158,11 +158,11 @@
...
@@ -158,11 +158,11 @@
<artifactId>
springfox-swagger2
</artifactId>
<artifactId>
springfox-swagger2
</artifactId>
<version>
${swagger2.version}
</version>
<version>
${swagger2.version}
</version>
</dependency>
</dependency>
<dependency
>
<!-- <dependency>--
>
<groupId>
io.springfox
</groupId
>
<!-- <groupId>io.springfox</groupId>--
>
<artifactId>
springfox-swagger-ui
</artifactId
>
<!-- <artifactId>springfox-swagger-ui</artifactId>--
>
<version>
${swagger2.version}
</version
>
<!-- <version>${swagger2.version}</version>--
>
</dependency
>
<!-- </dependency>--
>
<!-- swagger end -->
<!-- swagger end -->
<dependency>
<dependency>
...
...
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