Commit 64e3c00e authored by xinglei's avatar xinglei

免密登录

parent 6d13cee1
package com.yeejoin.amos.fas.business.controller;
import com.alibaba.fastjson.JSON;
import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
import com.yeejoin.amos.fas.business.vo.Toke;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
/**
* @Author: xinglei
* @Description:
* @Date: 2020/5/27 15:26
*/
@RestController
@RequestMapping("/api/login")
@Api("免密登录api")
public class AvoidLoginController extends BaseController{
@Value("${oauth2.accessToken}")
private String checkAccessToken;
@Value("${oauth2.password}")
private String password;
@Autowired
private RemoteSecurityService remoteSecurityService;
@ApiOperation(httpMethod = "GET",value = "免密登录获取token", notes = "免密登录获取token")
@RequestMapping(value = "/avoid/{loginId}/{accessToken}/{expireTime}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse avoidLogin(@PathVariable String loginId, @PathVariable String accessToken, @PathVariable Integer expireTime) {
if (accessToken.equals(checkAccessToken)){
Toke toke = remoteSecurityService.avoidLogin(loginId, password, expireTime);
return CommonResponseUtil.success(toke);
}
return CommonResponseUtil.failure("令牌不正确");
}
}
......@@ -174,4 +174,6 @@ public class CommonController extends BaseController {
List<AgencyUserModel> users = commonService.getAllUser(getToken(),getProduct(),getAppKey(), compCode);
return CommonResponseUtil.success(users);
}
}
......@@ -24,9 +24,6 @@ public class CurCompanyController extends BaseController {
map.put("company", getSelectedOrgInfo().getCompany());
map.put("department", getSelectedOrgInfo().getDepartment());
return CommonResponseUtil.success(map);
}
}
......@@ -164,11 +164,33 @@ public class RemoteSecurityService {
}
/**
* 免密登录
* @return
*/
public Toke avoidLogin(String loginId, String password, Integer expireTime){
StationAuthModel stationAuthModel=new StationAuthModel();
stationAuthModel.setLoginId(loginId);
stationAuthModel.setPassword(password);
stationAuthModel.setExpireTime(expireTime);
Map map=null;
FeignClientResult feignClientResult;
Toke oked=new Toke();
try {
RequestContext.setProduct(productWeb);
feignClientResult = Privilege.authClient.idpasswordStation(stationAuthModel);
//Privilege.authClient.idpasswordStation();
map = (Map) feignClientResult.getResult();
if(map!=null){
oked.setToke(map.get("token").toString());
oked.setProduct(productWeb);
oked.setAppKey(appKeyWeb);
}
} catch (InnerInvokException e) {
e.printStackTrace();
}
return oked;
}
/* public List<UserModel> listUserByRoleIds(String roleIds) {
CommonResponse commonResponse = iAmosSecurityServer.listUserByRoleIds(roleIds);
......
......@@ -56,6 +56,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.typroject.tyboot.component.cache.Redis;
import org.typroject.tyboot.component.cache.enumeration.CacheType;
......@@ -540,17 +541,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
content = fmeaPointInputitemMapper.listByFmeaId(fmeaId, pageNumber, pageSize);
if(!CollectionUtils.isEmpty(content)){
Set<String> userIds = new HashSet<>();
Set<String> deptIds = new HashSet<>();
for(Map<String, Object> map : content)
{
String userId = String.valueOf(map.get("userId"));
String deptId = String.valueOf(map.get("deptId"));
userIds.add(userId);
deptIds.add(deptId);
}
userIds.remove(null);
deptIds.remove(null);
Set<Object> userIds = content.stream().filter(x -> !StringUtils.isEmpty(x.get("userId"))).map(arg0 -> arg0.get("userId")).collect(Collectors.toSet());
Set<Object> deptIds = content.stream().filter(x -> !StringUtils.isEmpty(x.get("deptId"))).map(arg0 -> arg0.get("deptId")).collect(Collectors.toSet());
List<AgencyUserModel> users = new ArrayList<>();
if(!CollectionUtils.isEmpty(userIds)){
users = remoteSecurityService.listUserByUserIds(toke, product, appKey, Joiner.on(",").join(userIds));
......
......@@ -3,6 +3,9 @@ security.loginId=tw3
security.productWeb=CONVERTER_STATION_WEB
security.appKeyWeb=CONVERTER_STATION
oauth2.accessToken=my
oauth2.password=a123456
#environment
#spring.profiles.active = dev
eureka.client.serviceUrl.defaultZone=http://172.16.3.75:10001/eureka/
......
......@@ -3,6 +3,9 @@ security.loginId=tw3
security.productWeb=CONVERTER_STATION_WEB
security.appKeyWeb=CONVERTER_STATION
oauth2.accessToken=my
oauth2.password=a123456
#environment
#spring.profiles.active = dev
eureka.client.serviceUrl.defaultZone=http://amos-eurka:10001/eureka/
......
......@@ -3,6 +3,9 @@ security.loginId=tw3
security.productWeb=CONVERTER_STATION_WEB
security.appKeyWeb=CONVERTER_STATION
oauth2.accessToken=my
oauth2.password=a123456
#environment
#spring.profiles.active = dev
eureka.client.serviceUrl.defaultZone=http://172.16.10.72:10001/eureka/
......
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