| | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigImportExcelVO; |
| | | import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigImportReqVO; |
| | | import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigImportRespVO; |
| | | import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigPageReqVO; |
| | | import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigRespVO; |
| | | import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigSaveReqVO; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| | |
| | | @GetMapping(value = "/get") |
| | | @Operation(summary = "获得参数配置") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('infra:config:query')") |
| | | public CommonResult<ConfigRespVO> getConfig(@RequestParam("id") Long id) { |
| | | return success(ConfigConvert.INSTANCE.convert(configService.getConfig(id))); |
| | | } |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获取参数配置分页") |
| | | @PreAuthorize("@ss.hasPermission('infra:config:query')") |
| | | public CommonResult<PageResult<ConfigRespVO>> getConfigPage(@Valid ConfigPageReqVO pageReqVO) { |
| | | PageResult<ConfigDO> page = configService.getConfigPage(pageReqVO); |
| | | return success(ConfigConvert.INSTANCE.convertPage(page)); |
| | |
| | | ConfigConvert.INSTANCE.convertList(list)); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得导入参数配置模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<ConfigImportExcelVO> list = Arrays.asList( |
| | | ConfigImportExcelVO.builder().category("biz").name("示例参数").configKey("example.key") |
| | | .value("exampleValue").visible(true).remark("").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "参数配置导入模板.xls", "参数配置列表", ConfigImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入参数配置") |
| | | @PreAuthorize("@ss.hasPermission('infra:config:import')") |
| | | public CommonResult<ConfigImportRespVO> importExcel(@Valid ConfigImportReqVO importReqVO) |
| | | throws Exception { |
| | | List<ConfigImportExcelVO> list = ExcelUtils.read(importReqVO.getFile(), ConfigImportExcelVO.class); |
| | | return success(configService.importConfigList(list, importReqVO)); |
| | | } |
| | | |
| | | } |