『博客开发日记-后台』之获取通知表单数据接口的实现

本文最后更新于 2026年5月27日 晚上

获取通知表单数据接口的实现


获取通知表单数据接口的需求

根据通知id 查询通知详情

需要注意的是这个接口是在编辑通知时用上的

查看通知用的是另一个接口


代码实现

在 NoticeController 中添加接口

1
2
3
4
5
6
7
8
9
10
11
 @GetMapping("/{id}/form")
@PreAuthorize("@ps.hasPermission('blog:notice:update')")
@SystemLog(businessName = "获取通知表单数据(编辑公告时用上)")
@ApiOperation(value = "获取通知表单数据(编辑公告时用上)", notes = "获取通知表单数据,用于编辑通知详情", response = NoticeFormDetailVo.class)
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "友链id", dataType = "long", paramType = "path")
})
public ResponseResult<NoticeFormDetailVo> getNoticeFormDetail(@PathVariable Long id)
{
return sysNoticeService.getNoticeFormDetail(id);
}

创建 NoticeFormDetailVo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@ApiModel(description = "通知详情响应对象")
public class NoticeFormDetailVo
{
@ApiModelProperty(value = "通知id", example = "6")
private Long id;

@ApiModelProperty(value = "通知标题", example = "这里是标题")
private String title;

@ApiModelProperty(value = "通知内容", example = "这里是内容")
private String content;

@ApiModelProperty(value = "通知类型(关联字典编码:notice_type)", example = "系统维护")
private Integer type;

@ApiModelProperty(value = "通知等级(字典code:notice_level)", example = "M")
private String level;

@ApiModelProperty(value = "读取状态(0: 未读, 1: 已读)", example = "0")
private String status;

@ApiModelProperty(value = "目标人ID集合(多个使用英文逗号,分割)", example = "['1', '23']")
private List<Long> targetUserIds;

@ApiModelProperty(value = "目标类型(1: 全体, 2: 指定)", example = "1")
private String targetType;

@TableField(fill = FieldFill.INSERT_UPDATE)
@ApiModelProperty(value = "发布时间", example = "2024-01-01 12:00:00")
private Date publishTime;
}

在 SysNoticeServiceImpl 中

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//获取通知表单数据
@Override
public ResponseResult<NoticeFormDetailVo> getNoticeFormDetail(Long id)
{
//根据通知id 查询通知详情
SysNotice notice = sysNoticeService.getById(id);
if (notice == null) {
return ResponseResult.errorResult(AppHttpCodeEnum.SYSTEM_ERROR, "该通知不存在!");
}

//转换成Vo
NoticeFormDetailVo noticeFormDetailVo = BeanCopyUtils.copyBean(notice, NoticeFormDetailVo.class);

//返回
return ResponseResult.okResult(noticeFormDetailVo);
}




PS:该系列只做为作者学习开发项目做的笔记用

不一定符合读者来学习,仅供参考


预告

后续会记录博客的开发过程

每次学习会做一份笔记来进行发表

“一花一世界,一叶一菩提”


版权所有 © 2026 云梦泽
欢迎访问我的个人网站:https://hgt12.github.io/


『博客开发日记-后台』之获取通知表单数据接口的实现
http://example.com/2026/05/27/『博客开发日记-后台』之获取通知表单数据接口的实现/
作者
云梦泽
发布于
2026年5月27日
更新于
2026年5月27日
许可协议