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()); }