|
@@ -0,0 +1,46 @@
|
|
|
+package com.usky.system.controller.api;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.usky.common.core.bean.ApiResult;
|
|
|
+import com.usky.common.core.constants.CommonConst;
|
|
|
+import com.usky.common.core.exception.BusinessException;
|
|
|
+import com.usky.system.RemoteTenantService;
|
|
|
+import com.usky.system.domain.SysTenant;
|
|
|
+import com.usky.system.service.SysTenantService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author yq
|
|
|
+ * @date 2022/7/12 13:21
|
|
|
+ */
|
|
|
+@RequestMapping("/tenantApi")
|
|
|
+@RestController
|
|
|
+public class SysTenantControllerApi implements RemoteTenantService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysTenantService sysTenantService;
|
|
|
+ @Override
|
|
|
+ public ApiResult<List<Integer>> getTenantIds() {
|
|
|
+ LambdaQueryWrapper<SysTenant> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.select(SysTenant::getId);
|
|
|
+ return ApiResult.success(sysTenantService.list(queryWrapper).stream().map(SysTenant::getId).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ApiResult<Void> validTenant(Integer id) {
|
|
|
+ SysTenant tenant = sysTenantService.getById(id);
|
|
|
+ if (tenant == null) {
|
|
|
+ throw new BusinessException("租户信息为空");
|
|
|
+ }
|
|
|
+ if (tenant.getStatus().equals(CommonConst.FALSE_NUM_STR)) {
|
|
|
+ throw new BusinessException("租户已被停用");
|
|
|
+ }
|
|
|
+ return ApiResult.success();
|
|
|
+ }
|
|
|
+}
|