refactor: 通知公告重构
This commit is contained in:
@@ -4,11 +4,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.youlai.boot.common.result.PageResult;
|
||||
import com.youlai.boot.common.result.Result;
|
||||
import com.youlai.boot.system.model.form.NoticeForm;
|
||||
import com.youlai.boot.system.model.query.NoticeQuery;
|
||||
import com.youlai.boot.system.model.vo.NoticeStatusVO;
|
||||
import com.youlai.boot.system.model.query.NoticePageQuery;
|
||||
import com.youlai.boot.system.model.vo.NoticeDetailVO;
|
||||
import com.youlai.boot.system.model.vo.UserNoticePageVO;
|
||||
import com.youlai.boot.system.model.vo.NoticeVO;
|
||||
import com.youlai.boot.system.service.NoticeService;
|
||||
import com.youlai.boot.system.service.NoticeStatusService;
|
||||
import com.youlai.boot.system.service.UserNoticeService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -18,6 +19,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通知公告前端控制层
|
||||
*
|
||||
@@ -28,48 +31,51 @@ import org.springframework.web.bind.annotation.*;
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/notices")
|
||||
@RequiredArgsConstructor
|
||||
public class NoticeController {
|
||||
public class NoticeController {
|
||||
|
||||
private final NoticeService noticeService;
|
||||
|
||||
private final NoticeStatusService noticeStatusService;
|
||||
private final UserNoticeService userNoticeService;
|
||||
|
||||
@Operation(summary = "通知公告分页列表")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@ss.hasPerm('system:notice:query')")
|
||||
public PageResult<NoticeVO> getNoticePage(NoticeQuery queryParams ) {
|
||||
@PreAuthorize("@ss.hasPerm('sys:notice:query')")
|
||||
public PageResult<NoticeVO> getNoticePage(NoticePageQuery queryParams) {
|
||||
IPage<NoticeVO> result = noticeService.getNoticePage(queryParams);
|
||||
return PageResult.success(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "新增通知公告")
|
||||
@PostMapping
|
||||
@PreAuthorize("@ss.hasPerm('system:notice:add')")
|
||||
public Result<?> saveNotice(@RequestBody @Valid NoticeForm formData ) {
|
||||
@PreAuthorize("@ss.hasPerm('sys:notice:add')")
|
||||
public Result<?> saveNotice(@RequestBody @Valid NoticeForm formData) {
|
||||
boolean result = noticeService.saveNotice(formData);
|
||||
return Result.judge(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取通知公告表单数据")
|
||||
@GetMapping("/{id}/form")
|
||||
@PreAuthorize("@ss.hasPerm('system:notice:edit')")
|
||||
@PreAuthorize("@ss.hasPerm('sys:notice:edit')")
|
||||
public Result<NoticeForm> getNoticeForm(
|
||||
@Parameter(description = "通知公告ID") @PathVariable Long id
|
||||
@Parameter(description = "通知公告ID") @PathVariable Long id
|
||||
) {
|
||||
NoticeForm formData = noticeService.getNoticeFormData(id);
|
||||
return Result.success(formData);
|
||||
}
|
||||
@Operation(summary = "管理页面查看通知公告")
|
||||
@GetMapping("/detail/{id}")
|
||||
public Result<?> getReadNoticeDetail(
|
||||
@Parameter(description = "通知公告ID")@PathVariable Long id) {
|
||||
return Result.success(noticeService.getReadNoticeDetail(id));
|
||||
|
||||
@Operation(summary = "阅读获取通知公告详情")
|
||||
@GetMapping("/{id}/detail")
|
||||
public Result<NoticeDetailVO> getNoticeDetail(
|
||||
@Parameter(description = "通知公告ID") @PathVariable Long id
|
||||
) {
|
||||
NoticeDetailVO detailVO = noticeService.getNoticeDetail(id);
|
||||
return Result.success(detailVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "修改通知公告")
|
||||
@PutMapping(value = "/{id}")
|
||||
@PreAuthorize("@ss.hasPerm('system:notice:edit')")
|
||||
public Result<?> updateNotice(
|
||||
@PreAuthorize("@ss.hasPerm('sys:notice:edit')")
|
||||
public Result<Void> updateNotice(
|
||||
@Parameter(description = "通知公告ID") @PathVariable Long id,
|
||||
@RequestBody @Validated NoticeForm formData
|
||||
) {
|
||||
@@ -78,26 +84,30 @@ public class NoticeController {
|
||||
}
|
||||
|
||||
@Operation(summary = "发布通知公告")
|
||||
@PatchMapping(value = "/release/{id}")
|
||||
@PreAuthorize("@ss.hasPerm('system:notice:release')")
|
||||
public Result<?> releaseNotice(@Parameter(description = "通知公告ID") @PathVariable Long id) {
|
||||
boolean result = noticeService.releaseNotice(id);
|
||||
@PatchMapping(value = "/{id}/publish")
|
||||
@PreAuthorize("@ss.hasPerm('sys:notice:publish')")
|
||||
public Result<Void> publishNotice(
|
||||
@Parameter(description = "通知公告ID") @PathVariable Long id
|
||||
) {
|
||||
boolean result = noticeService.publishNotice(id);
|
||||
return Result.judge(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "撤回通知公告")
|
||||
@PatchMapping(value = "/recall/{id}")
|
||||
@PreAuthorize("@ss.hasPerm('system:notice:recall')")
|
||||
public Result<?> recallNotice(@Parameter(description = "通知公告ID") @PathVariable Long id) {
|
||||
boolean result = noticeService.recallNotice(id);
|
||||
@PatchMapping(value = "/{id}/revoke")
|
||||
@PreAuthorize("@ss.hasPerm('sys:notice:revoke')")
|
||||
public Result<Void> revokeNotice(
|
||||
@Parameter(description = "通知公告ID") @PathVariable Long id
|
||||
) {
|
||||
boolean result = noticeService.revokeNotice(id);
|
||||
return Result.judge(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除通知公告")
|
||||
@DeleteMapping("/{ids}")
|
||||
@PreAuthorize("@ss.hasPerm('system:notice:delete')")
|
||||
public Result<?> deleteNotices(
|
||||
@Parameter(description = "通知公告ID,多个以英文逗号(,)分割") @PathVariable String ids
|
||||
@PreAuthorize("@ss.hasPerm('sys:notice:delete')")
|
||||
public Result<Void> deleteNotices(
|
||||
@Parameter(description = "通知公告ID,多个以英文逗号(,)分割") @PathVariable String ids
|
||||
) {
|
||||
boolean result = noticeService.deleteNotices(ids);
|
||||
return Result.judge(result);
|
||||
@@ -105,27 +115,22 @@ public class NoticeController {
|
||||
|
||||
@Operation(summary = "获取未读的通知公告")
|
||||
@GetMapping("/unread")
|
||||
public Result<?> listUnreadNotices() {
|
||||
return Result.success(noticeStatusService.listUnreadNotices());
|
||||
}
|
||||
|
||||
@Operation(summary = "阅读通知公告")
|
||||
@PatchMapping("/read/{id}")
|
||||
public Result<?> readNotice(@PathVariable Long id) {
|
||||
return Result.success(noticeService.readNotice(id));
|
||||
public Result<List<UserNoticePageVO>> listUnreadNotices() {
|
||||
List<UserNoticePageVO> list = userNoticeService.listUnreadNotices();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
@Operation(summary = "全部已读")
|
||||
@PatchMapping("/readAll")
|
||||
public Result<?> readAll() {
|
||||
noticeStatusService.readAll();
|
||||
@PatchMapping("/read-all")
|
||||
public Result<Void> readAll() {
|
||||
userNoticeService.readAll();
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "获取我的通知公告")
|
||||
@Operation(summary = "获取我的通知公告分页列表")
|
||||
@GetMapping("/my/page")
|
||||
public PageResult<NoticeStatusVO> getMyNoticePage(NoticeQuery queryParams) {
|
||||
IPage<NoticeStatusVO> result = noticeService.getMyNoticePage(queryParams);
|
||||
public PageResult<UserNoticePageVO> getMyNoticePage(NoticePageQuery queryParams) {
|
||||
IPage<UserNoticePageVO> result = noticeService.getMyNoticePage(queryParams);
|
||||
return PageResult.success(result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user