From 386b0feac5d62f90a6410fd045a23a7a2042acc2 Mon Sep 17 00:00:00 2001 From: gxwebsoft Date: Sun, 28 Apr 2024 23:03:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=81=8A=E5=A4=A9=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/core/utils/RequestUtil.java | 4 +- .../ChatConversationController.java | 115 ++++++++++++++++++ .../controller/ChatMessageController.java | 115 ++++++++++++++++++ .../controller/MerchantAccountController.java | 13 +- .../controller/UserCollectionController.java | 115 ++++++++++++++++++ .../shop/entity/ChatConversation.java | 62 ++++++++++ .../gxwebsoft/shop/entity/ChatMessage.java | 74 +++++++++++ .../shop/entity/MerchantAccount.java | 9 ++ .../gxwebsoft/shop/entity/UserCollection.java | 42 +++++++ .../shop/mapper/ChatConversationMapper.java | 37 ++++++ .../shop/mapper/ChatMessageMapper.java | 37 ++++++ .../shop/mapper/UserCollectionMapper.java | 37 ++++++ .../mapper/xml/ChatConversationMapper.xml | 60 +++++++++ .../shop/mapper/xml/ChatMessageMapper.xml | 72 +++++++++++ .../shop/mapper/xml/UserCollectionMapper.xml | 42 +++++++ .../shop/param/ChatConversationParam.java | 57 +++++++++ .../shop/param/ChatMessageParam.java | 71 +++++++++++ .../shop/param/UserCollectionParam.java | 38 ++++++ .../shop/service/ChatConversationService.java | 42 +++++++ .../shop/service/ChatMessageService.java | 42 +++++++ .../shop/service/UserCollectionService.java | 42 +++++++ .../impl/ChatConversationServiceImpl.java | 47 +++++++ .../service/impl/ChatMessageServiceImpl.java | 47 +++++++ .../impl/UserCollectionServiceImpl.java | 47 +++++++ .../gxwebsoft/generator/ShopGenerator.java | 7 +- 25 files changed, 1265 insertions(+), 9 deletions(-) create mode 100644 src/main/java/com/gxwebsoft/shop/controller/ChatConversationController.java create mode 100644 src/main/java/com/gxwebsoft/shop/controller/ChatMessageController.java create mode 100644 src/main/java/com/gxwebsoft/shop/controller/UserCollectionController.java create mode 100644 src/main/java/com/gxwebsoft/shop/entity/ChatConversation.java create mode 100644 src/main/java/com/gxwebsoft/shop/entity/ChatMessage.java create mode 100644 src/main/java/com/gxwebsoft/shop/entity/UserCollection.java create mode 100644 src/main/java/com/gxwebsoft/shop/mapper/ChatConversationMapper.java create mode 100644 src/main/java/com/gxwebsoft/shop/mapper/ChatMessageMapper.java create mode 100644 src/main/java/com/gxwebsoft/shop/mapper/UserCollectionMapper.java create mode 100644 src/main/java/com/gxwebsoft/shop/mapper/xml/ChatConversationMapper.xml create mode 100644 src/main/java/com/gxwebsoft/shop/mapper/xml/ChatMessageMapper.xml create mode 100644 src/main/java/com/gxwebsoft/shop/mapper/xml/UserCollectionMapper.xml create mode 100644 src/main/java/com/gxwebsoft/shop/param/ChatConversationParam.java create mode 100644 src/main/java/com/gxwebsoft/shop/param/ChatMessageParam.java create mode 100644 src/main/java/com/gxwebsoft/shop/param/UserCollectionParam.java create mode 100644 src/main/java/com/gxwebsoft/shop/service/ChatConversationService.java create mode 100644 src/main/java/com/gxwebsoft/shop/service/ChatMessageService.java create mode 100644 src/main/java/com/gxwebsoft/shop/service/UserCollectionService.java create mode 100644 src/main/java/com/gxwebsoft/shop/service/impl/ChatConversationServiceImpl.java create mode 100644 src/main/java/com/gxwebsoft/shop/service/impl/ChatMessageServiceImpl.java create mode 100644 src/main/java/com/gxwebsoft/shop/service/impl/UserCollectionServiceImpl.java diff --git a/src/main/java/com/gxwebsoft/common/core/utils/RequestUtil.java b/src/main/java/com/gxwebsoft/common/core/utils/RequestUtil.java index 02f286d..f9dc83b 100644 --- a/src/main/java/com/gxwebsoft/common/core/utils/RequestUtil.java +++ b/src/main/java/com/gxwebsoft/common/core/utils/RequestUtil.java @@ -68,7 +68,7 @@ public class RequestUtil { } // 新增用户 - public void saveUserByPhone(MerchantAccount merchantAccount) { + public boolean saveUserByPhone(MerchantAccount merchantAccount) { String path = "/system/user/"; try { HashMap map = new HashMap<>(); @@ -92,9 +92,9 @@ public class RequestUtil { .body(JSONUtil.toJSONString(map))//表单内容 .timeout(20000)//超时,毫秒 .execute().body(); - System.out.println("result = " + result); } catch (Exception e) { e.printStackTrace(); } + return true; } } diff --git a/src/main/java/com/gxwebsoft/shop/controller/ChatConversationController.java b/src/main/java/com/gxwebsoft/shop/controller/ChatConversationController.java new file mode 100644 index 0000000..f602f6b --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/controller/ChatConversationController.java @@ -0,0 +1,115 @@ +package com.gxwebsoft.shop.controller; + +import com.gxwebsoft.common.core.web.BaseController; +import com.gxwebsoft.shop.service.ChatConversationService; +import com.gxwebsoft.shop.entity.ChatConversation; +import com.gxwebsoft.shop.param.ChatConversationParam; +import com.gxwebsoft.common.core.web.ApiResult; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.common.core.web.PageParam; +import com.gxwebsoft.common.core.web.BatchParam; +import com.gxwebsoft.common.core.annotation.OperationLog; +import com.gxwebsoft.common.system.entity.User; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 聊天消息表控制器 + * + * @author 科技小王子 + * @since 2024-04-27 16:08:04 + */ +@Api(tags = "聊天消息表管理") +@RestController +@RequestMapping("/api/shop/chat-conversation") +public class ChatConversationController extends BaseController { + @Resource + private ChatConversationService chatConversationService; + + @ApiOperation("分页查询聊天消息表") + @GetMapping("/page") + public ApiResult> page(ChatConversationParam param) { + // 使用关联查询 + return success(chatConversationService.pageRel(param)); + } + + @ApiOperation("查询全部聊天消息表") + @GetMapping() + public ApiResult> list(ChatConversationParam param) { + // 使用关联查询 + return success(chatConversationService.listRel(param)); + } + + @PreAuthorize("hasAuthority('shop:chatConversation:list')") + @ApiOperation("根据id查询聊天消息表") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Integer id) { + // 使用关联查询 + return success(chatConversationService.getByIdRel(id)); + } + + @ApiOperation("添加聊天消息表") + @PostMapping() + public ApiResult save(@RequestBody ChatConversation chatConversation) { + // 记录当前登录用户id + // User loginUser = getLoginUser(); + // if (loginUser != null) { + // chatConversation.setUserId(loginUser.getUserId()); + // } + if (chatConversationService.save(chatConversation)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("修改聊天消息表") + @PutMapping() + public ApiResult update(@RequestBody ChatConversation chatConversation) { + if (chatConversationService.updateById(chatConversation)) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("删除聊天消息表") + @DeleteMapping("/{id}") + public ApiResult remove(@PathVariable("id") Integer id) { + if (chatConversationService.removeById(id)) { + return success("删除成功"); + } + return fail("删除失败"); + } + + @ApiOperation("批量添加聊天消息表") + @PostMapping("/batch") + public ApiResult saveBatch(@RequestBody List list) { + if (chatConversationService.saveBatch(list)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("批量修改聊天消息表") + @PutMapping("/batch") + public ApiResult removeBatch(@RequestBody BatchParam batchParam) { + if (batchParam.update(chatConversationService, "id")) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("批量删除聊天消息表") + @DeleteMapping("/batch") + public ApiResult removeBatch(@RequestBody List ids) { + if (chatConversationService.removeByIds(ids)) { + return success("删除成功"); + } + return fail("删除失败"); + } + +} diff --git a/src/main/java/com/gxwebsoft/shop/controller/ChatMessageController.java b/src/main/java/com/gxwebsoft/shop/controller/ChatMessageController.java new file mode 100644 index 0000000..ae73bc4 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/controller/ChatMessageController.java @@ -0,0 +1,115 @@ +package com.gxwebsoft.shop.controller; + +import com.gxwebsoft.common.core.web.BaseController; +import com.gxwebsoft.shop.service.ChatMessageService; +import com.gxwebsoft.shop.entity.ChatMessage; +import com.gxwebsoft.shop.param.ChatMessageParam; +import com.gxwebsoft.common.core.web.ApiResult; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.common.core.web.PageParam; +import com.gxwebsoft.common.core.web.BatchParam; +import com.gxwebsoft.common.core.annotation.OperationLog; +import com.gxwebsoft.common.system.entity.User; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 聊天消息表控制器 + * + * @author 科技小王子 + * @since 2024-04-27 16:08:04 + */ +@Api(tags = "聊天消息表管理") +@RestController +@RequestMapping("/api/shop/chat-message") +public class ChatMessageController extends BaseController { + @Resource + private ChatMessageService chatMessageService; + + @ApiOperation("分页查询聊天消息表") + @GetMapping("/page") + public ApiResult> page(ChatMessageParam param) { + // 使用关联查询 + return success(chatMessageService.pageRel(param)); + } + + @ApiOperation("查询全部聊天消息表") + @GetMapping() + public ApiResult> list(ChatMessageParam param) { + // 使用关联查询 + return success(chatMessageService.listRel(param)); + } + + @PreAuthorize("hasAuthority('shop:chatMessage:list')") + @ApiOperation("根据id查询聊天消息表") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Integer id) { + // 使用关联查询 + return success(chatMessageService.getByIdRel(id)); + } + + @ApiOperation("添加聊天消息表") + @PostMapping() + public ApiResult save(@RequestBody ChatMessage chatMessage) { + // 记录当前登录用户id + // User loginUser = getLoginUser(); + // if (loginUser != null) { + // chatMessage.setUserId(loginUser.getUserId()); + // } + if (chatMessageService.save(chatMessage)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("修改聊天消息表") + @PutMapping() + public ApiResult update(@RequestBody ChatMessage chatMessage) { + if (chatMessageService.updateById(chatMessage)) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("删除聊天消息表") + @DeleteMapping("/{id}") + public ApiResult remove(@PathVariable("id") Integer id) { + if (chatMessageService.removeById(id)) { + return success("删除成功"); + } + return fail("删除失败"); + } + + @ApiOperation("批量添加聊天消息表") + @PostMapping("/batch") + public ApiResult saveBatch(@RequestBody List list) { + if (chatMessageService.saveBatch(list)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("批量修改聊天消息表") + @PutMapping("/batch") + public ApiResult removeBatch(@RequestBody BatchParam batchParam) { + if (batchParam.update(chatMessageService, "id")) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("批量删除聊天消息表") + @DeleteMapping("/batch") + public ApiResult removeBatch(@RequestBody List ids) { + if (chatMessageService.removeByIds(ids)) { + return success("删除成功"); + } + return fail("删除失败"); + } + +} diff --git a/src/main/java/com/gxwebsoft/shop/controller/MerchantAccountController.java b/src/main/java/com/gxwebsoft/shop/controller/MerchantAccountController.java index b760f88..cee7a72 100644 --- a/src/main/java/com/gxwebsoft/shop/controller/MerchantAccountController.java +++ b/src/main/java/com/gxwebsoft/shop/controller/MerchantAccountController.java @@ -65,17 +65,20 @@ public class MerchantAccountController extends BaseController { if (merchantAccountService.count(new LambdaQueryWrapper().eq(MerchantAccount::getPhone,merchantAccount.getPhone())) > 0) { return fail("手机号码已存在"); } - // 获取用户信息 + // 获取远程用户信息 final RequestUtil requestUtil = new RequestUtil(); String access_token = JwtUtil.getAccessToken(request); requestUtil.setAccessToken(access_token); requestUtil.setTenantId(getTenantId().toString()); - final User userByPhone = requestUtil.getUserByPhone(merchantAccount.getPhone()); - if (userByPhone != null) { - merchantAccount.setUserId(userByPhone.getUserId()); + User userByPhone = requestUtil.getUserByPhone(merchantAccount.getPhone()); + // 新增注册 + if (userByPhone == null) { + if (requestUtil.saveUserByPhone(merchantAccount)) { + userByPhone = requestUtil.getUserByPhone(merchantAccount.getPhone()); + } } + merchantAccount.setUserId(userByPhone.getUserId()); if (merchantAccountService.save(merchantAccount)) { - requestUtil.saveUserByPhone(merchantAccount); return success("添加成功"); } return fail("添加失败"); diff --git a/src/main/java/com/gxwebsoft/shop/controller/UserCollectionController.java b/src/main/java/com/gxwebsoft/shop/controller/UserCollectionController.java new file mode 100644 index 0000000..1218ec9 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/controller/UserCollectionController.java @@ -0,0 +1,115 @@ +package com.gxwebsoft.shop.controller; + +import com.gxwebsoft.common.core.web.BaseController; +import com.gxwebsoft.shop.service.UserCollectionService; +import com.gxwebsoft.shop.entity.UserCollection; +import com.gxwebsoft.shop.param.UserCollectionParam; +import com.gxwebsoft.common.core.web.ApiResult; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.common.core.web.PageParam; +import com.gxwebsoft.common.core.web.BatchParam; +import com.gxwebsoft.common.core.annotation.OperationLog; +import com.gxwebsoft.common.system.entity.User; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 我的收藏控制器 + * + * @author 科技小王子 + * @since 2024-04-28 18:17:37 + */ +@Api(tags = "我的收藏管理") +@RestController +@RequestMapping("/api/shop/user-collection") +public class UserCollectionController extends BaseController { + @Resource + private UserCollectionService userCollectionService; + + @ApiOperation("分页查询我的收藏") + @GetMapping("/page") + public ApiResult> page(UserCollectionParam param) { + // 使用关联查询 + return success(userCollectionService.pageRel(param)); + } + + @ApiOperation("查询全部我的收藏") + @GetMapping() + public ApiResult> list(UserCollectionParam param) { + // 使用关联查询 + return success(userCollectionService.listRel(param)); + } + + @PreAuthorize("hasAuthority('shop:userCollection:list')") + @ApiOperation("根据id查询我的收藏") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Integer id) { + // 使用关联查询 + return success(userCollectionService.getByIdRel(id)); + } + + @ApiOperation("添加我的收藏") + @PostMapping() + public ApiResult save(@RequestBody UserCollection userCollection) { + // 记录当前登录用户id + // User loginUser = getLoginUser(); + // if (loginUser != null) { + // userCollection.setUserId(loginUser.getUserId()); + // } + if (userCollectionService.save(userCollection)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("修改我的收藏") + @PutMapping() + public ApiResult update(@RequestBody UserCollection userCollection) { + if (userCollectionService.updateById(userCollection)) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("删除我的收藏") + @DeleteMapping("/{id}") + public ApiResult remove(@PathVariable("id") Integer id) { + if (userCollectionService.removeById(id)) { + return success("删除成功"); + } + return fail("删除失败"); + } + + @ApiOperation("批量添加我的收藏") + @PostMapping("/batch") + public ApiResult saveBatch(@RequestBody List list) { + if (userCollectionService.saveBatch(list)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("批量修改我的收藏") + @PutMapping("/batch") + public ApiResult removeBatch(@RequestBody BatchParam batchParam) { + if (batchParam.update(userCollectionService, "id")) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("批量删除我的收藏") + @DeleteMapping("/batch") + public ApiResult removeBatch(@RequestBody List ids) { + if (userCollectionService.removeByIds(ids)) { + return success("删除成功"); + } + return fail("删除失败"); + } + +} diff --git a/src/main/java/com/gxwebsoft/shop/entity/ChatConversation.java b/src/main/java/com/gxwebsoft/shop/entity/ChatConversation.java new file mode 100644 index 0000000..12be0f8 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/entity/ChatConversation.java @@ -0,0 +1,62 @@ +package com.gxwebsoft.shop.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 聊天消息表 + * + * @author 科技小王子 + * @since 2024-04-27 16:08:04 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "ChatConversation对象", description = "聊天消息表") +@TableName("shop_chat_conversation") +public class ChatConversation implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "自增ID") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "用户ID") + private Integer userId; + + @ApiModelProperty(value = "好友ID") + private Integer friendId; + + @ApiModelProperty(value = "消息类型") + private Integer type; + + @ApiModelProperty(value = "消息内容") + private String content; + + @ApiModelProperty(value = "未读消息") + private Integer unRead; + + @ApiModelProperty(value = "状态, 0未读, 1已读") + private Integer status; + + @ApiModelProperty(value = "是否删除, 0否, 1是") + @TableLogic + private Integer deleted; + + @ApiModelProperty(value = "租户id") + private Integer tenantId; + + @ApiModelProperty(value = "注册时间") + private LocalDateTime createTime; + + @ApiModelProperty(value = "修改时间") + private LocalDateTime updateTime; + +} diff --git a/src/main/java/com/gxwebsoft/shop/entity/ChatMessage.java b/src/main/java/com/gxwebsoft/shop/entity/ChatMessage.java new file mode 100644 index 0000000..22c2191 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/entity/ChatMessage.java @@ -0,0 +1,74 @@ +package com.gxwebsoft.shop.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 聊天消息表 + * + * @author 科技小王子 + * @since 2024-04-27 16:08:04 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "ChatMessage对象", description = "聊天消息表") +@TableName("shop_chat_message") +public class ChatMessage implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "自增ID") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "发送人ID") + private Integer formUserId; + + @ApiModelProperty(value = "接收人ID") + private Integer toUserId; + + @ApiModelProperty(value = "消息类型") + private String type; + + @ApiModelProperty(value = "消息内容") + private String content; + + @ApiModelProperty(value = "屏蔽接收方") + private Integer sideTo; + + @ApiModelProperty(value = "屏蔽发送方") + private Integer sideFrom; + + @ApiModelProperty(value = "是否撤回") + private Integer withdraw; + + @ApiModelProperty(value = "文件信息") + private String fileInfo; + + @ApiModelProperty(value = "存在联系方式") + private Integer hasContact; + + @ApiModelProperty(value = "状态, 0未读, 1已读") + private Integer status; + + @ApiModelProperty(value = "是否删除, 0否, 1是") + @TableLogic + private Integer deleted; + + @ApiModelProperty(value = "租户id") + private Integer tenantId; + + @ApiModelProperty(value = "注册时间") + private LocalDateTime createTime; + + @ApiModelProperty(value = "修改时间") + private LocalDateTime updateTime; + +} diff --git a/src/main/java/com/gxwebsoft/shop/entity/MerchantAccount.java b/src/main/java/com/gxwebsoft/shop/entity/MerchantAccount.java index 9ff3169..02f096c 100644 --- a/src/main/java/com/gxwebsoft/shop/entity/MerchantAccount.java +++ b/src/main/java/com/gxwebsoft/shop/entity/MerchantAccount.java @@ -1,5 +1,6 @@ package com.gxwebsoft.shop.entity; +import cn.hutool.core.util.DesensitizedUtil; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.IdType; @@ -76,4 +77,12 @@ public class MerchantAccount implements Serializable { @TableField(exist = false) private Boolean goodsReview; + @ApiModelProperty("手机号(脱敏)") + @TableField(exist = false) + private String mobile; + + public String getMobile(){ + return DesensitizedUtil.mobilePhone(this.phone); + } + } diff --git a/src/main/java/com/gxwebsoft/shop/entity/UserCollection.java b/src/main/java/com/gxwebsoft/shop/entity/UserCollection.java new file mode 100644 index 0000000..cf2c2fe --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/entity/UserCollection.java @@ -0,0 +1,42 @@ +package com.gxwebsoft.shop.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 我的收藏 + * + * @author 科技小王子 + * @since 2024-04-28 18:17:37 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "UserCollection对象", description = "我的收藏") +@TableName("shop_user_collection") +public class UserCollection implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键ID") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "租户ID") + private Integer tid; + + @ApiModelProperty(value = "用户ID") + private Integer userId; + + @ApiModelProperty(value = "租户id") + private Integer tenantId; + + @ApiModelProperty(value = "注册时间") + private LocalDateTime createTime; + +} diff --git a/src/main/java/com/gxwebsoft/shop/mapper/ChatConversationMapper.java b/src/main/java/com/gxwebsoft/shop/mapper/ChatConversationMapper.java new file mode 100644 index 0000000..1c5cf86 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/mapper/ChatConversationMapper.java @@ -0,0 +1,37 @@ +package com.gxwebsoft.shop.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.gxwebsoft.shop.entity.ChatConversation; +import com.gxwebsoft.shop.param.ChatConversationParam; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 聊天消息表Mapper + * + * @author 科技小王子 + * @since 2024-04-27 16:08:04 + */ +public interface ChatConversationMapper extends BaseMapper { + + /** + * 分页查询 + * + * @param page 分页对象 + * @param param 查询参数 + * @return List + */ + List selectPageRel(@Param("page") IPage page, + @Param("param") ChatConversationParam param); + + /** + * 查询全部 + * + * @param param 查询参数 + * @return List + */ + List selectListRel(@Param("param") ChatConversationParam param); + +} diff --git a/src/main/java/com/gxwebsoft/shop/mapper/ChatMessageMapper.java b/src/main/java/com/gxwebsoft/shop/mapper/ChatMessageMapper.java new file mode 100644 index 0000000..234a0ca --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/mapper/ChatMessageMapper.java @@ -0,0 +1,37 @@ +package com.gxwebsoft.shop.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.gxwebsoft.shop.entity.ChatMessage; +import com.gxwebsoft.shop.param.ChatMessageParam; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 聊天消息表Mapper + * + * @author 科技小王子 + * @since 2024-04-27 16:08:04 + */ +public interface ChatMessageMapper extends BaseMapper { + + /** + * 分页查询 + * + * @param page 分页对象 + * @param param 查询参数 + * @return List + */ + List selectPageRel(@Param("page") IPage page, + @Param("param") ChatMessageParam param); + + /** + * 查询全部 + * + * @param param 查询参数 + * @return List + */ + List selectListRel(@Param("param") ChatMessageParam param); + +} diff --git a/src/main/java/com/gxwebsoft/shop/mapper/UserCollectionMapper.java b/src/main/java/com/gxwebsoft/shop/mapper/UserCollectionMapper.java new file mode 100644 index 0000000..ba08881 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/mapper/UserCollectionMapper.java @@ -0,0 +1,37 @@ +package com.gxwebsoft.shop.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.gxwebsoft.shop.entity.UserCollection; +import com.gxwebsoft.shop.param.UserCollectionParam; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 我的收藏Mapper + * + * @author 科技小王子 + * @since 2024-04-28 18:17:37 + */ +public interface UserCollectionMapper extends BaseMapper { + + /** + * 分页查询 + * + * @param page 分页对象 + * @param param 查询参数 + * @return List + */ + List selectPageRel(@Param("page") IPage page, + @Param("param") UserCollectionParam param); + + /** + * 查询全部 + * + * @param param 查询参数 + * @return List + */ + List selectListRel(@Param("param") UserCollectionParam param); + +} diff --git a/src/main/java/com/gxwebsoft/shop/mapper/xml/ChatConversationMapper.xml b/src/main/java/com/gxwebsoft/shop/mapper/xml/ChatConversationMapper.xml new file mode 100644 index 0000000..32262ab --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/mapper/xml/ChatConversationMapper.xml @@ -0,0 +1,60 @@ + + + + + + + SELECT a.* + FROM shop_chat_conversation a + + + AND a.id = #{param.id} + + + AND a.user_id = #{param.userId} + + + AND a.friend_id = #{param.friendId} + + + AND a.type = #{param.type} + + + AND a.content LIKE CONCAT('%', #{param.content}, '%') + + + AND a.un_read = #{param.unRead} + + + AND a.status = #{param.status} + + + AND a.deleted = #{param.deleted} + + + AND a.deleted = 0 + + + AND a.create_time >= #{param.createTimeStart} + + + AND a.create_time <= #{param.createTimeEnd} + + + AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') + ) + + + + + + + + + + + diff --git a/src/main/java/com/gxwebsoft/shop/mapper/xml/ChatMessageMapper.xml b/src/main/java/com/gxwebsoft/shop/mapper/xml/ChatMessageMapper.xml new file mode 100644 index 0000000..ac3c97c --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/mapper/xml/ChatMessageMapper.xml @@ -0,0 +1,72 @@ + + + + + + + SELECT a.* + FROM shop_chat_message a + + + AND a.id = #{param.id} + + + AND a.form_user_id = #{param.formUserId} + + + AND a.to_user_id = #{param.toUserId} + + + AND a.type LIKE CONCAT('%', #{param.type}, '%') + + + AND a.content LIKE CONCAT('%', #{param.content}, '%') + + + AND a.side_to = #{param.sideTo} + + + AND a.side_from = #{param.sideFrom} + + + AND a.withdraw = #{param.withdraw} + + + AND a.file_info LIKE CONCAT('%', #{param.fileInfo}, '%') + + + AND a.has_contact = #{param.hasContact} + + + AND a.status = #{param.status} + + + AND a.deleted = #{param.deleted} + + + AND a.deleted = 0 + + + AND a.create_time >= #{param.createTimeStart} + + + AND a.create_time <= #{param.createTimeEnd} + + + AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') + ) + + + + + + + + + + + diff --git a/src/main/java/com/gxwebsoft/shop/mapper/xml/UserCollectionMapper.xml b/src/main/java/com/gxwebsoft/shop/mapper/xml/UserCollectionMapper.xml new file mode 100644 index 0000000..e5e3fe5 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/mapper/xml/UserCollectionMapper.xml @@ -0,0 +1,42 @@ + + + + + + + SELECT a.* + FROM shop_user_collection a + + + AND a.id = #{param.id} + + + AND a.tid = #{param.tid} + + + AND a.user_id = #{param.userId} + + + AND a.create_time >= #{param.createTimeStart} + + + AND a.create_time <= #{param.createTimeEnd} + + + AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') + ) + + + + + + + + + + + diff --git a/src/main/java/com/gxwebsoft/shop/param/ChatConversationParam.java b/src/main/java/com/gxwebsoft/shop/param/ChatConversationParam.java new file mode 100644 index 0000000..664f24b --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/param/ChatConversationParam.java @@ -0,0 +1,57 @@ +package com.gxwebsoft.shop.param; + +import java.math.BigDecimal; +import com.gxwebsoft.common.core.annotation.QueryField; +import com.gxwebsoft.common.core.annotation.QueryType; +import com.gxwebsoft.common.core.web.BaseParam; +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 聊天消息表查询参数 + * + * @author 科技小王子 + * @since 2024-04-27 16:08:04 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@JsonInclude(JsonInclude.Include.NON_NULL) +@ApiModel(value = "ChatConversationParam对象", description = "聊天消息表查询参数") +public class ChatConversationParam extends BaseParam { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "自增ID") + @QueryField(type = QueryType.EQ) + private Integer id; + + @ApiModelProperty(value = "用户ID") + @QueryField(type = QueryType.EQ) + private Integer userId; + + @ApiModelProperty(value = "好友ID") + @QueryField(type = QueryType.EQ) + private Integer friendId; + + @ApiModelProperty(value = "消息类型") + @QueryField(type = QueryType.EQ) + private Integer type; + + @ApiModelProperty(value = "消息内容") + private String content; + + @ApiModelProperty(value = "未读消息") + @QueryField(type = QueryType.EQ) + private Integer unRead; + + @ApiModelProperty(value = "状态, 0未读, 1已读") + @QueryField(type = QueryType.EQ) + private Integer status; + + @ApiModelProperty(value = "是否删除, 0否, 1是") + @QueryField(type = QueryType.EQ) + private Integer deleted; + +} diff --git a/src/main/java/com/gxwebsoft/shop/param/ChatMessageParam.java b/src/main/java/com/gxwebsoft/shop/param/ChatMessageParam.java new file mode 100644 index 0000000..24cf30b --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/param/ChatMessageParam.java @@ -0,0 +1,71 @@ +package com.gxwebsoft.shop.param; + +import java.math.BigDecimal; +import com.gxwebsoft.common.core.annotation.QueryField; +import com.gxwebsoft.common.core.annotation.QueryType; +import com.gxwebsoft.common.core.web.BaseParam; +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 聊天消息表查询参数 + * + * @author 科技小王子 + * @since 2024-04-27 16:08:04 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@JsonInclude(JsonInclude.Include.NON_NULL) +@ApiModel(value = "ChatMessageParam对象", description = "聊天消息表查询参数") +public class ChatMessageParam extends BaseParam { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "自增ID") + @QueryField(type = QueryType.EQ) + private Integer id; + + @ApiModelProperty(value = "发送人ID") + @QueryField(type = QueryType.EQ) + private Integer formUserId; + + @ApiModelProperty(value = "接收人ID") + @QueryField(type = QueryType.EQ) + private Integer toUserId; + + @ApiModelProperty(value = "消息类型") + private String type; + + @ApiModelProperty(value = "消息内容") + private String content; + + @ApiModelProperty(value = "屏蔽接收方") + @QueryField(type = QueryType.EQ) + private Integer sideTo; + + @ApiModelProperty(value = "屏蔽发送方") + @QueryField(type = QueryType.EQ) + private Integer sideFrom; + + @ApiModelProperty(value = "是否撤回") + @QueryField(type = QueryType.EQ) + private Integer withdraw; + + @ApiModelProperty(value = "文件信息") + private String fileInfo; + + @ApiModelProperty(value = "存在联系方式") + @QueryField(type = QueryType.EQ) + private Integer hasContact; + + @ApiModelProperty(value = "状态, 0未读, 1已读") + @QueryField(type = QueryType.EQ) + private Integer status; + + @ApiModelProperty(value = "是否删除, 0否, 1是") + @QueryField(type = QueryType.EQ) + private Integer deleted; + +} diff --git a/src/main/java/com/gxwebsoft/shop/param/UserCollectionParam.java b/src/main/java/com/gxwebsoft/shop/param/UserCollectionParam.java new file mode 100644 index 0000000..99a2013 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/param/UserCollectionParam.java @@ -0,0 +1,38 @@ +package com.gxwebsoft.shop.param; + +import java.math.BigDecimal; +import com.gxwebsoft.common.core.annotation.QueryField; +import com.gxwebsoft.common.core.annotation.QueryType; +import com.gxwebsoft.common.core.web.BaseParam; +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 我的收藏查询参数 + * + * @author 科技小王子 + * @since 2024-04-28 18:17:37 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@JsonInclude(JsonInclude.Include.NON_NULL) +@ApiModel(value = "UserCollectionParam对象", description = "我的收藏查询参数") +public class UserCollectionParam extends BaseParam { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键ID") + @QueryField(type = QueryType.EQ) + private Integer id; + + @ApiModelProperty(value = "租户ID") + @QueryField(type = QueryType.EQ) + private Integer tid; + + @ApiModelProperty(value = "用户ID") + @QueryField(type = QueryType.EQ) + private Integer userId; + +} diff --git a/src/main/java/com/gxwebsoft/shop/service/ChatConversationService.java b/src/main/java/com/gxwebsoft/shop/service/ChatConversationService.java new file mode 100644 index 0000000..3770af8 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/ChatConversationService.java @@ -0,0 +1,42 @@ +package com.gxwebsoft.shop.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.shop.entity.ChatConversation; +import com.gxwebsoft.shop.param.ChatConversationParam; + +import java.util.List; + +/** + * 聊天消息表Service + * + * @author 科技小王子 + * @since 2024-04-27 16:08:04 + */ +public interface ChatConversationService extends IService { + + /** + * 分页关联查询 + * + * @param param 查询参数 + * @return PageResult + */ + PageResult pageRel(ChatConversationParam param); + + /** + * 关联查询全部 + * + * @param param 查询参数 + * @return List + */ + List listRel(ChatConversationParam param); + + /** + * 根据id查询 + * + * @param id 自增ID + * @return ChatConversation + */ + ChatConversation getByIdRel(Integer id); + +} diff --git a/src/main/java/com/gxwebsoft/shop/service/ChatMessageService.java b/src/main/java/com/gxwebsoft/shop/service/ChatMessageService.java new file mode 100644 index 0000000..937ab3d --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/ChatMessageService.java @@ -0,0 +1,42 @@ +package com.gxwebsoft.shop.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.shop.entity.ChatMessage; +import com.gxwebsoft.shop.param.ChatMessageParam; + +import java.util.List; + +/** + * 聊天消息表Service + * + * @author 科技小王子 + * @since 2024-04-27 16:08:04 + */ +public interface ChatMessageService extends IService { + + /** + * 分页关联查询 + * + * @param param 查询参数 + * @return PageResult + */ + PageResult pageRel(ChatMessageParam param); + + /** + * 关联查询全部 + * + * @param param 查询参数 + * @return List + */ + List listRel(ChatMessageParam param); + + /** + * 根据id查询 + * + * @param id 自增ID + * @return ChatMessage + */ + ChatMessage getByIdRel(Integer id); + +} diff --git a/src/main/java/com/gxwebsoft/shop/service/UserCollectionService.java b/src/main/java/com/gxwebsoft/shop/service/UserCollectionService.java new file mode 100644 index 0000000..96556d8 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/UserCollectionService.java @@ -0,0 +1,42 @@ +package com.gxwebsoft.shop.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.shop.entity.UserCollection; +import com.gxwebsoft.shop.param.UserCollectionParam; + +import java.util.List; + +/** + * 我的收藏Service + * + * @author 科技小王子 + * @since 2024-04-28 18:17:37 + */ +public interface UserCollectionService extends IService { + + /** + * 分页关联查询 + * + * @param param 查询参数 + * @return PageResult + */ + PageResult pageRel(UserCollectionParam param); + + /** + * 关联查询全部 + * + * @param param 查询参数 + * @return List + */ + List listRel(UserCollectionParam param); + + /** + * 根据id查询 + * + * @param id 主键ID + * @return UserCollection + */ + UserCollection getByIdRel(Integer id); + +} diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/ChatConversationServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/ChatConversationServiceImpl.java new file mode 100644 index 0000000..8b4e606 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/impl/ChatConversationServiceImpl.java @@ -0,0 +1,47 @@ +package com.gxwebsoft.shop.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.gxwebsoft.shop.mapper.ChatConversationMapper; +import com.gxwebsoft.shop.service.ChatConversationService; +import com.gxwebsoft.shop.entity.ChatConversation; +import com.gxwebsoft.shop.param.ChatConversationParam; +import com.gxwebsoft.common.core.web.PageParam; +import com.gxwebsoft.common.core.web.PageResult; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 聊天消息表Service实现 + * + * @author 科技小王子 + * @since 2024-04-27 16:08:04 + */ +@Service +public class ChatConversationServiceImpl extends ServiceImpl implements ChatConversationService { + + @Override + public PageResult pageRel(ChatConversationParam param) { + PageParam page = new PageParam<>(param); + page.setDefaultOrder("sort_number asc, create_time desc"); + List list = baseMapper.selectPageRel(page, param); + return new PageResult<>(list, page.getTotal()); + } + + @Override + public List listRel(ChatConversationParam param) { + List list = baseMapper.selectListRel(param); + // 排序 + PageParam page = new PageParam<>(); + page.setDefaultOrder("sort_number asc, create_time desc"); + return page.sortRecords(list); + } + + @Override + public ChatConversation getByIdRel(Integer id) { + ChatConversationParam param = new ChatConversationParam(); + param.setId(id); + return param.getOne(baseMapper.selectListRel(param)); + } + +} diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/ChatMessageServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/ChatMessageServiceImpl.java new file mode 100644 index 0000000..8660878 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/impl/ChatMessageServiceImpl.java @@ -0,0 +1,47 @@ +package com.gxwebsoft.shop.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.gxwebsoft.shop.mapper.ChatMessageMapper; +import com.gxwebsoft.shop.service.ChatMessageService; +import com.gxwebsoft.shop.entity.ChatMessage; +import com.gxwebsoft.shop.param.ChatMessageParam; +import com.gxwebsoft.common.core.web.PageParam; +import com.gxwebsoft.common.core.web.PageResult; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 聊天消息表Service实现 + * + * @author 科技小王子 + * @since 2024-04-27 16:08:04 + */ +@Service +public class ChatMessageServiceImpl extends ServiceImpl implements ChatMessageService { + + @Override + public PageResult pageRel(ChatMessageParam param) { + PageParam page = new PageParam<>(param); + page.setDefaultOrder("sort_number asc, create_time desc"); + List list = baseMapper.selectPageRel(page, param); + return new PageResult<>(list, page.getTotal()); + } + + @Override + public List listRel(ChatMessageParam param) { + List list = baseMapper.selectListRel(param); + // 排序 + PageParam page = new PageParam<>(); + page.setDefaultOrder("sort_number asc, create_time desc"); + return page.sortRecords(list); + } + + @Override + public ChatMessage getByIdRel(Integer id) { + ChatMessageParam param = new ChatMessageParam(); + param.setId(id); + return param.getOne(baseMapper.selectListRel(param)); + } + +} diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/UserCollectionServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/UserCollectionServiceImpl.java new file mode 100644 index 0000000..b65ad72 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/impl/UserCollectionServiceImpl.java @@ -0,0 +1,47 @@ +package com.gxwebsoft.shop.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.gxwebsoft.shop.mapper.UserCollectionMapper; +import com.gxwebsoft.shop.service.UserCollectionService; +import com.gxwebsoft.shop.entity.UserCollection; +import com.gxwebsoft.shop.param.UserCollectionParam; +import com.gxwebsoft.common.core.web.PageParam; +import com.gxwebsoft.common.core.web.PageResult; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 我的收藏Service实现 + * + * @author 科技小王子 + * @since 2024-04-28 18:17:37 + */ +@Service +public class UserCollectionServiceImpl extends ServiceImpl implements UserCollectionService { + + @Override + public PageResult pageRel(UserCollectionParam param) { + PageParam page = new PageParam<>(param); + page.setDefaultOrder("sort_number asc, create_time desc"); + List list = baseMapper.selectPageRel(page, param); + return new PageResult<>(list, page.getTotal()); + } + + @Override + public List listRel(UserCollectionParam param) { + List list = baseMapper.selectListRel(param); + // 排序 + PageParam page = new PageParam<>(); + page.setDefaultOrder("sort_number asc, create_time desc"); + return page.sortRecords(list); + } + + @Override + public UserCollection getByIdRel(Integer id) { + UserCollectionParam param = new UserCollectionParam(); + param.setId(id); + return param.getOne(baseMapper.selectListRel(param)); + } + +} diff --git a/src/test/java/com/gxwebsoft/generator/ShopGenerator.java b/src/test/java/com/gxwebsoft/generator/ShopGenerator.java index abf72e3..8456dea 100644 --- a/src/test/java/com/gxwebsoft/generator/ShopGenerator.java +++ b/src/test/java/com/gxwebsoft/generator/ShopGenerator.java @@ -62,8 +62,11 @@ public class ShopGenerator { // "shop_merchant", // "shop_merchant_type", // "shop_merchant_apply", - "shop_order" -// "shop_merchant_account" +// "shop_order" +// "shop_merchant_account", +// "shop_chat_message", +// "shop_chat_conversation" +// "shop_user_collection" }; // 需要去除的表前缀 private static final String[] TABLE_PREFIX = new String[]{