|
@@ -17,22 +17,16 @@
|
|
package org.springblade.system.user.controller;
|
|
package org.springblade.system.user.controller;
|
|
|
|
|
|
|
|
|
|
-import cn.hutool.jwt.JWT;
|
|
|
|
-import cn.hutool.jwt.JWTUtil;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.nacos.common.utils.MD5Utils;
|
|
import com.alibaba.nacos.common.utils.MD5Utils;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
-import feign.Request;
|
|
|
|
-import io.jsonwebtoken.Claims;
|
|
|
|
import io.swagger.annotations.*;
|
|
import io.swagger.annotations.*;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
import org.apache.http.Consts;
|
|
import org.apache.http.Consts;
|
|
-import org.apache.http.HttpRequest;
|
|
|
|
import org.apache.http.HttpResponse;
|
|
import org.apache.http.HttpResponse;
|
|
import org.apache.http.NameValuePair;
|
|
import org.apache.http.NameValuePair;
|
|
import org.apache.http.client.HttpClient;
|
|
import org.apache.http.client.HttpClient;
|
|
@@ -43,7 +37,6 @@ import org.apache.http.impl.client.HttpClientBuilder;
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
import org.springblade.common.cache.CacheNames;
|
|
import org.springblade.common.cache.CacheNames;
|
|
import org.springblade.common.constant.CommonConstant;
|
|
import org.springblade.common.constant.CommonConstant;
|
|
-import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
|
import org.springblade.core.cache.utils.CacheUtil;
|
|
import org.springblade.core.cache.utils.CacheUtil;
|
|
import org.springblade.core.excel.util.ExcelUtil;
|
|
import org.springblade.core.excel.util.ExcelUtil;
|
|
import org.springblade.core.mp.support.Condition;
|
|
import org.springblade.core.mp.support.Condition;
|
|
@@ -58,26 +51,21 @@ import org.springblade.core.tool.constant.BladeConstant;
|
|
import org.springblade.core.tool.constant.RoleConstant;
|
|
import org.springblade.core.tool.constant.RoleConstant;
|
|
import org.springblade.core.tool.utils.*;
|
|
import org.springblade.core.tool.utils.*;
|
|
import org.springblade.manager.dto.SaveUserInfoByProjectDTO;
|
|
import org.springblade.manager.dto.SaveUserInfoByProjectDTO;
|
|
-import org.springblade.manager.entity.ContractInfo;
|
|
|
|
-import org.springblade.manager.entity.TextdictInfo;
|
|
|
|
-import org.springblade.manager.entity.WbsTreeContract;
|
|
|
|
-import org.springblade.manager.entity.WbsTreePrivate;
|
|
|
|
import org.springblade.manager.feign.SaveUserInfoByProjectClient;
|
|
import org.springblade.manager.feign.SaveUserInfoByProjectClient;
|
|
import org.springblade.system.cache.ParamCache;
|
|
import org.springblade.system.cache.ParamCache;
|
|
|
|
+import org.springblade.system.user.bean.CyGetToken;
|
|
|
|
+import org.springblade.system.user.bean.ResultCYData;
|
|
|
|
+import org.springblade.system.user.bean.ResultCYKey;
|
|
import org.springblade.system.user.dto.UserDTO;
|
|
import org.springblade.system.user.dto.UserDTO;
|
|
import org.springblade.system.user.entity.User;
|
|
import org.springblade.system.user.entity.User;
|
|
import org.springblade.system.user.excel.UserExcel;
|
|
import org.springblade.system.user.excel.UserExcel;
|
|
import org.springblade.system.user.excel.UserExcel2;
|
|
import org.springblade.system.user.excel.UserExcel2;
|
|
import org.springblade.system.user.excel.UserImporter;
|
|
import org.springblade.system.user.excel.UserImporter;
|
|
import org.springblade.system.user.service.IUserService;
|
|
import org.springblade.system.user.service.IUserService;
|
|
-import org.springblade.system.user.util.AesInfoUtil;
|
|
|
|
-import org.springblade.system.user.vo.DeptUserVO;
|
|
|
|
|
|
+import org.springblade.system.user.util.RsaUtils;
|
|
import org.springblade.system.user.vo.UserVO;
|
|
import org.springblade.system.user.vo.UserVO;
|
|
import org.springblade.system.user.wrapper.UserWrapper;
|
|
import org.springblade.system.user.wrapper.UserWrapper;
|
|
-import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
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.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import springfox.documentation.annotations.ApiIgnore;
|
|
import springfox.documentation.annotations.ApiIgnore;
|
|
@@ -88,9 +76,6 @@ import javax.validation.Valid;
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
|
-import java.net.URLDecoder;
|
|
|
|
-import java.text.ParseException;
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
import static org.springblade.core.cache.constant.CacheConstant.USER_CACHE;
|
|
import static org.springblade.core.cache.constant.CacheConstant.USER_CACHE;
|
|
@@ -586,7 +571,7 @@ public class UserController {
|
|
System.out.println("密码" + md5Pass);
|
|
System.out.println("密码" + md5Pass);
|
|
|
|
|
|
HttpClient httpClient = HttpClientBuilder.create().build();
|
|
HttpClient httpClient = HttpClientBuilder.create().build();
|
|
- String url = "http://user.hcxxy.com:8090/blade-auth/oauth/token";
|
|
|
|
|
|
+ String url = "http://localhost:8090/blade-auth/oauth/token";
|
|
String sys_isonline = ParamCache.getValue(CommonConstant.SYS_ISONLINE);
|
|
String sys_isonline = ParamCache.getValue(CommonConstant.SYS_ISONLINE);
|
|
if("20".equals(sys_isonline)){
|
|
if("20".equals(sys_isonline)){
|
|
url = "http://152.168.2.11:8090/blade-auth/oauth/token";
|
|
url = "http://152.168.2.11:8090/blade-auth/oauth/token";
|
|
@@ -620,4 +605,147 @@ public class UserController {
|
|
return R.fail("获取token失败");
|
|
return R.fail("获取token失败");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 成渝第三方登录接口 获取私钥
|
|
|
|
+ */
|
|
|
|
+ /**
|
|
|
|
+ * 获取公钥key
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/getPk")
|
|
|
|
+ public ResultCYKey getPublicKey(String appKey){
|
|
|
|
+ //后管配置appKey
|
|
|
|
+ String localAppKey = jdbcTemplate.queryForObject("select * from blade_param where param_key = 'appKey' and is_deleted = 0 order by create_time DESC limit 1", String.class);
|
|
|
|
+ if(StringUtil.isBlank(localAppKey)){
|
|
|
|
+ return ResultCYKey.fail("第三方系统为配置appKey");
|
|
|
|
+ }
|
|
|
|
+ //判断appKey是否为指定值
|
|
|
|
+ if(StringUtil.isNotBlank(localAppKey) && StringUtil.equals(localAppKey, appKey)){
|
|
|
|
+ String uuid = UUID.randomUUID().toString().trim().replaceAll("-", "");
|
|
|
|
+ //生成rsa公钥私钥
|
|
|
|
+ Map<String, String> keyPair = RsaUtils.createKeyPair();
|
|
|
|
+ bladeRedis.setEx("cy_public_key:"+uuid, keyPair, 300L);
|
|
|
|
+ return ResultCYKey.success(uuid,keyPair.get("pk"));
|
|
|
|
+ }
|
|
|
|
+ return ResultCYKey.fail("appKey未知");
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 成渝 获取质检 token
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/getQualityTestingToken")
|
|
|
|
+ public ResultCYData getQualityTestingToken(@RequestBody CyGetToken cyGetToken, HttpServletRequest request){
|
|
|
|
+ if(cyGetToken == null){
|
|
|
|
+ return ResultCYData.fail("参数不能为空");
|
|
|
|
+ }
|
|
|
|
+ if(StringUtil.isBlank(cyGetToken.getUuid())){
|
|
|
|
+ return ResultCYData.fail("随机字符不能为空");
|
|
|
|
+ }
|
|
|
|
+ if(StringUtil.isBlank(cyGetToken.getIdcard())){
|
|
|
|
+ return ResultCYData.fail("身份证号码(密文)不能为空");
|
|
|
|
+ }
|
|
|
|
+ if(StringUtil.isBlank(cyGetToken.getMobile())){
|
|
|
|
+ return ResultCYData.fail("手机号码(密文)不能为空");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String, String> keyPair = bladeRedis.get("cy_public_key:" + cyGetToken.getUuid());
|
|
|
|
+ if(keyPair == null){
|
|
|
|
+ return ResultCYData.fail("uuid 未知/已过期");
|
|
|
|
+ }
|
|
|
|
+ //私钥
|
|
|
|
+ String sk = keyPair.get("sk");
|
|
|
|
+
|
|
|
|
+ //手机号
|
|
|
|
+ String mobile = RsaUtils.decryptWithSk(cyGetToken.getMobile(), sk);
|
|
|
|
+
|
|
|
|
+ //掉用获取token接口
|
|
|
|
+ R r = loginByToken3(mobile, 1, request);
|
|
|
|
+ if(r.isSuccess()){
|
|
|
|
+ return ResultCYData.data(r.getData());
|
|
|
|
+ } else {
|
|
|
|
+ if(r.getMsg().equals("用户名或密码错误")){
|
|
|
|
+ return ResultCYData.fail(451,"用户不存在");
|
|
|
|
+ }
|
|
|
|
+ return ResultCYData.fail(r.getMsg());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 成渝 获取档案 token
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/getArchiveToken")
|
|
|
|
+ public ResultCYData getArchiveToken(@RequestBody CyGetToken cyGetToken, HttpServletRequest request){
|
|
|
|
+ if(cyGetToken == null){
|
|
|
|
+ return ResultCYData.fail("参数不能为空");
|
|
|
|
+ }
|
|
|
|
+ if(StringUtil.isBlank(cyGetToken.getUuid())){
|
|
|
|
+ return ResultCYData.fail("随机字符不能为空");
|
|
|
|
+ }
|
|
|
|
+ if(StringUtil.isBlank(cyGetToken.getMobile())){
|
|
|
|
+ return ResultCYData.fail("手机号码(密文)不能为空");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String, String> keyPair = bladeRedis.get("cy_public_key:" + cyGetToken.getUuid());
|
|
|
|
+ if(keyPair == null){
|
|
|
|
+ return ResultCYData.fail("uuid 未知/已过期");
|
|
|
|
+ }
|
|
|
|
+ //私钥
|
|
|
|
+ String sk = keyPair.get("sk");
|
|
|
|
+
|
|
|
|
+ //手机号
|
|
|
|
+ String mobile = RsaUtils.decryptWithSk(cyGetToken.getMobile(), sk);
|
|
|
|
+
|
|
|
|
+ //掉用获取token接口
|
|
|
|
+ R r = loginByToken3(mobile, 3, request);
|
|
|
|
+ if(r.isSuccess()){
|
|
|
|
+ return ResultCYData.data(r.getData());
|
|
|
|
+ } else {
|
|
|
|
+ if(r.getMsg().equals("用户名或密码错误")){
|
|
|
|
+ return ResultCYData.fail(451,"用户不存在");
|
|
|
|
+ }
|
|
|
|
+ return ResultCYData.fail(r.getMsg());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 成渝获取token接口
|
|
|
|
+ * @param account
|
|
|
|
+ * @param userType 1-质检,3-档案
|
|
|
|
+ * @param request
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public R loginByToken3(String account, Integer userType, HttpServletRequest request) {
|
|
|
|
+ if(account==null || Func.isNull(account) || Func.isEmpty(account)){
|
|
|
|
+ return R.fail("account值不能为空");
|
|
|
|
+ }
|
|
|
|
+ QueryWrapper<User> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("account", account);
|
|
|
|
+ queryWrapper.eq("sys_type", 2);
|
|
|
|
+ User userInfo = userService.getOne(queryWrapper);
|
|
|
|
+ if (userInfo == null) {
|
|
|
|
+ return R.fail("用户名或密码错误");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String Authorization = request.getHeader("Authorization");
|
|
|
|
+
|
|
|
|
+ if (Authorization == null || StringUtil.isEmpty(Authorization)) {
|
|
|
|
+ String dataInfo = "";
|
|
|
|
+ if(userType == 1){ //质量/试验平台
|
|
|
|
+ dataInfo ="client:client_secret";
|
|
|
|
+ }else if(userType == 3){ //档案平台"
|
|
|
|
+ dataInfo ="archives:archives_secret";
|
|
|
|
+ }
|
|
|
|
+ Authorization = "Basic "+Func.encodeBase64(dataInfo);
|
|
|
|
+ //Basic bWVhc3VyZTptZWFzdXJlX3NlY3JldA==
|
|
|
|
+ //Basic bWVhc3VyZTptZWFzdXJlX3NlY3JldA==
|
|
|
|
+ R loginInfo = this.getLoginInfo(Authorization, userInfo);
|
|
|
|
+ if(loginInfo.getCode()==200){
|
|
|
|
+ return loginInfo;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return this.getLoginInfo(Authorization, userInfo);
|
|
|
|
+ }
|
|
}
|
|
}
|