mirror of
https://github.com/zongzibinbin/MallChat.git
synced 2026-03-14 06:03:42 +08:00
feat:消息标记重构
This commit is contained in:
@@ -16,12 +16,22 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ChatMessageMarkDTO {
|
||||
|
||||
@ApiModelProperty("操作者")
|
||||
private Long uid;
|
||||
|
||||
@ApiModelProperty("消息id")
|
||||
private Long msgId;
|
||||
|
||||
/**
|
||||
* @see com.abin.mallchat.common.chat.domain.enums.MessageMarkTypeEnum
|
||||
*/
|
||||
@ApiModelProperty("标记类型 1点赞 2举报")
|
||||
private Integer markType;
|
||||
|
||||
/**
|
||||
* @see com.abin.mallchat.common.chat.domain.enums.MessageMarkActTypeEnum
|
||||
*/
|
||||
@ApiModelProperty("动作类型 1确认 2取消")
|
||||
private Integer actType;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.abin.mallchat.common.chat.domain.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Description: 消息标记动作类型
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-03-19
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum MessageMarkActTypeEnum {
|
||||
MARK(1, "确认标记"),
|
||||
UN_MARK(2, "取消标记"),
|
||||
;
|
||||
|
||||
private final Integer type;
|
||||
private final String desc;
|
||||
|
||||
private static Map<Integer, MessageMarkActTypeEnum> cache;
|
||||
|
||||
static {
|
||||
cache = Arrays.stream(MessageMarkActTypeEnum.values()).collect(Collectors.toMap(MessageMarkActTypeEnum::getType, Function.identity()));
|
||||
}
|
||||
|
||||
public static MessageMarkActTypeEnum of(Integer type) {
|
||||
return cache.get(type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.abin.mallchat.common.common.domain.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Description: 是否正常的通用枚举
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-03-19
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum NormalOrNoEnum {
|
||||
NORMAL(0, "正常"),
|
||||
NOT_NORMAL(1, "不正常"),
|
||||
;
|
||||
|
||||
private final Integer status;
|
||||
private final String desc;
|
||||
|
||||
private static Map<Integer, NormalOrNoEnum> cache;
|
||||
|
||||
static {
|
||||
cache = Arrays.stream(NormalOrNoEnum.values()).collect(Collectors.toMap(NormalOrNoEnum::getStatus, Function.identity()));
|
||||
}
|
||||
|
||||
public static NormalOrNoEnum of(Integer type) {
|
||||
return cache.get(type);
|
||||
}
|
||||
|
||||
public static Integer toStatus(Boolean bool) {
|
||||
return bool ? NORMAL.getStatus() : NOT_NORMAL.getStatus();
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,8 @@ public enum CommonErrorEnum implements ErrorEnum {
|
||||
FREQUENCY_LIMIT(-3, "请求太频繁了,请稍后再试哦~~"),
|
||||
LOCK_LIMIT(-4, "请求太频繁了,请稍后再试哦~~"),
|
||||
;
|
||||
private Integer code;
|
||||
private String msg;
|
||||
private final Integer code;
|
||||
private final String msg;
|
||||
|
||||
@Override
|
||||
public Integer getErrorCode() {
|
||||
|
||||
@@ -2,10 +2,7 @@ package com.abin.mallchat.common.common.factory;
|
||||
|
||||
import com.abin.mallchat.common.common.handler.GlobalUncaughtExceptionHandler;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
@@ -13,14 +10,12 @@ import java.util.concurrent.ThreadFactory;
|
||||
@AllArgsConstructor
|
||||
public class MyThreadFactory implements ThreadFactory {
|
||||
|
||||
private ThreadFactory factory;
|
||||
private final ThreadFactory factory;
|
||||
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
Thread thread =factory.newThread(r);
|
||||
thread.setUncaughtExceptionHandler(new GlobalUncaughtExceptionHandler());
|
||||
thread.setDaemon(false);
|
||||
thread.setPriority(5);
|
||||
return thread;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.abin.mallchat.common.common.handler;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@@ -10,7 +8,7 @@ public class GlobalUncaughtExceptionHandler implements Thread.UncaughtException
|
||||
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
log.error("{} task execute is error",t.getName());
|
||||
log.error("Exception in thread {} ", t.getName(), e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user