From 648d999a7c3920067241761e8487e61b864fc459 Mon Sep 17 00:00:00 2001 From: lijiaqi Date: Fri, 12 Aug 2022 15:09:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=BB=98=E8=AE=A4=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=97=B6=E9=97=B4=E5=92=8C=E4=BF=AE=E6=94=B9=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ydool/boot/api/controller/ApiNoticeController.java | 3 +++ .../java/com/ydool/boot/modules/rddb/web/NoticeController.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/main/java/com/ydool/boot/api/controller/ApiNoticeController.java b/src/main/java/com/ydool/boot/api/controller/ApiNoticeController.java index 57db744..8f4b1b6 100644 --- a/src/main/java/com/ydool/boot/api/controller/ApiNoticeController.java +++ b/src/main/java/com/ydool/boot/api/controller/ApiNoticeController.java @@ -21,6 +21,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; +import java.time.LocalDateTime; + /** * @author chenchen * @date 2020/10/12 @@ -101,6 +103,7 @@ public class ApiNoticeController extends ApiBaseController { @PostMapping("/save") public void ApiNoticeSave(String title, String content, String noticeDate, Integer top, String coverNames, String coverPaths, String fileNames, String filePaths, String type, String obj) { Notice bean = new Notice(); + bean.setCreatedAt(LocalDateTime.now()); bean.setTitle(title); bean.setContent(content); bean.setNoticeDate(noticeDate); diff --git a/src/main/java/com/ydool/boot/modules/rddb/web/NoticeController.java b/src/main/java/com/ydool/boot/modules/rddb/web/NoticeController.java index 247600e..d3039ba 100644 --- a/src/main/java/com/ydool/boot/modules/rddb/web/NoticeController.java +++ b/src/main/java/com/ydool/boot/modules/rddb/web/NoticeController.java @@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; +import java.time.LocalDateTime; import java.util.List; /** @@ -87,6 +88,8 @@ public class NoticeController extends BaseAdminController { @PreAuth("rddb:policy:save") @PostMapping("/save") public void save(@Validated NoticeBo noticeBo) { + if (noticeBo.getId()!=null) noticeBo.setCreatedAt(LocalDateTime.now()); + else noticeBo.setUpdatedAt(LocalDateTime.now()); boolean flag = noticeService.saveOrUpdate(noticeBo, getLoginUser()); render(flag ? Ret.ok() : Ret.fail("操作失败")); }