|
|
@@ -8,19 +8,23 @@ import com.hotent.base.conf.SsoConfig;
|
|
|
import com.hotent.base.feign.UCFeignService;
|
|
|
import com.hotent.base.jwt.JwtAuthenticationResponse;
|
|
|
import com.hotent.base.jwt.JwtTokenHandler;
|
|
|
+import com.hotent.base.model.CommonResult;
|
|
|
import com.hotent.base.service.PwdStrategyService;
|
|
|
import com.hotent.base.util.*;
|
|
|
import com.hotent.baseInfo.manager.AuditedUnitManager;
|
|
|
import com.hotent.dataMiddlePlatform.manager.DataMiddlePlatformManager;
|
|
|
import com.hotent.uc.api.model.IUser;
|
|
|
import com.hotent.uc.manager.OrgManager;
|
|
|
+import com.hotent.uc.manager.RoleManager;
|
|
|
import com.hotent.uc.manager.UserManager;
|
|
|
import com.hotent.uc.model.User;
|
|
|
import com.hotent.uc.params.org.OrgVo;
|
|
|
+import com.hotent.uc.params.role.RoleVo;
|
|
|
import com.hotent.uc.params.user.UserVo;
|
|
|
import com.integration.oauth2.sdk.OAuth2Client;
|
|
|
import com.integration.oauth2.sdk.method.OAuth2ToMethod;
|
|
|
import com.integration.oauth2.sdk.model.Org;
|
|
|
+import com.integration.oauth2.sdk.model.Role;
|
|
|
import com.integration.oauth2.sdk.model.UserDetail;
|
|
|
import com.integration.oauth2.sdk.model.UserInfo;
|
|
|
import com.integration.oauth2.sdk.response.AccessTokenResponse;
|
|
|
@@ -74,6 +78,9 @@ public class DataMiddlePlatformManagerImpl implements DataMiddlePlatformManager
|
|
|
@Autowired
|
|
|
UCFeignService uCFeignService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ RoleManager roleService;
|
|
|
+
|
|
|
@Override
|
|
|
public void sync() throws Exception {
|
|
|
try {
|
|
|
@@ -89,11 +96,6 @@ public class DataMiddlePlatformManagerImpl implements DataMiddlePlatformManager
|
|
|
List<Org> orgsAll = OAuth2ToMethod.getOrgsAll(openApiToken, "");
|
|
|
List<OrgVo> orgVoList = orgsAll.stream().map(o -> {
|
|
|
OrgVo orgVo = new OrgVo();
|
|
|
- /*orgVo.setId(o.getId());
|
|
|
- orgVo.setCode(o.getCode());
|
|
|
- orgVo.setName(o.getName());
|
|
|
- orgVo.setDemId(o.getDemId());
|
|
|
- orgVo.setParentId(o.getParentId());*/
|
|
|
BeanUtils.copyProperties(o,orgVo);
|
|
|
return orgVo;
|
|
|
}).collect(Collectors.toList());
|
|
|
@@ -102,17 +104,41 @@ public class DataMiddlePlatformManagerImpl implements DataMiddlePlatformManager
|
|
|
int j=1;
|
|
|
List<UserDetail> usersAll =new ArrayList<>();
|
|
|
for (int i = 1; i==j ; i++) {
|
|
|
- usersAll = OAuth2ToMethod.getUsersAll(openApiToken, Integer.toString(i), "100");
|
|
|
+ usersAll = OAuth2ToMethod.getUsersAll(openApiToken, Integer.toString(i), "50");
|
|
|
List<UserVo> userVos = usersAll.stream().map(u -> {
|
|
|
UserVo userVo = new UserVo();
|
|
|
BeanUtils.copyProperties(u,userVo);
|
|
|
return userVo;
|
|
|
}).collect(Collectors.toList());
|
|
|
userService.addUsers(userVos);
|
|
|
- if (usersAll.size()==100) {
|
|
|
+ if (usersAll.size()==50) {
|
|
|
+ j++;
|
|
|
+ }else {
|
|
|
+ j=1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //角色数据
|
|
|
+
|
|
|
+ List<com.hotent.uc.model.Role> roleList = new ArrayList<>();
|
|
|
+ for (int i = 1; i==j ; i++) {
|
|
|
+ List<Role> roles = OAuth2ToMethod.getRolesAll(openApiToken, "1", "50");
|
|
|
+ for (Role role : roles) {
|
|
|
+ com.hotent.uc.model.Role r = new com.hotent.uc.model.Role();
|
|
|
+ r.setId(UniqueIdUtil.getSuid());
|
|
|
+ r.setName(role.getName());
|
|
|
+ r.setCode(role.getCode());
|
|
|
+ r.setCreateTime(LocalDateTime.now());
|
|
|
+ roleList.add(r);
|
|
|
+ }
|
|
|
+ if (usersAll.size()==50) {
|
|
|
j++;
|
|
|
+ }else {
|
|
|
+ j=1;
|
|
|
}
|
|
|
}
|
|
|
+ roleService.saveBatch(roleList);
|
|
|
+
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
throw new RuntimeException(e);
|
|
|
@@ -131,10 +157,11 @@ public class DataMiddlePlatformManagerImpl implements DataMiddlePlatformManager
|
|
|
String accessToken = accessTokenWithCode.getValue().getAccess_token();
|
|
|
UserInfo userInfo = OAuth2ToMethod.getUserInfo(accessToken);
|
|
|
System.err.println("用户信息:"+JSON.toJSON(userInfo));
|
|
|
-
|
|
|
+ CacheEvictUtil.deleteUserDetailsCache(userInfo.getName());
|
|
|
// 当前切中的方法
|
|
|
HttpServletRequest request = HttpUtil.getRequest();
|
|
|
boolean isMobile = HttpUtil.isMobile(request);
|
|
|
+ //final UserDetails userDetails = userDetailsService.loadUserByUsername("zhangming0030");
|
|
|
final UserDetails userDetails = userDetailsService.loadUserByUsername(userInfo.getName());
|
|
|
final String token = jwtTokenHandler.generateToken(userDetails);
|
|
|
String userName = userDetails.getUsername();
|
|
|
@@ -160,9 +187,6 @@ public class DataMiddlePlatformManagerImpl implements DataMiddlePlatformManager
|
|
|
|
|
|
/* User user = userService.getByAccount(userInfo.getName());
|
|
|
CacheEvictUtil.deleteUserDetailsCache(user.getAccount());*/
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
//return null;
|
|
|
}
|
|
|
|