From c16c51e5e6634017de5c2d84bfec778ba4181b79 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Mon, 30 Jan 2023 16:35:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BD=AE=E9=A1=B6=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ningdatech/pmapi/sys/controller/NoticeController.java | 7 +++++++ .../main/java/com/ningdatech/pmapi/sys/entity/Notice.java | 3 +-- .../java/com/ningdatech/pmapi/sys/manage/NoticeManage.java | 12 ++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/NoticeController.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/NoticeController.java index 26cb952..f986cfc 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/NoticeController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/NoticeController.java @@ -52,6 +52,13 @@ public class NoticeController { return noticeManage.changeEnabled(req); } + @PostMapping("/topped") + @ApiOperation("置顶") + @WebLog("置顶") + public void topped(@RequestBody IdVo id) { + noticeManage.topped(id.getId()); + } + @GetMapping("/dashboard/list") @ApiOperation("工作台公告列表") public PageVo dashboardList(@RequestParam(required = false, defaultValue = "3") Integer limit) { diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/entity/Notice.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/entity/Notice.java index 1e8d750..e098ce9 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/entity/Notice.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/entity/Notice.java @@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.Api; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -63,6 +62,6 @@ public class Notice implements Serializable { private Boolean deleted; @ApiModelProperty("置顶时间") - private LocalDateTime setTopTime; + private LocalDateTime toppedTime; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NoticeManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NoticeManage.java index ee187ad..bf45d80 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NoticeManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NoticeManage.java @@ -22,6 +22,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDateTime; import java.util.List; /** @@ -64,6 +65,13 @@ public class NoticeManage { return noticeService.updateById(notice); } + public void topped(Long id) { + Notice notice = new Notice(); + notice.setId(id); + notice.setToppedTime(LocalDateTime.now()); + noticeService.updateById(notice); + } + public PageVo dashboardList(Integer limit) { NoticeListReq req = new NoticeListReq(); @@ -77,7 +85,7 @@ public class NoticeManage { .eq(req.getEnabled() != null, Notice::getEnabled, req.getEnabled()) .like(StrUtil.isNotBlank(req.getTitle()), Notice::getTitle, req.getTitle()) .eq(req.getType() != null, Notice::getType, req.getType()) - .orderByDesc(Notice::getSetTopTime, Notice::getUpdateOn); + .orderByDesc(Notice::getToppedTime, Notice::getUpdateOn); Page page = noticeService.page(req.page(), wrapper); if (page.getTotal() == 0) { return PageVo.empty(); @@ -89,7 +97,7 @@ public class NoticeManage { .title(w.getTitle()) .enabled(w.getEnabled()) .createOn(w.getCreateOn()) - .topped(w.getSetTopTime() != null) + .topped(w.getToppedTime() != null) .build()); return PageVo.of(tempDataList, page.getTotal()); }