mirror of
https://github.com/zongzibinbin/MallChat.git
synced 2026-03-13 21:53:41 +08:00
优化
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.abin.mallchat.common.common.annotation;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
@@ -75,6 +75,4 @@ public class FrequencyControlAspect {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#todo 记得把这些配置信息补充了
|
||||
##################mysql配置##################
|
||||
mallchat.mysql.ip=127.0.0.1
|
||||
mallchat.mysql.port=3306
|
||||
mallchat.mysql.db=mallchat
|
||||
mallchat.mysql.username=root
|
||||
mallchat.mysql.password=123456
|
||||
##################redis配置##################
|
||||
mallchat.redis.host=127.0.0.1
|
||||
mallchat.redis.port=6379
|
||||
mallchat.redis.password=123456
|
||||
##################jwt##################
|
||||
mallchat.jwt.secret=dsfsdfsdfsdfsd
|
||||
##################微信公众号信息##################
|
||||
mallchat.wx.callback=http://127.0.0.1:8080
|
||||
mallchat.wx.appId=appid
|
||||
mallchat.wx.secret=380bfc1c9147fdsf4sf07
|
||||
# 接口配置里的Token值
|
||||
mallchat.wx.token=sdfsf
|
||||
# 接口配置里的EncodingAESKey值
|
||||
mallchat.wx.aesKey=sha1
|
||||
@@ -2,6 +2,7 @@ package com.abin.mallchat.custom.chat.controller;
|
||||
|
||||
|
||||
import com.abin.mallchat.common.common.annotation.FrequencyControl;
|
||||
import com.abin.mallchat.common.common.annotation.FrequencyControlContainer;
|
||||
import com.abin.mallchat.common.common.domain.vo.request.CursorPageBaseReq;
|
||||
import com.abin.mallchat.common.common.domain.vo.response.ApiResult;
|
||||
import com.abin.mallchat.common.common.domain.vo.response.CursorPageBaseResp;
|
||||
@@ -68,14 +69,14 @@ public class ChatController {
|
||||
@FrequencyControl(time = 60, count = 10, target = FrequencyControl.Target.UID)
|
||||
public ApiResult<ChatMessageResp> sendMsg(@Valid @RequestBody ChatMessageReq request) {
|
||||
Long msgId = chatService.sendMsg(request, RequestHolder.get().getUid());
|
||||
//返回完整消息格式,方便前展示
|
||||
//返回完整消息格式,方便前端展示
|
||||
return ApiResult.success(chatService.getMsgResp(msgId, RequestHolder.get().getUid()));
|
||||
}
|
||||
|
||||
@PutMapping("/msg/mark")
|
||||
@ApiOperation("消息标记")
|
||||
@FrequencyControl(time = 20, count = 3, target = FrequencyControl.Target.UID)
|
||||
public ApiResult<Void> setMsgMark(@Valid @RequestBody ChatMessageMarkReq request) {//分布式锁
|
||||
public ApiResult<Void> setMsgMark(@Valid @RequestBody ChatMessageMarkReq request) {
|
||||
chatService.setMsgMark(RequestHolder.get().getUid(), request);
|
||||
return ApiResult.success();
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.abin.mallchat.common.chat.domain.dto.ChatMessageMarkDTO;
|
||||
import com.abin.mallchat.common.chat.domain.entity.Message;
|
||||
import com.abin.mallchat.common.chat.domain.entity.MessageMark;
|
||||
import com.abin.mallchat.common.chat.domain.entity.Room;
|
||||
import com.abin.mallchat.common.common.annotation.RedissonLock;
|
||||
import com.abin.mallchat.common.common.domain.enums.YesOrNoEnum;
|
||||
import com.abin.mallchat.common.common.domain.vo.request.CursorPageBaseReq;
|
||||
import com.abin.mallchat.common.common.domain.vo.response.CursorPageBaseResp;
|
||||
@@ -168,6 +169,7 @@ public class ChatServiceImpl implements ChatService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@RedissonLock(key = "#uid")
|
||||
public void setMsgMark(Long uid, ChatMessageMarkReq request) {
|
||||
//用户对该消息的标记
|
||||
MessageMark messageMark = messageMarkDao.get(uid, request.getMsgId(), request.getMarkType());
|
||||
|
||||
@@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.bean.WxOAuth2UserInfo;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpUser;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -54,6 +55,8 @@ public class UserAdapter {
|
||||
resp.setObtain(obtainItemSet.contains(a.getId()) ? YesOrNoEnum.YES.getStatus() : YesOrNoEnum.NO.getStatus());
|
||||
resp.setWearing(ObjectUtil.equal(a.getId(), user.getItemId()) ? YesOrNoEnum.YES.getStatus() : YesOrNoEnum.NO.getStatus());
|
||||
return resp;
|
||||
}).collect(Collectors.toList());
|
||||
}).sorted(Comparator.comparing(BadgeResp::getWearing, Comparator.reverseOrder())
|
||||
.thenComparing(BadgeResp::getObtain, Comparator.reverseOrder()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user