添加默认创建时间和修改时间
This commit is contained in:
parent
da91a40644
commit
648d999a7c
|
@ -21,6 +21,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author chenchen
|
* @author chenchen
|
||||||
* @date 2020/10/12
|
* @date 2020/10/12
|
||||||
|
@ -101,6 +103,7 @@ public class ApiNoticeController extends ApiBaseController {
|
||||||
@PostMapping("/save")
|
@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) {
|
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();
|
Notice bean = new Notice();
|
||||||
|
bean.setCreatedAt(LocalDateTime.now());
|
||||||
bean.setTitle(title);
|
bean.setTitle(title);
|
||||||
bean.setContent(content);
|
bean.setContent(content);
|
||||||
bean.setNoticeDate(noticeDate);
|
bean.setNoticeDate(noticeDate);
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,6 +88,8 @@ public class NoticeController extends BaseAdminController {
|
||||||
@PreAuth("rddb:policy:save")
|
@PreAuth("rddb:policy:save")
|
||||||
@PostMapping("/save")
|
@PostMapping("/save")
|
||||||
public void save(@Validated NoticeBo noticeBo) {
|
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());
|
boolean flag = noticeService.saveOrUpdate(noticeBo, getLoginUser());
|
||||||
render(flag ? Ret.ok() : Ret.fail("操作失败"));
|
render(flag ? Ret.ok() : Ret.fail("操作失败"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue