Selaa lähdekoodia

Merge branch 'doudian' of http://git.semsx.com/zhangxiaoyu/baseJapi into doudian

 Conflicts:
	src/main/java/com/api/controller/ApiTestController.java
	src/main/resources/application-dev.yml
	src/main/resources/application.yml
zhang 2 vuotta sitten
vanhempi
commit
e9ae4d4dd9

+ 21 - 0
src/main/java/com/api/config/DoudianConfig.java

@@ -0,0 +1,21 @@
1
+package com.api.config;
2
+
3
+import com.doudian.open.api.address_list.AddressListRequest;
4
+import com.doudian.open.core.GlobalConfig;
5
+import org.springframework.beans.factory.annotation.Value;
6
+import org.springframework.context.annotation.Bean;
7
+import org.springframework.context.annotation.Configuration;
8
+import org.springframework.stereotype.Repository;
9
+
10
+import javax.annotation.PostConstruct;
11
+
12
+/**
13
+ * 抖店config
14
+ */
15
+@Configuration
16
+public class DoudianConfig {
17
+    @Bean
18
+    public AddressListRequest addressListRequest() {
19
+        return new AddressListRequest();
20
+    }
21
+}

+ 1 - 0
src/main/java/com/api/config/FilterConfig.java

@@ -9,6 +9,7 @@
9 9
 package com.api.config;
10 10
 
11 11
 import com.common.xss.XssFilter;
12
+import org.springframework.beans.factory.annotation.Value;
12 13
 import org.springframework.boot.web.servlet.FilterRegistrationBean;
13 14
 import org.springframework.context.annotation.Bean;
14 15
 import org.springframework.context.annotation.Configuration;

+ 20 - 0
src/main/java/com/api/config/InitDoudian.java

@@ -0,0 +1,20 @@
1
+package com.api.config;
2
+
3
+import com.doudian.open.core.GlobalConfig;
4
+import org.springframework.beans.factory.annotation.Value;
5
+import org.springframework.stereotype.Repository;
6
+
7
+import javax.annotation.PostConstruct;
8
+
9
+@Repository
10
+public class InitDoudian {
11
+    @Value("${doudian.app-key}")
12
+    private String appKey;
13
+    @Value("${doudian.app-secret}")
14
+    private String appSecret;
15
+    @PostConstruct
16
+    public void init() {
17
+        GlobalConfig.initAppKey(appKey);
18
+        GlobalConfig.initAppSecret(appSecret);
19
+    }
20
+}

+ 3 - 4
src/main/java/com/api/controller/ApiTestController.java

@@ -9,7 +9,7 @@
9 9
 package com.api.controller;
10 10
 
11 11
 import com.api.dao.TokenDao;
12
-import com.api.service.TokenService;
12
+import com.api.service.DoudianTokenService;
13 13
 import com.common.utils.R;
14 14
 import com.api.annotation.Login;
15 15
 import com.api.annotation.LoginUser;
@@ -48,6 +48,8 @@ public class ApiTestController extends AbsctactController {
48 48
     TokenDao tokenDao;
49 49
     @Autowired
50 50
     TokenService tokenService;
51
+    @Autowired
52
+    DoudianTokenService doudianTokenService;
51 53
     @Login
52 54
     @GetMapping("userInfo")
53 55
     @ApiOperation(value="获取用户信息", response=UserEntity.class)
@@ -65,10 +67,7 @@ public class ApiTestController extends AbsctactController {
65 67
     @GetMapping("notToken")
66 68
     @ApiOperation("忽略Token验证测试")
67 69
     public R notToken(HttpServletRequest request, HttpSession httpSession){
68
-        GlobalConfig.initAppKey("7090080248619877901");
69
-        GlobalConfig.initAppSecret("a4d9d3e6-aa69-4f0c-bffa-be4039e74262");
70 70
         Object beanNamesForType = applicationContext.getBean(TokenDao.class);
71
-        TokenCreateRequest tokenCreateRequest = new TokenCreateRequest();
72 71
         TokenDao bean = beanFactory.getBean(TokenDao.class);
73 72
         TokenDao tokenDao = (TokenDao) beanNamesForType;
74 73
 //        return R.ok().put("msg", "无需token也能访问。。。");

+ 9 - 0
src/main/java/com/api/service/DoudianTokenService.java

@@ -0,0 +1,9 @@
1
+package com.api.service;
2
+
3
+import com.doudian.open.api.address_list.AddressListResponse;
4
+import com.doudian.open.core.AccessToken;
5
+
6
+public interface DoudianTokenService {
7
+    AccessToken getShopAccessToken(Long shopId);
8
+    AddressListResponse getAddressList(Long shopId);
9
+}

+ 40 - 0
src/main/java/com/api/service/impl/DoudianTokenServiceImpl.java

@@ -0,0 +1,40 @@
1
+package com.api.service.impl;
2
+
3
+import com.api.service.DoudianTokenService;
4
+import com.doudian.open.api.address_list.AddressListRequest;
5
+import com.doudian.open.api.address_list.AddressListResponse;
6
+import com.doudian.open.api.address_list.param.AddressListParam;
7
+import com.doudian.open.core.AccessToken;
8
+import com.doudian.open.core.AccessTokenBuilder;
9
+import org.springframework.beans.factory.annotation.Autowired;
10
+import org.springframework.stereotype.Service;
11
+
12
+import javax.annotation.PostConstruct;
13
+
14
+@Service
15
+public class DoudianTokenServiceImpl implements DoudianTokenService {
16
+    @Autowired
17
+    AddressListRequest addressListRequest;
18
+    private AccessToken accessToken;
19
+    // zxy测试预填入Token
20
+    @PostConstruct
21
+    public void initToken() {
22
+        accessToken = AccessTokenBuilder.refresh("3ce5a5db-bd29-471b-b7c1-1b277a760dbe");
23
+    }
24
+    @Override
25
+    public AccessToken getShopAccessToken(Long shopId) {
26
+        accessToken= AccessTokenBuilder.build(shopId);
27
+        return null;
28
+    }
29
+    @Override
30
+    public AddressListResponse getAddressList(Long shopId) {
31
+        AddressListParam param = addressListRequest.getParam();
32
+        param.setPageNo(1L);
33
+        param.setPageSize(10L);
34
+        param.setShopId(shopId);
35
+        param.setOrderBy("desc");
36
+        param.setOrderField("create_time");
37
+        AddressListResponse execute = addressListRequest.execute(accessToken);
38
+        return null;
39
+    }
40
+}

+ 3 - 3
src/main/resources/application.yml

@@ -34,7 +34,9 @@ spring:
34 34
 renren:
35 35
   redis:
36 36
     open: false  # 是否开启redis缓存  true开启   false关闭
37
-
37
+doudian:
38
+  app-key: 7090080248619877901
39
+  app-secret : a4d9d3e6-aa69-4f0c-bffa-be4039e74262
38 40
 #mybatis
39 41
 mybatis-plus:
40 42
   mapper-locations: classpath*:/mapper/**/*.xml
@@ -58,7 +60,5 @@ mybatis-plus:
58 60
     cache-enabled: false
59 61
     call-setters-on-nulls: true
60 62
     jdbc-type-for-null: 'null'
61
-    log-impl: org.apache.ibatis.logging.log4j2.Log4j2Impl
62
-
63 63
 
64 64