|
@@ -74,6 +74,7 @@ import org.springblade.system.user.vo.UserVO;
|
|
|
import org.springblade.system.user.wrapper.UserWrapper;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.jdbc.core.RowMapper;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -204,7 +205,7 @@ public class UserController {
|
|
|
data.setRoleId("1537248158277914626");
|
|
|
projectAndUserList.add(data);
|
|
|
user.setProjectAndUserList(projectAndUserList);
|
|
|
- }else if (ObjectUtil.isNotEmpty(user.getSysId()) && user.getSysId().equals("40")) {
|
|
|
+ } else if (ObjectUtil.isNotEmpty(user.getSysId()) && user.getSysId().equals("40")) {
|
|
|
user.setUserType("1,2,3,7");
|
|
|
user.setPassword("123456");
|
|
|
user.setPlaintextPassword("123456");
|
|
@@ -219,7 +220,7 @@ public class UserController {
|
|
|
data.setRoleId("1538760412710289409");
|
|
|
projectAndUserList.add(data);
|
|
|
user.setProjectAndUserList(projectAndUserList);
|
|
|
- }else if (ObjectUtil.isNotEmpty(user.getSysId()) && user.getSysId().equals("50")) {
|
|
|
+ } else if (ObjectUtil.isNotEmpty(user.getSysId()) && user.getSysId().equals("50")) {
|
|
|
user.setUserType("1,2,3,7");
|
|
|
user.setPassword("123456");
|
|
|
user.setPlaintextPassword("123456");
|
|
@@ -234,21 +235,6 @@ public class UserController {
|
|
|
data.setRoleId("1537249581371707394");
|
|
|
projectAndUserList.add(data);
|
|
|
user.setProjectAndUserList(projectAndUserList);
|
|
|
- }else{
|
|
|
- user.setUserType("1,2,3,7");
|
|
|
- user.setPassword("123456");
|
|
|
- user.setPlaintextPassword("123456");
|
|
|
- user.setTenantId("000000");
|
|
|
- user.setDeptId("1750404533561184258");
|
|
|
- user.setStatus(1);
|
|
|
- user.setSysType(2);
|
|
|
- List<SaveUserInfoByProjectDTO> projectAndUserList = new ArrayList<>();
|
|
|
- SaveUserInfoByProjectDTO data = new SaveUserInfoByProjectDTO();
|
|
|
- data.setContractId("1714919227250950146");
|
|
|
- data.setProjectId("1750070685257990145");
|
|
|
- data.setRoleId("1538760412710289409");
|
|
|
- projectAndUserList.add(data);
|
|
|
- user.setProjectAndUserList(projectAndUserList);
|
|
|
}
|
|
|
|
|
|
return R.status(userService.submit2(user));
|
|
@@ -502,11 +488,9 @@ public class UserController {
|
|
|
@ApiOperation(value = "token验证加密", notes = "token验证登录")
|
|
|
public R loginByToken(String token, HttpServletRequest request) {
|
|
|
|
|
|
-
|
|
|
-
|
|
|
token = "bearer " + token;
|
|
|
HttpClient httpClient = HttpClientBuilder.create().build();
|
|
|
- HttpGet httpPost = new HttpGet("http://39.108.216.210:8090/blade-auth/oauth/user-info");
|
|
|
+ HttpGet httpPost = new HttpGet("http://172.30.224.81:8090/blade-auth/oauth/user-info");
|
|
|
httpPost.setHeader("Authorization", token); //这个需要 client:
|
|
|
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
|
|
|
|
@@ -523,7 +507,7 @@ public class UserController {
|
|
|
if (jsonObject != null && ObjectUtil.isNotEmpty(jsonObject)) {
|
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
|
String name = data.getString("name");
|
|
|
- return this.loginByToken2(name,request);
|
|
|
+ return this.loginByToken2(name, request);
|
|
|
} else {
|
|
|
return R.fail("token解析用户失败");
|
|
|
}
|
|
@@ -534,249 +518,95 @@ public class UserController {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@PostMapping("/loginByToken2")
|
|
|
@ApiOperationSupport(order = 20)
|
|
|
@ApiOperation(value = "token验证加密", notes = "token验证登录")
|
|
|
- public R loginByToken2(String account,HttpServletRequest request) {
|
|
|
- String Authorization = request.getHeader("Authorization");
|
|
|
- if(Authorization==null || StringUtil.isEmpty(Authorization)){
|
|
|
- Authorization="Basic Y2xpZW50OmNsaWVudF9zZWNyZXQ=";
|
|
|
+ public R loginByToken2(String account, HttpServletRequest request) {
|
|
|
+ if(account==null || Func.isNull(account) || Func.isEmpty(account)){
|
|
|
+ return R.fail("account值不能为空");
|
|
|
}
|
|
|
- if (StringUtil.isBlank(account)) {
|
|
|
- return R.fail("请输出token");
|
|
|
+ QueryWrapper<User> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("account", account);
|
|
|
+ // queryWrapper.eq("password", tokenPw);
|
|
|
+ queryWrapper.eq("sys_type", 2);
|
|
|
+ User userInfo = userService.getOne(queryWrapper);
|
|
|
+ if (userInfo == null) {
|
|
|
+ return R.fail("用户名或密码错误");
|
|
|
}
|
|
|
|
|
|
- if (account != null) {
|
|
|
- QueryWrapper<User> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("account", account);
|
|
|
- // queryWrapper.eq("password", tokenPw);
|
|
|
- queryWrapper.eq("sys_type", 2);
|
|
|
- User userInfo = userService.getOne(queryWrapper);
|
|
|
- if (userInfo == null) {
|
|
|
- return R.fail("用户名或密码错误");
|
|
|
- }
|
|
|
- String tenId = userInfo.getTenantId();
|
|
|
- String pass = userInfo.getPlaintextPassword();
|
|
|
- String md5Pass = MD5Utils.md5Hex(pass, "UTF-8");
|
|
|
- System.out.println("密码" + md5Pass);
|
|
|
-
|
|
|
- HttpClient httpClient = HttpClientBuilder.create().build();
|
|
|
- HttpPost httpPost = new HttpPost("http://39.108.216.210:8090/blade-auth/oauth/token");
|
|
|
- httpPost.setHeader("Authorization", Authorization);
|
|
|
- httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
|
- httpPost.setHeader("Tenant-Id", userInfo.getTenantId());
|
|
|
- List<NameValuePair> params = new ArrayList<NameValuePair>();
|
|
|
- params.add(new BasicNameValuePair("grant_type", "password"));
|
|
|
- params.add(new BasicNameValuePair("username", account));
|
|
|
- params.add(new BasicNameValuePair("password", md5Pass));
|
|
|
- params.add(new BasicNameValuePair("scope", "all"));
|
|
|
- params.add(new BasicNameValuePair("tenantId", "000000"));
|
|
|
- httpPost.setEntity(new UrlEncodedFormEntity(params, Consts.UTF_8));
|
|
|
- try {
|
|
|
- HttpResponse httpResponse = httpClient.execute(httpPost);
|
|
|
- InputStream inputStream = httpResponse.getEntity().getContent();
|
|
|
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
|
- byte[] buffer = new byte[1024];
|
|
|
- int index = 0;
|
|
|
- while ((index = inputStream.read(buffer)) != -1) {
|
|
|
- outputStream.write(buffer, 0, index);
|
|
|
+ String Authorization = request.getHeader("Authorization");
|
|
|
+
|
|
|
+ if (Authorization == null || StringUtil.isEmpty(Authorization)) {
|
|
|
+ String useType = userInfo.getUserType();
|
|
|
+ List<String> strList = Func.toStrList(useType);
|
|
|
+ for(String sys_id:strList){
|
|
|
+ String dataInfo = "";
|
|
|
+ if(sys_id.equals("1")){ //质量/试验平台
|
|
|
+ dataInfo ="client:client_secret";
|
|
|
+ }else if(sys_id.equals("2")){ //APP端
|
|
|
+ dataInfo ="uni-app:app_secret";
|
|
|
+ }else if(sys_id.equals("3")){ //档案平台"
|
|
|
+ dataInfo ="archives:archives_secret";
|
|
|
+ }else if(sys_id.equals("4")){ //后台管理端"
|
|
|
+ dataInfo ="saber:saber_secret";
|
|
|
+ }else if(sys_id.equals("5")){ //成本管控系统"
|
|
|
+ dataInfo ="hac:hac_secret";
|
|
|
+ }else if(sys_id.equals("6")){ //征拆系统"
|
|
|
+ dataInfo ="lar:lar_secret";
|
|
|
+ }else if(sys_id.equals("7")){ //计量系统"
|
|
|
+ dataInfo ="measure:measure_secret";
|
|
|
+ }else if(sys_id.equals("8")){ //安全系统"
|
|
|
+ dataInfo ="measure:measure_secret";
|
|
|
+ }
|
|
|
+ Authorization = "Basic "+Func.encodeBase64(dataInfo);
|
|
|
+ //Basic bWVhc3VyZTptZWFzdXJlX3NlY3JldA==
|
|
|
+ //Basic bWVhc3VyZTptZWFzdXJlX3NlY3JldA==
|
|
|
+ R loginInfo = this.getLoginInfo(Authorization, userInfo);
|
|
|
+ if(loginInfo.getCode()==200){
|
|
|
+ return loginInfo;
|
|
|
}
|
|
|
- System.out.println("\n");
|
|
|
- return R.data(JSON.parseObject(outputStream.toString()));
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
}
|
|
|
- } else {
|
|
|
- return R.fail("请确认account是否有误");
|
|
|
}
|
|
|
- return R.fail("");
|
|
|
+ return this.getLoginInfo(Authorization,userInfo);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 定时同步白马项目用户信息 不在使用
|
|
|
- */
|
|
|
- // @Scheduled(cron = "0 0 4 * * ?")
|
|
|
- public void syncProjectUserInfo() throws ParseException, IOException {
|
|
|
- JSONObject json = new JSONObject();
|
|
|
- json.put("fn", "all");
|
|
|
-
|
|
|
- //测试数据
|
|
|
- String url = "http://js.cegc.com.cn:13426/login/japi/synUser";
|
|
|
- String encoding = "utf-8";
|
|
|
- String da = AesInfoUtil.sendPost(url, json, encoding);
|
|
|
- if (da != null) {
|
|
|
- JSONObject userInfo = JSONObject.parseObject(da);
|
|
|
- //System.out.println(userInfo);
|
|
|
- int code = userInfo.getInteger("status");
|
|
|
- if (code == 200) {
|
|
|
- JSONArray list = userInfo.getJSONArray("list");
|
|
|
- if (list != null && list.size() >= 1) {
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
- JSONObject jsonObject = list.getJSONObject(i);
|
|
|
- String id = jsonObject.getString("id"); //人员唯一编码
|
|
|
- String account = jsonObject.getString("account"); //账号
|
|
|
- //String password = jsonObject.getString("password"); //MD5加密后的密码
|
|
|
- String name = jsonObject.getString("name"); //人员姓名
|
|
|
- String idCard = jsonObject.getString("idcard"); //身份证号
|
|
|
- String phone = jsonObject.getString("phone"); //电话号码
|
|
|
-
|
|
|
- /*这里实际接口返回的数据都是companyName对应的公司名称*/
|
|
|
- String companyName = jsonObject.getString("companyName"); //公司名称
|
|
|
- //String constructionCompany = jsonObject.getString("constructionCompany"); //公司名称
|
|
|
- //String projectName = jsonObject.getString("projectName") + ""; //公司名称*/
|
|
|
- String status = jsonObject.getString("status"); //状态(1:启用 2:冻结 3:删除)
|
|
|
- /*修改需求前*/
|
|
|
- /*if (projectName.contains("白马项目")
|
|
|
- || constructionCompany.equals("重庆白马航运发展有限公司")
|
|
|
- || constructionCompany.equals("中国水利水电第八工程局有限公司") //二期
|
|
|
- || constructionCompany.equals("中国水利水电第四工程局中电建路桥集团联合体")//一期
|
|
|
- || companyName.equals("重庆白马航运发展有限公司")//二期一期(业主)
|
|
|
- || companyName.equals("中国水利水电第八工程局有限公司")
|
|
|
- || companyName.equals("中国水利水电第四工程局中电建路桥集团联合体")
|
|
|
- ) if (sysUser != null) {
|
|
|
- newUser = sysUser;
|
|
|
- } else {
|
|
|
- newUser.setId(SnowFlakeUtil.getId());
|
|
|
- newUser.setDeptId("1588069957940674562"); //白马部门
|
|
|
- newUser.setSysType(2);
|
|
|
- newUser.setIsDeleted(0);
|
|
|
- newUser.setCreateUser(Long.parseLong("1541381503819694081"));
|
|
|
- newUser.setUpdateUser(Long.parseLong("1541381503819694081"));
|
|
|
- newUser.setTenantId("000000");
|
|
|
- newUser.setSysId(id);
|
|
|
- newUser.setUpdateTime(new Date());
|
|
|
- newUser.setCreateTime(new Date());
|
|
|
- }
|
|
|
- newUser.setUserType("1,2");
|
|
|
- newUser.setAccount(account);
|
|
|
- newUser.setRealName(name);
|
|
|
- newUser.setName(name);
|
|
|
- newUser.setPassword("10470c3b4b1fed12c3baac014be15fac67c6e815");
|
|
|
- newUser.setName(name);
|
|
|
- newUser.setStatus(Integer.parseInt(status));
|
|
|
- newUser.setIdNumber(idCard);
|
|
|
- newUser.setCompanyName(companyName);*/
|
|
|
-
|
|
|
- /*2023年8月4日16:29:14,修改需求,匹配到对应合同段中去*/
|
|
|
- /*2023年10月13日13:43:26,修改需求,增加:中国水利水电第八工程局有限公司-属于二期合同段、重庆市交通工程监理咨询有限责任公司-属于一监办*/
|
|
|
- if (companyName.contains("重庆白马航运发展有限公司")
|
|
|
- || companyName.contains("四川二滩国际工程咨询有限责任公司")
|
|
|
- || companyName.contains("中国水利水电第四工程局中电建路桥集团联合体")
|
|
|
- || companyName.contains("中国水利水电第八工程局有限公司")
|
|
|
- || companyName.contains("重庆市交通工程监理咨询有限责任公司")
|
|
|
- || companyName.contains("中铁长江交通设计集团有限公司")
|
|
|
- || companyName.contains("中铁八局集团有限公司")) {
|
|
|
- List<User> sysUser = userService.getBaseMapper().selectList(Wrappers.<User>lambdaQuery().eq(User::getSysId, id).eq(User::getSysType, 2));
|
|
|
-
|
|
|
- /*修改电话号码*/
|
|
|
- if (sysUser.size() > 0 && ObjectUtil.isNotEmpty(phone) && phone.length() == 11) {
|
|
|
- for (User user : sysUser) {
|
|
|
- if (ObjectUtil.isEmpty(user.getPhone())) {
|
|
|
- userService.lambdaUpdate()
|
|
|
- .set(User::getPhone, phone)
|
|
|
- .eq(User::getId, user.getId())
|
|
|
- .update();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /*只有本系统不存在时才去新增*/
|
|
|
- if (sysUser.size() == 0L) {
|
|
|
- User newUser = new User();
|
|
|
- newUser.setId(SnowFlakeUtil.getId());
|
|
|
- newUser.setDeptId("1588069957940674562"); //白马部门
|
|
|
- newUser.setSysType(2);
|
|
|
- newUser.setIsDeleted(0);
|
|
|
- newUser.setCreateUser(Long.parseLong("1541381503819694081"));
|
|
|
- newUser.setUpdateUser(Long.parseLong("1541381503819694081"));
|
|
|
- newUser.setTenantId("000000");
|
|
|
- newUser.setSysId(id);
|
|
|
- newUser.setUpdateTime(new Date());
|
|
|
- newUser.setCreateTime(new Date());
|
|
|
- newUser.setUserType("1,2");
|
|
|
- newUser.setAccount(account);
|
|
|
- newUser.setRealName(name);
|
|
|
- newUser.setName(name);
|
|
|
- newUser.setPassword("10470c3b4b1fed12c3baac014be15fac67c6e815");
|
|
|
- newUser.setPlaintextPassword("123456");
|
|
|
- newUser.setName(name);
|
|
|
- newUser.setStatus(Integer.parseInt(status));
|
|
|
- newUser.setIdNumber(idCard);
|
|
|
- newUser.setCompanyName(companyName);
|
|
|
- newUser.setPhone(ObjectUtil.isNotEmpty(phone) && phone.length() == 11 ? phone : null);
|
|
|
-
|
|
|
- //所有合同段(白马)
|
|
|
- if (companyName.contains("重庆白马航运发展有限公司")) {
|
|
|
- List<ContractInfo> contractInfos = jdbcTemplate.query("select id from m_contract_info where p_id = 1612329251049537537 and is_deleted = 0 and status = 1", new BeanPropertyRowMapper<>(ContractInfo.class));
|
|
|
- for (ContractInfo contractInfo : contractInfos) {
|
|
|
- Long count = jdbcTemplate.queryForObject("select count(1) from m_project_assignment_user where user_id = " + newUser.getId() + " and project_id = 1612329251049537537 " + " and contract_id = " + contractInfo.getId() + " and post_id is null " + " and status = 1 and is_deleted = 0", Long.class);
|
|
|
- if (count == null || count == 0L) {
|
|
|
- //绑定项目,设置默认角色信息 白马项目id:1612329251049537537;所有合同段id:contractInfo.getId();角色施工-资料员id:1537249581371707394
|
|
|
- saveUserInfoByProjectClient.saveInfoRelation(newUser.getId(), 1612329251049537537L, contractInfo.getId(), 1537249581371707394L);
|
|
|
- newUser.setRoleId("1537249581371707394");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //二期合同段(八局、二滩、长江设计单位、中国水利水电第八工程局有限公司)
|
|
|
- if (companyName.contains("中铁八局集团有限公司") || companyName.contains("四川二滩国际工程咨询有限责任公司")
|
|
|
- || companyName.contains("中铁长江交通设计集团有限公司") || companyName.contains("中国水利水电第八工程局有限公司")) {
|
|
|
- Long count = jdbcTemplate.queryForObject("select count(1) from m_project_assignment_user where user_id = " + newUser.getId() + " and project_id = 1612329251049537537 and contract_id = 1612335077269143554 and post_id is null and status = 1 and is_deleted = 0", Long.class);
|
|
|
- if (count == null || count == 0L) {
|
|
|
- //绑定项目,设置默认角色信息 白马项目id:1612329251049537537;第二期合同段id:1612335077269143554;角色施工-资料员id:1537249581371707394
|
|
|
- saveUserInfoByProjectClient.saveInfoRelation(newUser.getId(), 1612329251049537537L, 1612335077269143554L, 1537249581371707394L);
|
|
|
- newUser.setRoleId("1537249581371707394");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //一期合同段(四局、长江设计单位)
|
|
|
- if (companyName.contains("中国水利水电第四工程局中电建路桥集团联合体") || companyName.contains("中铁长江交通设计集团有限公司")) {
|
|
|
- Long count = jdbcTemplate.queryForObject("select count(1) from m_project_assignment_user where user_id = " + newUser.getId() + " and project_id = 1612329251049537537 and contract_id = 1613022750656921601 and post_id is null and status = 1 and is_deleted = 0", Long.class);
|
|
|
- if (count == null || count == 0L) {
|
|
|
- //绑定项目,设置默认角色信息 白马项目id:1612329251049537537;第一期合同段id:1613022750656921601;角色施工-资料员id:1537249581371707394
|
|
|
- saveUserInfoByProjectClient.saveInfoRelation(newUser.getId(), 1612329251049537537L, 1613022750656921601L, 1537249581371707394L);
|
|
|
- newUser.setRoleId("1537249581371707394");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //二监办合同段(二滩)
|
|
|
- if (companyName.contains("四川二滩国际工程咨询有限责任公司")) {
|
|
|
- Long count = jdbcTemplate.queryForObject("select count(1) from m_project_assignment_user where user_id = " + newUser.getId() + " and project_id = 1612329251049537537 and contract_id = 1687370619295309826 and post_id is null and status = 1 and is_deleted = 0", Long.class);
|
|
|
- if (count == null || count == 0L) {
|
|
|
- //绑定项目,设置默认角色信息 白马项目id:1612329251049537537;二监办合同段id:1687370619295309826;角色施工-资料员id:1537249581371707394
|
|
|
- saveUserInfoByProjectClient.saveInfoRelation(newUser.getId(), 1612329251049537537L, 1687370619295309826L, 1537249581371707394L);
|
|
|
- newUser.setRoleId("1537249581371707394");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //一监办合同段(重庆市交通工程监理咨询有限责任公司)
|
|
|
- if (companyName.contains("重庆市交通工程监理咨询有限责任公司")) {
|
|
|
- Long count = jdbcTemplate.queryForObject("select count(1) from m_project_assignment_user where user_id = " + newUser.getId() + " and project_id = 1612329251049537537 and contract_id = 1687370014959017986 and post_id is null and status = 1 and is_deleted = 0", Long.class);
|
|
|
- if (count == null || count == 0L) {
|
|
|
- //绑定项目,设置默认角色信息 白马项目id:1612329251049537537;一监办合同段id:1687370014959017986;角色施工-资料员id:1537249581371707394
|
|
|
- saveUserInfoByProjectClient.saveInfoRelation(newUser.getId(), 1612329251049537537L, 1687370014959017986L, 1537249581371707394L);
|
|
|
- newUser.setRoleId("1537249581371707394");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /*修改需求前*/
|
|
|
- /*Long count = jdbcTemplate.queryForObject("select count(1) from m_project_assignment_user where user_id = " + newUser.getId() + " and project_id = 1612329251049537537 and contract_id = 1612335077269143554 and post_id is null and status = 1 and is_deleted = 0", Long.class);
|
|
|
- if (count == null || count == 0L) {
|
|
|
- //绑定项目,设置默认角色信息 白马项目id:1612329251049537537;第二期合同段id:1612335077269143554;角色施工-资料员id:1537249581371707394
|
|
|
- saveUserInfoByProjectClient.saveInfoRelation(newUser.getId(), 1612329251049537537L, 1612335077269143554L, 1537249581371707394L);
|
|
|
- newUser.setRoleId("1537249581371707394"); //角色施工-资料员id:1537249581371707394
|
|
|
- }*/
|
|
|
-
|
|
|
- //userService.saveOrUpdate(newUser);
|
|
|
-
|
|
|
- /*2023年10月13日14:05:51 改为save新增,而不是像以前一样用saveOrUpdate*/
|
|
|
- userService.save(newUser);
|
|
|
- userService.submitUserDept(newUser);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+ public R getLoginInfo( String Authorization, User userInfo) {
|
|
|
+ String tenId = userInfo.getTenantId();
|
|
|
+ String account = userInfo.getAccount();
|
|
|
+ String pass = userInfo.getPlaintextPassword();
|
|
|
+ String md5Pass = MD5Utils.md5Hex(pass, "UTF-8");
|
|
|
+ System.out.println("密码" + md5Pass);
|
|
|
+
|
|
|
+ HttpClient httpClient = HttpClientBuilder.create().build();
|
|
|
+ HttpPost httpPost = new HttpPost("http://172.30.224.81:8090/blade-auth/oauth/token");
|
|
|
+ httpPost.setHeader("Authorization", Authorization);
|
|
|
+ httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
|
+ httpPost.setHeader("Tenant-Id", tenId);
|
|
|
+ List<NameValuePair> params = new ArrayList<NameValuePair>();
|
|
|
+ params.add(new BasicNameValuePair("grant_type", "password"));
|
|
|
+ params.add(new BasicNameValuePair("username", account));
|
|
|
+ params.add(new BasicNameValuePair("password", md5Pass));
|
|
|
+ params.add(new BasicNameValuePair("scope", "all"));
|
|
|
+ params.add(new BasicNameValuePair("tenantId", tenId));
|
|
|
+ params.add(new BasicNameValuePair("type", "account"));
|
|
|
+ httpPost.setEntity(new UrlEncodedFormEntity(params, Consts.UTF_8));
|
|
|
+ try {
|
|
|
+ HttpResponse httpResponse = httpClient.execute(httpPost);
|
|
|
+ InputStream inputStream = httpResponse.getEntity().getContent();
|
|
|
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
|
+ byte[] buffer = new byte[1024];
|
|
|
+ int index = 0;
|
|
|
+ while ((index = inputStream.read(buffer)) != -1) {
|
|
|
+ outputStream.write(buffer, 0, index);
|
|
|
}
|
|
|
+ System.out.println("\n");
|
|
|
+ return R.data(JSON.parseObject(outputStream.toString()));
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
+ return R.fail("获取token失败");
|
|
|
}
|
|
|
+
|
|
|
}
|