1.新增爱心、愤怒、礼炮、火箭等消息标记
2.优化群解散缓存
This commit is contained in:
@@ -15,21 +15,36 @@ import java.util.stream.Collectors;
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum MessageMarkTypeEnum {
|
||||
LIKE(1, "点赞", 10),
|
||||
DISLIKE(2, "点踩", 5),
|
||||
;
|
||||
LIKE(1, "点赞", 10),
|
||||
DISLIKE(2, "点踩", 5),
|
||||
// 新增表情互动类型
|
||||
HEART(3, "爱心", 15), // 表达喜爱
|
||||
ANGRY(4, "愤怒", 20), // 表达不满
|
||||
CELEBRATE(5, "礼炮", 30), // 庆祝消息
|
||||
ROCKET(6, "火箭", 50), // 超级认可
|
||||
LOL(7, "笑哭", 15), // 觉得有趣
|
||||
APPLAUSE(8, "鼓掌", 25), // 表示赞赏
|
||||
FLOWER(9, "鲜花", 20), // 送花支持
|
||||
BOMB(10, "炸弹", 40), // 强烈反对
|
||||
CONFUSED(11, "疑问", 15), // 表示疑惑
|
||||
VICTORY(12, "胜利", 35), // 庆祝胜利
|
||||
LIGHT(13, "灯光", 30), // 打call支持
|
||||
MONEY(14, "红包", 45); // 打赏支持
|
||||
|
||||
private final Integer type;
|
||||
private final String desc;
|
||||
private final Integer riseNum;//需要多少个标记升级
|
||||
private final Integer type;
|
||||
private final String desc;
|
||||
private final Integer riseNum; // 需要多少个标记升级
|
||||
|
||||
private static Map<Integer, MessageMarkTypeEnum> cache;
|
||||
private static final Map<Integer, MessageMarkTypeEnum> CACHE;
|
||||
|
||||
static {
|
||||
cache = Arrays.stream(MessageMarkTypeEnum.values()).collect(Collectors.toMap(MessageMarkTypeEnum::getType, Function.identity()));
|
||||
}
|
||||
static {
|
||||
CACHE = Arrays.stream(values()).collect(Collectors.toMap(
|
||||
MessageMarkTypeEnum::getType,
|
||||
Function.identity()
|
||||
));
|
||||
}
|
||||
|
||||
public static MessageMarkTypeEnum of(Integer type) {
|
||||
return cache.get(type);
|
||||
}
|
||||
}
|
||||
public static MessageMarkTypeEnum of(Integer type) {
|
||||
return CACHE.get(type);
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,9 @@ public class ChatMessageMarkReq {
|
||||
@Schema(description ="消息id")
|
||||
private Long msgId;
|
||||
|
||||
/**
|
||||
* @see com.hula.core.chat.domain.enums.MessageMarkTypeEnum
|
||||
*/
|
||||
@NotNull
|
||||
@Schema(description ="标记类型 1点赞 2举报")
|
||||
private Integer markType;
|
||||
|
||||
@@ -20,4 +20,7 @@ public class MemberExitReq {
|
||||
@NotNull
|
||||
@Schema(description ="会话id")
|
||||
private Long roomId;
|
||||
|
||||
@Schema(description ="搜索关键字")
|
||||
private String account;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.hula.core.chat.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.hula.core.chat.service.adapter.RoomAdapter;
|
||||
import com.hula.core.chat.service.cache.RoomGroupCache;
|
||||
import com.hula.enums.CommonErrorEnum;
|
||||
@@ -128,6 +129,9 @@ public class GroupMemberServiceImpl implements IGroupMemberService {
|
||||
boolean isDelRoom = roomDao.removeById(roomId);
|
||||
roomGroupCache.removeById(roomGroup.getId());
|
||||
roomGroupCache.evictGroup(roomGroup.getAccount());
|
||||
if(StrUtil.isNotEmpty(request.getAccount())){
|
||||
roomGroupCache.evictGroup(request.getAccount());
|
||||
}
|
||||
AssertUtil.isTrue(isDelRoom, CommonErrorEnum.SYSTEM_ERROR);
|
||||
// 4.2 删除会话
|
||||
Boolean isDelContact = contactDao.removeByRoomId(roomId, Collections.EMPTY_LIST);
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.hula.core.chat.service.strategy.mark;
|
||||
|
||||
import com.hula.core.chat.domain.enums.MessageMarkTypeEnum;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 愤怒标记策略
|
||||
* @author 乾乾
|
||||
*/
|
||||
@Component
|
||||
public class AngryStrategy extends AbstractMsgMarkStrategy {
|
||||
@Override
|
||||
protected MessageMarkTypeEnum getTypeEnum() {
|
||||
return MessageMarkTypeEnum.ANGRY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doMark(Long uid, Long msgId) {
|
||||
super.doMark(uid, msgId);
|
||||
// 标记愤怒时清除正向表情
|
||||
MsgMarkFactory.getStrategyNoNull(MessageMarkTypeEnum.LIKE.getType()).unMark(uid, msgId);
|
||||
MsgMarkFactory.getStrategyNoNull(MessageMarkTypeEnum.HEART.getType()).unMark(uid, msgId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.hula.core.chat.service.strategy.mark;
|
||||
|
||||
import com.hula.core.chat.domain.enums.MessageMarkTypeEnum;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 鼓掌标记策略
|
||||
* @author 乾乾
|
||||
*/
|
||||
@Component
|
||||
public class ApplauseStrategy extends AbstractMsgMarkStrategy {
|
||||
@Override
|
||||
protected MessageMarkTypeEnum getTypeEnum() {
|
||||
return MessageMarkTypeEnum.APPLAUSE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.hula.core.chat.service.strategy.mark;
|
||||
|
||||
import com.hula.core.chat.domain.enums.MessageMarkTypeEnum;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 炸弹标记策略
|
||||
* @author 乾乾
|
||||
*/
|
||||
@Component
|
||||
public class BombStrategy extends AbstractMsgMarkStrategy {
|
||||
@Override
|
||||
protected MessageMarkTypeEnum getTypeEnum() {
|
||||
return MessageMarkTypeEnum.BOMB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doMark(Long uid, Long msgId) {
|
||||
super.doMark(uid, msgId);
|
||||
// 使用炸弹时清除正向标记
|
||||
MsgMarkFactory.getStrategyNoNull(MessageMarkTypeEnum.LIKE.getType()).unMark(uid, msgId);
|
||||
MsgMarkFactory.getStrategyNoNull(MessageMarkTypeEnum.MONEY.getType()).unMark(uid, msgId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.hula.core.chat.service.strategy.mark;
|
||||
|
||||
import com.hula.core.chat.domain.enums.MessageMarkTypeEnum;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 礼炮标记策略
|
||||
* @author 乾乾
|
||||
*/
|
||||
@Component
|
||||
public class CelebrateStrategy extends AbstractMsgMarkStrategy {
|
||||
@Override
|
||||
protected MessageMarkTypeEnum getTypeEnum() {
|
||||
return MessageMarkTypeEnum.CELEBRATE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.hula.core.chat.service.strategy.mark;
|
||||
|
||||
import com.hula.core.chat.domain.enums.MessageMarkTypeEnum;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 疑问标记策略
|
||||
* @author 乾乾
|
||||
*/
|
||||
@Component
|
||||
public class ConfusedStrategy extends AbstractMsgMarkStrategy {
|
||||
@Override
|
||||
protected MessageMarkTypeEnum getTypeEnum() {
|
||||
return MessageMarkTypeEnum.CONFUSED;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.hula.core.chat.service.strategy.mark;
|
||||
|
||||
import com.hula.core.chat.domain.enums.MessageMarkTypeEnum;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 鲜花标记策略
|
||||
* @author 乾乾
|
||||
*/
|
||||
@Component
|
||||
public class FlowerStrategy extends AbstractMsgMarkStrategy {
|
||||
@Override
|
||||
protected MessageMarkTypeEnum getTypeEnum() {
|
||||
return MessageMarkTypeEnum.FLOWER;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.hula.core.chat.service.strategy.mark;
|
||||
|
||||
import com.hula.core.chat.domain.enums.MessageMarkTypeEnum;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 爱心标记策略
|
||||
* @author 乾乾
|
||||
*/
|
||||
@Component
|
||||
public class HeartStrategy extends AbstractMsgMarkStrategy {
|
||||
@Override
|
||||
protected MessageMarkTypeEnum getTypeEnum() {
|
||||
return MessageMarkTypeEnum.HEART;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.hula.core.chat.service.strategy.mark;
|
||||
|
||||
import com.hula.core.chat.domain.enums.MessageMarkTypeEnum;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 笑哭标记策略
|
||||
* @author 乾乾
|
||||
*/
|
||||
@Component
|
||||
public class LOLStrategy extends AbstractMsgMarkStrategy {
|
||||
@Override
|
||||
protected MessageMarkTypeEnum getTypeEnum() {
|
||||
return MessageMarkTypeEnum.LOL;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.hula.core.chat.service.strategy.mark;
|
||||
|
||||
import com.hula.core.chat.domain.enums.MessageMarkTypeEnum;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 灯光标记策略
|
||||
* @author 乾乾
|
||||
*/
|
||||
@Component
|
||||
public class LightStrategy extends AbstractMsgMarkStrategy {
|
||||
@Override
|
||||
protected MessageMarkTypeEnum getTypeEnum() {
|
||||
return MessageMarkTypeEnum.LIGHT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.hula.core.chat.service.strategy.mark;
|
||||
|
||||
import com.hula.core.chat.domain.enums.MessageMarkTypeEnum;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 红包标记策略
|
||||
* @author 乾乾
|
||||
*/
|
||||
@Component
|
||||
public class MoneyStrategy extends AbstractMsgMarkStrategy {
|
||||
@Override
|
||||
protected MessageMarkTypeEnum getTypeEnum() {
|
||||
return MessageMarkTypeEnum.MONEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doMark(Long uid, Long msgId) {
|
||||
super.doMark(uid, msgId);
|
||||
// 打赏时清除所有负面标记
|
||||
MsgMarkFactory.getStrategyNoNull(MessageMarkTypeEnum.BOMB.getType()).unMark(uid, msgId);
|
||||
MsgMarkFactory.getStrategyNoNull(MessageMarkTypeEnum.DISLIKE.getType()).unMark(uid, msgId);
|
||||
MsgMarkFactory.getStrategyNoNull(MessageMarkTypeEnum.ANGRY.getType()).unMark(uid, msgId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.hula.core.chat.service.strategy.mark;
|
||||
|
||||
import com.hula.core.chat.domain.enums.MessageMarkTypeEnum;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 火箭标记策略
|
||||
* @author 乾乾
|
||||
*/
|
||||
@Component
|
||||
public class RocketStrategy extends AbstractMsgMarkStrategy {
|
||||
@Override
|
||||
protected MessageMarkTypeEnum getTypeEnum() {
|
||||
return MessageMarkTypeEnum.ROCKET;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.hula.core.chat.service.strategy.mark;
|
||||
|
||||
import com.hula.core.chat.domain.enums.MessageMarkTypeEnum;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 胜利标记策略
|
||||
* @author 乾乾
|
||||
*/
|
||||
@Component
|
||||
public class VictoryStrategy extends AbstractMsgMarkStrategy {
|
||||
@Override
|
||||
protected MessageMarkTypeEnum getTypeEnum() {
|
||||
return MessageMarkTypeEnum.VICTORY;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user