From 2c2131098233f37b424598d633ed8c742f4710bb Mon Sep 17 00:00:00 2001
From: zhongzb <972627721@qq.com>
Date: Sun, 9 Jul 2023 19:46:50 +0800
Subject: [PATCH] =?UTF-8?q?fix:1.=E4=BC=98=E5=8C=96=E8=A1=A8=E6=83=85?=
=?UTF-8?q?=E5=8C=85=E5=8A=9F=E8=83=BD=202.=E4=BC=98=E5=8C=96oss=E5=AD=98?=
=?UTF-8?q?=E5=82=A8=E8=B7=AF=E5=BE=84=203.=E5=88=A0=E9=99=A4=E5=85=BC?=
=?UTF-8?q?=E5=AE=B9=E5=8E=86=E5=8F=B2=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/mallchat.sql | 12 +++
docs/version/2023-07-09.sql | 10 +++
docs/version/user_emojis.sql | 10 ---
.../chat/domain/enums/MessageTypeEnum.java | 2 +-
.../common/domain/vo/request/IdReqVO.java | 20 +++++
.../common/utils/oss/MinIOTemplate.java | 4 +-
.../common/user/dao/UserEmojiDao.java | 28 +++++++
.../domain/entity/UserEmoji.java} | 39 +++++----
.../common/user/mapper/UserEmojiMapper.java | 16 ++++
.../common/user/mapper/UserEmojisMapper.java | 4 +-
.../resources/mapper/user/UserEmojiMapper.xml | 5 ++
.../chat/controller/ChatController.java | 2 +-
.../domain/vo/request/ChatMessageReq.java | 3 +-
.../domain/vo/response/ChatMessageResp.java | 42 ----------
.../chat/service/adapter/MessageAdapter.java | 43 ++--------
.../chat/service/impl/ChatServiceImpl.java | 12 +--
.../strategy/msg/EmojisMsgHandler.java | 3 +-
.../user/controller/UserEmojiController.java | 77 ++++++++++++++++++
.../user/controller/UserEmojisController.java | 78 ------------------
.../user/domain/enums/OssSceneEnum.java | 2 +-
.../domain/vo/request/user/UserEmojiReq.java | 26 ++++++
.../vo/response/user/UserEmojiResp.java | 32 ++++++++
.../custom/user/service/UserEmojiService.java | 45 +++++++++++
.../user/service/UserEmojisService.java | 37 ---------
.../user/service/impl/OssServiceImpl.java | 1 -
.../service/impl/UserEmojiServiceImpl.java | 75 ++++++++++++++++++
.../service/impl/UserEmojisServiceImpl.java | 79 -------------------
27 files changed, 387 insertions(+), 320 deletions(-)
create mode 100644 docs/version/2023-07-09.sql
delete mode 100644 docs/version/user_emojis.sql
create mode 100644 mallchat-common/src/main/java/com/abin/mallchat/common/common/domain/vo/request/IdReqVO.java
create mode 100644 mallchat-common/src/main/java/com/abin/mallchat/common/user/dao/UserEmojiDao.java
rename mallchat-common/src/main/java/com/abin/mallchat/common/{chat/domain/entity/UserEmojis.java => user/domain/entity/UserEmoji.java} (51%)
create mode 100644 mallchat-common/src/main/java/com/abin/mallchat/common/user/mapper/UserEmojiMapper.java
create mode 100644 mallchat-common/src/main/resources/mapper/user/UserEmojiMapper.xml
create mode 100644 mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/controller/UserEmojiController.java
delete mode 100644 mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/controller/UserEmojisController.java
create mode 100644 mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/domain/vo/request/user/UserEmojiReq.java
create mode 100644 mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/domain/vo/response/user/UserEmojiResp.java
create mode 100644 mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/UserEmojiService.java
delete mode 100644 mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/UserEmojisService.java
create mode 100644 mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/UserEmojiServiceImpl.java
delete mode 100644 mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/UserEmojisServiceImpl.java
diff --git a/docs/mallchat.sql b/docs/mallchat.sql
index be0146d..f2db654 100644
--- a/docs/mallchat.sql
+++ b/docs/mallchat.sql
@@ -191,3 +191,15 @@ CREATE TABLE `sensitive_word` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='敏感词库';
INSERT INTO `sensitive_word` (`word`) VALUES ('TMD');
INSERT INTO `sensitive_word` (`word`) VALUES ('tmd');
+
+DROP TABLE IF EXISTS `user_emoji`;
+CREATE TABLE `user_emoji` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+ `uid` bigint(20) NOT NULL COMMENT '用户表ID',
+ `expression_url` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '表情地址',
+ `delete_status` int(1) NOT NULL DEFAULT '0' COMMENT '逻辑删除(0-正常,1-删除)',
+ `create_time` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
+ `update_time` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '修改时间',
+ PRIMARY KEY (`id`) USING BTREE,
+ KEY `IDX_USER_EMOJIS_UID` (`uid`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='用户表情包';
\ No newline at end of file
diff --git a/docs/version/2023-07-09.sql b/docs/version/2023-07-09.sql
new file mode 100644
index 0000000..22ea074
--- /dev/null
+++ b/docs/version/2023-07-09.sql
@@ -0,0 +1,10 @@
+CREATE TABLE `user_emoji` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+ `uid` bigint(20) NOT NULL COMMENT '用户表ID',
+ `expression_url` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '表情地址',
+ `delete_status` int(1) NOT NULL DEFAULT '0' COMMENT '逻辑删除(0-正常,1-删除)',
+ `create_time` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
+ `update_time` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '修改时间',
+ PRIMARY KEY (`id`) USING BTREE,
+ KEY `IDX_USER_EMOJIS_UID` (`uid`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='用户表情包';
\ No newline at end of file
diff --git a/docs/version/user_emojis.sql b/docs/version/user_emojis.sql
deleted file mode 100644
index f0078ce..0000000
--- a/docs/version/user_emojis.sql
+++ /dev/null
@@ -1,10 +0,0 @@
-CREATE TABLE `user_emojis` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
- `uid` bigint(20) NOT NULL COMMENT '用户表ID',
- `expression_url` varchar(255) NOT NULL COMMENT '表情地址',
- `create_time` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
- `update_time` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '修改时间',
- `delete_status` int(1) NOT NULL DEFAULT '0' COMMENT '逻辑删除(0-正常,1-删除)',
- PRIMARY KEY (`id`),
- KEY `IDX_USER_EMOJIS_UID` (`uid`)
-) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='用户表情包';
\ No newline at end of file
diff --git a/mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/enums/MessageTypeEnum.java b/mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/enums/MessageTypeEnum.java
index 7d66214..73d7b97 100644
--- a/mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/enums/MessageTypeEnum.java
+++ b/mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/enums/MessageTypeEnum.java
@@ -22,7 +22,7 @@ public enum MessageTypeEnum {
FILE(4, "文件"),
SOUND(5, "语音"),
VIDEO(6, "视频"),
- EMOJIS(7, "表情"),
+ EMOJI(7, "表情"),
;
private final Integer type;
diff --git a/mallchat-common/src/main/java/com/abin/mallchat/common/common/domain/vo/request/IdReqVO.java b/mallchat-common/src/main/java/com/abin/mallchat/common/common/domain/vo/request/IdReqVO.java
new file mode 100644
index 0000000..9c0f417
--- /dev/null
+++ b/mallchat-common/src/main/java/com/abin/mallchat/common/common/domain/vo/request/IdReqVO.java
@@ -0,0 +1,20 @@
+package com.abin.mallchat.common.common.domain.vo.request;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author zhongzb create on 2021/05/31
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class IdReqVO {
+ @ApiModelProperty("id")
+ @NotNull
+ private long id;
+}
diff --git a/mallchat-common/src/main/java/com/abin/mallchat/common/common/utils/oss/MinIOTemplate.java b/mallchat-common/src/main/java/com/abin/mallchat/common/common/utils/oss/MinIOTemplate.java
index f49a5fa..99e6e6a 100644
--- a/mallchat-common/src/main/java/com/abin/mallchat/common/common/utils/oss/MinIOTemplate.java
+++ b/mallchat-common/src/main/java/com/abin/mallchat/common/common/utils/oss/MinIOTemplate.java
@@ -136,8 +136,8 @@ public class MinIOTemplate {
String uid = Optional.ofNullable(req.getUid()).map(String::valueOf).orElse("000000");
cn.hutool.core.lang.UUID uuid = cn.hutool.core.lang.UUID.fastUUID();
String suffix = FileNameUtil.getSuffix(req.getFileName());
- String year = DateUtil.format(new Date(), DatePattern.NORM_YEAR_PATTERN);
- return req.getFilePath() + StrUtil.SLASH + year + StrUtil.SLASH + uid + StrUtil.SLASH + uuid + StrUtil.DOT + suffix;
+ String yearAndMonth = DateUtil.format(new Date(), DatePattern.NORM_MONTH_PATTERN);
+ return req.getFilePath() + StrUtil.SLASH + yearAndMonth + StrUtil.SLASH + uid + StrUtil.SLASH + uuid + StrUtil.DOT + suffix;
}
/**
diff --git a/mallchat-common/src/main/java/com/abin/mallchat/common/user/dao/UserEmojiDao.java b/mallchat-common/src/main/java/com/abin/mallchat/common/user/dao/UserEmojiDao.java
new file mode 100644
index 0000000..8b8b2ad
--- /dev/null
+++ b/mallchat-common/src/main/java/com/abin/mallchat/common/user/dao/UserEmojiDao.java
@@ -0,0 +1,28 @@
+package com.abin.mallchat.common.user.dao;
+
+import com.abin.mallchat.common.user.domain.entity.UserEmoji;
+import com.abin.mallchat.common.user.mapper.UserEmojiMapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ *
+ * 用户表情包 服务实现类
+ *
+ *
+ * @author abin
+ * @since 2023-07-09
+ */
+@Service
+public class UserEmojiDao extends ServiceImpl {
+
+ public List listByUid(Long uid) {
+ return lambdaQuery().eq(UserEmoji::getUid, uid).list();
+ }
+
+ public int countByUid(Long uid) {
+ return lambdaQuery().eq(UserEmoji::getUid, uid).count();
+ }
+}
diff --git a/mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/entity/UserEmojis.java b/mallchat-common/src/main/java/com/abin/mallchat/common/user/domain/entity/UserEmoji.java
similarity index 51%
rename from mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/entity/UserEmojis.java
rename to mallchat-common/src/main/java/com/abin/mallchat/common/user/domain/entity/UserEmoji.java
index de707ff..4a9f2dd 100644
--- a/mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/entity/UserEmojis.java
+++ b/mallchat-common/src/main/java/com/abin/mallchat/common/user/domain/entity/UserEmoji.java
@@ -1,22 +1,28 @@
-package com.abin.mallchat.common.chat.domain.entity;
+package com.abin.mallchat.common.user.domain.entity;
import com.baomidou.mybatisplus.annotation.*;
-import lombok.Data;
+import lombok.*;
-import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
+ *
* 用户表情包
+ *
*
- * @author: WuShiJie
- * @createTime: 2023/7/2 22:00
+ * @author abin
+ * @since 2023-07-09
*/
@Data
-@TableName(value = "user_emojis")
-public class UserEmojis implements Serializable {
- private static final long serialVersionUID = -7690290707154737263L;
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+@EqualsAndHashCode(callSuper = false)
+@TableName("user_emoji")
+public class UserEmoji implements Serializable {
+
+ private static final long serialVersionUID = 1L;
/**
* id
@@ -27,17 +33,22 @@ public class UserEmojis implements Serializable {
/**
* 用户表ID
*/
- @TableField(value = "uid")
+ @TableField("uid")
private Long uid;
-
/**
* 表情地址
*/
- @NotNull
- @TableField(value = "expression_url")
+ @TableField("expression_url")
private String expressionUrl;
+ /**
+ * 逻辑删除(0-正常,1-删除)
+ */
+ @TableField("delete_status")
+ @TableLogic(value = "0", delval = "1")
+ private Integer deleteStatus;
+
/**
* 创建时间
*/
@@ -50,9 +61,5 @@ public class UserEmojis implements Serializable {
@TableField("update_time")
private Date updateTime;
- @TableField(value = "delete_status")
- @TableLogic(value = "0",delval = "1")
- private Integer deleteStatus;
-
}
diff --git a/mallchat-common/src/main/java/com/abin/mallchat/common/user/mapper/UserEmojiMapper.java b/mallchat-common/src/main/java/com/abin/mallchat/common/user/mapper/UserEmojiMapper.java
new file mode 100644
index 0000000..cc36c9c
--- /dev/null
+++ b/mallchat-common/src/main/java/com/abin/mallchat/common/user/mapper/UserEmojiMapper.java
@@ -0,0 +1,16 @@
+package com.abin.mallchat.common.user.mapper;
+
+import com.abin.mallchat.common.user.domain.entity.UserEmoji;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ *
+ * 用户表情包 Mapper 接口
+ *
+ *
+ * @author abin
+ * @since 2023-07-09
+ */
+public interface UserEmojiMapper extends BaseMapper {
+
+}
diff --git a/mallchat-common/src/main/java/com/abin/mallchat/common/user/mapper/UserEmojisMapper.java b/mallchat-common/src/main/java/com/abin/mallchat/common/user/mapper/UserEmojisMapper.java
index dd6b5b2..2f1fbd2 100644
--- a/mallchat-common/src/main/java/com/abin/mallchat/common/user/mapper/UserEmojisMapper.java
+++ b/mallchat-common/src/main/java/com/abin/mallchat/common/user/mapper/UserEmojisMapper.java
@@ -1,6 +1,6 @@
package com.abin.mallchat.common.user.mapper;
-import com.abin.mallchat.common.chat.domain.entity.UserEmojis;
+import com.abin.mallchat.common.user.domain.entity.UserEmoji;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
@@ -9,5 +9,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author: WuShiJie
* @createTime: 2023/7/3 14:24
*/
-public interface UserEmojisMapper extends BaseMapper {
+public interface UserEmojisMapper extends BaseMapper {
}
diff --git a/mallchat-common/src/main/resources/mapper/user/UserEmojiMapper.xml b/mallchat-common/src/main/resources/mapper/user/UserEmojiMapper.xml
new file mode 100644
index 0000000..eea5b91
--- /dev/null
+++ b/mallchat-common/src/main/resources/mapper/user/UserEmojiMapper.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/controller/ChatController.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/controller/ChatController.java
index 1f32401..10bbbd6 100644
--- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/controller/ChatController.java
+++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/controller/ChatController.java
@@ -84,7 +84,7 @@ public class ChatController {
@GetMapping("/public/msg/page")
@ApiOperation("消息列表")
@FrequencyControl(time = 120, count = 20, target = FrequencyControl.Target.IP)
- public ApiResult> getMsgPage1(@Valid ChatMessagePageReq request) {
+ public ApiResult> getMsgPage(@Valid ChatMessagePageReq request) {
// black(request);
CursorPageBaseResp msgPage = chatService.getMsgPage(request, RequestHolder.get().getUid());
filterBlackMsg(msgPage);
diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/domain/vo/request/ChatMessageReq.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/domain/vo/request/ChatMessageReq.java
index 2fd2040..b255a34 100644
--- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/domain/vo/request/ChatMessageReq.java
+++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/domain/vo/request/ChatMessageReq.java
@@ -1,6 +1,5 @@
package com.abin.mallchat.custom.chat.domain.vo.request;
-import com.abin.mallchat.common.chat.domain.enums.MessageTypeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -30,7 +29,7 @@ public class ChatMessageReq {
@ApiModelProperty("消息类型")
@NotNull
- private Integer msgType = MessageTypeEnum.TEXT.getType();
+ private Integer msgType;
@ApiModelProperty("消息内容,类型不同传值不同,见https://www.yuque.com/snab/mallcaht/rkb2uz5k1qqdmcmd")
@NotNull
diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/domain/vo/response/ChatMessageResp.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/domain/vo/response/ChatMessageResp.java
index 2cfed96..096eaf7 100644
--- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/domain/vo/response/ChatMessageResp.java
+++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/domain/vo/response/ChatMessageResp.java
@@ -1,6 +1,5 @@
package com.abin.mallchat.custom.chat.domain.vo.response;
-import com.abin.mallchat.common.common.utils.discover.domain.UrlInfo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -8,7 +7,6 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
-import java.util.Map;
/**
* Description: 消息
@@ -28,16 +26,8 @@ public class ChatMessageResp {
@Data
public static class UserInfo {
- @ApiModelProperty("用户名称")
- private String username;
@ApiModelProperty("用户id")
private Long uid;
- @ApiModelProperty("头像")
- private String avatar;
- @ApiModelProperty("归属地")
- private String locPlace;
- @ApiModelProperty("徽章标识,如果没有展示null")
- private Badge badge;
}
@Data
@@ -46,36 +36,12 @@ public class ChatMessageResp {
private Long id;
@ApiModelProperty("消息发送时间")
private Date sendTime;
- @ApiModelProperty("消息内容-废弃")
- @Deprecated
- private String content;
- @ApiModelProperty("消息链接映射-废弃")
- @Deprecated
- private Map urlContentMap;
@ApiModelProperty("消息类型 1正常文本 2.撤回消息")
private Integer type;
@ApiModelProperty("消息内容不同的消息类型,内容体不同,见https://www.yuque.com/snab/mallcaht/rkb2uz5k1qqdmcmd")
private Object body;
@ApiModelProperty("消息标记")
private MessageMark messageMark;
- @ApiModelProperty("父消息,如果没有父消息,返回的是null")
- private ReplyMsg reply;
-
- }
-
- @Data
- @Deprecated
- public static class ReplyMsg {
- @ApiModelProperty("消息id")
- private Long id;
- @ApiModelProperty("用户名称")
- private String username;
- @ApiModelProperty("消息内容")
- private String content;
- @ApiModelProperty("是否可消息跳转 0否 1是")
- private Integer canCallback;
- @ApiModelProperty("跳转间隔的消息条数")
- private Integer gapCount;
}
@Data
@@ -89,12 +55,4 @@ public class ChatMessageResp {
@ApiModelProperty("该用户是否已经举报 0否 1是")
private Integer userDislike;
}
-
- @Data
- public static class Badge {
- @ApiModelProperty("徽章图像")
- private String img;
- @ApiModelProperty("徽章说明")
- private String describe;
- }
}
diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/adapter/MessageAdapter.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/adapter/MessageAdapter.java
index a751ad6..38f0a3c 100644
--- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/adapter/MessageAdapter.java
+++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/adapter/MessageAdapter.java
@@ -3,14 +3,9 @@ package com.abin.mallchat.custom.chat.service.adapter;
import cn.hutool.core.bean.BeanUtil;
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.msg.MessageExtra;
import com.abin.mallchat.common.chat.domain.enums.MessageMarkTypeEnum;
import com.abin.mallchat.common.chat.domain.enums.MessageStatusEnum;
import com.abin.mallchat.common.common.domain.enums.YesOrNoEnum;
-import com.abin.mallchat.common.user.domain.entity.IpDetail;
-import com.abin.mallchat.common.user.domain.entity.IpInfo;
-import com.abin.mallchat.common.user.domain.entity.ItemConfig;
-import com.abin.mallchat.common.user.domain.entity.User;
import com.abin.mallchat.custom.chat.domain.vo.request.ChatMessageReq;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatMessageResp;
import com.abin.mallchat.custom.chat.service.strategy.msg.AbstractMsgHandler;
@@ -38,37 +33,25 @@ public class MessageAdapter {
}
- public static List buildMsgResp(List messages, Map replyMap, Map userMap, List msgMark, Long receiveUid, Map itemMap) {
+ public static List buildMsgResp(List messages, Map replyMap, List msgMark, Long receiveUid) {
Map> markMap = msgMark.stream().collect(Collectors.groupingBy(MessageMark::getMsgId));
return messages.stream().map(a -> {
ChatMessageResp resp = new ChatMessageResp();
- resp.setFromUser(buildFromUser(userMap.get(a.getFromUid()), itemMap));
- resp.setMessage(buildMessage(a, replyMap, userMap, markMap.getOrDefault(a.getId(), new ArrayList<>()), receiveUid));
+ resp.setFromUser(buildFromUser(a.getFromUid()));
+ resp.setMessage(buildMessage(a, replyMap, markMap.getOrDefault(a.getId(), new ArrayList<>()), receiveUid));
return resp;
})
.sorted(Comparator.comparing(a -> a.getMessage().getSendTime()))//帮前端排好序,更方便它展示
.collect(Collectors.toList());
}
- private static ChatMessageResp.Message buildMessage(Message message, Map replyMap, Map userMap, List marks, Long receiveUid) {
+ private static ChatMessageResp.Message buildMessage(Message message, Map replyMap, List marks, Long receiveUid) {
ChatMessageResp.Message messageVO = new ChatMessageResp.Message();
BeanUtil.copyProperties(message, messageVO);
messageVO.setSendTime(message.getCreateTime());
AbstractMsgHandler msgHandler = MsgHandlerFactory.getStrategyNoNull(message.getType());
- messageVO.setBody(msgHandler.showMsg(message));
- messageVO.setUrlContentMap(Optional.ofNullable(message.getExtra()).map(MessageExtra::getUrlContentMap).orElse(null));
- Message replyMessage = replyMap.get(message.getReplyMsgId());
-
- //回复消息
- if (Objects.nonNull(replyMessage)) {
- ChatMessageResp.ReplyMsg replyMsgVO = new ChatMessageResp.ReplyMsg();
- replyMsgVO.setId(replyMessage.getId());
- replyMsgVO.setContent(replyMessage.getContent());
- User replyUser = userMap.get(replyMessage.getFromUid());
- replyMsgVO.setUsername(replyUser.getName());
- replyMsgVO.setCanCallback(YesOrNoEnum.toStatus(Objects.nonNull(message.getGapCount()) && message.getGapCount() <= CAN_CALLBACK_GAP_COUNT));
- replyMsgVO.setGapCount(message.getGapCount());
- messageVO.setReply(replyMsgVO);
+ if (Objects.nonNull(msgHandler)) {
+ messageVO.setBody(msgHandler.showMsg(message));
}
//消息标记
messageVO.setMessageMark(buildMsgMark(marks, receiveUid));
@@ -87,19 +70,9 @@ public class MessageAdapter {
return mark;
}
- private static ChatMessageResp.UserInfo buildFromUser(User fromUser, Map itemMap) {
+ private static ChatMessageResp.UserInfo buildFromUser(Long fromUid) {
ChatMessageResp.UserInfo userInfo = new ChatMessageResp.UserInfo();
- userInfo.setUsername(fromUser.getName());
- userInfo.setAvatar(fromUser.getAvatar());
- userInfo.setLocPlace(Optional.ofNullable(fromUser.getIpInfo()).map(IpInfo::getUpdateIpDetail).map(IpDetail::getCity).orElse(null));
- userInfo.setUid(fromUser.getId());
- if (Objects.nonNull(fromUser.getItemId())) {
- ChatMessageResp.Badge badge = new ChatMessageResp.Badge();
- ItemConfig itemConfig = itemMap.get(fromUser.getItemId());
- badge.setImg(itemConfig.getImg());
- badge.setDescribe(itemConfig.getDescribe());
- userInfo.setBadge(badge);
- }
+ userInfo.setUid(fromUid);
return userInfo;
}
diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/impl/ChatServiceImpl.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/impl/ChatServiceImpl.java
index adbb1d3..03ab62f 100644
--- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/impl/ChatServiceImpl.java
+++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/impl/ChatServiceImpl.java
@@ -19,8 +19,6 @@ import com.abin.mallchat.common.common.domain.vo.response.CursorPageBaseResp;
import com.abin.mallchat.common.common.event.MessageSendEvent;
import com.abin.mallchat.common.common.utils.AssertUtil;
import com.abin.mallchat.common.user.dao.UserDao;
-import com.abin.mallchat.common.user.domain.entity.ItemConfig;
-import com.abin.mallchat.common.user.domain.entity.User;
import com.abin.mallchat.common.user.domain.enums.ChatActiveStatusEnum;
import com.abin.mallchat.common.user.domain.enums.RoleEnum;
import com.abin.mallchat.common.user.service.IRoleService;
@@ -49,7 +47,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
-import java.util.stream.Stream;
/**
* Description: 消息处理类
@@ -226,21 +223,14 @@ public class ChatServiceImpl implements ChatService {
return new ArrayList<>();
}
Map replyMap = new HashMap<>();
- Map userMap;
- Map itemMap;
//批量查出回复的消息
List replyIds = messages.stream().map(Message::getReplyMsgId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(replyIds)) {
replyMap = messageDao.listByIds(replyIds).stream().collect(Collectors.toMap(Message::getId, Function.identity()));
}
- //批量查询消息关联用户
- Set uidSet = Stream.concat(replyMap.values().stream().map(Message::getFromUid), messages.stream().map(Message::getFromUid)).collect(Collectors.toSet());
- userMap = userCache.getUserInfoBatch(uidSet);
- //批量查询item信息
- itemMap = userMap.values().stream().map(User::getItemId).distinct().filter(Objects::nonNull).map(itemCache::getById).collect(Collectors.toMap(ItemConfig::getId, Function.identity()));
//查询消息标志
List msgMark = messageMarkDao.getValidMarkByMsgIdBatch(messages.stream().map(Message::getId).collect(Collectors.toList()));
- return MessageAdapter.buildMsgResp(messages, replyMap, userMap, msgMark, receiveUid, itemMap);
+ return MessageAdapter.buildMsgResp(messages, replyMap, msgMark, receiveUid);
}
}
diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/strategy/msg/EmojisMsgHandler.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/strategy/msg/EmojisMsgHandler.java
index 969595d..d7f93a5 100644
--- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/strategy/msg/EmojisMsgHandler.java
+++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/strategy/msg/EmojisMsgHandler.java
@@ -4,7 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
import com.abin.mallchat.common.chat.dao.MessageDao;
import com.abin.mallchat.common.chat.domain.entity.Message;
import com.abin.mallchat.common.chat.domain.entity.msg.EmojisMsgDTO;
-import com.abin.mallchat.common.chat.domain.entity.msg.ImgMsgDTO;
import com.abin.mallchat.common.chat.domain.entity.msg.MessageExtra;
import com.abin.mallchat.common.chat.domain.enums.MessageTypeEnum;
import com.abin.mallchat.common.common.utils.AssertUtil;
@@ -26,7 +25,7 @@ public class EmojisMsgHandler extends AbstractMsgHandler {
@Override
MessageTypeEnum getMsgTypeEnum() {
- return MessageTypeEnum.EMOJIS;
+ return MessageTypeEnum.EMOJI;
}
@Override
diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/controller/UserEmojiController.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/controller/UserEmojiController.java
new file mode 100644
index 0000000..9692359
--- /dev/null
+++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/controller/UserEmojiController.java
@@ -0,0 +1,77 @@
+package com.abin.mallchat.custom.user.controller;
+
+import com.abin.mallchat.common.common.domain.vo.request.IdReqVO;
+import com.abin.mallchat.common.common.domain.vo.response.ApiResult;
+import com.abin.mallchat.common.common.domain.vo.response.IdRespVO;
+import com.abin.mallchat.common.common.utils.RequestHolder;
+import com.abin.mallchat.custom.user.domain.vo.request.user.UserEmojiReq;
+import com.abin.mallchat.custom.user.domain.vo.response.user.UserEmojiResp;
+import com.abin.mallchat.custom.user.service.UserEmojiService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import java.util.List;
+
+/**
+ * 用户表情包
+ *
+ * @author: WuShiJie
+ * @createTime: 2023/7/3 14:21
+ */
+@RestController
+@RequestMapping("/capi/user/emoji")
+@Api(tags = "用户表情包管理相关接口")
+public class UserEmojiController {
+
+ /**
+ * 用户表情包 Service
+ */
+ @Resource
+ private UserEmojiService emojiService;
+
+
+ /**
+ * 表情包列表
+ *
+ * @return 表情包列表
+ * @author WuShiJie
+ * @createTime 2023/7/3 14:46
+ **/
+ @GetMapping("/list")
+ @ApiOperation("表情包列表")
+ public ApiResult> getEmojisPage() {
+ return ApiResult.success(emojiService.list(RequestHolder.get().getUid()));
+ }
+
+
+ /**
+ * 新增表情包
+ *
+ * @param req 用户表情包
+ * @return 表情包
+ * @author WuShiJie
+ * @createTime 2023/7/3 14:46
+ **/
+ @PostMapping()
+ @ApiOperation("新增表情包")
+ public ApiResult insertEmojis(@Valid @RequestBody UserEmojiReq req) {
+ return emojiService.insert(req, RequestHolder.get().getUid());
+ }
+
+ /**
+ * 删除表情包
+ *
+ * @return 删除结果
+ * @author WuShiJie
+ * @createTime 2023/7/3 14:46
+ **/
+ @DeleteMapping()
+ @ApiOperation("删除表情包")
+ public ApiResult deleteEmojis(@Valid @RequestBody IdReqVO reqVO) {
+ emojiService.remove(reqVO.getId(), RequestHolder.get().getUid());
+ return ApiResult.success();
+ }
+}
diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/controller/UserEmojisController.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/controller/UserEmojisController.java
deleted file mode 100644
index f88e69a..0000000
--- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/controller/UserEmojisController.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package com.abin.mallchat.custom.user.controller;
-
-import com.abin.mallchat.common.chat.domain.entity.UserEmojis;
-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;
-import com.abin.mallchat.common.common.utils.RequestHolder;
-import com.abin.mallchat.custom.user.service.UserEmojisService;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-
-/**
- * 用户表情包
- *
- * @author: WuShiJie
- * @createTime: 2023/7/3 14:21
- */
-@RestController
-@RequestMapping("/capi/userEmojis")
-@Api(tags = "用户表情包管理相关接口")
-public class UserEmojisController {
-
- /**
- * 用户表情包 Service
- */
- @Resource
- private UserEmojisService emojisService;
-
-
- /**
- * 表情包列表
- *
- * @param request 游标翻页请求参数
- * @return 表情包列表
- * @author WuShiJie
- * @createTime 2023/7/3 14:46
- **/
- @GetMapping("/getEmojisPage")
- @ApiOperation("表情包列表")
- public ApiResult> getEmojisPage(@Valid CursorPageBaseReq request) {
- return ApiResult.success(emojisService.getEmojisPage(request, RequestHolder.get().getUid()));
- }
-
-
- /**
- * 新增表情包
- *
- * @param emojis 用户表情包
- * @return 表情包
- * @author WuShiJie
- * @createTime 2023/7/3 14:46
- **/
- @PostMapping("/insertEmojis")
- @ApiOperation("新增表情包")
- public ApiResult insertEmojis(@Valid @RequestBody UserEmojis emojis) {
- return emojisService.insertEmojis(emojis,RequestHolder.get().getUid());
- }
-
- /**
- * 删除表情包
- *
- * @param id 用户表情包ID
- * @return 删除结果
- * @author WuShiJie
- * @createTime 2023/7/3 14:46
- **/
- @GetMapping("/deleteEmojis")
- @ApiOperation("删除表情包")
- public ApiResult deleteEmojis(@RequestParam("id") String id) {
- emojisService.removeById(id);
- return ApiResult.success();
- }
-}
diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/domain/enums/OssSceneEnum.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/domain/enums/OssSceneEnum.java
index a21f94a..67a5214 100644
--- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/domain/enums/OssSceneEnum.java
+++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/domain/enums/OssSceneEnum.java
@@ -17,7 +17,7 @@ import java.util.stream.Collectors;
@Getter
public enum OssSceneEnum {
CHAT(1, "聊天", "/chat"),
- EMOJIS(2, "表情包", "/emojis"),
+ EMOJI(2, "表情包", "/emoji"),
;
private final Integer type;
diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/domain/vo/request/user/UserEmojiReq.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/domain/vo/request/user/UserEmojiReq.java
new file mode 100644
index 0000000..5a31343
--- /dev/null
+++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/domain/vo/request/user/UserEmojiReq.java
@@ -0,0 +1,26 @@
+package com.abin.mallchat.custom.user.domain.vo.request.user;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+
+/**
+ * Description: 表情包反参
+ * Author: abin
+ * Date: 2023-07-09
+ */
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class UserEmojiReq {
+ /**
+ * 表情地址
+ */
+ @ApiModelProperty(value = "新增的表情url")
+ private String expressionUrl;
+
+}
diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/domain/vo/response/user/UserEmojiResp.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/domain/vo/response/user/UserEmojiResp.java
new file mode 100644
index 0000000..696393d
--- /dev/null
+++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/domain/vo/response/user/UserEmojiResp.java
@@ -0,0 +1,32 @@
+package com.abin.mallchat.custom.user.domain.vo.response.user;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+
+/**
+ * Description: 表情包反参
+ * Author: abin
+ * Date: 2023-07-09
+ */
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class UserEmojiResp {
+ /**
+ * id
+ */
+ @ApiModelProperty(value = "id")
+ private Long id;
+
+ /**
+ * 表情地址
+ */
+ @ApiModelProperty(value = "表情url")
+ private String expressionUrl;
+
+}
diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/UserEmojiService.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/UserEmojiService.java
new file mode 100644
index 0000000..302a58b
--- /dev/null
+++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/UserEmojiService.java
@@ -0,0 +1,45 @@
+package com.abin.mallchat.custom.user.service;
+
+import com.abin.mallchat.common.common.domain.vo.response.ApiResult;
+import com.abin.mallchat.common.common.domain.vo.response.IdRespVO;
+import com.abin.mallchat.custom.user.domain.vo.request.user.UserEmojiReq;
+import com.abin.mallchat.custom.user.domain.vo.response.user.UserEmojiResp;
+
+import java.util.List;
+
+/**
+ * 用户表情包 Service
+ *
+ * @author: WuShiJie
+ * @createTime: 2023/7/3 14:22
+ */
+public interface UserEmojiService {
+
+ /**
+ * 表情包列表
+ *
+ * @return 表情包列表
+ * @author WuShiJie
+ * @createTime 2023/7/3 14:46
+ **/
+ List list(Long uid);
+
+ /**
+ * 新增表情包
+ *
+ * @param emojis 用户表情包
+ * @param uid 用户ID
+ * @return 表情包
+ * @author WuShiJie
+ * @createTime 2023/7/3 14:46
+ **/
+ ApiResult insert(UserEmojiReq emojis, Long uid);
+
+ /**
+ * 删除表情包
+ *
+ * @param id
+ * @param uid
+ */
+ void remove(Long id, Long uid);
+}
diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/UserEmojisService.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/UserEmojisService.java
deleted file mode 100644
index 31a8ddd..0000000
--- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/UserEmojisService.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.abin.mallchat.custom.user.service;
-
-import com.abin.mallchat.common.chat.domain.entity.UserEmojis;
-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;
-import com.baomidou.mybatisplus.extension.service.IService;
-
-/**
- * 用户表情包 Service
- *
- * @author: WuShiJie
- * @createTime: 2023/7/3 14:22
- */
-public interface UserEmojisService extends IService {
-
- /**
- * 表情包列表
- *
- * @param request 游标翻页请求参数
- * @return 表情包列表
- * @author WuShiJie
- * @createTime 2023/7/3 14:46
- **/
- CursorPageBaseResp getEmojisPage(CursorPageBaseReq request, Long uid);
-
- /**
- * 新增表情包
- *
- * @param emojis 用户表情包
- * @param uid 用户ID
- * @return 表情包
- * @author WuShiJie
- * @createTime 2023/7/3 14:46
- **/
- ApiResult insertEmojis(UserEmojis emojis, Long uid);
-}
diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/OssServiceImpl.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/OssServiceImpl.java
index 08bf513..fa533e8 100644
--- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/OssServiceImpl.java
+++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/OssServiceImpl.java
@@ -17,7 +17,6 @@ import org.springframework.stereotype.Service;
*/
@Service
public class OssServiceImpl implements OssService {
- private static final String BUCKET_NAME = "mallchat";
@Autowired
private MinIOTemplate minIOTemplate;
diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/UserEmojiServiceImpl.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/UserEmojiServiceImpl.java
new file mode 100644
index 0000000..3a0b882
--- /dev/null
+++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/UserEmojiServiceImpl.java
@@ -0,0 +1,75 @@
+package com.abin.mallchat.custom.user.service.impl;
+
+import com.abin.mallchat.common.common.annotation.RedissonLock;
+import com.abin.mallchat.common.common.domain.vo.response.ApiResult;
+import com.abin.mallchat.common.common.domain.vo.response.IdRespVO;
+import com.abin.mallchat.common.common.utils.AssertUtil;
+import com.abin.mallchat.common.user.dao.UserEmojiDao;
+import com.abin.mallchat.common.user.domain.entity.UserEmoji;
+import com.abin.mallchat.custom.user.domain.vo.request.user.UserEmojiReq;
+import com.abin.mallchat.custom.user.domain.vo.response.user.UserEmojiResp;
+import com.abin.mallchat.custom.user.service.UserEmojiService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 用户表情包 ServiceImpl
+ *
+ * @author: WuShiJie
+ * @createTime: 2023/7/3 14:23
+ */
+@Service
+@Slf4j
+public class UserEmojiServiceImpl implements UserEmojiService {
+
+ @Autowired
+ private UserEmojiDao userEmojiDao;
+
+ @Override
+ public List list(Long uid) {
+ return userEmojiDao.listByUid(uid).
+ stream()
+ .map(a -> UserEmojiResp.builder()
+ .id(a.getId())
+ .expressionUrl(a.getExpressionUrl())
+ .build())
+ .collect(Collectors.toList());
+ }
+
+ /**
+ * 新增表情包
+ *
+ * @param uid 用户ID
+ * @return 表情包
+ * @author WuShiJie
+ * @createTime 2023/7/3 14:46
+ **/
+ @Override
+ @RedissonLock(key = "#uid")
+ public ApiResult insert(UserEmojiReq req, Long uid) {
+ //校验表情数量是否超过30
+ int count = userEmojiDao.countByUid(uid);
+ AssertUtil.isFalse(count > 30, "最多只能添加30个表情哦~~");
+ //校验表情是否存在
+ Integer existsCount = userEmojiDao.lambdaQuery()
+ .eq(UserEmoji::getExpressionUrl, req.getExpressionUrl())
+ .eq(UserEmoji::getUid, uid)
+ .count();
+ AssertUtil.isFalse(existsCount > 0, "当前表情已存在哦~~");
+ UserEmoji insert = UserEmoji.builder().uid(uid).expressionUrl(req.getExpressionUrl()).build();
+ userEmojiDao.save(insert);
+ return ApiResult.success(IdRespVO.id(insert.getId()));
+ }
+
+ @Override
+ public void remove(Long id, Long uid) {
+ UserEmoji userEmoji = userEmojiDao.getById(id);
+ AssertUtil.isNotEmpty(userEmoji, "表情不能为空");
+ AssertUtil.equal(userEmoji.getUid(), uid, "小黑子,别人表情不是你能删的");
+ userEmojiDao.removeById(id);
+ }
+}
diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/UserEmojisServiceImpl.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/UserEmojisServiceImpl.java
deleted file mode 100644
index fe51f7a..0000000
--- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/UserEmojisServiceImpl.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package com.abin.mallchat.custom.user.service.impl;
-
-import com.abin.mallchat.common.chat.domain.entity.UserEmojis;
-import com.abin.mallchat.common.common.annotation.RedissonLock;
-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;
-import com.abin.mallchat.common.common.utils.AssertUtil;
-import com.abin.mallchat.common.common.utils.CursorUtils;
-import com.abin.mallchat.common.common.utils.RequestHolder;
-import com.abin.mallchat.common.user.mapper.UserEmojisMapper;
-import com.abin.mallchat.custom.user.service.UserEmojisService;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-
-/**
- * 用户表情包 ServiceImpl
- *
- * @author: WuShiJie
- * @createTime: 2023/7/3 14:23
- */
-@Service
-@Slf4j
-public class UserEmojisServiceImpl extends ServiceImpl implements UserEmojisService {
-
- /**
- * 游标分页工具类
- */
- @Resource
- private CursorUtils cursorUtils;
-
- /**
- * 表情包列表
- *
- * @param request 游标翻页请求参数
- * @return 表情包列表
- * @author WuShiJie
- * @createTime 2023/7/3 14:46
- **/
- @Override
- public CursorPageBaseResp getEmojisPage(CursorPageBaseReq request, Long uid) {
- CursorPageBaseResp cursorPageByMysql = cursorUtils.getCursorPageByMysql(this, request, wrapper -> {
- wrapper.eq(UserEmojis::getUid, uid);
- }, UserEmojis::getId);
- return cursorPageByMysql;
- }
-
-
- /**
- * 新增表情包
- *
- * @param emojis 用户表情包
- * @param uid 用户ID
- * @return 表情包
- * @author WuShiJie
- * @createTime 2023/7/3 14:46
- **/
- @Override
- @RedissonLock(key = "#uid")
- public ApiResult insertEmojis(UserEmojis emojis, Long uid) {
- //校验表情数量是否超过30
- LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.eq(UserEmojis::getUid,uid);
- int count = this.count(queryWrapper);
- AssertUtil.isFalse(count>30, "最多只能添加30个表情哦~~");
- //校验表情是否存在
- queryWrapper.eq(UserEmojis::getExpressionUrl,emojis.getExpressionUrl());
- count = this.count(queryWrapper);
- AssertUtil.isFalse(count >0, "当前表情已存在哦~~");
- emojis.setUid(RequestHolder.get().getUid());
- this.saveOrUpdate(emojis, queryWrapper);
- return ApiResult.success(emojis);
- }
-}