Commit 0bca015b authored by guangjing.gao's avatar guangjing.gao

根据uuid或者userids获取用户信息

parent 9aa6529c
...@@ -5,7 +5,6 @@ import cn.quantgroup.xyqb.event.DisableActiveEvent; ...@@ -5,7 +5,6 @@ import cn.quantgroup.xyqb.event.DisableActiveEvent;
import cn.quantgroup.xyqb.model.JsonResult; import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.service.user.IUserService; import cn.quantgroup.xyqb.service.user.IUserService;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -81,19 +80,20 @@ public class UserController { ...@@ -81,19 +80,20 @@ public class UserController {
* 根据uuid或者userids 获取用户信息 * 根据uuid或者userids 获取用户信息
* *
* @param params * @param params
* @return * @return http://yapi.quantgroups.com/project/17/interface/api/29902
*/ */
@PostMapping("/getByUuidsOrUserIds") @PostMapping("/getByUuidsOrUserIds")
public JsonResult getByUuidsOrUserIds(@RequestBody Map<String, Object> params) { public JsonResult getByUuidsOrUserIds(@RequestBody Map<String, Object> params) {
List<String> vals = (List<String>) params.get("vals"); List<String> vals = (List<String>) params.get("vals");
Integer type = (Integer) params.get("type"); Integer type = (Integer) params.get("type");
Integer tenantId = Integer.valueOf(String.valueOf(params.get("tenantId")));
if (type == null || (type != 1 && type != 2)) { if (type == null || (type != 1 && type != 2)) {
return JsonResult.buildErrorStateResult("type错误", null); return JsonResult.buildErrorStateResult("type错误", null);
} }
if (vals.size() > 500) { if (vals.size() > 500) {
vals = vals.subList(0,500); vals = vals.subList(0,500);
} }
return JsonResult.buildSuccessResultGeneric(userService.findByUuidsOrUserIds(vals, type)); return JsonResult.buildSuccessResultGeneric(userService.findByUuidsOrUserIds(vals, type, tenantId));
} }
} }
...@@ -21,4 +21,14 @@ public interface IProductLoginRepository extends JpaRepository<ProductLoginEntit ...@@ -21,4 +21,14 @@ public interface IProductLoginRepository extends JpaRepository<ProductLoginEntit
ProductLoginEntity findByInstitutionIdAndProductIdAndExtensionAccountId(String institutionId, String productId, Long userId); ProductLoginEntity findByInstitutionIdAndProductIdAndExtensionAccountId(String institutionId, String productId, Long userId);
List<ProductLoginEntity> findAllByExtensionAccountId(Long userId); List<ProductLoginEntity> findAllByExtensionAccountId(Long userId);
/**
* @author -REYLI
* @createTime 2021-11-17
* @description 根据条件获取租户下用户列表
* @param institutionId
* @param productId
* @return Arraylist
*/
List<ProductLoginEntity> findProductLoginsByInstitutionIdAndProductId(String institutionId, String productId);
} }
\ No newline at end of file
...@@ -10,4 +10,14 @@ import java.util.List; ...@@ -10,4 +10,14 @@ import java.util.List;
public interface IProductLoginService { public interface IProductLoginService {
ProductLoginEntity findSlaveByPloginInfo(String institutionId, String productId, Long userId); ProductLoginEntity findSlaveByPloginInfo(String institutionId, String productId, Long userId);
List<ProductLoginEntity> findSlaveByUserId(Long userId); List<ProductLoginEntity> findSlaveByUserId(Long userId);
/**
* @author -REYLI
* @createTime 2021-11-17
* @description 根据条件获取租户下用户列表
* @param institutionId
* @param productId
* @return Arraylist
*/
List<ProductLoginEntity> findProductLoginsByInstitutionIdAndProductId(String institutionId, String productId);
} }
...@@ -4,6 +4,8 @@ import cn.quantgroup.xyqb.entity.User; ...@@ -4,6 +4,8 @@ import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.UserDetail; import cn.quantgroup.xyqb.entity.UserDetail;
import cn.quantgroup.xyqb.model.UserBrief; import cn.quantgroup.xyqb.model.UserBrief;
import java.util.List;
/** /**
* Created by 11 on 2016/12/29. * Created by 11 on 2016/12/29.
*/ */
...@@ -14,4 +16,14 @@ public interface ITenantService { ...@@ -14,4 +16,14 @@ public interface ITenantService {
UserDetail getTenantUserDetail(UserDetail userDetail, Integer tenantId); UserDetail getTenantUserDetail(UserDetail userDetail, Integer tenantId);
UserBrief getTenantCustomerInfo(UserDetail userDetail, Integer tenantId); UserBrief getTenantCustomerInfo(UserDetail userDetail, Integer tenantId);
/**
* @author -REYLI
* @createTime 2021-11-17
* @description 根据条件获取租户下用户列表
* @param users
* @param tenantId
* @return Arraylist
*/
List<User> selectUsersByTenantId(List<User> users, Integer tenantId);
} }
...@@ -96,7 +96,7 @@ public interface IUserService { ...@@ -96,7 +96,7 @@ public interface IUserService {
* @param type * @param type
* @return * @return
*/ */
List<User> findByUuidsOrUserIds(List<String> vals,Integer type); List<User> findByUuidsOrUserIds(List<String> vals,Integer type, Integer tenantId);
/** /**
* 登出 * 登出
......
...@@ -33,4 +33,9 @@ public class ProductLoginServiceImpl implements IProductLoginService { ...@@ -33,4 +33,9 @@ public class ProductLoginServiceImpl implements IProductLoginService {
List<ProductLoginEntity> productLoginEntityList = productLoginRepository.findAllByExtensionAccountId(userId); List<ProductLoginEntity> productLoginEntityList = productLoginRepository.findAllByExtensionAccountId(userId);
return productLoginEntityList; return productLoginEntityList;
} }
@Override
public List<ProductLoginEntity> findProductLoginsByInstitutionIdAndProductId(String institutionId, String productId) {
return productLoginRepository.findProductLoginsByInstitutionIdAndProductId(institutionId, productId);
}
} }
...@@ -10,6 +10,8 @@ import lombok.extern.slf4j.Slf4j; ...@@ -10,6 +10,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional; import java.util.Optional;
/** /**
...@@ -98,4 +100,24 @@ public class TenantServiceImpl implements ITenantService { ...@@ -98,4 +100,24 @@ public class TenantServiceImpl implements ITenantService {
} }
return null; return null;
} }
@Override
public List<User> selectUsersByTenantId(List<User> users, Integer tenantId) {
List<User> result = new ArrayList<>();
OauthClientDetailsEntity oauthClientDetails = oauthClientDetailsService.findFirstByClientId(tenantId);
if (oauthClientDetails != null) {
List<ProductLoginEntity> productLoginEntities = productLoginService.findProductLoginsByInstitutionIdAndProductId(oauthClientDetails.getInstitutionId(), oauthClientDetails.getProductId());
if (productLoginEntities != null && productLoginEntities.size()>0) {
users.forEach(a->{
productLoginEntities.forEach(b->{
if (a.getPhoneNo().equals(b.getPhoneNo())) {
a.setPassword(b.getPassword());
result.add(a);
}
});
});
}
}
return result;
}
} }
...@@ -88,6 +88,9 @@ public class UserServiceImpl implements IUserService, IBaseController { ...@@ -88,6 +88,9 @@ public class UserServiceImpl implements IUserService, IBaseController {
@Autowired @Autowired
private IOauthLoginInfoService oauthLoginInfoService; private IOauthLoginInfoService oauthLoginInfoService;
@Autowired
private ITenantService tenantService;
@Override @Override
// @Cacheable(value = "usercache", key = "'xyqbuser' + #phone", unless = "#result == null", cacheManager = "cacheManager") // @Cacheable(value = "usercache", key = "'xyqbuser' + #phone", unless = "#result == null", cacheManager = "cacheManager")
public User findByPhoneInDb(String phone) { public User findByPhoneInDb(String phone) {
...@@ -486,7 +489,7 @@ public class UserServiceImpl implements IUserService, IBaseController { ...@@ -486,7 +489,7 @@ public class UserServiceImpl implements IUserService, IBaseController {
} }
@Override @Override
public List<User> findByUuidsOrUserIds(List<String> vals, Integer type) { public List<User> findByUuidsOrUserIds(List<String> vals, Integer type, Integer tenantId) {
if (CollectionUtils.isEmpty(vals)) { if (CollectionUtils.isEmpty(vals)) {
return Collections.EMPTY_LIST; return Collections.EMPTY_LIST;
} }
...@@ -496,10 +499,17 @@ public class UserServiceImpl implements IUserService, IBaseController { ...@@ -496,10 +499,17 @@ public class UserServiceImpl implements IUserService, IBaseController {
List<Long> collect = vals.stream() List<Long> collect = vals.stream()
.map(Long::valueOf) .map(Long::valueOf)
.collect(Collectors.toList()); .collect(Collectors.toList());
List<User> users = userRepository.findByIdIn(collect);
return userRepository.findByIdIn(collect); if (TenantUtil.checkoutTenantIsDefault(tenantId)) {
return tenantService.selectUsersByTenantId(users, tenantId);
}
return users;
} else { //不是1 就是 uuids } else { //不是1 就是 uuids
return userRepository.findByUuidIn(vals); List<User> users = userRepository.findByUuidIn(vals);
if (TenantUtil.checkoutTenantIsDefault(tenantId)) {
return tenantService.selectUsersByTenantId(users, tenantId);
}
return users;
} }
} }
......
...@@ -4,4 +4,11 @@ public class TenantUtil { ...@@ -4,4 +4,11 @@ public class TenantUtil {
/* 租户羊小咩 */ /* 租户羊小咩 */
public static final Integer TENANT_DEFAULT = 560761; public static final Integer TENANT_DEFAULT = 560761;
public static boolean checkoutTenantIsDefault(Integer tenantId) {
if (tenantId == null || tenantId.equals(0) || TenantUtil.TENANT_DEFAULT.equals(tenantId)) {
return false;
}
return true;
}
} }
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