|
@@ -33,9 +33,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
-import org.springframework.http.HttpMethod;
|
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
|
|
|
+import org.springframework.http.*;
|
|
import org.springframework.ldap.core.LdapTemplate;
|
|
import org.springframework.ldap.core.LdapTemplate;
|
|
import org.springframework.ldap.filter.EqualsFilter;
|
|
import org.springframework.ldap.filter.EqualsFilter;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -241,6 +239,20 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
@Resource
|
|
@Resource
|
|
private SysDictService sysDictService;
|
|
private SysDictService sysDictService;
|
|
|
|
|
|
|
|
+
|
|
|
|
+ @Value("${supersonic.ip:localhost}")
|
|
|
|
+ private String supersonicIP;
|
|
|
|
+
|
|
|
|
+ @Value("${supersonic.port:9080}")
|
|
|
|
+ private String supersonicPort;
|
|
|
|
+
|
|
|
|
+ @Value("${supersonic.username:admin}")
|
|
|
|
+ private String supersonicUserName;
|
|
|
|
+
|
|
|
|
+ @Value("${supersonic.password:e6+jQ26AESREiBBuKM1u1A==}")
|
|
|
|
+ private String supersonicPassWord;
|
|
|
|
+
|
|
|
|
+
|
|
//登录网页端
|
|
//登录网页端
|
|
@Override
|
|
@Override
|
|
public HttpRespMsg loginAdmin(String username, String password){
|
|
public HttpRespMsg loginAdmin(String username, String password){
|
|
@@ -306,6 +318,14 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
userVO.setHasAuditDept(num>0);
|
|
userVO.setHasAuditDept(num>0);
|
|
//获取当前角色的权限菜单
|
|
//获取当前角色的权限菜单
|
|
setUserRoleMenu(userVO);
|
|
setUserRoleMenu(userVO);
|
|
|
|
+ //获取supersonicToken
|
|
|
|
+ String superSonicToken = getSuperSonicToken();
|
|
|
|
+ if(org.apache.commons.lang3.StringUtils.isBlank(superSonicToken)){
|
|
|
|
+ httpRespMsg.setError(MessageUtils.message("user.supersonicLogin"));
|
|
|
|
+ return httpRespMsg;
|
|
|
|
+ }else{
|
|
|
|
+ userVO.setSupersonicToken(superSonicToken);
|
|
|
|
+ }
|
|
httpRespMsg.data = userVO;
|
|
httpRespMsg.data = userVO;
|
|
}else {
|
|
}else {
|
|
httpRespMsg.setError(MessageUtils.message("user.pwdError"));
|
|
httpRespMsg.setError(MessageUtils.message("user.pwdError"));
|
|
@@ -314,6 +334,35 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public String getSuperSonicToken(){
|
|
|
|
+ String token = "";
|
|
|
|
+ String apiUrl = "http://"+supersonicIP+":"+supersonicPort+"/api/auth/user/login";
|
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
|
+ headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
|
+ params.put("name", supersonicUserName);
|
|
|
|
+ params.put("password", supersonicPassWord);
|
|
|
|
+ String requestBody = params.toJSONString();
|
|
|
|
+ HttpEntity<String> entity = new HttpEntity<>(requestBody, headers);
|
|
|
|
+ ResponseEntity<String> responseEntity = restTemplate.exchange(apiUrl, HttpMethod.POST, entity, String.class);
|
|
|
|
+
|
|
|
|
+ if (responseEntity.getStatusCode() == HttpStatus.OK) {
|
|
|
|
+ String responseBody = responseEntity.getBody();
|
|
|
|
+ System.out.println("Response from API: " + responseBody);
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(responseBody);
|
|
|
|
+ System.out.println("jsonObject== "+jsonObject);
|
|
|
|
+ if(jsonObject.getString("msg").equals("success") && jsonObject.getString("code").equals("200")){
|
|
|
|
+ token = jsonObject.get("data").toString();
|
|
|
|
+// System.out.println("token=== "+token);
|
|
|
|
+ }else{
|
|
|
|
+ System.out.println("请求失败");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ System.out.println("请求失败");
|
|
|
|
+ }
|
|
|
|
+ return token;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public HttpRespMsg loginAdminByThirdParty(String jobNumber, String token) {
|
|
public HttpRespMsg loginAdminByThirdParty(String jobNumber, String token) {
|
|
HttpRespMsg httpRespMsg;
|
|
HttpRespMsg httpRespMsg;
|