| | |
| | | import cn.dev33.satoken.annotation.SaCheckRole; |
| | | import com.baomidou.lock.annotation.Lock4j; |
| | | import com.ruoyi.common.core.constant.TenantConstants; |
| | | import com.ruoyi.common.core.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.validate.AddGroup; |
| | |
| | | @RepeatSubmit() |
| | | @PostMapping() |
| | | public R<Void> add(@Validated(AddGroup.class) @RequestBody SysTenantBo bo) { |
| | | if (TenantConstants.NOT_PASS.equals(sysTenantService.checkCompanyNameUnique(bo))) { |
| | | if (!sysTenantService.checkCompanyNameUnique(bo)) { |
| | | throw new ServiceException("新增租户'" + bo.getCompanyName() + "'失败,企业名称已存在"); |
| | | } |
| | | SysUserBo userBo = new SysUserBo(); |
| | | userBo.setUserName(bo.getUsername()); |
| | | // 判断用户名是否重复 |
| | | if (UserConstants.NOT_UNIQUE.equals(sysUserService.checkUserNameUnique(userBo))) { |
| | | if (!sysUserService.checkUserNameUnique(userBo)) { |
| | | throw new ServiceException("新增用户'" + bo.getUsername() + "'失败,登录账号已存在"); |
| | | } |
| | | return toAjax(sysTenantService.insertByBo(bo)); |
| | |
| | | @RepeatSubmit() |
| | | @PutMapping() |
| | | public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysTenantBo bo) { |
| | | if (UserConstants.NOT_UNIQUE.equals(sysTenantService.checkCompanyNameUnique(bo))) { |
| | | if (!sysTenantService.checkCompanyNameUnique(bo)) { |
| | | throw new ServiceException("修改租户'" + bo.getCompanyName() + "'失败,公司名称已存在"); |
| | | } |
| | | return toAjax(sysTenantService.updateByBo(bo)); |
| | |
| | | * 状态修改 |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenantPackage:edit") |
| | | @Log(title = "租户套餐", businessType = BusinessType.UPDATE) |
| | | @SaCheckPermission("system:tenant:edit") |
| | | @Log(title = "租户", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public R<Void> changeStatus(@RequestBody SysTenantBo bo) { |
| | | return toAjax(sysTenantService.updateTenantStatus(bo)); |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 同步租户套餐 |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param packageId 套餐id |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @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(sysTenantService.syncTenantPackage(tenantId, packageId)); |
| | | } |
| | | |
| | | } |