Authored by mali

初始化

... ... @@ -12,93 +12,22 @@
<groupId>com.yoho.ufo</groupId>
<artifactId>ufo-platform-common</artifactId>
<packaging>jar</packaging>
<name>A Camel Route</name>
<name>ufo-platform-common</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencyManagement>
<dependencies>
<!-- Camel BOM -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-parent</artifactId>
<version>2.22.1</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>
<!-- logging -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>runtime</scope>
<groupId>com.yoho.core</groupId>
<artifactId>yoho-core-rest-client-simple</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<scope>runtime</scope>
</dependency>
<!-- testing -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test</artifactId>
<scope>test</scope>
<groupId>com.yoho.core</groupId>
<artifactId>yoho-core-rest-server</artifactId>
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- Allows the example to be run via 'mvn compile exec:java' -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<mainClass>com.yoho.ufo.MainApp</mainClass>
<includePluginDependencies>false</includePluginDependencies>
</configuration>
</plugin>
</plugins>
</build>
</project>
... ...
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);
}
... ...
... ... @@ -94,6 +94,15 @@
<dependency>
<groupId>com.yoho.core</groupId>
<artifactId>yoho-core-rest-client-simple</artifactId>
</dependency>
<dependency>
<groupId>com.yoho.core</groupId>
<artifactId>yoho-core-rest-server</artifactId>
</dependency>
<dependency>
<groupId>com.yoho.core</groupId>
<artifactId>yoho-core-cache</artifactId>
</dependency>
... ...