gongfuzhu 1 rok temu
rodzic
commit
5986c5b30b

+ 14 - 0
SpringBatchServiceServer/pom.xml

@@ -98,6 +98,20 @@
             <version>${project.version}</version>
         </dependency>
 
+
+        <dependency>
+            <groupId>com.xiaoju.open</groupId>
+            <artifactId>oil-core</artifactId>
+            <version>1.0.13</version>
+            <scope>system</scope>
+            <systemPath>${basedir}/src/main/resources/lib/oil-sdk-jar-1.0.13.jar</systemPath>
+        </dependency>
+        <dependency>
+            <groupId>com.github.microservice.components</groupId>
+            <artifactId>MongodbData</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
     </dependencies>
 
     <build>

+ 56 - 0
SpringBatchServiceServer/src/main/java/com/zswl/cloud/springBtach/server/core/api/xiaoju/XiaoJuApi.java

@@ -0,0 +1,56 @@
+package com.zswl.cloud.springBtach.server.core.api.xiaoju;
+
+import com.xiaoju.open.oil.commons.config.OilConfig;
+import com.xiaoju.open.oil.core.QueryClient;
+import com.xiaoju.open.oil.core.QueryClientFactory;
+import com.xiaoju.open.oil.interfaces.request.QueryTokenRequest;
+import com.xiaoju.open.oil.interfaces.response.QueryTokenResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.util.Base64;
+
+
+@Component
+public class XiaoJuApi {
+
+    @Autowired
+    OilConfig oilConfig;
+
+    public String queryToken(){
+
+        QueryTokenRequest queryTokenRequest = new QueryTokenRequest();
+        queryTokenRequest.setAppSecret(oilConfig.getAppSecret());
+        QueryClient queryClient = QueryClientFactory.create(oilConfig);
+        QueryTokenResponse queryTokenResponse = queryClient.api().queryToken(queryTokenRequest);
+        return queryTokenResponse.getAccessToken();
+    }
+
+    public static String encrypt(String data, String dataSecret, String dataSecretIv) {
+        try {
+            if (dataSecret == null) {
+                System.out.print("Key为空null");
+                return null;
+            } else if (dataSecret.length() != 16) {
+                System.out.print("Key长度不是16位");
+                return null;
+            } else {
+                byte[] raw = dataSecret.getBytes("UTF-8");
+                SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
+                Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
+                IvParameterSpec iv = new IvParameterSpec(dataSecretIv.getBytes());
+                cipher.init(1, skeySpec, iv);
+                byte[] encrypted = cipher.doFinal(data.getBytes());
+                String str = Base64.getEncoder().encodeToString(encrypted);
+                str = str.replaceAll("\r", "");
+                str = str.replaceAll("\n", "");
+                return str;
+            }
+        } catch (Exception var9) {
+            return null;
+        }
+    }
+}

+ 46 - 0
SpringBatchServiceServer/src/main/java/com/zswl/cloud/springBtach/server/core/api/xiaoju/XiaoJunConfig.java

@@ -0,0 +1,46 @@
+package com.zswl.cloud.springBtach.server.core.api.xiaoju;
+
+import com.xiaoju.open.oil.commons.config.OilConfig;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class XiaoJunConfig {
+
+    @Value("${xiaoju.appId}")
+    private String appid;
+
+    @Value("${xiaoju.appSecret}")
+    private String appSecret;
+
+    @Value("${xiaoju.dataSecret}")
+    private String dataSecret;
+
+    @Value("${xiaoju.dataSecretIV}")
+    private String dataSecretIV;
+
+    @Value("${xiaoju.sigSecret}")
+    private String sigSecret;
+
+    @Value("${xiaoju.serverUrl}")
+    private String serverUrl;
+
+    @Bean
+    public OilConfig config() {
+
+        OilConfig oilConfig = new OilConfig();
+        oilConfig.setAppId(appid);
+        oilConfig.setAppSecret(appSecret);
+        oilConfig.setDataSecret(dataSecret);
+        oilConfig.setDataSecretIV(dataSecretIV);
+        oilConfig.setSigSecret(sigSecret);
+        oilConfig.setServerUrl(serverUrl);
+        return oilConfig;
+
+
+    }
+
+
+
+}

+ 18 - 0
SpringBatchServiceServer/src/main/java/com/zswl/cloud/springBtach/server/core/config/MongoConfig.java

@@ -0,0 +1,18 @@
+package com.zswl.cloud.springBtach.server.core.config;
+
+
+import com.github.microservice.components.data.mongo.mongo.config.MongoConfiguration;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
+
+@Configuration
+@Import(MongoConfiguration.class)
+@EnableMongoRepositories("com.zswl.cloud.springBtach.server.core.dao")
+public class MongoConfig {
+
+
+
+
+
+}

+ 7 - 0
SpringBatchServiceServer/src/main/java/com/zswl/cloud/springBtach/server/core/dao/XiaoJuStoreDao.java

