Browse Source

添加了新闻更新置顶和附件功能

bigcat 2 years ago
parent
commit
4a31ee57f4

+ 2 - 1
src/main/java/sqgxy/xxydz/controller/NewsController.java

@@ -54,9 +54,10 @@ public class NewsController {
     @GeneralAdmin
     @ApiOperation(value = "修改新闻")
     @PostMapping("/update")
-    public Result updateNews(MultipartFile pictureFile, NewsUpdateVO vo) throws IOException {
+    public Result updateNews(MultipartFile pictureFile, NewsUpdateVO vo,MultipartFile attachment) throws IOException {
         NewsUpdateDTO newsUpdateDTO = modelMapper.map(vo, NewsUpdateDTO.class);
         newsUpdateDTO.setPictureFile(pictureFile);
+        newsUpdateDTO.setAttachment(attachment);
         return new Result().ok().data(newsService.updateNews(newsUpdateDTO));
     }
 

+ 2 - 0
src/main/java/sqgxy/xxydz/dto/NewsQueryDTO.java

@@ -26,4 +26,6 @@ public class NewsQueryDTO {
     private Integer hits;
 
     private String content;
+
+    private String attachmentPath;
 }

+ 6 - 0
src/main/java/sqgxy/xxydz/dto/NewsUpdateDTO.java

@@ -32,4 +32,10 @@ public class NewsUpdateDTO {
     private String content;
 
     private Integer newsCategoryId;
+
+    private Integer sticky;
+
+    private MultipartFile attachment;
+
+    private String attachmentPath;
 }

+ 6 - 0
src/main/java/sqgxy/xxydz/service/impl/NewsServiceImpl.java

@@ -96,6 +96,12 @@ public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements Ne
             String s = HeaderImgUpload.headPortraitUpload(dto.getPictureFile());
             dto.setPicturePath(s);
         }
+
+        // 需要修改附件
+        if (dto.getAttachment() != null) {
+            String s = HeaderImgUpload.headPortraitUpload(dto.getAttachment());
+            dto.setAttachmentPath(s);
+        }
         return updateById(modelMapper.map(dto, News.class));
     }
 

+ 4 - 0
src/main/java/sqgxy/xxydz/vo/news/NewsUpdateVO.java

@@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import org.springframework.format.annotation.DateTimeFormat;
+import org.springframework.web.multipart.MultipartFile;
 
 
 import java.util.Date;
@@ -29,5 +30,8 @@ public class NewsUpdateVO {
 
     private String content;
 
+    private Integer sticky;
+
+
     private Integer newsCategoryId;
 }