Pārlūkot izejas kodu

修改返图匿名聊天的对方备注

fangzhen 5 mēneši atpakaļ
vecāks
revīzija
483651fa5d

+ 14 - 12
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityChatMsgController.java

@@ -6,7 +6,6 @@ import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.exception.user.ProjectException;
-import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.bean.BeanUtils;
 import com.ruoyi.generator.domain.Community.CommunityReturnRecord;
@@ -217,21 +216,24 @@ public class CommunityChatMsgController extends BaseController {
         long otherUserId = updateAnonName.getOtherUserId();
         String newAnonName = updateAnonName.getNewAnonName();
         String type = updateAnonName.getType();
+        String returnRecordId = updateAnonName.getReturnRecordId();
         try {
             if ("anonymous".equals(type)) {
-                List<CommunityChatMsg> chatMsgList = communitychatMsgMapper.getChatMsgRecord(userId, otherUserId, type);
-                for (CommunityChatMsg chatMsg : chatMsgList) {
-                    if (chatMsg.getSenderId().equals(otherUserId)) {
-                        chatMsg.setSenderAnonName(newAnonName);
-                    }
+                CommunityReturnRecord returnRecord = communityReturnRecordService.getOne(new UpdateWrapper<CommunityReturnRecord>()
+                        .eq("id", returnRecordId));
+                if (returnRecord.getReturnCreateUserId().equals(otherUserId)) {
+                    System.out.println("修改创建者者匿名名称:" + newAnonName);
+                    communityReturnRecordService.update(new UpdateWrapper<CommunityReturnRecord>()
+                            .eq("id", returnRecordId)
+                            .set("return_create_anon_name", newAnonName));
+                }
 
-                    if (chatMsg.getReceiverId().equals(otherUserId)) {
-                        chatMsg.setReceiverAnonName(newAnonName);
-                    }
-                    chatMsg.setUpdateBy(SecurityUtils.getUserId());
-                    chatMsg.setUpdateTime(DateUtils.parseDate(DateUtils.getDate()));
+                if (returnRecord.getReturnReceiveUserId().equals(otherUserId)) {
+                    System.out.println("修改接收者者匿名名称:" + newAnonName);
+                    communityReturnRecordService.update(new UpdateWrapper<CommunityReturnRecord>()
+                            .eq("id", returnRecordId)
+                            .set("return_receive_anon_name", newAnonName));
                 }
-                communityChatMsgService.updateBatchById(chatMsgList);
             }
         } catch (Exception e) {
             System.out.println(e.getMessage());

+ 1 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/ReqEntity/UpdateAnonName.java

@@ -8,6 +8,7 @@ import lombok.NoArgsConstructor;
 @NoArgsConstructor
 @AllArgsConstructor
 public class UpdateAnonName {
+    private String returnRecordId;
     private long otherUserId;
     private String newAnonName;
     private String type;