Commit 717a229b 717a229be4a933beca59a1c133c13dcf5c556812 by 文鑫

init

0 parents
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.topdraw</groupId>
<artifactId>docking-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>docking-api</name>
<description>docking-api</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.6.13</spring-boot.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--愉快办对接-->
<dependency>
<groupId>com.ykb</groupId>
<artifactId>sdk</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>com.topdraw.dockingapi.DockingApiApplication</mainClass>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
package com.topdraw.dockingapi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@Slf4j
public class DockingApiApplication {
public static void main(String[] args) {
SpringApplication application = new SpringApplication(DockingApiApplication.class);
application.run(args);
}
}
package com.topdraw.dockingapi.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.stereotype.Component;
/**
* @author wenxin
* @version 1.0
* @date 2024/5/10 上午9:23
*/
@Component
@Slf4j
public class ApplicationStartedListener implements ApplicationListener<ApplicationStartedEvent> {
@Override
public void onApplicationEvent(ApplicationStartedEvent event) {
ConfigurableApplicationContext context = event.getApplicationContext();
ConfigurableEnvironment environment = context.getEnvironment();
ServerProperties bean = context.getBean(ServerProperties.class);
Integer port = bean.getPort();
String activeProfile = environment.getActiveProfiles()[0]; // 获取第一个激活的环境
log.info("启动环境:{},端口号:{}", activeProfile, port);
}
}
package com.topdraw.dockingapi.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @author wenxin
* @version 1.0
* @date 2024/5/9 下午5:57
*/
@ConfigurationProperties(prefix = "interface.config")
@Configuration
@Data
public class EnvConfiguration {
private String appId;
private String appIv;
private String appKey;
private String appSecret;
private String url;
}
package com.topdraw.dockingapi.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.digital.szzz.gateway.sdk.api.GatewaySender;
import com.digital.szzz.gateway.sdk.bean.GatewayResponse;
import com.topdraw.dockingapi.config.EnvConfiguration;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
/**
* 对接愉快办接口
* @author wenxin
* @version 1.0
* @date 2024/5/9 下午5:46
*/
@RestController
@Slf4j
@RequestMapping("/api")
@RequiredArgsConstructor
public class ApiController {
private final EnvConfiguration configuration;
String url;
String appId;
String iv;
String appKey;
String appSecretKey;
String authCode;
int readTimeout = 1000;
int connTimeout = 1000;
@PostConstruct
public void init() {
url = configuration.getUrl();
appId = configuration.getAppId();
iv = configuration.getAppIv();
appKey = configuration.getAppKey();
appSecretKey = configuration.getAppSecret();
authCode = "";
}
/**
* 获取jsToken
* @return token信息
*/
@GetMapping("/js/token")
public GatewayResponse getJsApiToken() {
String method = "ykb.app.jsapi.getToken";
JSONObject param = new JSONObject();
param.put("appId", appId);
Map<String, String> headerMap = new HashMap<>();
return GatewaySender.send(url, appId, method, iv, appKey, appSecretKey, param, authCode, headerMap, readTimeout, connTimeout);
}
/**
* 获取authCode
* @param userId 用户id
* @return authCode信息
*/
@GetMapping("/auth/code")
public GatewayResponse getAuthCodeByUserId(String userId) {
String method = "app.ykb.uc.oauth.get";
JSONObject param = new JSONObject();
param.put("appId", appId);
param.put("userId", userId);
param.put("forceScopes", new JSONArray().fluentAdd("ykb_user_info").fluentAdd("ykb_divide"));
Map<String, String> headerMap = new HashMap<>();
return GatewaySender.send(url, appId, method, iv, appKey, appSecretKey, param, authCode, headerMap, readTimeout, connTimeout);
}
/**
* 获取用户脱敏信息
* @param authCode 认证code
* @return 用户信息
*/
@GetMapping("/user/info")
public GatewayResponse getUserInfoByAuthCode(String authCode) {
String method = "app.ykb.uc.oauth.userInfo";
JSONObject param = new JSONObject();
param.put("authCode", authCode);
Map<String, String> headerMap = new HashMap<>();
return GatewaySender.send(url, appId, method, iv, appKey, appSecretKey, param, authCode, headerMap, readTimeout, connTimeout);
}
}
interface:
config:
appId: 9d92e7ea-2f6b-4c7c-8f70-dda6e91fc778
appIv: ynDi62eQ8WKQtZhUMUqTmQ==
appKey: y4pBvyDY8cgSNsxukn0DlQ==
appSecret: 04t5li0m
url: https://ykbapp-test.cqdcg.com:1443/gateway/open/api/do
\ No newline at end of file
interface:
config:
appId: 9d92e7ea-2f6b-4c7c-8f70-dda6e91fc778
appIv: ynDi62eQ8WKQtZhUMUqTmQ==
appKey: y4pBvyDY8cgSNsxukn0DlQ==
appSecret: 04t5li0m
url: https://ykbapp-test.cqdcg.com:1443/gateway/open/api/do
\ No newline at end of file
# 应用服务 WEB 访问端口
server.port=7078
# 指定启动的时候springboot的激活环境
spring.profiles.active=test
<html>
<body>
<h1>hello word!!!</h1>
<p>this is a html page</p>
</body>
</html>
\ No newline at end of file
package com.topdraw.dockingapi;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class DockingApiApplicationTests {
@Test
void contextLoads() {
}
}