提交 | 用户 | 时间
|
5f25e3
|
1 |
package com.iailab.module.system.controller.admin.app; |
潘 |
2 |
|
|
3 |
import com.iailab.framework.apilog.core.annotation.ApiAccessLog; |
|
4 |
import com.iailab.framework.common.pojo.CommonResult; |
|
5 |
import com.iailab.framework.common.pojo.PageParam; |
|
6 |
import com.iailab.framework.common.pojo.PageResult; |
|
7 |
import com.iailab.framework.common.util.object.BeanUtils; |
|
8 |
import com.iailab.framework.excel.core.util.ExcelUtils; |
|
9 |
import com.iailab.module.system.controller.admin.app.vo.AppPageReqVO; |
|
10 |
import com.iailab.module.system.controller.admin.app.vo.AppRespVO; |
|
11 |
import com.iailab.module.system.controller.admin.app.vo.AppSaveReqVO; |
|
12 |
import com.iailab.module.system.dal.dataobject.app.AppDO; |
|
13 |
import com.iailab.module.system.service.app.AppService; |
|
14 |
import io.swagger.v3.oas.annotations.Operation; |
|
15 |
import io.swagger.v3.oas.annotations.Parameter; |
|
16 |
import io.swagger.v3.oas.annotations.tags.Tag; |
|
17 |
import org.springframework.beans.factory.annotation.Autowired; |
|
18 |
import org.springframework.security.access.prepost.PreAuthorize; |
|
19 |
import org.springframework.web.bind.annotation.*; |
|
20 |
|
|
21 |
import javax.servlet.http.HttpServletResponse; |
|
22 |
import javax.validation.Valid; |
|
23 |
|
|
24 |
import java.io.IOException; |
|
25 |
import java.util.List; |
|
26 |
|
|
27 |
import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
|
28 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
|
29 |
|
|
30 |
@Tag(name = "管理后台 - 应用管理") |
|
31 |
@RestController |
|
32 |
@RequestMapping("/system/app") |
|
33 |
public class AppController { |
|
34 |
|
|
35 |
@Autowired |
|
36 |
private AppService appService; |
|
37 |
|
|
38 |
@PostMapping("/create") |
|
39 |
@Operation(summary = "创建应用") |
|
40 |
@PreAuthorize("@ss.hasPermission('system:app:create')") |
|
41 |
public CommonResult<Long> createApp(@Valid @RequestBody AppSaveReqVO createReqVO) { |
|
42 |
return success(appService.create(createReqVO)); |
|
43 |
} |
|
44 |
|
|
45 |
@PutMapping("/update") |
|
46 |
@Operation(summary = "更新应用") |
|
47 |
@PreAuthorize("@ss.hasPermission('system:app:update')") |
|
48 |
public CommonResult<Boolean> updateApp(@Valid @RequestBody AppSaveReqVO updateReqVO) { |
|
49 |
appService.update(updateReqVO); |
|
50 |
return success(true); |
|
51 |
} |
|
52 |
|
|
53 |
@DeleteMapping("/delete") |
|
54 |
@Operation(summary = "删除应用") |
|
55 |
@Parameter(name = "id", description = "ID", required = true, example = "1024") |
|
56 |
@PreAuthorize("@ss.hasPermission('system:app:delete')") |
|
57 |
public CommonResult<Boolean> deleteApp(@RequestParam("id") Long id) { |
|
58 |
appService.delete(id); |
|
59 |
return success(true); |
|
60 |
} |
|
61 |
|
|
62 |
@GetMapping("/get") |
|
63 |
@Operation(summary = "获得应用") |
|
64 |
@Parameter(name = "id", description = "ID", required = true, example = "1024") |
|
65 |
@PreAuthorize("@ss.hasPermission('system:app:query')") |
|
66 |
public CommonResult<AppRespVO> getTenant(@RequestParam("id") Long id) { |
|
67 |
AppDO data = appService.getInfo(id); |
|
68 |
return success(BeanUtils.toBean(data, AppRespVO.class)); |
|
69 |
} |
|
70 |
|
|
71 |
@GetMapping("/page") |
256352
|
72 |
@Operation(summary = "获得分页") |
5f25e3
|
73 |
@PreAuthorize("@ss.hasPermission('system:app:query')") |
潘 |
74 |
public CommonResult<PageResult<AppRespVO>> getTenantPage(@Valid AppPageReqVO pageVO) { |
|
75 |
PageResult<AppDO> pageResult = appService.getPage(pageVO); |
|
76 |
return success(BeanUtils.toBean(pageResult, AppRespVO.class)); |
|
77 |
} |
|
78 |
|
|
79 |
@GetMapping("/export-excel") |
|
80 |
@Operation(summary = "导出租户 Excel") |
|
81 |
@PreAuthorize("@ss.hasPermission('system:tenant:export')") |
|
82 |
@ApiAccessLog(operateType = EXPORT) |
|
83 |
public void exportTenantExcel(@Valid AppPageReqVO exportReqVO, |
|
84 |
HttpServletResponse response) throws IOException { |
|
85 |
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
|
86 |
List<AppDO> list = appService.getPage(exportReqVO).getList(); |
|
87 |
// 导出 Excel |
|
88 |
ExcelUtils.write(response, "租户.xls", "数据", AppRespVO.class, |
|
89 |
BeanUtils.toBean(list, AppRespVO.class)); |
|
90 |
} |
|
91 |
} |