| | |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.core.validate.AddGroup; |
| | | import org.dromara.common.core.validate.EditGroup; |
| | | import org.dromara.common.encrypt.annotation.ApiEncrypt; |
| | | import org.dromara.common.excel.utils.ExcelUtil; |
| | | import org.dromara.common.idempotent.annotation.RepeatSubmit; |
| | | import org.dromara.common.log.annotation.Log; |
| | |
| | | import org.dromara.system.domain.bo.SysTenantBo; |
| | | import org.dromara.system.domain.vo.SysTenantVo; |
| | | import org.dromara.system.service.ISysTenantService; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/tenant") |
| | | @ConditionalOnProperty(value = "tenant.enable", havingValue = "true") |
| | | public class SysTenantController extends BaseController { |
| | | |
| | | private final ISysTenantService tenantService; |
| | |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenant:export") |
| | | @Log(title = "租户", businessType = BusinessType.EXPORT) |
| | | @Log(title = "租户管理", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(SysTenantBo bo, HttpServletResponse response) { |
| | | List<SysTenantVo> list = tenantService.queryList(bo); |
| | |
| | | /** |
| | | * 新增租户 |
| | | */ |
| | | @ApiEncrypt |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenant:add") |
| | | @Log(title = "租户", businessType = BusinessType.INSERT) |
| | | @Log(title = "租户管理", businessType = BusinessType.INSERT) |
| | | @Lock4j |
| | | @RepeatSubmit() |
| | | @PostMapping() |
| | |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenant:edit") |
| | | @Log(title = "租户", businessType = BusinessType.UPDATE) |
| | | @Log(title = "租户管理", businessType = BusinessType.UPDATE) |
| | | @RepeatSubmit() |
| | | @PutMapping() |
| | | public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysTenantBo bo) { |
| | |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenant:edit") |
| | | @Log(title = "租户", businessType = BusinessType.UPDATE) |
| | | @Log(title = "租户管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public R<Void> changeStatus(@RequestBody SysTenantBo bo) { |
| | | tenantService.checkTenantAllowed(bo.getTenantId()); |
| | |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenant:remove") |
| | | @Log(title = "租户", businessType = BusinessType.DELETE) |
| | | @Log(title = "租户管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public R<Void> remove(@NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] ids) { |
| | |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @GetMapping("/dynamic/{tenantId}") |
| | | public R<Void> dynamicTenant(@NotBlank(message = "租户ID不能为空") @PathVariable String tenantId) { |
| | | TenantHelper.setDynamic(tenantId); |
| | | TenantHelper.setDynamic(tenantId, true); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenant:edit") |
| | | @Log(title = "租户", businessType = BusinessType.UPDATE) |
| | | @Log(title = "租户管理", businessType = BusinessType.UPDATE) |
| | | @GetMapping("/syncTenantPackage") |
| | | public R<Void> syncTenantPackage(@NotBlank(message = "租户ID不能为空") String tenantId, @NotBlank(message = "套餐ID不能为空") String packageId) { |
| | | public R<Void> syncTenantPackage(@NotBlank(message = "租户ID不能为空") String tenantId, |
| | | @NotNull(message = "套餐ID不能为空") Long packageId) { |
| | | return toAjax(TenantHelper.ignore(() -> tenantService.syncTenantPackage(tenantId, packageId))); |
| | | } |
| | | |
| | | /** |
| | | * 同步租户字典 |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @Log(title = "租户管理", businessType = BusinessType.INSERT) |
| | | @GetMapping("/syncTenantDict") |
| | | public R<Void> syncTenantDict() { |
| | | if (!TenantHelper.isEnable()) { |
| | | return R.fail("当前未开启租户模式"); |
| | | } |
| | | tenantService.syncTenantDict(); |
| | | return R.ok("同步租户字典成功"); |
| | | } |
| | | |
| | | } |