Authored by mali

初始化

... ... @@ -9,7 +9,11 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.util.List;
... ... @@ -38,16 +42,26 @@ public class LoginService {
logger.warn("login error. password is empty. with loginName={}", loginName);
return new Response<UserInfoResponseBO>(202, "密码为空");
}
logger.info("enter login with loginName={}", loginName);
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);
//restTemplate.postForEntity();
ResponseEntity<Response> responseResponseEntity = restTemplate.postForEntity(url, requestEntity, Response.class);
Response<Map<String, Object>> response = restTemplate.getForObject(url, Response.class);
logger.info("login success with loginName={}, response={}", loginName, response);
logger.info("login success with loginName={}, responseResponseEntity={}", loginName, responseResponseEntity);
UserInfoResponseBO user = new UserInfoResponseBO();
setUser(response.getData(), user);
Response body = responseResponseEntity.getBody();
Object data = body.getData();
logger.info("login success with loginName={}, data={}", loginName, data);
setUser((Map<String, Object>) data, user);
return new Response<>(user);
}
... ...