Browse Source

增加置顶接口

master
WendyYang 1 year ago
parent
commit
c16c51e5e6
3 changed files with 18 additions and 4 deletions
  1. +7
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/NoticeController.java
  2. +1
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/sys/entity/Notice.java
  3. +10
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NoticeManage.java

+ 7
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/NoticeController.java View File

@@ -52,6 +52,13 @@ public class NoticeController {
return noticeManage.changeEnabled(req); return noticeManage.changeEnabled(req);
} }


@PostMapping("/topped")
@ApiOperation("置顶")
@WebLog("置顶")
public void topped(@RequestBody IdVo<Long> id) {
noticeManage.topped(id.getId());
}

@GetMapping("/dashboard/list") @GetMapping("/dashboard/list")
@ApiOperation("工作台公告列表") @ApiOperation("工作台公告列表")
public PageVo<NoticeListItemVO> dashboardList(@RequestParam(required = false, defaultValue = "3") Integer limit) { public PageVo<NoticeListItemVO> dashboardList(@RequestParam(required = false, defaultValue = "3") Integer limit) {


+ 1
- 2
pmapi/src/main/java/com/ningdatech/pmapi/sys/entity/Notice.java View File

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@@ -63,6 +62,6 @@ public class Notice implements Serializable {
private Boolean deleted; private Boolean deleted;


@ApiModelProperty("置顶时间") @ApiModelProperty("置顶时间")
private LocalDateTime setTopTime;
private LocalDateTime toppedTime;


} }

+ 10
- 2
pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NoticeManage.java View File

@@ -22,6 +22,7 @@ import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;


import java.time.LocalDateTime;
import java.util.List; import java.util.List;


/** /**
@@ -64,6 +65,13 @@ public class NoticeManage {
return noticeService.updateById(notice); 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<NoticeListItemVO> dashboardList(Integer limit) { public PageVo<NoticeListItemVO> dashboardList(Integer limit) {
NoticeListReq req = new NoticeListReq(); NoticeListReq req = new NoticeListReq();
@@ -77,7 +85,7 @@ public class NoticeManage {
.eq(req.getEnabled() != null, Notice::getEnabled, req.getEnabled()) .eq(req.getEnabled() != null, Notice::getEnabled, req.getEnabled())
.like(StrUtil.isNotBlank(req.getTitle()), Notice::getTitle, req.getTitle()) .like(StrUtil.isNotBlank(req.getTitle()), Notice::getTitle, req.getTitle())
.eq(req.getType() != null, Notice::getType, req.getType()) .eq(req.getType() != null, Notice::getType, req.getType())
.orderByDesc(Notice::getSetTopTime, Notice::getUpdateOn);
.orderByDesc(Notice::getToppedTime, Notice::getUpdateOn);
Page<Notice> page = noticeService.page(req.page(), wrapper); Page<Notice> page = noticeService.page(req.page(), wrapper);
if (page.getTotal() == 0) { if (page.getTotal() == 0) {
return PageVo.empty(); return PageVo.empty();
@@ -89,7 +97,7 @@ public class NoticeManage {
.title(w.getTitle()) .title(w.getTitle())
.enabled(w.getEnabled()) .enabled(w.getEnabled())
.createOn(w.getCreateOn()) .createOn(w.getCreateOn())
.topped(w.getSetTopTime() != null)
.topped(w.getToppedTime() != null)
.build()); .build());
return PageVo.of(tempDataList, page.getTotal()); return PageVo.of(tempDataList, page.getTotal());
} }


Loading…
Cancel
Save