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("操作失败")); }