mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
MALL-KEFU: 完善APP端聊天消息获取
This commit is contained in:
parent
285a431616
commit
cdb20539ea
@ -1,37 +1,39 @@
|
|||||||
DROP TABLE IF EXISTS `promotion_kefu_conversation`;
|
DROP TABLE IF EXISTS `promotion_kefu_conversation`;
|
||||||
CREATE TABLE `promotion_kefu_conversation` (
|
CREATE TABLE `promotion_kefu_conversation` (
|
||||||
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '编号',
|
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
||||||
`user_id` BIGINT NOT NULL COMMENT '会话所属用户',
|
`user_id` bigint NOT NULL COMMENT '会话所属用户',
|
||||||
`last_message_time` DATETIME NOT NULL COMMENT '最后聊天时间',
|
`last_message_time` datetime NOT NULL COMMENT '最后聊天时间',
|
||||||
`last_message_content` VARCHAR(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '最后聊天内容',
|
`last_message_content` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '最后聊天内容',
|
||||||
`last_message_content_type` INT NOT NULL COMMENT '最后发送的消息类型',
|
`last_message_content_type` int NOT NULL COMMENT '最后发送的消息类型',
|
||||||
`admin_pinned` BIT(1) NOT NULL DEFAULT b'0' COMMENT '管理端置顶',
|
`admin_pinned` bit(1) NOT NULL DEFAULT b'0' COMMENT '管理端置顶',
|
||||||
`user_deleted` BIT(1) NOT NULL DEFAULT b'0' COMMENT '用户是否可见',
|
`user_deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '用户是否可见',
|
||||||
`admin_deleted` BIT(1) NOT NULL DEFAULT b'0' COMMENT '管理员是否可见',
|
`admin_deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '管理员是否可见',
|
||||||
`admin_unread_message_count` INT NOT NULL COMMENT '管理员未读消息数',
|
`admin_unread_message_count` int NOT NULL COMMENT '管理员未读消息数',
|
||||||
`creator` VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者',
|
||||||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
`updater` VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者',
|
||||||
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
`deleted` BIT(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||||
|
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||||
PRIMARY KEY (`id`) USING BTREE
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '客服会话' ROW_FORMAT = Dynamic;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='客服会话';
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `promotion_kefu_message`;
|
DROP TABLE IF EXISTS `promotion_kefu_message`;
|
||||||
CREATE TABLE `promotion_kefu_message` (
|
CREATE TABLE `promotion_kefu_message` (
|
||||||
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '编号',
|
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
||||||
`conversation_id` BIGINT NOT NULL COMMENT '会话编号',
|
`conversation_id` bigint NOT NULL COMMENT '会话编号',
|
||||||
`sender_id` BIGINT NOT NULL COMMENT '发送人编号',
|
`sender_id` bigint NOT NULL COMMENT '发送人编号',
|
||||||
`sender_type` INT NOT NULL COMMENT '发送人类型',
|
`sender_type` int NOT NULL COMMENT '发送人类型',
|
||||||
`receiver_id` BIGINT NOT NULL COMMENT '接收人编号',
|
`receiver_id` bigint DEFAULT NULL COMMENT '接收人编号',
|
||||||
`receiver_type` INT NOT NULL COMMENT '接收人类型',
|
`receiver_type` int DEFAULT NULL COMMENT '接收人类型',
|
||||||
`content_type` INT NOT NULL COMMENT '消息类型',
|
`content_type` int NOT NULL COMMENT '消息类型',
|
||||||
`content` VARCHAR(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '消息',
|
`content` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '消息',
|
||||||
`read_status` BIT(1) NOT NULL DEFAULT b'0' COMMENT '是否已读',
|
`read_status` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否已读',
|
||||||
`creator` VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者',
|
||||||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
`updater` VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者',
|
||||||
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
`deleted` BIT(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||||
|
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||||
PRIMARY KEY (`id`) USING BTREE
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '客服消息' ROW_FORMAT = Dynamic;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='客服消息';
|
@ -5,9 +5,8 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessagePageReqVO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageRespVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageSendReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessagePageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessageSendReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessageSendReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO;
|
||||||
import cn.iocoder.yudao.module.promotion.service.kefu.KeFuMessageService;
|
import cn.iocoder.yudao.module.promotion.service.kefu.KeFuMessageService;
|
||||||
@ -16,14 +15,13 @@ import io.swagger.v3.oas.annotations.Parameter;
|
|||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 客服消息")
|
@Tag(name = "用户 APP - 客服消息")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/promotion/kefu-message")
|
@RequestMapping("/promotion/kefu-message")
|
||||||
@Validated
|
@Validated
|
||||||
@ -52,8 +50,8 @@ public class AppKeFuMessageController {
|
|||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得客服消息分页")
|
@Operation(summary = "获得客服消息分页")
|
||||||
@PreAuthenticated
|
@PreAuthenticated
|
||||||
public CommonResult<PageResult<KeFuMessageRespVO>> getKefuMessagePage(@Valid KeFuMessagePageReqVO pageReqVO) {
|
public CommonResult<PageResult<KeFuMessageRespVO>> getKefuMessagePage(@Valid AppKeFuMessagePageReqVO pageReqVO) {
|
||||||
PageResult<KeFuMessageDO> pageResult = kefuMessageService.getKefuMessagePage(pageReqVO);
|
PageResult<KeFuMessageDO> pageResult = kefuMessageService.getKefuMessagePage(pageReqVO, getLoginUserId());
|
||||||
return success(BeanUtils.toBean(pageResult, KeFuMessageRespVO.class));
|
return success(BeanUtils.toBean(pageResult, KeFuMessageRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessagePageReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessagePageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessagePageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
@ -23,7 +24,7 @@ public interface KeFuMessageMapper extends BaseMapperX<KeFuMessageDO> {
|
|||||||
default PageResult<KeFuMessageDO> selectPage(KeFuMessagePageReqVO reqVO) {
|
default PageResult<KeFuMessageDO> selectPage(KeFuMessagePageReqVO reqVO) {
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<KeFuMessageDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<KeFuMessageDO>()
|
||||||
.eqIfPresent(KeFuMessageDO::getConversationId, reqVO.getConversationId())
|
.eqIfPresent(KeFuMessageDO::getConversationId, reqVO.getConversationId())
|
||||||
.orderByDesc(KeFuMessageDO::getId));
|
.orderByDesc(KeFuMessageDO::getCreateTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<KeFuMessageDO> selectListByConversationIdAndReadStatus(Long conversationId, Boolean readStatus) {
|
default List<KeFuMessageDO> selectListByConversationIdAndReadStatus(Long conversationId, Boolean readStatus) {
|
||||||
@ -37,4 +38,10 @@ public interface KeFuMessageMapper extends BaseMapperX<KeFuMessageDO> {
|
|||||||
.in(KeFuMessageDO::getId, ids));
|
.in(KeFuMessageDO::getId, ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default PageResult<KeFuMessageDO> selectPage(AppKeFuMessagePageReqVO pageReqVO){
|
||||||
|
return selectPage(pageReqVO, new LambdaQueryWrapperX<KeFuMessageDO>()
|
||||||
|
.eqIfPresent(KeFuMessageDO::getConversationId, pageReqVO.getConversationId())
|
||||||
|
.orderByDesc(KeFuMessageDO::getCreateTime));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -74,4 +74,12 @@ public interface KeFuConversationService {
|
|||||||
*/
|
*/
|
||||||
KeFuConversationDO validateKefuConversationExists(Long id);
|
KeFuConversationDO validateKefuConversationExists(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 【会员】获得客服会话
|
||||||
|
*
|
||||||
|
* @param userId 用户编号
|
||||||
|
* @return 客服会话
|
||||||
|
*/
|
||||||
|
KeFuConversationDO getConversationByUserId(Long userId);
|
||||||
|
|
||||||
}
|
}
|
@ -104,4 +104,9 @@ public class KeFuConversationServiceImpl implements KeFuConversationService {
|
|||||||
return conversation;
|
return conversation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KeFuConversationDO getConversationByUserId(Long userId) {
|
||||||
|
return conversationMapper.selectOne(KeFuConversationDO::getUserId, userId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.promotion.service.kefu;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessagePageReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessagePageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageSendReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageSendReqVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessagePageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessageSendReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessageSendReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
@ -45,4 +46,13 @@ public interface KeFuMessageService {
|
|||||||
*/
|
*/
|
||||||
PageResult<KeFuMessageDO> getKefuMessagePage(KeFuMessagePageReqVO pageReqVO);
|
PageResult<KeFuMessageDO> getKefuMessagePage(KeFuMessagePageReqVO pageReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 【会员】获得客服消息分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 请求
|
||||||
|
* @param userId 用户编号
|
||||||
|
* @return 客服消息分页
|
||||||
|
*/
|
||||||
|
PageResult<KeFuMessageDO> getKefuMessagePage(AppKeFuMessagePageReqVO pageReqVO, Long userId);
|
||||||
|
|
||||||
}
|
}
|
@ -10,6 +10,7 @@ import cn.iocoder.yudao.module.infra.api.websocket.WebSocketSenderApi;
|
|||||||
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessagePageReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessagePageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageSendReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageSendReqVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessagePageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessageSendReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessageSendReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuConversationDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuConversationDO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO;
|
||||||
@ -21,6 +22,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||||
@ -131,6 +133,18 @@ public class KeFuMessageServiceImpl implements KeFuMessageService {
|
|||||||
return keFuMessageMapper.selectPage(pageReqVO);
|
return keFuMessageMapper.selectPage(pageReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<KeFuMessageDO> getKefuMessagePage(AppKeFuMessagePageReqVO pageReqVO, Long userId) {
|
||||||
|
// 1. 获得客服会话
|
||||||
|
KeFuConversationDO conversation = conversationService.getConversationByUserId(userId);
|
||||||
|
if (conversation == null) {
|
||||||
|
return PageResult.empty();
|
||||||
|
}
|
||||||
|
// 2. 设置会话编号
|
||||||
|
pageReqVO.setConversationId(conversation.getId());
|
||||||
|
return keFuMessageMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
private KeFuMessageServiceImpl getSelf() {
|
private KeFuMessageServiceImpl getSelf() {
|
||||||
return SpringUtil.getBean(getClass());
|
return SpringUtil.getBean(getClass());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user