1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-05 23:11:24 +08:00

modify the function of paging the noticeType

This commit is contained in:
cccccyb
2023-05-28 18:21:46 +08:00
parent e6e9ce9965
commit 10d3d0e4e8
12 changed files with 194 additions and 86 deletions

View File

@@ -7,12 +7,13 @@ import com.cfive.pinnacle.entity.common.ResponseCode;
import com.cfive.pinnacle.entity.common.ResponseResult;
import com.cfive.pinnacle.service.INoticeReceiveService;
import com.cfive.pinnacle.service.INoticeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.stream.Collectors;
/**
* <p>
@@ -26,6 +27,7 @@ import java.util.List;
@RestController
@RequestMapping("/notice")
@CrossOrigin
@Slf4j
public class NoticeController {
@Autowired
private INoticeService noticeService;
@@ -34,7 +36,6 @@ public class NoticeController {
//根据公告id查公告信息及发布人
@GetMapping("/{nid}")
@PreAuthorize("hasAuthority('notice:manage:get')")
public ResponseResult<Notice> selectByNoticeId(@PathVariable Long nid) {
Notice noticeById = noticeService.selectByNoticeId(nid);
Integer code = noticeById != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
@@ -44,7 +45,6 @@ public class NoticeController {
//查询所有公告或模糊查询
@GetMapping
@PreAuthorize("hasAuthority('notice:manage:get')")
public ResponseResult<List<Notice>> selectAllNotice(String title, String type, String startTime, String endTime) {
List<Notice> noticeList;
if (!StringUtils.hasText(title) && !StringUtils.hasText(type) && !StringUtils.hasText(startTime) && !StringUtils.hasText(endTime)) {
@@ -60,7 +60,6 @@ public class NoticeController {
//根据登录用户id查询所接收的公告
@GetMapping("/self")
@PreAuthorize("hasAuthority('notice:self:get')")
public ResponseResult<List<Notice>> selectByUserId(Integer readStatus) {
List<Notice> noticesByUserId = noticeReceiveService.selectByUserId(readStatus);
Integer code = noticesByUserId != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
@@ -70,9 +69,8 @@ public class NoticeController {
//修改登录用户所接收公告的阅读状态
@PutMapping("/modify_notice_read")
@PreAuthorize("hasAuthority('notice:self:get')")
public ResponseResult<?> modifyNoticeIsRead(@RequestBody Notice notice) {
boolean updateById = false;
Boolean updateById = false;
if (null != notice) {
updateById = noticeReceiveService.modifyNoticeIsRead(notice);
}
@@ -84,24 +82,22 @@ public class NoticeController {
//更新公告
@PutMapping
public ResponseResult<?> updateNotice(@RequestBody Notice notice) {
boolean updateById = noticeService.updateNotice(notice);
Boolean updateById = noticeService.updateNotice(notice);
String msg = updateById ? "" : "数据修改失败,请重试!";
return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, null);
}
//修改公告置顶状态
@PutMapping("/update_notice_top")
@PreAuthorize("hasAuthority('notice:self:get')")
public ResponseResult<?> updateNoticeTop(@RequestBody Notice notice) {
String operationMessage = notice.getTop() == 1 ? "取消置顶" : "置顶";
boolean updateResult = noticeService.updateNoticeTop(notice);
Boolean updateResult = noticeService.updateNoticeTop(notice);
String msg = updateResult ? "已成功" + operationMessage : operationMessage + "失败,请重试!";
return ResponseResult.build(updateResult ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, null);
}
//添加公告
@PostMapping
@PreAuthorize("hasAuthority('notice:manage:add')")
public ResponseResult<?> addNotice(@RequestBody Notice notice) {
Boolean insertNotice = noticeService.addNotice(notice);
String msg = insertNotice ? "" : "数据添加失败,请重试!";
@@ -110,19 +106,27 @@ public class NoticeController {
//删除公告
@DeleteMapping("/{nid}")
@PreAuthorize("hasAuthority('notice:manage:modify')")
public ResponseResult<?> deleteByNoticeId(@PathVariable Long nid) {
boolean removeById = noticeService.deleteById(nid);
Boolean removeById = noticeService.deleteById(nid);
String msg = removeById ? "" : "数据删除失败,请重试!";
return ResponseResult.build(removeById ? ResponseCode.DATABASE_DELETE_OK : ResponseCode.DATABASE_DELETE_ERROR, msg, null);
}
//批量删除公告
@PostMapping("/batch")
public ResponseResult<?> deleteBatchByIds(@RequestBody List<String> noticeIds){
// List<String>转List<Long>
List<Long> nIds = noticeIds.stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
Boolean deleteBatchByIds = noticeService.deleteBatchByIds(nIds);
String msg = deleteBatchByIds ? "" : "数据删除失败,请重试!";
return ResponseResult.build(deleteBatchByIds ? ResponseCode.DATABASE_DELETE_OK : ResponseCode.DATABASE_DELETE_ERROR, msg, null);
}
//分页查询所有公告或分页模糊查询
@GetMapping("/page")
@PreAuthorize("hasAuthority('notice:manage:get')")
public ResponseResult<List<Notice>> selectPageAllNotice(Integer currentPage, Integer pageSize, String title, String type, String startTime, String endTime) {
IPage<Notice> noticePageList;
Page<?> page = new Page();
Page<Notice> page = new Page();
if (null != currentPage && null != pageSize) {
page.setCurrent(currentPage.intValue());
page.setSize(pageSize.intValue());