| | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import cn.dev33.satoken.annotation.SaCheckRole; |
| | | import com.baomidou.lock.annotation.Lock4j; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.constant.TenantConstants; |
| | | 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 jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/tenant") |
| | | @ConditionalOnProperty(value = "tenant.enable", havingValue = "true") |
| | | public class SysTenantController extends BaseController { |
| | | |
| | | private final ISysTenantService tenantService; |
| | |
| | | @SaCheckPermission("system:tenant:query") |
| | | @GetMapping("/{id}") |
| | | public R<SysTenantVo> getInfo(@NotNull(message = "主键不能为空") |
| | | @PathVariable Long id) { |
| | | @PathVariable Long id) { |
| | | return R.ok(tenantService.queryById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 新增租户 |
| | | */ |
| | | @ApiEncrypt |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenant:add") |
| | | @Log(title = "租户", businessType = BusinessType.INSERT) |
| | |
| | | if (!tenantService.checkCompanyNameUnique(bo)) { |
| | | return R.fail("新增租户'" + bo.getCompanyName() + "'失败,企业名称已存在"); |
| | | } |
| | | return toAjax(tenantService.insertByBo(bo)); |
| | | return toAjax(TenantHelper.ignore(() -> tenantService.insertByBo(bo))); |
| | | } |
| | | |
| | | /** |
| | |
| | | @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(); |
| | | } |
| | | |
| | |
| | | @SaCheckPermission("system:tenant:edit") |
| | | @Log(title = "租户", businessType = BusinessType.UPDATE) |
| | | @GetMapping("/syncTenantPackage") |
| | | public R<Void> syncTenantPackage(@NotBlank(message = "租户ID不能为空") String tenantId, @NotBlank(message = "套餐ID不能为空") String packageId) { |
| | | return toAjax(tenantService.syncTenantPackage(tenantId, packageId)); |
| | | public R<Void> syncTenantPackage(@NotBlank(message = "租户ID不能为空") String tenantId, |
| | | @NotNull(message = "套餐ID不能为空") Long packageId) { |
| | | return toAjax(TenantHelper.ignore(() -> tenantService.syncTenantPackage(tenantId, packageId))); |
| | | } |
| | | |
| | | } |