提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.infra.controller.admin.file; |
H |
2 |
|
|
3 |
import com.iailab.framework.common.pojo.CommonResult; |
|
4 |
import com.iailab.framework.common.pojo.PageResult; |
|
5 |
import com.iailab.framework.common.util.object.BeanUtils; |
|
6 |
import com.iailab.module.infra.controller.admin.file.vo.config.FileConfigPageReqVO; |
|
7 |
import com.iailab.module.infra.controller.admin.file.vo.config.FileConfigRespVO; |
|
8 |
import com.iailab.module.infra.controller.admin.file.vo.config.FileConfigSaveReqVO; |
|
9 |
import com.iailab.module.infra.dal.dataobject.file.FileConfigDO; |
|
10 |
import com.iailab.module.infra.service.file.FileConfigService; |
|
11 |
import io.swagger.v3.oas.annotations.Operation; |
|
12 |
import io.swagger.v3.oas.annotations.Parameter; |
|
13 |
import io.swagger.v3.oas.annotations.tags.Tag; |
|
14 |
import org.springframework.security.access.prepost.PreAuthorize; |
|
15 |
import org.springframework.validation.annotation.Validated; |
|
16 |
import org.springframework.web.bind.annotation.*; |
|
17 |
|
|
18 |
import javax.annotation.Resource; |
|
19 |
import javax.validation.Valid; |
|
20 |
|
|
21 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
|
22 |
|
|
23 |
@Tag(name = "管理后台 - 文件配置") |
|
24 |
@RestController |
|
25 |
@RequestMapping("/infra/file-config") |
|
26 |
@Validated |
|
27 |
public class FileConfigController { |
|
28 |
|
|
29 |
@Resource |
|
30 |
private FileConfigService fileConfigService; |
|
31 |
|
|
32 |
@PostMapping("/create") |
|
33 |
@Operation(summary = "创建文件配置") |
|
34 |
@PreAuthorize("@ss.hasPermission('infra:file-config:create')") |
|
35 |
public CommonResult<Long> createFileConfig(@Valid @RequestBody FileConfigSaveReqVO createReqVO) { |
|
36 |
return success(fileConfigService.createFileConfig(createReqVO)); |
|
37 |
} |
|
38 |
|
|
39 |
@PutMapping("/update") |
|
40 |
@Operation(summary = "更新文件配置") |
|
41 |
@PreAuthorize("@ss.hasPermission('infra:file-config:update')") |
|
42 |
public CommonResult<Boolean> updateFileConfig(@Valid @RequestBody FileConfigSaveReqVO updateReqVO) { |
|
43 |
fileConfigService.updateFileConfig(updateReqVO); |
|
44 |
return success(true); |
|
45 |
} |
|
46 |
|
|
47 |
@PutMapping("/update-master") |
|
48 |
@Operation(summary = "更新文件配置为 Master") |
|
49 |
@PreAuthorize("@ss.hasPermission('infra:file-config:update')") |
|
50 |
public CommonResult<Boolean> updateFileConfigMaster(@RequestParam("id") Long id) { |
|
51 |
fileConfigService.updateFileConfigMaster(id); |
|
52 |
return success(true); |
|
53 |
} |
|
54 |
|
|
55 |
@DeleteMapping("/delete") |
|
56 |
@Operation(summary = "删除文件配置") |
|
57 |
@Parameter(name = "id", description = "编号", required = true) |
|
58 |
@PreAuthorize("@ss.hasPermission('infra:file-config:delete')") |
|
59 |
public CommonResult<Boolean> deleteFileConfig(@RequestParam("id") Long id) { |
|
60 |
fileConfigService.deleteFileConfig(id); |
|
61 |
return success(true); |
|
62 |
} |
|
63 |
|
|
64 |
@GetMapping("/get") |
|
65 |
@Operation(summary = "获得文件配置") |
|
66 |
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
|
67 |
@PreAuthorize("@ss.hasPermission('infra:file-config:query')") |
|
68 |
public CommonResult<FileConfigRespVO> getFileConfig(@RequestParam("id") Long id) { |
|
69 |
FileConfigDO config = fileConfigService.getFileConfig(id); |
|
70 |
return success(BeanUtils.toBean(config, FileConfigRespVO.class)); |
|
71 |
} |
|
72 |
|
|
73 |
@GetMapping("/page") |
|
74 |
@Operation(summary = "获得文件配置分页") |
|
75 |
@PreAuthorize("@ss.hasPermission('infra:file-config:query')") |
|
76 |
public CommonResult<PageResult<FileConfigRespVO>> getFileConfigPage(@Valid FileConfigPageReqVO pageVO) { |
|
77 |
PageResult<FileConfigDO> pageResult = fileConfigService.getFileConfigPage(pageVO); |
|
78 |
return success(BeanUtils.toBean(pageResult, FileConfigRespVO.class)); |
|
79 |
} |
|
80 |
|
|
81 |
@GetMapping("/test") |
|
82 |
@Operation(summary = "测试文件配置是否正确") |
|
83 |
@PreAuthorize("@ss.hasPermission('infra:file-config:query')") |
|
84 |
public CommonResult<String> testFileConfig(@RequestParam("id") Long id) throws Exception { |
|
85 |
String url = fileConfigService.testFileConfig(id); |
|
86 |
return success(url); |
|
87 |
} |
|
88 |
} |