本文最后更新于 2026年5月30日 下午
获取配置表单数据接口的实现
获取配置表单数据接口的需求
根据配置id获取配置表单数据
代码实现
在 ConfigController 中添加接口
1 2 3 4 5 6 7 8 9 10 11
| @GetMapping("/{id}/form") @PreAuthorize("@ps.hasPermission('sys:config:update')") @SystemLog(businessName = "获取配置表单数据") @ApiOperation(value = "获取配置表单数据", notes = "获取配置表单数据,用于编辑配置详情", response = ConfigFormDetailVo.class) @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "配置id", dataType = "long", paramType = "path") }) public ResponseResult<ConfigFormDetailVo> getConfigFormDetail(@PathVariable Long id) { return adminConfigService.getConfigFormDetail(id); }
|
创建 ConfigFormDetailVo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| @Data @AllArgsConstructor @NoArgsConstructor @ApiModel(description = "后台配置表单详情响应对象") public class ConfigFormDetailVo { @ApiModelProperty(value = "配置ID", example = "1") private Long id;
@ApiModelProperty(value = "配置名称", example = "这里是配置名称") private String configName;
@ApiModelProperty(value = "配置键", example = "这里是配置键") private String configKey;
@ApiModelProperty(value = "配置值", example = "这里是配置值") private String configValue;
@ApiModelProperty(value = "备注", example = "对该配的一些描述") private String remark; }
|
在 AdminConfigServiceImpl 中
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| @Override public ResponseResult<ConfigFormDetailVo> getConfigFormDetail(Long id) { Config config = adminConfigService.getById(id); if (config == null) { return ResponseResult.errorResult(AppHttpCodeEnum.SYSTEM_ERROR, "该配置不存在!"); }
ConfigFormDetailVo configFormDetailVo = BeanCopyUtils.copyBean(config, ConfigFormDetailVo.class);
return ResponseResult.okResult(configFormDetailVo); }
|
PS:该系列只做为作者学习开发项目做的笔记用
不一定符合读者来学习,仅供参考
预告
后续会记录博客的开发过程
每次学习会做一份笔记来进行发表
“一花一世界,一叶一菩提”
版权所有 © 2026 云梦泽
欢迎访问我的个人网站:https://hgt12.github.io/