Commit 29fa2d0a authored by 李健华's avatar 李健华

获取租户列表历史数据处理

parent c8b3d979
package cn.quantgroup.xyqb.controller.tenant; package cn.quantgroup.xyqb.controller.tenant;
import cn.quantgroup.xyqb.entity.ProductLoginEntity; import cn.quantgroup.xyqb.entity.ProductLoginEntity;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.model.JsonResult; import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.service.user.IOauthClientDetailsService; import cn.quantgroup.xyqb.service.user.IOauthClientDetailsService;
import cn.quantgroup.xyqb.service.user.IProductLoginService; import cn.quantgroup.xyqb.service.user.IProductLoginService;
import cn.quantgroup.xyqb.service.user.IUserService;
import cn.quantgroup.xyqb.util.TenantUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Slf4j @Slf4j
...@@ -24,6 +28,9 @@ public class TenantController { ...@@ -24,6 +28,9 @@ public class TenantController {
@Autowired @Autowired
private IOauthClientDetailsService oauthClientDetailsService; private IOauthClientDetailsService oauthClientDetailsService;
@Autowired
private IUserService userService;
/** /**
* 根据用户ID查询租户列表 * 根据用户ID查询租户列表
* @param userId * @param userId
...@@ -34,12 +41,20 @@ public class TenantController { ...@@ -34,12 +41,20 @@ public class TenantController {
public JsonResult findTenantByUserId(Long userId) { public JsonResult findTenantByUserId(Long userId) {
// 通过userId获取租户机构和产品 // 通过userId获取租户机构和产品
List<ProductLoginEntity> productLoginEntityList = productLoginService.findSlaveByUserId(userId); List<ProductLoginEntity> productLoginEntityList = productLoginService.findSlaveByUserId(userId);
if (productLoginEntityList.isEmpty()) { List<Integer> tenantList = new ArrayList<>();
return JsonResult.buildErrorStateResult("该用户不存在", null); if (!productLoginEntityList.isEmpty()) {
// 通过机构和产品Id 获取租户id
tenantList = oauthClientDetailsService.findTenantList(productLoginEntityList);
}
if (!tenantList.contains(TenantUtil.TENANT_DEFAULT)) {
User user = userService.findById(userId);
if (user == null) {
return JsonResult.buildErrorStateResult("该用户不存在", null);
}
tenantList.add(TenantUtil.TENANT_DEFAULT);
} }
// 通过机构和产品Id 获取租户id
List<Integer> tenantList = oauthClientDetailsService.findTenantList(productLoginEntityList);
return JsonResult.buildSuccessResult("租户列表", tenantList); return JsonResult.buildSuccessResult("租户列表", tenantList);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment