修改

parent 5a5ab2e2
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
<dependency> <dependency>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-client</artifactId> <artifactId>apollo-client</artifactId>
<version>0.10.0</version> <version>0.9.2</version>
</dependency> </dependency>
<!--<dependency>--> <!--<dependency>-->
<!--<groupId>cn.quantgroup</groupId>--> <!--<groupId>cn.quantgroup</groupId>-->
...@@ -337,13 +337,6 @@ ...@@ -337,13 +337,6 @@
<properties> <properties>
<profiles.activation>product</profiles.activation> <profiles.activation>product</profiles.activation>
</properties> </properties>
<dependencies>
<dependency>
<groupId>cn.quantgroup</groupId>
<artifactId>quantgroup-sms-sdk</artifactId>
<version>3.0</version>
</dependency>
</dependencies>
<build> <build>
<resources> <resources>
<resource> <resource>
...@@ -359,8 +352,6 @@ ...@@ -359,8 +352,6 @@
<properties> <properties>
<profiles.activation>dev</profiles.activation> <profiles.activation>dev</profiles.activation>
</properties> </properties>
<dependencies>
</dependencies>
<build> <build>
<resources> <resources>
<resource> <resource>
...@@ -375,6 +366,13 @@ ...@@ -375,6 +366,13 @@
<id>test</id> <id>test</id>
<properties> <properties>
<profiles.activation>test</profiles.activation> <profiles.activation>test</profiles.activation>
<dependencies>
<dependency>
<groupId>cn.quantgroup</groupId>
<artifactId>quantgroup-sms-sdk</artifactId>
<version>2.0.0.3-SNAPSHOT</version>
</dependency>
</dependencies>
</properties> </properties>
<build> <build>
<resources> <resources>
......
package cn.quantgroup.xyqb; package cn.quantgroup.xyqb;
import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig; import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
import com.ctrip.framework.apollo.spring.config.ApolloPropertySourceInitializer;
import com.weibo.api.motan.common.MotanConstants; import com.weibo.api.motan.common.MotanConstants;
import com.weibo.api.motan.util.MotanSwitcherUtil; import com.weibo.api.motan.util.MotanSwitcherUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -22,7 +21,7 @@ import org.springframework.scheduling.annotation.EnableAsync; ...@@ -22,7 +21,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
@EnableAutoConfiguration @EnableAutoConfiguration
@SpringBootApplication @SpringBootApplication
@EnableCaching @EnableCaching
//@EnableApolloConfig({"application", "tech.msg.sdk", "cash.common"}) @EnableApolloConfig({"application", "tech.msg.sdk", "cash.common"})
@PropertySource(value = {"classpath:application.properties", "classpath:xyqb.properties"}, ignoreResourceNotFound = true) @PropertySource(value = {"classpath:application.properties", "classpath:xyqb.properties"}, ignoreResourceNotFound = true)
@Configuration @Configuration
@EnableAspectJAutoProxy @EnableAspectJAutoProxy
...@@ -32,7 +31,7 @@ public class Bootstrap { ...@@ -32,7 +31,7 @@ public class Bootstrap {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(Bootstrap.class); SpringApplication springApplication = new SpringApplication(Bootstrap.class);
springApplication.addInitializers(new ApolloPropertySourceInitializer("application", "tech.msg.sdk", "cash.common")); //springApplication.addInitializers(new ApolloPropertySourceInitializer("application", "tech.msg.sdk", "cash.common"));
springApplication.addListeners(new ApplicationListener<ContextRefreshedEvent>() { springApplication.addListeners(new ApplicationListener<ContextRefreshedEvent>() {
@Override @Override
......
...@@ -4,13 +4,23 @@ import cn.quantgroup.xyqb.Bootstrap; ...@@ -4,13 +4,23 @@ import cn.quantgroup.xyqb.Bootstrap;
import cn.quantgroup.xyqb.Constants; import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.controller.external.user.InnerController; import cn.quantgroup.xyqb.controller.external.user.InnerController;
import cn.quantgroup.xyqb.controller.internal.user.UserController; import cn.quantgroup.xyqb.controller.internal.user.UserController;
import cn.quantgroup.xyqb.model.AuthBean;
import cn.quantgroup.xyqb.model.JsonResult; import cn.quantgroup.xyqb.model.JsonResult;
import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig; import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
import com.ctrip.framework.apollo.spring.config.ApolloPropertySourceInitializer;
import com.weibo.api.motan.common.MotanConstants; import com.weibo.api.motan.common.MotanConstants;
import com.weibo.api.motan.util.MotanSwitcherUtil; import com.weibo.api.motan.util.MotanSwitcherUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -23,6 +33,11 @@ import org.springframework.mock.web.MockHttpServletRequest; ...@@ -23,6 +33,11 @@ import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.context.web.WebAppConfiguration;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/** /**
* Created by 11 on 2017/1/3. * Created by 11 on 2017/1/3.
*/ */
...@@ -31,7 +46,7 @@ import org.springframework.test.context.web.WebAppConfiguration; ...@@ -31,7 +46,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
@Slf4j @Slf4j
public class TestUserLogin { public class TestUserLogin {
private MockHttpServletRequest request; private MockHttpServletRequest request = new MockHttpServletRequest();;
@Autowired @Autowired
private UserController userController; private UserController userController;
...@@ -48,33 +63,38 @@ public class TestUserLogin { ...@@ -48,33 +63,38 @@ public class TestUserLogin {
} }
@Test @Test
public void testJson() { public void testJson() {
SpringApplication springApplication = new SpringApplication(Bootstrap.class);
JsonResult addressByUserId = innerController.findAddressByUserId(22L); JsonResult addressByUserId = innerController.findAddressByUserId(22L);
// JsonResult userByUserId = innerController.findUserByPhoneNo("17811111122"); // JsonResult userByUserId = innerController.findUserByPhoneNo("17811111122");
System.out.println("-------------result:"+addressByUserId); System.out.println("-------------result:"+addressByUserId);
} }
/**
* 用户密码登陆接口
*/
@Test @Test
public void testUserLogin() { public void testUserLogin() {
Long code = 1L; Long code = 1L;
String format = String.format(Constants.ZERO_FILL_TEMPLATE, code); String format = String.format(Constants.ZERO_FILL_TEMPLATE, code);
System.out.println("-----------format:"+format); System.out.println("-----------format:"+format);
//访问xyqb-user拿到登录token //访问xyqb-user拿到登录token
/*Long channelId = 1L; Long channelId = 1L;
String appChannel = "3"; String appChannel = "3";
Long createFrom = 152L; Long createFrom = 152L;
//String userId = "8c02a7b8-815f-4ba0-b39c-a9e6e52904de"; //String userId = "8c02a7b8-815f-4ba0-b39c-a9e6e52904de";
//测试userId为空的情况 //测试userId为空的情况
String userId = ""; String userId = "";
request.addHeader("authorization", "Basic "); request.addHeader("x-original-client-ip", "172.16.0.1");
JsonResult jsonResult = userController.login(channelId, appChannel, createFrom, userId, request); request.addHeader("authorization", "Basic MTg1MTMzNDE4MDg6MTIzNDU2");
JsonResult jsonResult = userController.login(channelId, appChannel, createFrom, userId,"xyqb", request,"xyqb","aaa");
AuthBean authBean = (AuthBean) jsonResult.getData(); AuthBean authBean = (AuthBean) jsonResult.getData();
String token = authBean.getToken(); String token = authBean.getToken();
System.out.println("user token:" + token); System.out.println("user token:" + token);
//用获取到的token请求xyqb的receive_token //用获取到的token请求xyqb的receive_token
CloseableHttpClient httpClient = HttpClient.httpClient();
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost post = new HttpPost("http://localhost:9004/ex/login/receive_token"); HttpPost post = new HttpPost("http://localhost:9004/ex/login/receive_token");
List<NameValuePair> pairList = new ArrayList<>(); List<NameValuePair> pairList = new ArrayList<>();
pairList.add(new BasicNameValuePair("token", token)); pairList.add(new BasicNameValuePair("token", token));
HttpEntity entity = null; HttpEntity entity = null;
...@@ -90,7 +110,7 @@ public class TestUserLogin { ...@@ -90,7 +110,7 @@ public class TestUserLogin {
result = EntityUtils.toString(response.getEntity()); result = EntityUtils.toString(response.getEntity());
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}*/ }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment