소스 검색

留言修改

licailing 4 년 전
부모
커밋
d57b0252f0

+ 2 - 0
src/main/java/com/izouma/zhirongip/domain/Information.java

@@ -27,5 +27,7 @@ public class Information extends BaseEntity {
     @ApiModelProperty(value = "内容")
     private String content;
 
+    private Long messageId;
+
     private boolean isRead;
 }

+ 8 - 0
src/main/java/com/izouma/zhirongip/repo/InformationRepo.java

@@ -34,4 +34,12 @@ public interface InformationRepo extends JpaRepository<Information, Long>, JpaSp
     未读数量
      */
     int countByReceiveUserIdAndIsReadFalse(Long receiveUserId);
+
+    /*
+   批量删除留言消息
+    */
+    @Query("update Information t set t.del = true where t.messageId = ?1")
+    @Modifying
+    @Transactional
+    void batchSoftDeleteByMessageId(Long messageId);
 }

+ 1 - 0
src/main/java/com/izouma/zhirongip/service/MessageService.java

@@ -32,6 +32,7 @@ public class MessageService {
                 .builder()
                 .receiveUserId(message.getUserId())
                 .isRead(false)
+                .messageId(id)
                 .content("收到关于提问" + message.getTitle() + "的内容回复:" + message.getReplyContent())
                 .build());
 

+ 9 - 4
src/main/java/com/izouma/zhirongip/service/resource/IntellectualPropertyService.java

@@ -67,10 +67,15 @@ public class IntellectualPropertyService {
 
     public IntellectualProperty get(Long id) {
         IntellectualProperty property = intellectualPropertyRepo.findById(id).orElseThrow(new BusinessException("无记录"));
-        settingRepo.findById(property.getTypeId())
-                .ifPresent(setting -> property.setType(setting.getName()));
-        settingRepo.findById(property.getLawStatusId())
-                .ifPresent(setting -> property.setLawStatus(setting.getName()));
+        if (ObjectUtil.isNotNull(property.getTypeId())){
+            settingRepo.findById(property.getTypeId())
+                    .ifPresent(setting -> property.setType(setting.getName()));
+        }
+        if (ObjectUtil.isNotNull(property.getLawStatusId())){
+            settingRepo.findById(property.getLawStatusId())
+                    .ifPresent(setting -> property.setLawStatus(setting.getName()));
+        }
+
         return property;
     }
 

+ 14 - 3
src/main/java/com/izouma/zhirongip/web/MessageController.java

@@ -1,6 +1,8 @@
 package com.izouma.zhirongip.web;
 
+import com.izouma.zhirongip.domain.Information;
 import com.izouma.zhirongip.domain.Message;
+import com.izouma.zhirongip.repo.InformationRepo;
 import com.izouma.zhirongip.service.MessageService;
 import com.izouma.zhirongip.dto.PageQuery;
 import com.izouma.zhirongip.exception.BusinessException;
@@ -22,8 +24,9 @@ import java.util.List;
 @RequestMapping("/message")
 @AllArgsConstructor
 public class MessageController extends BaseController {
-    private final MessageService messageService;
-    private final MessageRepo    messageRepo;
+    private final MessageService  messageService;
+    private final MessageRepo     messageRepo;
+    private final InformationRepo informationRepo;
 
     //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/save")
@@ -35,7 +38,13 @@ public class MessageController extends BaseController {
             return messageRepo.save(orig);
         }
         record.setUserId(userId);
-        return messageRepo.save(record);
+        record = messageRepo.save(record);
+        informationRepo.save(Information.builder()
+                .messageId(record.getId())
+                .receiveUserId(userId)
+                .content("已收到您的留言" + record.getTitle() + ",请耐心等待回复!")
+                .build());
+        return record;
     }
 
 
@@ -53,6 +62,8 @@ public class MessageController extends BaseController {
     @PostMapping("/del/{id}")
     public void del(@PathVariable Long id) {
         messageRepo.softDelete(id);
+        //删除相关留言消息
+        informationRepo.batchSoftDeleteByMessageId(id);
     }
 
     @GetMapping("/excel")