@@ -0,0 +1,7 @@
+package com.zswl.cloud.springBtach.server.core.dao;
+
+import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
+import com.zswl.cloud.springBtach.server.core.domain.XiaoJuStore;
+
+public interface XiaoJuStoreDao extends MongoDao<XiaoJuStore> {
+}

+ 38 - 0
SpringBatchServiceServer/src/main/java/com/zswl/cloud/springBtach/server/core/domain/XiaoJuStore.java

@@ -0,0 +1,38 @@
+package com.zswl.cloud.springBtach.server.core.domain;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import com.github.microservice.components.data.mongo.mongo.domain.SuperEntity;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.util.List;
+
+@Data
+@Builder
+@Document
+@AllArgsConstructor
+@NoArgsConstructor
+public class XiaoJuStore  extends SuperEntity{
+
+    private String storeId;
+    private String storeName;
+    private String address;
+    private Float lat;
+    private Float lon;
+    private String cityName;
+    private String provinceName;
+    private String brandName;
+    private String tel;
+    private String openTimeHourStart;
+    private String openTimeHourEnd;
+    private String logo;
+    private List<String> picList;
+    private List<Object> itemInfoList;
+    private String status;
+    private String invoiceManner;
+    private String marketTags;
+
+
+}

+ 12 - 5
SpringBatchServiceServer/src/main/resources/application-dev.yml

@@ -4,11 +4,10 @@ spring:
     username: root
     password: c7ix0bJv2GvyhbkRw6
     driver-class-name: com.mysql.jdbc.Driver
-  cloud:
-    consul:
-      discovery:
-        prefer-ip-address: false
-        hostname: 192.168.110.241
+  data:
+    mongodb:
+      uri: mongodb://springbatch:springbatch@192.168.110.241:30117/springbatch?replicaSet=MongoSetsShard1
+      auto-index-creation: true
   batch:
     job:
       enabled: false
@@ -47,6 +46,14 @@ dfy:
     apikey: hoteltest
     secretkey: aaaaaaaa
 
+xiaoju:
+  appId: zhongshutest
+  appSecret: mMkL/1/BVfLY8a2p8049YIXofqAwNFKACWIUzimfacs=
+  dataSecret: mMkL/1/BVfLY8a2p
+  dataSecretIV: mMkL/1/BVfLY8a2p
+  sigSecret: NFKACWIUzimfacs=
+  serverUrl: https://gw.am.xiaojukeji.com/sandbox
+#  serverUrl: https://gw.am.xiaojukeji.com/pre
 
 #logging:
 #  level:

+ 3 - 2
SpringBatchServiceServer/src/main/resources/bootstrap.yml

@@ -5,7 +5,7 @@ spring:
       matching-strategy: ant_path_matcher
   main: #允许循环引用
     allow-circular-references: true
-  # 应用名
+    allow-bean-definition-overriding: true
   application:
     name: SpringBatchService
   # 当前读取配置文件的类型
@@ -18,4 +18,5 @@ spring:
       name: ${project.artifactId},ConfigCenter
   autoconfigure:
     exclude:
-      - org.springframework.cloud.netflix.ribbon.RibbonAutoConfiguration
+      - org.springframework.cloud.netflix.ribbon.RibbonAutoConfiguration
+      - org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration

BIN
SpringBatchServiceServer/src/main/resources/lib/oil-sdk-jar-1.0.13.jar


+ 5 - 4
SpringBatchServiceServer/src/test/java/com/zswl/cloud/springBtach/server/boot/ServerApplicationTests.java

@@ -1,12 +1,10 @@
 package com.zswl.cloud.springBtach.server.boot;
 
-import cn.hutool.json.JSONObject;
-import cn.hutool.json.JSONUtil;
 import com.github.microservice.auth.client.content.ResultContent;
 import com.github.microservice.auth.client.service.EnterpriseService;
 import com.zhongshu.payment.client.model.payment.SubOrdersConfirmResponseModel;
-import com.zhongshu.payment.client.service.OrderService;
 import com.zhongshu.payment.client.service.v2.PaymentService2;
+import com.zswl.cloud.springBtach.server.core.api.xiaoju.XiaoJuApi;
 import com.zswl.cloud.springBtach.server.core.api.ypp.YppApi;
 import com.zswl.cloud.springBtach.server.core.controller.TestSpringBatch;
 import com.zswl.cloud.springBtach.server.core.service.OrderServiceImp;
@@ -34,7 +32,8 @@ public class ServerApplicationTests {
     @Autowired
     PaymentService2 paymentService2;
 
-
+    @Autowired
+    XiaoJuApi xiaoJuApi;
     @Test
     public void test1() {
         ResultContent<SubOrdersConfirmResponseModel> subOrdersConfirmResponseModelResultContent = paymentService2.subOrdersConfirm("66043b7f41096a5155e6c377", "65fe7c9174d67a7dbd842b74");
@@ -54,7 +53,9 @@ public class ServerApplicationTests {
 
     @Test
     public void test2() {
+        String s = xiaoJuApi.queryToken();
 
+        System.out.println(s);
 
 
     }