fix:聊天会员限制
This commit is contained in:
1 parent
13cdff58bb
commit
20e20f1690
6 files changed
+15
-12
No files matched your search
+1
-1
@@ -292,7 +292,7 @@ public class ChatApiImpl implements ChatApi {
|
||||
*/
|
||||
@Override
|
||||
public ChatPrivateMessageSendResVO send(ChatPrivateMessageSendReqVO dto) {
|
||||
ChatApiTool.API api = setApiConfig(ChatApiTool.PRIVATE_MSG_INFO);
|
||||
ChatApiTool.API api = setApiConfig(ChatApiTool.PRIVATE_MSG_SEND);
|
||||
try {
|
||||
String body = JSONUtil.toJsonStr(dto);
|
||||
String res = HttpRequest.post(api.getFullPath()).header(apiCountersign(body)).body(body).execute().body();
|
||||
|
||||
+1
@@ -26,6 +26,7 @@ public class ChatApiTool {
|
||||
public static final API FRIEND_ADD = API.builder().summary("添加好友").url("/third/friend/add").method(HttpMethod.POST).build();
|
||||
|
||||
// 私聊
|
||||
public static final API PRIVATE_MSG_SEND = API.builder().summary("发送私聊消息").url("/third/privateMsg/send").method(HttpMethod.POST).build();
|
||||
public static final API PRIVATE_MSG_PAGE = API.builder().summary("私聊分页").url("/third/privateMsg/page").method(HttpMethod.POST).build();
|
||||
public static final API PRIVATE_MSG_INFO = API.builder().summary("私聊详情").url("/third/privateMsg/getById").method(HttpMethod.POST).build();
|
||||
public static final API PRIVATE_MSG_COUNT = API.builder().summary("私聊统计").url("/third/privateMsg/dailyCount").method(HttpMethod.POST).build();
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ public class ChatPrivateTotalMessageTotalReqVo {
|
||||
/**
|
||||
* 发送时间范围
|
||||
*/
|
||||
private LocalDateTime[] timeRange;
|
||||
private String[] timeRange;
|
||||
|
||||
|
||||
}
|
||||
+3
-3
@@ -28,8 +28,8 @@ public class AppChatController {
|
||||
@Resource
|
||||
private ChatApi chatApi;
|
||||
|
||||
@GetMapping("/send-private-msg")
|
||||
@Operation(summary = "创建用户反馈")
|
||||
@PostMapping("/send-private-msg")
|
||||
@Operation(summary = "发送私聊消息(有会员限制)")
|
||||
public CommonResult<ChatPrivateMessageSendResVO> sendPrivateMsg(@RequestBody ChatPrivateMessageSendReqVO body) {
|
||||
Long sendId = getLoginUserId();
|
||||
openTypeService.isUserCanSendMessage(sendId, body.getRecvId());
|
||||
@@ -39,7 +39,7 @@ public class AppChatController {
|
||||
}
|
||||
|
||||
@GetMapping("/add-friend")
|
||||
@Operation(summary = "创建用户反馈")
|
||||
@Operation(summary = "添加好友")
|
||||
public CommonResult<Boolean> createFeedback(@RequestParam("friendUserId") Long friendUserId) {
|
||||
Long currentUserId = getLoginUserId();
|
||||
// 相互添加一下好友
|
||||
|
||||
+7
-5
@@ -1,5 +1,7 @@
|
||||
package cn.iocoder.yudao.module.member.service.opentype;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
||||
import cn.iocoder.yudao.module.member.client.service.ChatApi;
|
||||
@@ -178,7 +180,7 @@ public class OpenTypeServiceImpl implements OpenTypeService {
|
||||
@Override
|
||||
public boolean isUserCanSendMessage(Long sendId, Long receiveId) {
|
||||
// 判断是否是会员
|
||||
if (isUserOpenType(sendId)) return true;
|
||||
// if (isUserOpenType(sendId)) return true;
|
||||
// 获取配置
|
||||
MemberConfigDO config = memberConfigService.getConfig();
|
||||
// 普通用户每天可以和几个人聊天
|
||||
@@ -194,9 +196,9 @@ public class OpenTypeServiceImpl implements OpenTypeService {
|
||||
|
||||
ChatPrivateTotalMessageTotalReqVo dto = new ChatPrivateTotalMessageTotalReqVo();
|
||||
dto.setSendId(sendId);
|
||||
dto.setTimeRange(new LocalDateTime[]{
|
||||
startDate,
|
||||
endDate
|
||||
dto.setTimeRange(new String[]{
|
||||
LocalDateTimeUtil.format(startDate, DatePattern.NORM_DATETIME_PATTERN),
|
||||
LocalDateTimeUtil.format(endDate, DatePattern.NORM_DATETIME_PATTERN),
|
||||
});
|
||||
try {
|
||||
List<ChatPrivateTotalMessageTotalResVo> msgList = chatApi.privateTotal(dto);
|
||||
@@ -215,8 +217,8 @@ public class OpenTypeServiceImpl implements OpenTypeService {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("|判断用户是否还可以发送消息|意外的错误:{}", e.getMessage());
|
||||
throw exception(MemberErrorCode.EMPTY, e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void validateOpenTypeExists(Long id) {
|
||||
|
||||
@@ -250,8 +250,8 @@ pf4j:
|
||||
pluginsDir: ../plugins
|
||||
|
||||
chat:
|
||||
# base-url: http://127.0.0.1:8888
|
||||
base-url: http://chatsever.zianxin.com
|
||||
base-url: http://127.0.0.1:8888
|
||||
# base-url: http://chatsever.zianxin.com
|
||||
app-key: 4H2HkBLygMsxaQKO
|
||||
app-secret: JIizm84av3TK5xaQdsng7X5mqLPjbeQ0
|
||||
|
||||
|
||||
Reference in new issue
Block a user