mirror of
				https://github.com/YunaiV/ruoyi-vue-pro.git
				synced 2025-10-31 02:28:03 +08:00 
			
		
		
		
	【功能完善】商城: 客服消息
This commit is contained in:
		| @ -1,6 +1,8 @@ | ||||
| package cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import jakarta.validation.constraints.Max; | ||||
| import jakarta.validation.constraints.Min; | ||||
| import jakarta.validation.constraints.NotNull; | ||||
| import lombok.Data; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
| @ -13,6 +15,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ | ||||
| @Data | ||||
| public class KeFuMessageListReqVO { | ||||
|  | ||||
|     private static final Integer PAGE_SIZE = 10; | ||||
|  | ||||
|     @Schema(description = "会话编号", example = "12580") | ||||
|     @NotNull(message = "会话编号不能为空") | ||||
|     private Long conversationId; | ||||
| @ -21,4 +25,10 @@ public class KeFuMessageListReqVO { | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     private LocalDateTime createTime; | ||||
|  | ||||
|     @Schema(description = "每页条数,最大值为 100", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") | ||||
|     @NotNull(message = "每页条数不能为空") | ||||
|     @Min(value = 1, message = "每页条数最小值为 1") | ||||
|     @Max(value = 100, message = "每页条数最大值为 100") | ||||
|     private Integer pageSize = PAGE_SIZE; | ||||
|  | ||||
| } | ||||
| @ -9,6 +9,8 @@ import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuM | ||||
| 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.service.kefu.KeFuMessageService; | ||||
| import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | ||||
| import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | ||||
| import io.swagger.v3.oas.annotations.Operation; | ||||
| import io.swagger.v3.oas.annotations.Parameter; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| @ -18,8 +20,12 @@ import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||
| import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | ||||
| import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; | ||||
| import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; | ||||
| import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | ||||
|  | ||||
| @Tag(name = "用户 APP - 客服消息") | ||||
| @ -30,6 +36,8 @@ public class AppKeFuMessageController { | ||||
|  | ||||
|     @Resource | ||||
|     private KeFuMessageService kefuMessageService; | ||||
|     @Resource | ||||
|     private AdminUserApi adminUserApi; | ||||
|  | ||||
|     @PostMapping("/send") | ||||
|     @Operation(summary = "发送客服消息") | ||||
| @ -52,8 +60,14 @@ public class AppKeFuMessageController { | ||||
|     @Operation(summary = "获得客服消息列表") | ||||
|     @PreAuthenticated | ||||
|     public CommonResult<List<KeFuMessageRespVO>> getKefuMessageList(@Valid AppKeFuMessagePageReqVO pageReqVO) { | ||||
|         List<KeFuMessageDO> pageResult = kefuMessageService.getKeFuMessageList(pageReqVO, getLoginUserId()); | ||||
|         return success(BeanUtils.toBean(pageResult, KeFuMessageRespVO.class)); | ||||
|         List<KeFuMessageDO> list = kefuMessageService.getKeFuMessageList(pageReqVO, getLoginUserId()); | ||||
|  | ||||
|         // 拼接数据 | ||||
|         List<KeFuMessageRespVO> result = BeanUtils.toBean(list, KeFuMessageRespVO.class); | ||||
|         Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(filterList(result, | ||||
|                 item -> UserTypeEnum.ADMIN.getValue().equals(item.getSenderType())), KeFuMessageRespVO::getSenderId)); | ||||
|         result.forEach(item -> findAndThen(userMap, item.getSenderId(), user -> item.setSenderAvatar(user.getAvatar()))); | ||||
|         return success(result); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @ -1,6 +1,9 @@ | ||||
| package cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import jakarta.validation.constraints.Max; | ||||
| import jakarta.validation.constraints.Min; | ||||
| import jakarta.validation.constraints.NotNull; | ||||
| import lombok.Data; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
|  | ||||
| @ -12,6 +15,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ | ||||
| @Data | ||||
| public class AppKeFuMessagePageReqVO { | ||||
|  | ||||
|     private static final Integer PAGE_SIZE = 10; | ||||
|  | ||||
|     @Schema(description = "会话编号", example = "12580") | ||||
|     private Long conversationId; | ||||
|  | ||||
| @ -19,4 +24,10 @@ public class AppKeFuMessagePageReqVO { | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     private LocalDateTime createTime; | ||||
|  | ||||
|     @Schema(description = "每页条数,最大值为 100", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") | ||||
|     @NotNull(message = "每页条数不能为空") | ||||
|     @Min(value = 1, message = "每页条数最小值为 1") | ||||
|     @Max(value = 100, message = "每页条数最大值为 100") | ||||
|     private Integer pageSize = PAGE_SIZE; | ||||
|  | ||||
| } | ||||
| @ -1,7 +1,7 @@ | ||||
| package cn.iocoder.yudao.module.promotion.dal.mysql.kefu; | ||||
|  | ||||
| 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.QueryWrapperX; | ||||
| import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageListReqVO; | ||||
| import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO; | ||||
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
| @ -28,11 +28,11 @@ public interface KeFuMessageMapper extends BaseMapperX<KeFuMessageDO> { | ||||
|      * @return 消息列表 | ||||
|      */ | ||||
|     default List<KeFuMessageDO> selectList(KeFuMessageListReqVO reqVO) { | ||||
|         return selectList(new LambdaQueryWrapperX<KeFuMessageDO>() | ||||
|                 .eqIfPresent(KeFuMessageDO::getConversationId, reqVO.getConversationId()) | ||||
|                 .ltIfPresent(KeFuMessageDO::getCreateTime, reqVO.getCreateTime()) | ||||
|                 .orderByDesc(KeFuMessageDO::getCreateTime) | ||||
|                 .last("limit 10")); // TODO @puhui999:使用 limitN 哈。然后 10 通过 reqVO 传递。 | ||||
|         return selectList(new QueryWrapperX<KeFuMessageDO>() | ||||
|                 .eqIfPresent("conversation_id", reqVO.getConversationId()) | ||||
|                 .ltIfPresent("create_time", reqVO.getCreateTime()) | ||||
|                 .orderByDesc("create_time") | ||||
|                 .limitN(reqVO.getPageSize())); | ||||
|     } | ||||
|  | ||||
|     default List<KeFuMessageDO> selectListByConversationIdAndUserTypeAndReadStatus(Long conversationId, Integer userType, | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 puhui999
					puhui999