houzhongjian
2024-09-14 818a0170d8f2950d52cc7300a302356bbc523236
提交 | 用户 | 时间
e7c126 1 package com.iailab.module.system.controller.admin.tenant;
H 2
3 import com.iailab.framework.common.enums.CommonStatusEnum;
4 import com.iailab.framework.common.pojo.CommonResult;
5 import com.iailab.framework.common.pojo.PageResult;
6 import com.iailab.framework.common.util.object.BeanUtils;
7 import com.iailab.module.system.controller.admin.tenant.vo.packages.TenantPackagePageReqVO;
8 import com.iailab.module.system.controller.admin.tenant.vo.packages.TenantPackageRespVO;
9 import com.iailab.module.system.controller.admin.tenant.vo.packages.TenantPackageSaveReqVO;
10 import com.iailab.module.system.controller.admin.tenant.vo.packages.TenantPackageSimpleRespVO;
11 import com.iailab.module.system.dal.dataobject.tenant.TenantPackageDO;
12 import com.iailab.module.system.service.tenant.TenantPackageService;
13 import io.swagger.v3.oas.annotations.Operation;
14 import io.swagger.v3.oas.annotations.Parameter;
15 import io.swagger.v3.oas.annotations.tags.Tag;
16 import org.springframework.security.access.prepost.PreAuthorize;
17 import org.springframework.validation.annotation.Validated;
18 import org.springframework.web.bind.annotation.*;
19
20 import javax.annotation.Resource;
21 import javax.validation.Valid;
22 import java.util.List;
23
24 import static com.iailab.framework.common.pojo.CommonResult.success;
25
26 @Tag(name = "管理后台 - 租户套餐")
27 @RestController
28 @RequestMapping("/system/tenant-package")
29 @Validated
30 public class TenantPackageController {
31
32     @Resource
33     private TenantPackageService tenantPackageService;
34
35     @PostMapping("/create")
36     @Operation(summary = "创建租户套餐")
37     @PreAuthorize("@ss.hasPermission('system:tenant-package:create')")
38     public CommonResult<Long> createTenantPackage(@Valid @RequestBody TenantPackageSaveReqVO createReqVO) {
39         return success(tenantPackageService.createTenantPackage(createReqVO));
40     }
41
42     @PutMapping("/update")
43     @Operation(summary = "更新租户套餐")
44     @PreAuthorize("@ss.hasPermission('system:tenant-package:update')")
45     public CommonResult<Boolean> updateTenantPackage(@Valid @RequestBody TenantPackageSaveReqVO updateReqVO) {
46         tenantPackageService.updateTenantPackage(updateReqVO);
47         return success(true);
48     }
49
50     @DeleteMapping("/delete")
51     @Operation(summary = "删除租户套餐")
52     @Parameter(name = "id", description = "编号", required = true)
53     @PreAuthorize("@ss.hasPermission('system:tenant-package:delete')")
54     public CommonResult<Boolean> deleteTenantPackage(@RequestParam("id") Long id) {
55         tenantPackageService.deleteTenantPackage(id);
56         return success(true);
57     }
58
59     @GetMapping("/get")
60     @Operation(summary = "获得租户套餐")
61     @Parameter(name = "id", description = "编号", required = true, example = "1024")
62     @PreAuthorize("@ss.hasPermission('system:tenant-package:query')")
63     public CommonResult<TenantPackageRespVO> getTenantPackage(@RequestParam("id") Long id) {
64         TenantPackageDO tenantPackage = tenantPackageService.getTenantPackage(id);
65         return success(BeanUtils.toBean(tenantPackage, TenantPackageRespVO.class));
66     }
67
68     @GetMapping("/page")
69     @Operation(summary = "获得租户套餐分页")
70     @PreAuthorize("@ss.hasPermission('system:tenant-package:query')")
71     public CommonResult<PageResult<TenantPackageRespVO>> getTenantPackagePage(@Valid TenantPackagePageReqVO pageVO) {
72         PageResult<TenantPackageDO> pageResult = tenantPackageService.getTenantPackagePage(pageVO);
73         return success(BeanUtils.toBean(pageResult, TenantPackageRespVO.class));
74     }
75
76     @GetMapping({"/get-simple-list", "simple-list"})
77     @Operation(summary = "获取租户套餐精简信息列表", description = "只包含被开启的租户套餐,主要用于前端的下拉选项")
78     public CommonResult<List<TenantPackageSimpleRespVO>> getTenantPackageList() {
79         List<TenantPackageDO> list = tenantPackageService.getTenantPackageListByStatus(CommonStatusEnum.ENABLE.getStatus());
80         return success(BeanUtils.toBean(list, TenantPackageSimpleRespVO.class));
81     }
82
83 }