|
|
package com.yohobuy.ufo.login.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yohobuy.ufo.constants.PlatformConstant;
|
|
|
import com.yohobuy.ufo.login.model.MenuInfoResponseBO;
|
|
|
import com.yohobuy.ufo.login.model.Response;
|
...
|
...
|
@@ -10,6 +11,8 @@ import org.slf4j.Logger; |
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.http.HttpEntity;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
...
|
...
|
@@ -46,22 +49,25 @@ public class LoginService { |
|
|
String url = erpDomain + PlatformConstant.ERP_LOGIN_URL;
|
|
|
logger.info("enter login with loginName={}, url is {}", loginName, url);
|
|
|
|
|
|
MultiValueMap<String, String> param = new LinkedMultiValueMap<String, String>();
|
|
|
param.add("account", loginName);
|
|
|
param.add("password", password);
|
|
|
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<MultiValueMap<String, String>>(param, null);
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
|
|
|
headers.setContentType(type);
|
|
|
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
|
|
|
JSONObject jsonObj = new JSONObject();
|
|
|
jsonObj.put("account", loginName);
|
|
|
jsonObj.put("password", password);
|
|
|
HttpEntity<String> formEntity = new HttpEntity<String>(jsonObj.toString(), headers);
|
|
|
|
|
|
ResponseEntity<Response> responseResponseEntity = restTemplate.postForEntity(url, requestEntity, Response.class);
|
|
|
ResponseEntity<Object> responseResponseEntity = restTemplate.postForEntity(url, formEntity, Object.class);
|
|
|
Map<String, Object> body = (Map<String, Object>) responseResponseEntity.getBody();
|
|
|
Map<String, Object> data = (Map<String, Object>) body.get("data");
|
|
|
|
|
|
|
|
|
logger.info("login success with loginName={}, responseResponseEntity={}", loginName, responseResponseEntity);
|
|
|
UserInfoResponseBO user = new UserInfoResponseBO();
|
|
|
Response body = responseResponseEntity.getBody();
|
|
|
Object data = body.getData();
|
|
|
|
|
|
logger.info("login success with loginName={}, data={}", loginName, data);
|
|
|
|
|
|
setUser((Map<String, Object>) data, user);
|
|
|
setUser(data, user);
|
|
|
return new Response<>(user);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -69,26 +75,24 @@ public class LoginService { |
|
|
if (MapUtils.isEmpty(map)) {
|
|
|
return;
|
|
|
}
|
|
|
Map<String, Object> data = (Map<String, Object>) map.get("data");
|
|
|
Map<String, Object> auth = (Map<String, Object>) data.get("auth");
|
|
|
user.setAccount((String) auth.get("account"));
|
|
|
user.setAuth_site((String) auth.get("auth_site"));
|
|
|
user.setCreate_date((String) auth.get("create_date"));
|
|
|
user.setCreate_id(String.valueOf(auth.get("create_id")));
|
|
|
user.setCreate_time(String.valueOf(auth.get("create_time")));
|
|
|
user.setDept_id(String.valueOf(auth.get("dept_id")));
|
|
|
user.setEmail((String) auth.get("email"));
|
|
|
user.setExpires(String.valueOf(auth.get("expires")));
|
|
|
user.setIdentity(String.valueOf(auth.get("identity")));
|
|
|
user.setLogin_time(String.valueOf(auth.get("login_time")));
|
|
|
user.setLogout_time(String.valueOf(auth.get("logout_time")));
|
|
|
user.setPhone(String.valueOf(auth.get("phone")));
|
|
|
user.setPid(String.valueOf( auth.get("pid")));
|
|
|
user.setRole_id(String.valueOf(auth.get("role_id")));
|
|
|
user.setStaff_code(String.valueOf(auth.get("staff_code")));
|
|
|
user.setStatus(String.valueOf(auth.get("status")));
|
|
|
user.setSupplier_id(Integer.parseInt(auth.get("supplier_id").toString()) );
|
|
|
user.setTruename((String) auth.get("truename"));
|
|
|
user.setAccount((String) map.get("account"));
|
|
|
user.setAuth_site((String) map.get("auth_site"));
|
|
|
user.setCreate_date((String) map.get("create_date"));
|
|
|
user.setCreate_id(String.valueOf(map.get("create_id")));
|
|
|
user.setCreate_time(String.valueOf(map.get("create_time")));
|
|
|
user.setDept_id(String.valueOf(map.get("dept_id")));
|
|
|
user.setEmail((String) map.get("email"));
|
|
|
user.setExpires(String.valueOf(map.get("expires")));
|
|
|
user.setIdentity(String.valueOf(map.get("identity")));
|
|
|
user.setLogin_time(String.valueOf(map.get("login_time")));
|
|
|
user.setLogout_time(String.valueOf(map.get("logout_time")));
|
|
|
user.setPhone(String.valueOf(map.get("phone")));
|
|
|
user.setPid(String.valueOf( map.get("pid")));
|
|
|
user.setRole_id(String.valueOf(map.get("role_id")));
|
|
|
user.setStaff_code(String.valueOf(map.get("staff_code")));
|
|
|
user.setStatus(String.valueOf(map.get("status")));
|
|
|
user.setSupplier_id(Integer.parseInt(map.get("supplier_id").toString()) );
|
|
|
user.setTruename((String) map.get("truename"));
|
|
|
}
|
|
|
|
|
|
public Response<Map<String, List<MenuInfoResponseBO>>> getUserMenu(String pid, String role_id) {
|
...
|
...
|
|