Commit 9eac2ec1 authored by tangwei's avatar tangwei

自动登录机器人

parent d452ff3d
......@@ -51,21 +51,21 @@
<artifactId>geodesy</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-component-authtoken</artifactId>
<version>1.7.13-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>io.springfox</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.yeejoin</groupId>-->
<!-- <artifactId>amos-component-authtoken</artifactId>-->
<!-- <version>1.7.13-SNAPSHOT</version>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <groupId>org.typroject</groupId>-->
<!-- <artifactId>*</artifactId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>*</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
</dependencies>
</project>
......@@ -47,17 +47,28 @@ import com.yeejoin.equipmanage.common.vo.Token;
@Service("remoteSecurityService")
public class RemoteSecurityService {
@Autowired
AmosRequestContext amosRequestContext;
@Value("${amos.system.user.password}")
private String password;
// @Value("${security.password}")
// private String password;
// @Value("${security.loginId}")
// private String loginId;
//
// @Value("${security.productWeb}")
// private String productWeb;
//
@Value("${security.productApp}")
private String productApp;
@Value("${amos.system.user.app-key}")
private String appKeyApp;
@Value("${amos.system.user.user-name}")
private String userName;
@Value("${amos.system.user.app-key}")
private String appKey;
@Value("${amos.system.user.product}")
private String product;
@Autowired
private RedisTemplate<String, String> redisTemplate;
......@@ -67,6 +78,9 @@ public class RemoteSecurityService {
@Autowired
private HttpServletRequest request;
@Autowired
AmosRequestContext amosRequestContext ;
// * 根据公司id查询机构用户
public List<AgencyUserModel> listUserByCompanyId(String companyId) {
......@@ -407,23 +421,28 @@ public class RemoteSecurityService {
// }
public Token getServerToken() {
IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel();
dPasswordAuthModel.setLoginId(amosRequestContext.getUserName());
dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz"));
Token toke = null;
try {
toke = JSON.parseObject(this.redisTemplate.opsForValue().get(buildKey(amosRequestContext.getUserName())), Token.class);
if (ObjectUtils.isEmpty(toke)) {
toke = getLogin(dPasswordAuthModel);
} else {
RequestContext.setProduct(amosRequestContext.getProduct());
if (!redisUtils.refresh(toke.getToke())) {
toke = getLogin(dPasswordAuthModel);
}
}
} catch (InnerInvokException e) {
e.printStackTrace();
}
// IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel();
// dPasswordAuthModel.setLoginId(loginId);
// dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz"));
// Token toke = null;
// try {
// toke = JSON.parseObject(this.redisTemplate.opsForValue().get(buildKey(loginId)), Token.class);
// if (ObjectUtils.isEmpty(toke)) {
// toke = getLogin(dPasswordAuthModel);
// } else {
// RequestContext.setProduct(productWeb);
// if (!redisUtils.refresh(toke.getToke())) {
// toke = getLogin(dPasswordAuthModel);
// }
// }
// } catch (InnerInvokException e) {
// e.printStackTrace();
// }
Token toke=new Token();
toke.setAppKey(appKeyApp);
toke.setProduct(product);
toke.setToke(amosRequestContext.getToken());
redisTemplate.opsForValue().set(buildKey(userName), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
return toke;
}
......@@ -432,13 +451,17 @@ public class RemoteSecurityService {
return "system_" + username;
}
private Token getLogin(IdPasswordAuthModel dPasswordAuthModel) {
Token toke = new Token();
RequestContext.setProduct(amosRequestContext.getProduct());
toke.setToke(amosRequestContext.getToken());
toke.setProduct(amosRequestContext.getProduct());
toke.setAppKey(amosRequestContext.getAppKey());
redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
return toke;
}
// private Token getLogin(IdPasswordAuthModel dPasswordAuthModel) {
// Token toke = new Token();
// RequestContext.setProduct(productWeb);
// FeignClientResult feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel);
// Map map = (Map) feignClientResult.getResult();
// if (map != null) {
// toke.setToke(map.get("token").toString());
// toke.setProduct(productWeb);
// toke.setAppKey(appKeyApp);
// redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
// }
// return toke;
// }
}
......@@ -64,10 +64,10 @@ public class LoginController {
@Value("${outSystem.user.password}")
private String password;
@Value("${security.productWeb}")
@Value("${amos.system.user.product}")
private String product;
@Value("${security.appKey}")
@Value("${amos.system.user.app-key}")
private String appKey;
@ApiOperation(value = "通过userId登录", notes = "查询设备指标")
......
......@@ -9,6 +9,7 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.yeejoin.amos.component.authtoken.robot.AmosRequestContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
......@@ -38,50 +39,64 @@ import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
@Service("remoteSecurityService")
public class RemoteSecurityService {
@Value("${security.password}")
private String password;
@Value("${security.loginId}")
private String loginId;
@Value("${security.productWeb}")
private String productWeb;
@Value("${security.appKey}")
private String appKey;
@Autowired
// @Value("${security.password}")
// private String password;
//
// @Value("${security.loginId}")
// private String loginId;
//
// @Value("${security.productWeb}")
// private String productWeb;
//
// @Value("${security.appKey}")
// private String appKey;
@Value("${amos.system.user.user-name}")
private String userName;
@Value("${amos.system.user.app-key}")
private String appKey;
@Value("${amos.system.user.product}")
private String product;
@Autowired
AmosRequestContext amosRequestContext ;
@Autowired
private RedisTemplate<String, String> redisTemplate;
//根据公司名称获取公司人
public List<CompanyModel> listCompanyTree(String toke,String product,String appKey,String companyName) {
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<CompanyModel> userModel=null;
FeignClientResult feignClientResult;
//根据公司名称获取公司人
public List<CompanyModel> listCompanyTree(String toke,String product,String appKey,String companyName) {
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<CompanyModel> userModel=null;
FeignClientResult feignClientResult;
try {
feignClientResult = Privilege.companyClient.queryAgencyTree(companyName);
userModel = (List<CompanyModel>) feignClientResult.getResult();
userModel = (List<CompanyModel>) feignClientResult.getResult();
} catch (InnerInvokException e) {
e.printStackTrace();
}
return userModel;
}
//部门id获取部门信息
public DepartmentModel getDepartmentByDeptId(String toke,String product,String appKey,String deparmentId) {
if (deparmentId == null || deparmentId.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
DepartmentModel departmentModel=null;
FeignClientResult feignClientResult;
return userModel;
}
//部门id获取部门信息
public DepartmentModel getDepartmentByDeptId(String toke,String product,String appKey,String deparmentId) {
if (deparmentId == null || deparmentId.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
DepartmentModel departmentModel=null;
FeignClientResult feignClientResult;
try {
feignClientResult = Privilege.departmentClient.seleteOne(Long.valueOf(deparmentId));
departmentModel = (DepartmentModel) feignClientResult.getResult();
......@@ -89,18 +104,18 @@ public class RemoteSecurityService {
} catch (InnerInvokException e) {
e.printStackTrace();
}
return departmentModel;
}
//查询指定部门数
public List<DepartmentModel> listDepartmentsByCompanyId(String toke,String product,String appKey,String companyId) {
if (companyId == null || companyId.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<DepartmentModel> departmentModel=null;
FeignClientResult feignClientResult;
return departmentModel;
}
//查询指定部门数
public List<DepartmentModel> listDepartmentsByCompanyId(String toke,String product,String appKey,String companyId) {
if (companyId == null || companyId.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<DepartmentModel> departmentModel=null;
FeignClientResult feignClientResult;
try {
feignClientResult = Privilege.departmentClient.queryDeptTree(null,Long.valueOf(companyId));
departmentModel = ( List<DepartmentModel>) feignClientResult.getResult();
......@@ -108,19 +123,19 @@ public class RemoteSecurityService {
} catch (InnerInvokException e) {
e.printStackTrace();
}
return departmentModel;
}
// * 根据公司id查询机构用户
public List<AgencyUserModel> listUserByCompanyId(String toke,String product,String appKey,String companyId) {
if (companyId == null || companyId.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<AgencyUserModel> AgencyUserModel=null;
FeignClientResult feignClientResult;
return departmentModel;
}
// * 根据公司id查询机构用户
public List<AgencyUserModel> listUserByCompanyId(String toke,String product,String appKey,String companyId) {
if (companyId == null || companyId.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<AgencyUserModel> AgencyUserModel=null;
FeignClientResult feignClientResult;
try {
feignClientResult = Privilege.agencyUserClient.queryByCompanyId(Long.valueOf(companyId),null,null,true);
AgencyUserModel = ( List<AgencyUserModel>) feignClientResult.getResult();
......@@ -128,69 +143,76 @@ public class RemoteSecurityService {
} catch (InnerInvokException e) {
e.printStackTrace();
}
return AgencyUserModel;
//CommonResponse commonResponse = iAmosSecurityServer.listUserByCompanyId(companyId);
//return handleArray(commonResponse, UserModel.class);
}
// * 根据公司RoleIds
public List<AgencyUserModel> getUserByRoleIds(String toke,String product,String appKey,String RoleIds) {
if (RoleIds == null || RoleIds.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<AgencyUserModel> agencyUserModel=null;
FeignClientResult feignClientResult;
try {
feignClientResult = Privilege.agencyUserClient.queryByRoleId(RoleIds,null);
agencyUserModel = (List<AgencyUserModel>)feignClientResult.getResult();
} catch (InnerInvokException e) {
e.printStackTrace();
}
return agencyUserModel;
}
public Toke getServerToken() {
IdPasswordAuthModel dPasswordAuthModel=new IdPasswordAuthModel();
dPasswordAuthModel.setLoginId(loginId);
dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz"));
Toke toke = null;
return AgencyUserModel;
//CommonResponse commonResponse = iAmosSecurityServer.listUserByCompanyId(companyId);
//return handleArray(commonResponse, UserModel.class);
}
// * 根据公司RoleIds
public List<AgencyUserModel> getUserByRoleIds(String toke,String product,String appKey,String RoleIds) {
if (RoleIds == null || RoleIds.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<AgencyUserModel> agencyUserModel=null;
FeignClientResult feignClientResult;
try {
toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class);
if(ObjectUtils.isEmpty(toke)){
toke = getLogin(dPasswordAuthModel);
}else{
RequestContext.setProduct(productWeb);
if (!TokenOperation.refresh(toke.getToke())) {
toke = getLogin(dPasswordAuthModel);
}
}
feignClientResult = Privilege.agencyUserClient.queryByRoleId(RoleIds,null);
agencyUserModel = (List<AgencyUserModel>)feignClientResult.getResult();
} catch (InnerInvokException e) {
e.printStackTrace();
}
return toke;
}
return agencyUserModel;
}
public Toke getServerToken() {
// IdPasswordAuthModel dPasswordAuthModel=new IdPasswordAuthModel();
// dPasswordAuthModel.setLoginId(loginId);
// dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz"));
// Toke toke = null;
// try {
// toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class);
// if(ObjectUtils.isEmpty(toke)){
// toke = getLogin(dPasswordAuthModel);
// }else{
// RequestContext.setProduct(productWeb);
// if (!TokenOperation.refresh(toke.getToke())) {
// toke = getLogin(dPasswordAuthModel);
// }
// }
// } catch (InnerInvokException e) {
// e.printStackTrace();
// }
// return toke;
Toke toke=new Toke();
toke.setProduct(product);
toke.setAppKey(appKey);
toke.setToke(amosRequestContext.getToken());
redisTemplate.opsForValue().set(buildKey(userName), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
return toke;
}
private Toke getLogin(IdPasswordAuthModel dPasswordAuthModel){
Toke toke = new Toke();
RequestContext.setProduct(productWeb);
RequestContext.setProduct(product);
FeignClientResult feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel);
Map map = (Map) feignClientResult.getResult();
if(map!=null){
toke.setToke(map.get("token").toString());
toke.setProduct(productWeb);
toke.setAppKey(appKey);
redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke),28,TimeUnit.DAYS);
}
if(map!=null){
toke.setToke(map.get("token").toString());
toke.setProduct(product);
toke.setAppKey(appKey);
redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke),28,TimeUnit.DAYS);
}
return toke;
}
//redi缓存系统用户token信息
private String buildKey(String username) {
return "system_" + username;
......@@ -205,12 +227,12 @@ public class RemoteSecurityService {
* @param userIds
* @return
*/
public List<AgencyUserModel> listUserByUserIds(String toke,String product,String appKey,String userIds) {
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<AgencyUserModel> agencyUserModel=null;
FeignClientResult feignClientResult;
public List<AgencyUserModel> listUserByUserIds(String toke,String product,String appKey,String userIds) {
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<AgencyUserModel> agencyUserModel=null;
FeignClientResult feignClientResult;
try {
feignClientResult = Privilege.agencyUserClient.queryByIds(userIds,true);
agencyUserModel = (List<AgencyUserModel> ) feignClientResult.getResult();
......@@ -218,75 +240,75 @@ public class RemoteSecurityService {
} catch (InnerInvokException e) {
e.printStackTrace();
}
return agencyUserModel;
}
/**
* 根据用户ids获取用户实体列表
* @param toke
* @param product
* @param appKey
* @param userIds
* @return
*/
public Map<String,AgencyUserModel> getUsersMap(String toke,String product,String appKey,Set<Object> userIds){
List<AgencyUserModel> users = listUserByUserIds(toke, product, appKey, Joiner.on(",").join(userIds));
Map<String, AgencyUserModel> userMap = new HashMap<>();
if(users!=null){
userMap = users.stream().collect(Collectors.toMap(AgencyUserModel::getUserId,v->v, (v1, v2) -> v1));
}
return userMap;
}
/**
* 根据用户ids获取用户名称列表
* @param toke
* @param product
* @param appKey
* @param userIds
* @return
*/
public Map<String,String> getUserRealName(String toke,String product,String appKey,Set<Object> userIds){
List<AgencyUserModel> users = listUserByUserIds(toke, product, appKey, Joiner.on(",").join(userIds));
Map<String, String> userMap = new HashMap<>();
if(users!=null){
userMap = users.stream().collect(Collectors.toMap(AgencyUserModel::getUserId,AgencyUserModel::getRealName));
}
return userMap;
}
/**
* 根据部门ids获取部门名称
* @param toke
* @param product
* @param appKey
* @param depIds
* @return
*/
public Map<Long,String> getDepName(String toke,String product,String appKey,Set<Object> depIds){
List<DepartmentModel> depts = new ArrayList<>();
if(!CollectionUtils.isEmpty(depIds)){
depts = this.listDepartmentByDeptIds(toke, product, appKey, Joiner.on(",").join(depIds));
}
Map<Long, String> deptMap = new HashMap<>();
if(depts!=null){
deptMap = depts.stream().collect(Collectors.toMap(DepartmentModel::getSequenceNbr,DepartmentModel::getDepartmentName));
}
return agencyUserModel;
}
/**
* 根据用户ids获取用户实体列表
* @param toke
* @param product
* @param appKey
* @param userIds
* @return
*/
public Map<String,AgencyUserModel> getUsersMap(String toke,String product,String appKey,Set<Object> userIds){
List<AgencyUserModel> users = listUserByUserIds(toke, product, appKey, Joiner.on(",").join(userIds));
Map<String, AgencyUserModel> userMap = new HashMap<>();
if(users!=null){
userMap = users.stream().collect(Collectors.toMap(AgencyUserModel::getUserId,v->v, (v1, v2) -> v1));
}
return userMap;
}
/**
* 根据用户ids获取用户名称列表
* @param toke
* @param product
* @param appKey
* @param userIds
* @return
*/
public Map<String,String> getUserRealName(String toke,String product,String appKey,Set<Object> userIds){
List<AgencyUserModel> users = listUserByUserIds(toke, product, appKey, Joiner.on(",").join(userIds));
Map<String, String> userMap = new HashMap<>();
if(users!=null){
userMap = users.stream().collect(Collectors.toMap(AgencyUserModel::getUserId,AgencyUserModel::getRealName));
}
return userMap;
}
/**
* 根据部门ids获取部门名称
* @param toke
* @param product
* @param appKey
* @param depIds
* @return
*/
public Map<Long,String> getDepName(String toke,String product,String appKey,Set<Object> depIds){
List<DepartmentModel> depts = new ArrayList<>();
if(!CollectionUtils.isEmpty(depIds)){
depts = this.listDepartmentByDeptIds(toke, product, appKey, Joiner.on(",").join(depIds));
}
Map<Long, String> deptMap = new HashMap<>();
if(depts!=null){
deptMap = depts.stream().collect(Collectors.toMap(DepartmentModel::getSequenceNbr,DepartmentModel::getDepartmentName));
}
return deptMap;
}
//用户id获取用户信息
public AgencyUserModel getUserById(String toke,String product,String appKey,String userId) {
if (userId == null || userId.equals("")) {
return null;
}
// CommonResponse commonResponse = iAmosSecurityServer.getUserById(userId);
// return handleObj(commonResponse, UserModel.class);
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
AgencyUserModel agencyUserModel=null;
FeignClientResult feignClientResult;
}
//用户id获取用户信息
public AgencyUserModel getUserById(String toke,String product,String appKey,String userId) {
if (userId == null || userId.equals("")) {
return null;
}
// CommonResponse commonResponse = iAmosSecurityServer.getUserById(userId);
// return handleObj(commonResponse, UserModel.class);
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
AgencyUserModel agencyUserModel=null;
FeignClientResult feignClientResult;
try {
feignClientResult = Privilege.agencyUserClient.queryByUserId(userId);
agencyUserModel = (AgencyUserModel)feignClientResult.getResult();
......@@ -294,8 +316,8 @@ public class RemoteSecurityService {
} catch (InnerInvokException e) {
e.printStackTrace();
}
return agencyUserModel;
}
return agencyUserModel;
}
/**
* 根据orgCode查询机构用户
......@@ -305,22 +327,22 @@ public class RemoteSecurityService {
* @param orgCode orgCode
* @return List<AgencyUserModel>
*/
public List<AgencyUserModel> listUserByOrgCode(String toke,String product,String appKey,String orgCode) {
if (orgCode == null || orgCode.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<AgencyUserModel> agencyUserModel=null;
FeignClientResult feignClientResult = new FeignClientResult();
public List<AgencyUserModel> listUserByOrgCode(String toke,String product,String appKey,String orgCode) {
if (orgCode == null || orgCode.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<AgencyUserModel> agencyUserModel=null;
FeignClientResult feignClientResult = new FeignClientResult();
try {
feignClientResult = Privilege.agencyUserClient.queryByOrgCode(orgCode,null);
} catch (InnerInvokException e) {
e.printStackTrace();
}
return handleArray(feignClientResult,AgencyUserModel.class);
}
return handleArray(feignClientResult,AgencyUserModel.class);
}
/**
* 根据orgCode查询机构
......@@ -330,15 +352,15 @@ public class RemoteSecurityService {
* @param orgCode orgCode
* @return Map<String, Object>
*/
public Map<String, Object> listByOrgCode(String toke,String product,String appKey,String orgCode) {
if (orgCode == null || orgCode.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
Map<String, Object> agencyUserModel=null;
FeignClientResult feignClientResult;
public Map<String, Object> listByOrgCode(String toke,String product,String appKey,String orgCode) {
if (orgCode == null || orgCode.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
Map<String, Object> agencyUserModel=null;
FeignClientResult feignClientResult;
try {
feignClientResult = Privilege.companyClient.queryByOrgcode(orgCode);
agencyUserModel = (Map<String, Object>) feignClientResult.getResult();
......@@ -346,31 +368,31 @@ public class RemoteSecurityService {
} catch (InnerInvokException e) {
e.printStackTrace();
}
return agencyUserModel;
}
// 根据部门id查询机构用户
public List<AgencyUserModel> listUserByDepartmentId(String toke,String product,String appKey,String departmentId) {
if (departmentId == null || departmentId.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<AgencyUserModel> agencyUserModel=null;
FeignClientResult feignClientResult;
return agencyUserModel;
}
// 根据部门id查询机构用户
public List<AgencyUserModel> listUserByDepartmentId(String toke,String product,String appKey,String departmentId) {
if (departmentId == null || departmentId.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<AgencyUserModel> agencyUserModel=null;
FeignClientResult feignClientResult;
try {
feignClientResult = Privilege.agencyUserClient.queryByDepartmentId(Long.valueOf(departmentId),null,null,true);
agencyUserModel = (List<AgencyUserModel>)feignClientResult.getResult();
......@@ -378,26 +400,26 @@ public class RemoteSecurityService {
} catch (InnerInvokException e) {
e.printStackTrace();
}
return agencyUserModel;
}
/**
* 获取子公司信息树结构
* @param toke
* @param product
* @param appKey
* @param companyId
* @return
*/
public List<CompanyModel> getCompanyTreeByCompanyId(String toke,String product,String appKey,String companyId) {
if (companyId == null || companyId.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<CompanyModel> companyModel=null;
FeignClientResult feignClientResult;
return agencyUserModel;
}
/**
* 获取子公司信息树结构
* @param toke
* @param product
* @param appKey
* @param companyId
* @return
*/
public List<CompanyModel> getCompanyTreeByCompanyId(String toke,String product,String appKey,String companyId) {
if (companyId == null || companyId.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<CompanyModel> companyModel=null;
FeignClientResult feignClientResult;
try {
feignClientResult = Privilege.companyClient.querySubAgencyTree(Long.valueOf(companyId));
companyModel = (List<CompanyModel>)feignClientResult.getResult();
......@@ -405,26 +427,26 @@ public class RemoteSecurityService {
} catch (InnerInvokException e) {
e.printStackTrace();
}
return companyModel;
}
/**
* 查询指定公司的部门树
* @param toke
* @param product
* @param appKey
* @param companyId
* @return
*/
public List<DepartmentModel> getDepartmentTreeByCompanyId(String toke,String product,String appKey,String companyId) {
if (companyId == null || companyId.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<DepartmentModel> departmentModel=null;
FeignClientResult feignClientResult;
return companyModel;
}
/**
* 查询指定公司的部门树
* @param toke
* @param product
* @param appKey
* @param companyId
* @return
*/
public List<DepartmentModel> getDepartmentTreeByCompanyId(String toke,String product,String appKey,String companyId) {
if (companyId == null || companyId.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<DepartmentModel> departmentModel=null;
FeignClientResult feignClientResult;
try {
feignClientResult = Privilege.departmentClient.queryDeptTree(null,Long.valueOf(companyId));
departmentModel = (List<DepartmentModel>)feignClientResult.getResult();
......@@ -432,10 +454,10 @@ public class RemoteSecurityService {
} catch (InnerInvokException e) {
e.printStackTrace();
}
return departmentModel;
// CommonResponse commonResponse = iAmosSecurityServer.getDepartmentTreeByCompanyId(companyId);
// return handleArray(commonResponse, DepartmentBo.class);
}
return departmentModel;
// CommonResponse commonResponse = iAmosSecurityServer.getDepartmentTreeByCompanyId(companyId);
// return handleArray(commonResponse, DepartmentBo.class);
}
/**
* 根据id批量获取部门信息
......@@ -445,44 +467,44 @@ public class RemoteSecurityService {
* @param "200".equals(feignClientResult.getStatus())departmentIds 部门ids
* @return List<DepartmentModel>
*/
public List<DepartmentModel> listDepartmentByDeptIds(String toke,String product,String appKey,String departmentIds) {
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
FeignClientResult feignClientResult = new FeignClientResult();
public List<DepartmentModel> listDepartmentByDeptIds(String toke,String product,String appKey,String departmentIds) {
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
FeignClientResult feignClientResult = new FeignClientResult();
try {
feignClientResult = Privilege.departmentClient.queryDeptByIds(departmentIds);
} catch (InnerInvokException e) {
e.printStackTrace();
}
return handleArray(feignClientResult,DepartmentModel.class);
}
return handleArray(feignClientResult,DepartmentModel.class);
}
private <T> List<T> handleArray(FeignClientResult feignClientResult, Class<T> t) {
List<T> list = new ArrayList<>();
if (feignClientResult != null && feignClientResult.getStatus() == 200) {
String jsonStr = JSON.toJSONString(feignClientResult.getResult());
private <T> List<T> handleArray(FeignClientResult feignClientResult, Class<T> t) {
List<T> list = new ArrayList<>();
if (feignClientResult != null && feignClientResult.getStatus() == 200) {
String jsonStr = JSON.toJSONString(feignClientResult.getResult());
list = JSONArray.parseArray(jsonStr, t);
}
return list;
}
private <T> T handleObj(CommonResponse commonResponse, Class<T> t) {
if (commonResponse != null && commonResponse.isSuccess()) {
String jsonStr = JSON.toJSONString(commonResponse.getDataList());
return JSONObject.parseObject(jsonStr, t);
}
return null;
}
/**
* 基础平台全部菜单权限树,用于平台登录前端初始化路由
*/
public CommonResponse searchPermissionTree(String toke,String product,String appKey,String appType) {
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<PermissionModel> dictionarieModel=null;
FeignClientResult feignClientResult;
}
return list;
}
private <T> T handleObj(CommonResponse commonResponse, Class<T> t) {
if (commonResponse != null && commonResponse.isSuccess()) {
String jsonStr = JSON.toJSONString(commonResponse.getDataList());
return JSONObject.parseObject(jsonStr, t);
}
return null;
}
/**
* 基础平台全部菜单权限树,用于平台登录前端初始化路由
*/
public CommonResponse searchPermissionTree(String toke,String product,String appKey,String appType) {
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<PermissionModel> dictionarieModel=null;
FeignClientResult feignClientResult;
try {
feignClientResult = Privilege.permissionClient.queryPermissionTree(appType,null,null,null,appKey);
dictionarieModel = (List<PermissionModel>)feignClientResult.getResult();
......@@ -490,23 +512,23 @@ public class RemoteSecurityService {
} catch (InnerInvokException e) {
e.printStackTrace();
}
CommonResponse commonResponse =new CommonResponse("SUCCESS",dictionarieModel);
return commonResponse ;
}
/**
* 根据Code查询指定的字典信息.
* @param toke
* @param product
* @param appKey
* @param dictCode
* @return
*/
public JSONArray listDictionaryByDictCode(String toke,String product,String appKey,String dictCode) {
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<DictionarieValueModel> dictionarieModel=null;
FeignClientResult feignClientResult;
CommonResponse commonResponse =new CommonResponse("SUCCESS",dictionarieModel);
return commonResponse ;
}
/**
* 根据Code查询指定的字典信息.
* @param toke
* @param product
* @param appKey
* @param dictCode
* @return
*/
public JSONArray listDictionaryByDictCode(String toke,String product,String appKey,String dictCode) {
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<DictionarieValueModel> dictionarieModel=null;
FeignClientResult feignClientResult;
try {
feignClientResult = Systemctl.dictionarieClient.dictValues(dictCode);
dictionarieModel = (List<DictionarieValueModel>)feignClientResult.getResult();
......@@ -515,29 +537,29 @@ public class RemoteSecurityService {
e.printStackTrace();
}
if (dictionarieModel != null ) {
String jsonStr = JSON.toJSONString(dictionarieModel);
return JSONArray.parseArray(jsonStr);
}
return null;
}
/**
* 查询指定公司信息与其部门用户树
* @param toke
* @param product
* @param appKey
* @param companyId
* @return
*/
public CompanyModel listUserByCompanyId1(String toke,String product,String appKey,String companyId) {
if (companyId == null || companyId.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
String jsonStr = JSON.toJSONString(dictionarieModel);
return JSONArray.parseArray(jsonStr);
}
return null;
}
/**
* 查询指定公司信息与其部门用户树
* @param toke
* @param product
* @param appKey
* @param companyId
* @return
*/
public CompanyModel listUserByCompanyId1(String toke,String product,String appKey,String companyId) {
if (companyId == null || companyId.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
CompanyModel companyModel=null;
FeignClientResult feignClientResult;
FeignClientResult feignClientResult;
try {
feignClientResult = Privilege.companyClient.withDeptAndUsers(Long.valueOf(companyId));
companyModel = (CompanyModel)feignClientResult.getResult();
......@@ -545,34 +567,34 @@ public class RemoteSecurityService {
} catch (InnerInvokException e) {
e.printStackTrace();
}
return companyModel;
}
return companyModel;
}
public boolean loginOutFromApp(String toke,String product,String appKey) {
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
boolean flag=false;
FeignClientResult feignClientResult;
public boolean loginOutFromApp(String toke,String product,String appKey) {
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
boolean flag=false;
FeignClientResult feignClientResult;
try {
feignClientResult = Privilege.authClient.removeToken();
flag=true;
} catch (InnerInvokException e) {
e.printStackTrace();
}
return flag;
}
public JSONArray listDepartmentUserTree(String toke,String product,String appKey,String companyId) {
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
CompanyModel companyModel=null;
FeignClientResult feignClientResult;
return flag;
}
public JSONArray listDepartmentUserTree(String toke,String product,String appKey,String companyId) {
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
CompanyModel companyModel=null;
FeignClientResult feignClientResult;
try {
feignClientResult = Privilege.companyClient.withDeptAndUsers(Long.valueOf(companyId));
companyModel = (CompanyModel)feignClientResult.getResult();
......@@ -580,29 +602,29 @@ public class RemoteSecurityService {
} catch (InnerInvokException e) {
e.printStackTrace();
}
if (companyModel != null ) {
String jsonStr =null;
jsonStr = JSON.toJSONString(companyModel.getChildren());
return JSONArray.parseArray(jsonStr);
}
return null;
}
public boolean editPassword(String toke,String product,String appKey,String userId, String oldPassword, String newPassword) {
boolean flag=false;
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
AgencyUserModel agencyUserModel=new AgencyUserModel();
agencyUserModel.setPassword(oldPassword);
agencyUserModel.setRePassword(newPassword);
agencyUserModel.setOriginalPassword(newPassword);
AgencyUserModel agencyUserModel2=null;
FeignClientResult feignClientResult;
jsonStr = JSON.toJSONString(companyModel.getChildren());
return JSONArray.parseArray(jsonStr);
}
return null;
}
public boolean editPassword(String toke,String product,String appKey,String userId, String oldPassword, String newPassword) {
boolean flag=false;
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
AgencyUserModel agencyUserModel=new AgencyUserModel();
agencyUserModel.setPassword(oldPassword);
agencyUserModel.setRePassword(newPassword);
agencyUserModel.setOriginalPassword(newPassword);
AgencyUserModel agencyUserModel2=null;
FeignClientResult feignClientResult;
try {
feignClientResult = Privilege.agencyUserClient.modifyPassword(userId,agencyUserModel);
......@@ -611,11 +633,11 @@ public class RemoteSecurityService {
} catch (InnerInvokException e) {
e.printStackTrace();
}
if(agencyUserModel2!=null){
flag=true;
}
return false;
}
if(agencyUserModel2!=null){
flag=true;
}
return false;
}
}
......@@ -10,6 +10,7 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.yeejoin.amos.component.authtoken.robot.AmosRequestContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -44,17 +45,35 @@ import com.yeejoin.amos.latentdanger.common.remote.IAMOSSecurityServer;
@Service("remoteSecurityService-danger")
public class RemoteSecurityService {
@Value("${security.password}")
private String password;
@Value("${security.loginId}")
private String loginId;
@Value("${security.productWeb}")
private String productWeb;
@Value("${security.appKey}")
private String appKey;
// @Value("${security.password}")
// private String password;
// @Value("${security.loginId}")
// private String loginId;
// @Value("${security.productWeb}")
// private String productWeb;
// @Value("${security.appKey}")
// private String appKey;
// @Value("${security.productApp}")
// private String productApp;
@Value("${security.productApp}")
private String productApp;
@Value("${amos.system.user.user-name}")
private String userName;
@Value("${amos.system.user.app-key}")
private String appKey;
@Value("${amos.system.user.product}")
private String product;
@Autowired
AmosRequestContext amosRequestContext ;
private static final Logger log = LoggerFactory.getLogger(RemoteSecurityService.class);
@Autowired
......@@ -101,34 +120,39 @@ public class RemoteSecurityService {
}
public Toke getServerToken() {
IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel();
dPasswordAuthModel.setLoginId(loginId);
dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz"));
Toke toke = null;
try {
toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class);
if (ObjectUtils.isEmpty(toke)) {
toke = getLogin(dPasswordAuthModel);
} else {
RequestContext.setProduct(productWeb);
if (!TokenOperation.refresh(toke.getToke())) {
toke = getLogin(dPasswordAuthModel);
}
}
} catch (InnerInvokException e) {
e.printStackTrace();
}
// IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel();
// dPasswordAuthModel.setLoginId(loginId);
// dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz"));
// Toke toke = null;
// try {
// toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class);
// if (ObjectUtils.isEmpty(toke)) {
// toke = getLogin(dPasswordAuthModel);
// } else {
// RequestContext.setProduct(productWeb);
// if (!TokenOperation.refresh(toke.getToke())) {
// toke = getLogin(dPasswordAuthModel);
// }
// }
// } catch (InnerInvokException e) {
// e.printStackTrace();
// }
Toke toke=new Toke();
toke.setProduct(product);
toke.setAppKey(appKey);
toke.setToke(amosRequestContext.getToken());
redisTemplate.opsForValue().set(buildKey(userName), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
return toke;
}
private Toke getLogin(IdPasswordAuthModel dPasswordAuthModel) {
Toke toke = new Toke();
RequestContext.setProduct(productWeb);
RequestContext.setProduct(product);
FeignClientResult feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel);
Map map = (Map) feignClientResult.getResult();
if (map != null) {
toke.setToke(map.get("token").toString());
toke.setProduct(productWeb);
toke.setProduct(product);
toke.setAppKey(appKey);
redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
}
......@@ -558,6 +582,7 @@ public class RemoteSecurityService {
return null;
}
public boolean loginOutFromApp(String toke, String product, String appKey) {
RequestContext.setToken(toke);
RequestContext.setProduct(product);
......@@ -628,7 +653,7 @@ public class RemoteSecurityService {
public AgencyUserModel getAgencyUserModel(String token) {
RequestContext.setToken(token);
RequestContext.setAppKey(appKey);
RequestContext.setProduct(productWeb);
RequestContext.setProduct(product);
try {
AgencyUserModel result = Privilege.agencyUserClient.getme().getResult();
return result;
......
......@@ -11,6 +11,7 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.yeejoin.amos.component.authtoken.robot.AmosRequestContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -45,17 +46,35 @@ import com.yeejoin.amos.maintenance.common.remote.IAMOSSecurityServer;
@Service("remoteSecurityService")
public class RemoteSecurityService {
@Value("${security.password}")
private String password;
@Value("${security.loginId}")
private String loginId;
@Value("${security.productWeb}")
private String productWeb;
@Value("${security.appKey}")
private String appKey;
// @Value("${security.password}")
// private String password;
// @Value("${security.loginId}")
// private String loginId;
// @Value("${security.productWeb}")
// private String productWeb;
// @Value("${security.appKey}")
// private String appKey;
// @Value("${security.productApp}")
// private String productApp;
@Value("${security.productApp}")
private String productApp;
@Value("${amos.system.user.user-name}")
private String userName;
@Value("${amos.system.user.app-key}")
private String appKey;
@Value("${amos.system.user.product}")
private String product;
@Autowired
AmosRequestContext amosRequestContext ;
private static final Logger log = LoggerFactory.getLogger(RemoteSecurityService.class);
@Autowired
......@@ -102,34 +121,39 @@ public class RemoteSecurityService {
}
public Toke getServerToken() {
IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel();
dPasswordAuthModel.setLoginId(loginId);
dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz"));
Toke toke = null;
try {
toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class);
if (ObjectUtils.isEmpty(toke)) {
toke = getLogin(dPasswordAuthModel);
} else {
RequestContext.setProduct(productWeb);
if (!TokenOperation.refresh(toke.getToke())) {
toke = getLogin(dPasswordAuthModel);
}
}
} catch (InnerInvokException e) {
e.printStackTrace();
}
// IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel();
// dPasswordAuthModel.setLoginId(loginId);
// dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz"));
// Toke toke = null;
// try {
// toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class);
// if (ObjectUtils.isEmpty(toke)) {
// toke = getLogin(dPasswordAuthModel);
// } else {
// RequestContext.setProduct(product);
// if (!TokenOperation.refresh(toke.getToke())) {
// toke = getLogin(dPasswordAuthModel);
// }
// }
// } catch (InnerInvokException e) {
// e.printStackTrace();
// }
Toke toke=new Toke();
toke.setProduct(product);
toke.setAppKey(appKey);
toke.setToke(amosRequestContext.getToken());
redisTemplate.opsForValue().set(buildKey(userName), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
return toke;
}
private Toke getLogin(IdPasswordAuthModel dPasswordAuthModel) {
Toke toke = new Toke();
RequestContext.setProduct(productWeb);
RequestContext.setProduct(product);
FeignClientResult feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel);
Map map = (Map) feignClientResult.getResult();
if (map != null) {
toke.setToke(map.get("token").toString());
toke.setProduct(productWeb);
toke.setProduct(product);
toke.setAppKey(appKey);
redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
}
......@@ -637,7 +661,7 @@ public class RemoteSecurityService {
public AgencyUserModel getAgencyUserModel(String token) {
RequestContext.setToken(token);
RequestContext.setAppKey(appKey);
RequestContext.setProduct(productWeb);
RequestContext.setProduct(product);
try {
AgencyUserModel result = Privilege.agencyUserClient.getme().getResult();
return result;
......
......@@ -11,6 +11,7 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.yeejoin.amos.component.authtoken.robot.AmosRequestContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -45,17 +46,38 @@ import com.yeejoin.amos.patrol.common.remote.IAMOSSecurityServer;
@Service("remoteSecurityService")
public class RemoteSecurityService {
@Value("${security.password}")
private String password;
@Value("${security.loginId}")
private String loginId;
@Value("${security.productWeb}")
private String productWeb;
@Value("${security.appKey}")
private String appKey;
// @Value("${security.password}")
// private String password;
// @Value("${security.loginId}")
// private String loginId;
// @Value("${security.productWeb}")
// private String productWeb;
// @Value("${security.appKey}")
// private String appKey;
// @Value("${security.productApp}")
// private String productApp;
@Value("${security.productApp}")
private String productApp;
@Value("${amos.system.user.user-name}")
private String userName;
@Value("${amos.system.user.app-key}")
private String appKey;
@Value("${amos.system.user.product}")
private String product;
@Autowired
AmosRequestContext amosRequestContext ;
private static final Logger log = LoggerFactory.getLogger(RemoteSecurityService.class);
@Autowired
......@@ -102,36 +124,44 @@ public class RemoteSecurityService {
}
public Toke getServerToken() {
IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel();
dPasswordAuthModel.setLoginId(loginId);
dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz"));
Toke toke = null;
try {
toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class);
if (ObjectUtils.isEmpty(toke)) {
toke = getLogin(dPasswordAuthModel);
} else {
RequestContext.setProduct(productWeb);
if (!TokenOperation.refresh(toke.getToke())) {
toke = getLogin(dPasswordAuthModel);
}
}
RequestContext.setAppKey(toke.getAppKey());
RequestContext.setToken(toke.getToke());
} catch (InnerInvokException e) {
e.printStackTrace();
}
// IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel();
// dPasswordAuthModel.setLoginId(loginId);
// dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz"));
// Toke toke = null;
// try {
// toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class);
// if (ObjectUtils.isEmpty(toke)) {
// toke = getLogin(dPasswordAuthModel);
// } else {
// RequestContext.setProduct(productWeb);
// if (!TokenOperation.refresh(toke.getToke())) {
// toke = getLogin(dPasswordAuthModel);
// }
// }
// RequestContext.setAppKey(toke.getAppKey());
// RequestContext.setToken(toke.getToke());
// } catch (InnerInvokException e) {
// e.printStackTrace();
// }
// return toke;
Toke toke=new Toke();
toke.setProduct(product);
toke.setAppKey(appKey);
toke.setToke(amosRequestContext.getToken());
redisTemplate.opsForValue().set(buildKey(userName), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
return toke;
}
private Toke getLogin(IdPasswordAuthModel dPasswordAuthModel) {
Toke toke = new Toke();
RequestContext.setProduct(productWeb);
RequestContext.setProduct(product);
FeignClientResult feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel);
Map map = (Map) feignClientResult.getResult();
if (map != null) {
toke.setToke(map.get("token").toString());
toke.setProduct(productWeb);
toke.setProduct(product);
toke.setAppKey(appKey);
redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
}
......@@ -631,7 +661,7 @@ public class RemoteSecurityService {
public AgencyUserModel getAgencyUserModel(String token) {
RequestContext.setToken(token);
RequestContext.setAppKey(appKey);
RequestContext.setProduct(productWeb);
RequestContext.setProduct(product);
try {
AgencyUserModel result = Privilege.agencyUserClient.getme().getResult();
return result;
......
......@@ -87,7 +87,7 @@ public class UserController extends AbstractBaseController {
private String SecurityName;
@Value("${security.productApp}")
private String productApp;
@Value("${security.appKey}")
@Value("${amos.system.user.app-key}")
private String appKey;
@Autowired
private RestTemplate restTemplate;
......
......@@ -11,6 +11,7 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.yeejoin.amos.component.authtoken.robot.AmosRequestContext;
import com.yeejoin.amos.feign.systemctl.model.MessageModel;
import com.yeejoin.amos.supervision.business.feign.JCSFeignClient;
import com.yeejoin.amos.supervision.common.remote.IAMOSSecurityServer;
......@@ -48,17 +49,33 @@ import org.typroject.tyboot.core.foundation.context.RequestContextModel;
@Service("remoteSecurityService")
public class RemoteSecurityService {
@Value("${security.password}")
private String password;
@Value("${security.loginId}")
private String loginId;
@Value("${security.productWeb}")
private String productWeb;
@Value("${security.appKey}")
private String appKey;
// @Value("${security.password}")
// private String password;
// @Value("${security.loginId}")
// private String loginId;
// @Value("${security.productWeb}")
// private String productWeb;
// @Value("${security.appKey}")
// private String appKey;
// @Value("${security.productApp}")
// private String productApp;
@Value("${security.productApp}")
private String productApp;
@Value("${amos.system.user.user-name}")
private String userName;
@Value("${amos.system.user.app-key}")
private String appKey;
@Value("${amos.system.user.product}")
private String product;
private static final Logger log = LoggerFactory.getLogger(RemoteSecurityService.class);
@Autowired
......@@ -70,6 +87,9 @@ public class RemoteSecurityService {
@Autowired
private JCSFeignClient jcsFeignClient;
@Autowired
AmosRequestContext amosRequestContext ;
//根据公司名称获取公司人
public List<CompanyModel> listCompanyTree(String toke, String product, String appKey, String companyName) {
RequestContext.setToken(toke);
......@@ -107,34 +127,39 @@ public class RemoteSecurityService {
}
public Toke getServerToken() {
IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel();
dPasswordAuthModel.setLoginId(loginId);
dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz"));
Toke toke = null;
try {
toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class);
if (ObjectUtils.isEmpty(toke)) {
toke = getLogin(dPasswordAuthModel);
} else {
RequestContext.setProduct(productWeb);
if (!TokenOperation.refresh(toke.getToke())) {
toke = getLogin(dPasswordAuthModel);
}
}
} catch (InnerInvokException e) {
e.printStackTrace();
}
// IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel();
// dPasswordAuthModel.setLoginId(loginId);
// dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz"));
// Toke toke = null;
// try {
// toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class);
// if (ObjectUtils.isEmpty(toke)) {
// toke = getLogin(dPasswordAuthModel);
// } else {
// RequestContext.setProduct(productWeb);
// if (!TokenOperation.refresh(toke.getToke())) {
// toke = getLogin(dPasswordAuthModel);
// }
// }
// } catch (InnerInvokException e) {
// e.printStackTrace();
// }
Toke toke=new Toke();
toke.setProduct(product);
toke.setAppKey(appKey);
toke.setToke(amosRequestContext.getToken());
redisTemplate.opsForValue().set(buildKey(userName), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
return toke;
}
private Toke getLogin(IdPasswordAuthModel dPasswordAuthModel) {
Toke toke = new Toke();
RequestContext.setProduct(productWeb);
RequestContext.setProduct(product);
FeignClientResult feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel);
Map map = (Map) feignClientResult.getResult();
if (map != null) {
toke.setToke(map.get("token").toString());
toke.setProduct(productWeb);
toke.setProduct(product);
toke.setAppKey(appKey);
redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
}
......@@ -642,7 +667,7 @@ public class RemoteSecurityService {
public AgencyUserModel getAgencyUserModel(String token) {
RequestContext.setToken(token);
RequestContext.setAppKey(appKey);
RequestContext.setProduct(productWeb);
RequestContext.setProduct(product);
try {
AgencyUserModel result = Privilege.agencyUserClient.getme().getResult();
return result;
......
......@@ -33,6 +33,14 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<!--平台用户登录-->
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-component-authtoken</artifactId>
<version>1.7.13-SNAPSHOT</version>
</dependency>
</dependencies>
<modules>
......
......@@ -90,7 +90,13 @@ dcs.x.hw.appKey=s+YkvQhwilx91TRJHhNDmw==
equip.enabled =true
management.endpoints.enabled-by-default=false
#management.endpoints.enabled-by-default=false
## 增加接口文档验证
knife4j.enable=true
knife4j.basic.enable=true
knife4j.basic.username= admin
knife4j.basic.password= yeejoin@2020
# 权限标识-物联区域
auth-key-area=area_info
......
......@@ -9,12 +9,37 @@ spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1
#系统服务账号,用户后端服务调用
security.password=a1234560
security.loginId=fas_autosys
#security.password=a1234560
#security.loginId=fas_autosys
#
##应用product appkey
#security.productWeb=STUDIO_APP_WEB
#security.appKey =studio_normalapp_2681691
#security.password=a1234560
#security.loginId=fas_autosys
##应用product appkey
#security.productWeb=STUDIO_APP_WEB
#security.appKey =studio_normalapp_2681691
amos.system.user.user-name=fas_autosys
amos.system.user.password=a1234560
amos.system.user.app-key=studio_normalapp_2681691
amos.system.user.product=AMOS_STUDIO_WEB
#应用product appkey
security.productWeb=STUDIO_APP_WEB
security.appKey =studio_normalapp_2681691
eureka.client.serviceUrl.defaultZone=http://172.16.10.72:10001/eureka/
eureka.client.registry-fetch-interval-seconds=5
......
......@@ -123,7 +123,16 @@ mybatis.interceptor.enabled = false
## 消防救援保障部ID
fire-rescue=1432549862557130753
management.endpoints.enabled-by-default=false
#management.endpoints.enabled-by-default=false
## 增加接口文档验证
knife4j.enable=true
knife4j.basic.enable=true
knife4j.basic.username= admin
knife4j.basic.password= yeejoin@2020
#阿里云实时语音识别参数
speech-config.access-key-id=LTAI5t62oH95jgbjRiNXPsho
speech-config.access-key-secret=shy9SpogYgcdDoyTB3bvP21VSRmz8n
......
......@@ -22,4 +22,9 @@ mybatis-plus.mapper-locations=classpath:mapper/*
## redis失效时间
redis.cache.failure.time=10800
management.endpoints.enabled-by-default=false
#management.endpoints.enabled-by-default=false
## 增加接口文档验证
knife4j.enable=true
knife4j.basic.enable=true
knife4j.basic.username= admin
knife4j.basic.password= yeejoin@2020
\ No newline at end of file
......@@ -4,6 +4,7 @@ import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.elasticsearch.ElasticSearchRestHealthContributorAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.ServletComponentScan;
......@@ -36,7 +37,8 @@ import java.net.UnknownHostException;
* @author amos
* @version $Id: LatentDangerApplication.java, v 0.1 2018年11月26日 下午4:56:29 amos Exp $
*/
@SpringBootApplication
@SpringBootApplication(exclude = { ElasticSearchRestHealthContributorAutoConfiguration.class,//es健康检测
})
@EnableTransactionManagement
@EnableConfigurationProperties
@ServletComponentScan
......
......@@ -27,11 +27,19 @@ spring.datasource.hikari.maximum-pool-size = 10
spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1
security.password=a1234560
security.loginId=jc_wjk006
security.productWeb=STUDIO_APP_WEB
#security.password=a1234560
#security.loginId=jc_wjk006
#security.productWeb=STUDIO_APP_WEB
#security.productApp=STUDIO_APP_MOBILE
#security.appKey=studio_normalapp_3168830
security.productApp=STUDIO_APP_MOBILE
security.appKey=studio_normalapp_3168830
amos.system.user.user-name=jc_wjk006
amos.system.user.password=a1234560
amos.system.user.app-key=studio_normalapp_3168830
amos.system.user.product=STUDIO_APP_WEB
#redis 配置
spring.redis.database=1
......
......@@ -64,4 +64,9 @@ latentDanger.feign.name=AMOS-LATENT-DANGER
Knowledgebase.fegin.name=AMOS-API-KNOWLEDGEBASE
## 消防救援保障部ID
fire-rescue=1432549862557130753
management.endpoints.enabled-by-default=false
#management.endpoints.enabled-by-default=false
## 增加接口文档验证
knife4j.enable=true
knife4j.basic.enable=true
knife4j.basic.username= admin
knife4j.basic.password= yeejoin@2020
\ No newline at end of file
......@@ -9,11 +9,22 @@ eureka.client.serviceUrl.defaultZone=http://172.16.10.211:10001/eureka/
jcs.fegin.name=JCS
security.password=a1234560
security.loginId=jc_wjk006
security.productWeb=STUDIO_APP_WEB
#security.password=a1234560
#security.loginId=jc_wjk006
#security.productWeb=STUDIO_APP_WEB
#security.productApp=STUDIO_APP_MOBILE
#security.appKey=studio_normalapp_3168830
security.productApp=STUDIO_APP_MOBILE
security.appKey=studio_normalapp_3168830
amos.system.user.user-name=jc_wjk006
amos.system.user.password=a1234560
amos.system.user.app-key=studio_normalapp_3168830
amos.system.user.product=STUDIO_APP_WEB
#redis 配置
spring.redis.database=1
spring.redis.host=172.16.10.211
......
......@@ -67,4 +67,10 @@ eureka.instance.metadata-map.management.context-path=${server.servlet.context-pa
eureka.instance.status-page-url-path=/actuator/info
eureka.instance.metadata-map.management.api-docs=http://localhost:${server.port}${server.servlet.context-path}/swagger-ui.html
management.endpoints.enabled-by-default=false
\ No newline at end of file
#management.endpoints.enabled-by-default=false
## 增加接口文档验证
knife4j.enable=true
knife4j.basic.enable=true
knife4j.basic.username= admin
knife4j.basic.password= yeejoin@2020
\ No newline at end of file
......@@ -27,11 +27,20 @@ spring.datasource.hikari.maximum-pool-size = 10
spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1
security.password=a1234560
security.loginId=jc_wjk006
security.productWeb=STUDIO_APP_WEB
#security.password=a1234560
#security.loginId=jc_wjk006
#security.productWeb=STUDIO_APP_WEB
#security.productApp=STUDIO_APP_MOBILE
#security.appKey=studio_normalapp_3168830
security.productApp=STUDIO_APP_MOBILE
security.appKey=studio_normalapp_3168830
amos.system.user.user-name=jc_wjk006
amos.system.user.password=a1234560
amos.system.user.app-key=studio_normalapp_3168830
amos.system.user.product=STUDIO_APP_WEB
#redis 配置
spring.redis.database=1
......
......@@ -58,6 +58,13 @@ rule.definition.default-agency=STATE_GRID
jcs.fegin.name=JCS
emergency.command.section.id=1418223840361709569
management.endpoints.enabled-by-default=false
#management.endpoints.enabled-by-default=false
## 增加接口文档验证
knife4j.enable=true
knife4j.basic.enable=true
knife4j.basic.username= admin
knife4j.basic.password= yeejoin@2020
equipment.hierarchy=1,2,4,6
\ No newline at end of file
......@@ -5,11 +5,19 @@ spring.datasource.password= Yeejoin@2020
## eureka properties:
eureka.client.serviceUrl.defaultZone=http://172.16.10.211:10001/eureka/
security.password=a1234560
security.loginId=jc_wjk006
security.productWeb=STUDIO_APP_WEB
#security.password=a1234560
#security.loginId=jc_wjk006
#security.productWeb=STUDIO_APP_WEB
#security.productApp=STUDIO_APP_MOBILE
#security.appKey=studio_normalapp_3168830
security.productApp=STUDIO_APP_MOBILE
security.appKey=studio_normalapp_3168830
amos.system.user.user-name=jc_wjk006
amos.system.user.password=a1234560
amos.system.user.app-key=studio_normalapp_3056965
amos.system.user.product=STUDIO_APP_WEB
#redis 配置
......
......@@ -73,4 +73,10 @@ eureka.instance.metadata-map.management.context-path=${server.servlet.context-pa
eureka.instance.status-page-url-path=/actuator/info
eureka.instance.metadata-map.management.api-docs=http://localhost:${server.port}${server.servlet.context-path}/swagger-ui.html
management.endpoints.enabled-by-default=false
\ No newline at end of file
#management.endpoints.enabled-by-default=false
## 增加接口文档验证
knife4j.enable=true
knife4j.basic.enable=true
knife4j.basic.username= admin
knife4j.basic.password= yeejoin@2020
\ No newline at end of file
......@@ -5,3 +5,10 @@ spring.profiles.active=dev
spring.jackson.time-zone=GMT+8
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.serialization.write-dates-as-timestamps=true
## ӽӿĵ֤
knife4j.enable=true
knife4j.basic.enable=true
knife4j.basic.username= admin
knife4j.basic.password= yeejoin@2020
\ No newline at end of file
......@@ -35,3 +35,11 @@ spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## 增加接口文档验证
knife4j.enable=true
knife4j.basic.enable=true
knife4j.basic.username= admin
knife4j.basic.password= yeejoin@2020
\ No newline at end of file
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