From 5347d4f56bf60ed4b0362a6c952617d3e40d8671 Mon Sep 17 00:00:00 2001 From: WSJ <996387929@qq.com> Date: Mon, 3 Jul 2023 18:17:08 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A1=A8=E6=83=85?= =?UTF-8?q?=E5=8C=85=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/version/emojis.sql | 10 +++ .../common/chat/domain/entity/McEmojis.java | 58 +++++++++++++ .../common/user/mapper/EmojisMapper.java | 13 +++ .../user/controller/EmojisController.java | 84 +++++++++++++++++++ .../domain/vo/request/user/EmojisPageReq.java | 14 ++++ .../custom/user/service/EmojisService.java | 26 ++++++ .../user/service/impl/EmojisServiceImpl.java | 43 ++++++++++ 7 files changed, 248 insertions(+) create mode 100644 docs/version/emojis.sql create mode 100644 mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/entity/McEmojis.java create mode 100644 mallchat-common/src/main/java/com/abin/mallchat/common/user/mapper/EmojisMapper.java create mode 100644 mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/controller/EmojisController.java create mode 100644 mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/domain/vo/request/user/EmojisPageReq.java create mode 100644 mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/EmojisService.java create mode 100644 mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/EmojisServiceImpl.java diff --git a/docs/version/emojis.sql b/docs/version/emojis.sql new file mode 100644 index 0000000..ea238de --- /dev/null +++ b/docs/version/emojis.sql @@ -0,0 +1,10 @@ +CREATE TABLE `mc_emojis` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `user_id` 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 '修改时间', + `del_flg` int(1) NOT NULL DEFAULT '0' COMMENT '逻辑删除(0-正常,1-删除)', + PRIMARY KEY (`id`), + KEY `IDX_MC_EMOJIS_USER_ID` (`user_id`) +) 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/entity/McEmojis.java b/mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/entity/McEmojis.java new file mode 100644 index 0000000..09d7ecf --- /dev/null +++ b/mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/entity/McEmojis.java @@ -0,0 +1,58 @@ +package com.abin.mallchat.common.chat.domain.entity; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.Date; + +/** + * 用户表情包 + * + * @author: WuShiJie + * @createTime: 2023/7/2 22:00 + */ +@Data +@TableName(value = "mc_emojis") +public class McEmojis implements Serializable { + private static final long serialVersionUID = -7690290707154737263L; + + /** + * id + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 用户表ID + */ + @TableField(value = "user_id") + private Long userId; + + + /** + * 表情地址 + */ + @NotNull + @TableField(value = "expression_url") + private String expressionUrl; + + /** + * 创建时间 + */ + @TableField("create_time") + private Date createTime; + + /** + * 修改时间 + */ + @TableField("update_time") + private Date updateTime; + + @TableField(value = "del_flg") + @TableLogic(value = "0",delval = "1") + private Integer delFlg; + + +} diff --git a/mallchat-common/src/main/java/com/abin/mallchat/common/user/mapper/EmojisMapper.java b/mallchat-common/src/main/java/com/abin/mallchat/common/user/mapper/EmojisMapper.java new file mode 100644 index 0000000..67af9e6 --- /dev/null +++ b/mallchat-common/src/main/java/com/abin/mallchat/common/user/mapper/EmojisMapper.java @@ -0,0 +1,13 @@ +package com.abin.mallchat.common.user.mapper; + +import com.abin.mallchat.common.chat.domain.entity.McEmojis; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * 用户表情包 Mapper + * + * @author: WuShiJie + * @createTime: 2023/7/3 14:24 + */ +public interface EmojisMapper extends BaseMapper { +} diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/controller/EmojisController.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/controller/EmojisController.java new file mode 100644 index 0000000..2121797 --- /dev/null +++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/controller/EmojisController.java @@ -0,0 +1,84 @@ +package com.abin.mallchat.custom.user.controller; + +import cn.hutool.core.util.StrUtil; +import com.abin.mallchat.common.chat.domain.entity.McEmojis; +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.EmojisService; +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/emojis") +@Api(tags = "用户表情包管理相关接口") +public class EmojisController { + + /** + * 用户表情包 Service + */ + @Resource + private EmojisService 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 McEmojis emojis) { + emojis.setUserId(RequestHolder.get().getUid()); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(McEmojis::getUserId,emojis.getUserId()); + queryWrapper.eq(McEmojis::getExpressionUrl,emojis.getExpressionUrl()); + emojisService.saveOrUpdate(emojis, queryWrapper); + return ApiResult.success(emojis); + } + + /** + * 删除表情包 + * + * @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/vo/request/user/EmojisPageReq.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/domain/vo/request/user/EmojisPageReq.java new file mode 100644 index 0000000..9dfe00f --- /dev/null +++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/domain/vo/request/user/EmojisPageReq.java @@ -0,0 +1,14 @@ +package com.abin.mallchat.custom.user.domain.vo.request.user; + +import com.abin.mallchat.common.common.domain.vo.request.CursorPageBaseReq; +import lombok.Data; + +/** + * 描述此类的作用 + * + * @author: WuShiJie + * @createTime: 2023/7/3 14:52 + */ +@Data +public class EmojisPageReq extends CursorPageBaseReq { +} diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/EmojisService.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/EmojisService.java new file mode 100644 index 0000000..89fb81f --- /dev/null +++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/EmojisService.java @@ -0,0 +1,26 @@ +package com.abin.mallchat.custom.user.service; + +import com.abin.mallchat.common.chat.domain.entity.McEmojis; +import com.abin.mallchat.common.common.domain.vo.request.CursorPageBaseReq; +import com.abin.mallchat.common.common.domain.vo.response.CursorPageBaseResp; +import com.abin.mallchat.custom.chat.domain.vo.response.ChatRoomResp; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 用户表情包 Service + * + * @author: WuShiJie + * @createTime: 2023/7/3 14:22 + */ +public interface EmojisService extends IService { + + /** + * 表情包列表 + * + * @param request 游标翻页请求参数 + * @return 表情包列表 + * @author WuShiJie + * @createTime 2023/7/3 14:46 + **/ + CursorPageBaseResp getEmojisPage(CursorPageBaseReq request, Long uid); +} diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/EmojisServiceImpl.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/EmojisServiceImpl.java new file mode 100644 index 0000000..26dbe09 --- /dev/null +++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/EmojisServiceImpl.java @@ -0,0 +1,43 @@ +package com.abin.mallchat.custom.user.service.impl; + +import com.abin.mallchat.common.chat.domain.entity.McEmojis; +import com.abin.mallchat.common.common.domain.vo.request.CursorPageBaseReq; +import com.abin.mallchat.common.common.domain.vo.response.CursorPageBaseResp; +import com.abin.mallchat.common.common.utils.CursorUtils; +import com.abin.mallchat.common.user.mapper.EmojisMapper; +import com.abin.mallchat.custom.chat.service.adapter.RoomAdapter; +import com.abin.mallchat.custom.user.service.EmojisService; +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; + +/** + * 用户表情包 ServiceImpl + * + * @author: WuShiJie + * @createTime: 2023/7/3 14:23 + */ +@Service +@Slf4j +public class EmojisServiceImpl extends ServiceImpl implements EmojisService { + + @Autowired + 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(McEmojis::getUserId, uid); + }, McEmojis::getId); + return cursorPageByMysql; + } +} From ae1c1ed098b6b24d9c7bb72b251094f153985066 Mon Sep 17 00:00:00 2001 From: WSJ <996387929@qq.com> Date: Tue, 4 Jul 2023 09:22:35 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A1=A8=E6=83=85?= =?UTF-8?q?=E5=8C=85=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/version/emojis.sql | 10 --- docs/version/user_emojis.sql | 10 +++ .../entity/{McEmojis.java => UserEmojis.java} | 12 +-- ...mojisMapper.java => UserEmojisMapper.java} | 4 +- ...troller.java => UserEmojisController.java} | 26 +++--- .../custom/user/service/EmojisService.java | 26 ------ .../user/service/UserEmojisService.java | 37 +++++++++ .../user/service/impl/EmojisServiceImpl.java | 43 ---------- .../service/impl/UserEmojisServiceImpl.java | 82 +++++++++++++++++++ 9 files changed, 147 insertions(+), 103 deletions(-) delete mode 100644 docs/version/emojis.sql create mode 100644 docs/version/user_emojis.sql rename mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/entity/{McEmojis.java => UserEmojis.java} (80%) rename mallchat-common/src/main/java/com/abin/mallchat/common/user/mapper/{EmojisMapper.java => UserEmojisMapper.java} (60%) rename mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/controller/{EmojisController.java => UserEmojisController.java} (65%) delete mode 100644 mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/EmojisService.java create mode 100644 mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/UserEmojisService.java delete mode 100644 mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/EmojisServiceImpl.java create mode 100644 mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/UserEmojisServiceImpl.java diff --git a/docs/version/emojis.sql b/docs/version/emojis.sql deleted file mode 100644 index ea238de..0000000 --- a/docs/version/emojis.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE `mc_emojis` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', - `user_id` 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 '修改时间', - `del_flg` int(1) NOT NULL DEFAULT '0' COMMENT '逻辑删除(0-正常,1-删除)', - PRIMARY KEY (`id`), - KEY `IDX_MC_EMOJIS_USER_ID` (`user_id`) -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='用户表情包'; \ No newline at end of file diff --git a/docs/version/user_emojis.sql b/docs/version/user_emojis.sql new file mode 100644 index 0000000..875edf0 --- /dev/null +++ b/docs/version/user_emojis.sql @@ -0,0 +1,10 @@ +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_MC_EMOJIS_USER_ID` (`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/entity/McEmojis.java b/mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/entity/UserEmojis.java similarity index 80% rename from mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/entity/McEmojis.java rename to mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/entity/UserEmojis.java index 09d7ecf..de707ff 100644 --- a/mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/entity/McEmojis.java +++ b/mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/entity/UserEmojis.java @@ -14,8 +14,8 @@ import java.util.Date; * @createTime: 2023/7/2 22:00 */ @Data -@TableName(value = "mc_emojis") -public class McEmojis implements Serializable { +@TableName(value = "user_emojis") +public class UserEmojis implements Serializable { private static final long serialVersionUID = -7690290707154737263L; /** @@ -27,8 +27,8 @@ public class McEmojis implements Serializable { /** * 用户表ID */ - @TableField(value = "user_id") - private Long userId; + @TableField(value = "uid") + private Long uid; /** @@ -50,9 +50,9 @@ public class McEmojis implements Serializable { @TableField("update_time") private Date updateTime; - @TableField(value = "del_flg") + @TableField(value = "delete_status") @TableLogic(value = "0",delval = "1") - private Integer delFlg; + private Integer deleteStatus; } diff --git a/mallchat-common/src/main/java/com/abin/mallchat/common/user/mapper/EmojisMapper.java b/mallchat-common/src/main/java/com/abin/mallchat/common/user/mapper/UserEmojisMapper.java similarity index 60% rename from mallchat-common/src/main/java/com/abin/mallchat/common/user/mapper/EmojisMapper.java rename to mallchat-common/src/main/java/com/abin/mallchat/common/user/mapper/UserEmojisMapper.java index 67af9e6..dd6b5b2 100644 --- a/mallchat-common/src/main/java/com/abin/mallchat/common/user/mapper/EmojisMapper.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.McEmojis; +import com.abin.mallchat.common.chat.domain.entity.UserEmojis; 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 EmojisMapper extends BaseMapper { +public interface UserEmojisMapper extends BaseMapper { } diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/controller/EmojisController.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/controller/UserEmojisController.java similarity index 65% rename from mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/controller/EmojisController.java rename to mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/controller/UserEmojisController.java index 2121797..f88e69a 100644 --- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/controller/EmojisController.java +++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/controller/UserEmojisController.java @@ -1,12 +1,11 @@ package com.abin.mallchat.custom.user.controller; -import cn.hutool.core.util.StrUtil; -import com.abin.mallchat.common.chat.domain.entity.McEmojis; +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.EmojisService; +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; @@ -22,15 +21,15 @@ import javax.validation.Valid; * @createTime: 2023/7/3 14:21 */ @RestController -@RequestMapping("/capi/emojis") +@RequestMapping("/capi/userEmojis") @Api(tags = "用户表情包管理相关接口") -public class EmojisController { +public class UserEmojisController { /** * 用户表情包 Service */ @Resource - private EmojisService emojisService; + private UserEmojisService emojisService; /** @@ -43,7 +42,7 @@ public class EmojisController { **/ @GetMapping("/getEmojisPage") @ApiOperation("表情包列表") - public ApiResult> getEmojisPage(@Valid CursorPageBaseReq request) { + public ApiResult> getEmojisPage(@Valid CursorPageBaseReq request) { return ApiResult.success(emojisService.getEmojisPage(request, RequestHolder.get().getUid())); } @@ -57,14 +56,9 @@ public class EmojisController { * @createTime 2023/7/3 14:46 **/ @PostMapping("/insertEmojis") - @ApiOperation("表情包列表") - public ApiResult insertEmojis(@Valid @RequestBody McEmojis emojis) { - emojis.setUserId(RequestHolder.get().getUid()); - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(McEmojis::getUserId,emojis.getUserId()); - queryWrapper.eq(McEmojis::getExpressionUrl,emojis.getExpressionUrl()); - emojisService.saveOrUpdate(emojis, queryWrapper); - return ApiResult.success(emojis); + @ApiOperation("新增表情包") + public ApiResult insertEmojis(@Valid @RequestBody UserEmojis emojis) { + return emojisService.insertEmojis(emojis,RequestHolder.get().getUid()); } /** @@ -76,7 +70,7 @@ public class EmojisController { * @createTime 2023/7/3 14:46 **/ @GetMapping("/deleteEmojis") - @ApiOperation("表情包列表") + @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/service/EmojisService.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/EmojisService.java deleted file mode 100644 index 89fb81f..0000000 --- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/EmojisService.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.abin.mallchat.custom.user.service; - -import com.abin.mallchat.common.chat.domain.entity.McEmojis; -import com.abin.mallchat.common.common.domain.vo.request.CursorPageBaseReq; -import com.abin.mallchat.common.common.domain.vo.response.CursorPageBaseResp; -import com.abin.mallchat.custom.chat.domain.vo.response.ChatRoomResp; -import com.baomidou.mybatisplus.extension.service.IService; - -/** - * 用户表情包 Service - * - * @author: WuShiJie - * @createTime: 2023/7/3 14:22 - */ -public interface EmojisService extends IService { - - /** - * 表情包列表 - * - * @param request 游标翻页请求参数 - * @return 表情包列表 - * @author WuShiJie - * @createTime 2023/7/3 14:46 - **/ - CursorPageBaseResp getEmojisPage(CursorPageBaseReq request, 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 new file mode 100644 index 0000000..31a8ddd --- /dev/null +++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/UserEmojisService.java @@ -0,0 +1,37 @@ +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/EmojisServiceImpl.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/EmojisServiceImpl.java deleted file mode 100644 index 26dbe09..0000000 --- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/EmojisServiceImpl.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.abin.mallchat.custom.user.service.impl; - -import com.abin.mallchat.common.chat.domain.entity.McEmojis; -import com.abin.mallchat.common.common.domain.vo.request.CursorPageBaseReq; -import com.abin.mallchat.common.common.domain.vo.response.CursorPageBaseResp; -import com.abin.mallchat.common.common.utils.CursorUtils; -import com.abin.mallchat.common.user.mapper.EmojisMapper; -import com.abin.mallchat.custom.chat.service.adapter.RoomAdapter; -import com.abin.mallchat.custom.user.service.EmojisService; -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; - -/** - * 用户表情包 ServiceImpl - * - * @author: WuShiJie - * @createTime: 2023/7/3 14:23 - */ -@Service -@Slf4j -public class EmojisServiceImpl extends ServiceImpl implements EmojisService { - - @Autowired - 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(McEmojis::getUserId, uid); - }, McEmojis::getId); - return cursorPageByMysql; - } -} 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 new file mode 100644 index 0000000..0f2302d --- /dev/null +++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/UserEmojisServiceImpl.java @@ -0,0 +1,82 @@ +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.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); + if (count>30){ + return ApiResult.fail(-1,"最多只能添加30个表情"); + } + //校验表情是否存在 + queryWrapper.eq(UserEmojis::getExpressionUrl,emojis.getExpressionUrl()); + count = this.count(queryWrapper); + if (count >0){ + return ApiResult.fail(-1,"当前表情已存在"); + } + emojis.setUid(RequestHolder.get().getUid()); + this.saveOrUpdate(emojis, queryWrapper); + return ApiResult.success(emojis); + } +} From 8610078169d1e9688771324ad9b0dc331d94910c Mon Sep 17 00:00:00 2001 From: WSJ <996387929@qq.com> Date: Tue, 4 Jul 2023 09:31:16 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A1=A8=E6=83=85?= =?UTF-8?q?=E5=8C=85=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/version/user_emojis.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/version/user_emojis.sql b/docs/version/user_emojis.sql index 875edf0..f0078ce 100644 --- a/docs/version/user_emojis.sql +++ b/docs/version/user_emojis.sql @@ -6,5 +6,5 @@ CREATE TABLE `user_emojis` ( `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_MC_EMOJIS_USER_ID` (`uid`) + KEY `IDX_USER_EMOJIS_UID` (`uid`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='用户表情包'; \ No newline at end of file From 7d62a59da5cc64d47d2b75318ab984fea1c668fd Mon Sep 17 00:00:00 2001 From: WSJ <996387929@qq.com> Date: Sat, 8 Jul 2023 17:49:21 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E8=A1=A8=E6=83=85=E5=8C=85=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E5=A2=9E=E5=8A=A0=E4=B8=8A=E4=BC=A0=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../abin/mallchat/custom/user/domain/enums/OssSceneEnum.java | 1 + .../custom/user/domain/vo/request/oss/UploadUrlReq.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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 ce7c7ac..a21f94a 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,6 +17,7 @@ import java.util.stream.Collectors; @Getter public enum OssSceneEnum { CHAT(1, "聊天", "/chat"), + EMOJIS(2, "表情包", "/emojis"), ; private final Integer type; diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/domain/vo/request/oss/UploadUrlReq.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/domain/vo/request/oss/UploadUrlReq.java index d0b0028..df1f473 100644 --- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/domain/vo/request/oss/UploadUrlReq.java +++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/domain/vo/request/oss/UploadUrlReq.java @@ -23,7 +23,7 @@ public class UploadUrlReq { @ApiModelProperty(value = "文件名(带后缀)") @NotBlank private String fileName; - @ApiModelProperty(value = "上传场景1.聊天室") + @ApiModelProperty(value = "上传场景1.聊天室,2.表情包") @NotNull private Integer scene; } From 5bdad1351c0018a28a394fce98e7a7f4eddafe3e Mon Sep 17 00:00:00 2001 From: WSJ <996387929@qq.com> Date: Sat, 8 Jul 2023 18:28:20 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A1=A8=E6=83=85?= =?UTF-8?q?=E5=8C=85=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/domain/entity/msg/EmojisMsgDTO.java | 29 ++++++++++ .../chat/domain/entity/msg/MessageExtra.java | 5 ++ .../chat/domain/enums/MessageTypeEnum.java | 1 + .../strategy/msg/EmojisMsgHandler.java | 58 +++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/entity/msg/EmojisMsgDTO.java create mode 100644 mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/strategy/msg/EmojisMsgHandler.java diff --git a/mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/entity/msg/EmojisMsgDTO.java b/mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/entity/msg/EmojisMsgDTO.java new file mode 100644 index 0000000..d8aaa2c --- /dev/null +++ b/mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/entity/msg/EmojisMsgDTO.java @@ -0,0 +1,29 @@ +package com.abin.mallchat.common.chat.domain.entity.msg; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * Description: 表情图片消息入参 + * Author: abin + * Date: 2023-06-04 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class EmojisMsgDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("下载地址") + @NotBlank + private String url; +} + + diff --git a/mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/entity/msg/MessageExtra.java b/mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/entity/msg/MessageExtra.java index 9a68c74..ffbc008 100644 --- a/mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/entity/msg/MessageExtra.java +++ b/mallchat-common/src/main/java/com/abin/mallchat/common/chat/domain/entity/msg/MessageExtra.java @@ -36,4 +36,9 @@ public class MessageExtra implements Serializable { private SoundMsgDTO soundMsgDTO; //文件消息 private VideoMsgDTO videoMsgDTO; + + /** + * 表情图片信息 + */ + private EmojisMsgDTO emojisMsgDTO; } 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 cc262a9..7d66214 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,6 +22,7 @@ public enum MessageTypeEnum { FILE(4, "文件"), SOUND(5, "语音"), VIDEO(6, "视频"), + EMOJIS(7, "表情"), ; private final Integer type; 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 new file mode 100644 index 0000000..1012160 --- /dev/null +++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/strategy/msg/EmojisMsgHandler.java @@ -0,0 +1,58 @@ +package com.abin.mallchat.custom.chat.service.strategy.msg; + +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; +import com.abin.mallchat.custom.chat.domain.vo.request.ChatMessageReq; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Optional; + +/** + * Description:表情消息 + * Author: abin + * Date: 2023-06-04 + */ +@Component +public class EmojisMsgHandler extends AbstractMsgHandler { + @Autowired + private MessageDao messageDao; + + @Override + MessageTypeEnum getMsgTypeEnum() { + return MessageTypeEnum.EMOJIS; + } + + @Override + public void checkMsg(ChatMessageReq request, Long uid) { + EmojisMsgDTO body = BeanUtil.toBean(request.getBody(), EmojisMsgDTO.class); + AssertUtil.allCheckValidateThrow(body); + } + + @Override + public void saveMsg(Message msg, ChatMessageReq request) { + EmojisMsgDTO body = BeanUtil.toBean(request.getBody(), EmojisMsgDTO.class); + MessageExtra extra = Optional.ofNullable(msg.getExtra()).orElse(new MessageExtra()); + Message update = new Message(); + update.setId(msg.getId()); + update.setExtra(extra); + extra.setEmojisMsgDTO(body); + messageDao.updateById(update); + } + + @Override + public Object showMsg(Message msg) { + return msg.getExtra().getImgMsgDTO(); + } + + @Override + public Object showReplyMsg(Message msg) { + return "表情"; + } +} From 630e6da05c2eb2b870960e760c41bb4ba86b94e2 Mon Sep 17 00:00:00 2001 From: WSJ <996387929@qq.com> Date: Sat, 8 Jul 2023 18:35:32 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A1=A8=E6=83=85?= =?UTF-8?q?=E5=8C=85=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom/user/service/impl/UserEmojisServiceImpl.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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 index 0f2302d..fe51f7a 100644 --- 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 @@ -5,6 +5,7 @@ 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; @@ -66,15 +67,11 @@ public class UserEmojisServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(UserEmojis::getUid,uid); int count = this.count(queryWrapper); - if (count>30){ - return ApiResult.fail(-1,"最多只能添加30个表情"); - } + AssertUtil.isFalse(count>30, "最多只能添加30个表情哦~~"); //校验表情是否存在 queryWrapper.eq(UserEmojis::getExpressionUrl,emojis.getExpressionUrl()); count = this.count(queryWrapper); - if (count >0){ - return ApiResult.fail(-1,"当前表情已存在"); - } + AssertUtil.isFalse(count >0, "当前表情已存在哦~~"); emojis.setUid(RequestHolder.get().getUid()); this.saveOrUpdate(emojis, queryWrapper); return ApiResult.success(emojis); From e64659b4912ae3a0e6adcacfa6de2b32b3fd6b00 Mon Sep 17 00:00:00 2001 From: WSJ <996387929@qq.com> Date: Sat, 8 Jul 2023 19:07:12 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A1=A8=E6=83=85?= =?UTF-8?q?=E5=8C=85=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom/chat/service/strategy/msg/EmojisMsgHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1012160..969595d 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 @@ -48,7 +48,7 @@ public class EmojisMsgHandler extends AbstractMsgHandler { @Override public Object showMsg(Message msg) { - return msg.getExtra().getImgMsgDTO(); + return msg.getExtra().getEmojisMsgDTO(); } @Override