Commit 396051b41ebe3e074bab6d7ac759b64fdac028fd
1 parent
c239d9cc
【代码合并】商城:合并最新的 master-jdk17 分支
Showing
1 changed file
with
22 additions
and
9 deletions
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/kefu/AppKeFuMessageController.java
| ... | ... | @@ -3,12 +3,13 @@ package cn.iocoder.yudao.module.promotion.controller.app.kefu; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 6 | -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; | |
| 7 | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageRespVO; |
| 8 | 7 | import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessagePageReqVO; |
| 9 | 8 | import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessageSendReqVO; |
| 10 | 9 | import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO; |
| 11 | 10 | import cn.iocoder.yudao.module.promotion.service.kefu.KeFuMessageService; |
| 11 | +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | |
| 12 | +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | |
| 12 | 13 | import io.swagger.v3.oas.annotations.Operation; |
| 13 | 14 | import io.swagger.v3.oas.annotations.Parameter; |
| 14 | 15 | import io.swagger.v3.oas.annotations.tags.Tag; |
| ... | ... | @@ -17,7 +18,13 @@ import jakarta.validation.Valid; |
| 17 | 18 | import org.springframework.validation.annotation.Validated; |
| 18 | 19 | import org.springframework.web.bind.annotation.*; |
| 19 | 20 | |
| 21 | +import java.util.List; | |
| 22 | +import java.util.Map; | |
| 23 | + | |
| 20 | 24 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 25 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 26 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; | |
| 27 | +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; | |
| 21 | 28 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 22 | 29 | |
| 23 | 30 | @Tag(name = "用户 APP - 客服消息") |
| ... | ... | @@ -29,9 +36,11 @@ public class AppKeFuMessageController { |
| 29 | 36 | @Resource |
| 30 | 37 | private KeFuMessageService kefuMessageService; |
| 31 | 38 | |
| 39 | + @Resource | |
| 40 | + private AdminUserApi adminUserApi; | |
| 41 | + | |
| 32 | 42 | @PostMapping("/send") |
| 33 | 43 | @Operation(summary = "发送客服消息") |
| 34 | - @PreAuthenticated | |
| 35 | 44 | public CommonResult<Long> sendKefuMessage(@Valid @RequestBody AppKeFuMessageSendReqVO sendReqVO) { |
| 36 | 45 | sendReqVO.setSenderId(getLoginUserId()).setSenderType(UserTypeEnum.MEMBER.getValue()); // 设置用户编号和类型 |
| 37 | 46 | return success(kefuMessageService.sendKefuMessage(sendReqVO)); |
| ... | ... | @@ -40,18 +49,22 @@ public class AppKeFuMessageController { |
| 40 | 49 | @PutMapping("/update-read-status") |
| 41 | 50 | @Operation(summary = "更新客服消息已读状态") |
| 42 | 51 | @Parameter(name = "conversationId", description = "会话编号", required = true) |
| 43 | - @PreAuthenticated | |
| 44 | 52 | public CommonResult<Boolean> updateKefuMessageReadStatus(@RequestParam("conversationId") Long conversationId) { |
| 45 | 53 | kefuMessageService.updateKeFuMessageReadStatus(conversationId, getLoginUserId(), UserTypeEnum.MEMBER.getValue()); |
| 46 | 54 | return success(true); |
| 47 | 55 | } |
| 48 | 56 | |
| 49 | - @GetMapping("/page") | |
| 50 | - @Operation(summary = "获得客服消息分页") | |
| 51 | - @PreAuthenticated | |
| 52 | - public CommonResult<PageResult<KeFuMessageRespVO>> getKefuMessagePage(@Valid AppKeFuMessagePageReqVO pageReqVO) { | |
| 53 | - PageResult<KeFuMessageDO> pageResult = kefuMessageService.getKeFuMessagePage(pageReqVO, getLoginUserId()); | |
| 54 | - return success(BeanUtils.toBean(pageResult, KeFuMessageRespVO.class)); | |
| 57 | + @GetMapping("/list") | |
| 58 | + @Operation(summary = "获得客服消息列表") | |
| 59 | + public CommonResult<List<KeFuMessageRespVO>> getKefuMessageList(@Valid AppKeFuMessagePageReqVO pageReqVO) { | |
| 60 | + List<KeFuMessageDO> list = kefuMessageService.getKeFuMessageList(pageReqVO, getLoginUserId()); | |
| 61 | + | |
| 62 | + // 拼接数据 | |
| 63 | + List<KeFuMessageRespVO> result = BeanUtils.toBean(list, KeFuMessageRespVO.class); | |
| 64 | + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(filterList(result, | |
| 65 | + item -> UserTypeEnum.ADMIN.getValue().equals(item.getSenderType())), KeFuMessageRespVO::getSenderId)); | |
| 66 | + result.forEach(item -> findAndThen(userMap, item.getSenderId(), user -> item.setSenderAvatar(user.getAvatar()))); | |
| 67 | + return success(result); | |
| 55 | 68 | } |
| 56 | 69 | |
| 57 | 70 | } |
| 58 | 71 | \ No newline at end of file | ... | ... |