-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 项目框架 * 配置依赖项 * 实现accessToken接口 * 封装AccessTokenResponse * 封装SessionResponse * 增加获取手机号的接口 * 封装UserPhoneResponse * 关闭对未知属性的抛出异常,提高兼容性
- Loading branch information
Showing
16 changed files
with
832 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Maven Verify and Deploy CI | ||
|
||
on: | ||
push: | ||
branches: | ||
paths-ignore: | ||
- '.github/workflows/release.yml' | ||
- 'README.md' | ||
|
||
jobs: | ||
maven: | ||
permissions: | ||
packages: write | ||
uses: dbstar-org/general/.github/workflows/maven.yml@v1 | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: Maven Release CI | ||
|
||
on: workflow_dispatch | ||
|
||
jobs: | ||
release: | ||
permissions: | ||
contents: write | ||
packages: write | ||
uses: dbstar-org/general/.github/workflows/maven-release.yml@v1 | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,5 @@ | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
replay_pid* | ||
*.iml | ||
target/ | ||
/.idea/ | ||
pom.xml.* | ||
/release.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.github.dbstarll.parent</groupId> | ||
<artifactId>base</artifactId> | ||
<version>1.3.0</version> | ||
</parent> | ||
<groupId>io.github.dbstarll</groupId> | ||
<artifactId>weixin-sdk</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
|
||
<name>weixin-sdk</name> | ||
<description>WeiXin SDK</description> | ||
<url>https://github.com/dbstar-org/weixin-sdk</url> | ||
|
||
<scm> | ||
<connection>scm:git:${project.git.git.root}</connection> | ||
<developerConnection>scm:git:${project.git.web.root}</developerConnection> | ||
<url>${project.git.web.master}</url> | ||
<tag>HEAD</tag> | ||
</scm> | ||
|
||
<properties> | ||
<project.git.project>weixin-sdk</project.git.project> | ||
<!-- module version --> | ||
<version.utils-net-api>1.1.0</version.utils-net-api> | ||
<version.utils-json>1.1.0</version.utils-json> | ||
<version.jackson>2.15.0</version.jackson> | ||
<version.logback>1.3.7</version.logback> | ||
</properties> | ||
|
||
<dependencies> | ||
<!-- commons utils --> | ||
<dependency> | ||
<groupId>io.github.dbstarll.utils</groupId> | ||
<artifactId>utils-net-api</artifactId> | ||
<version>${version.utils-net-api}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.github.dbstarll.utils</groupId> | ||
<artifactId>utils-json</artifactId> | ||
<version>${version.utils-json}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<version>${version.jackson}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<version>${version.logback}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<profiles> | ||
<profile> | ||
<id>site-local</id> | ||
<distributionManagement> | ||
<site> | ||
<id>local</id> | ||
<url>${project.site.root.project}</url> | ||
</site> | ||
</distributionManagement> | ||
</profile> | ||
</profiles> | ||
</project> |
43 changes: 43 additions & 0 deletions
43
src/main/java/io/github/dbstarll/weixin/sdk/AccessTokenResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.github.dbstarll.weixin.sdk; | ||
|
||
import java.io.Serializable; | ||
import java.util.StringJoiner; | ||
|
||
public final class AccessTokenResponse implements Serializable { | ||
private String accessToken; | ||
private int expiresIn; | ||
|
||
/** | ||
* 获得获取到的凭证. | ||
* | ||
* @return 获取到的凭证 | ||
*/ | ||
public String getAccessToken() { | ||
return accessToken; | ||
} | ||
|
||
void setAccessToken(final String accessToken) { | ||
this.accessToken = accessToken; | ||
} | ||
|
||
/** | ||
* 获得凭证有效时间,单位:秒. | ||
* | ||
* @return 凭证有效时间 | ||
*/ | ||
public int getExpiresIn() { | ||
return expiresIn; | ||
} | ||
|
||
void setExpiresIn(final int expiresIn) { | ||
this.expiresIn = expiresIn; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new StringJoiner(", ", AccessTokenResponse.class.getSimpleName() + "[", "]") | ||
.add("expiresIn=" + getExpiresIn()) | ||
.add("accessToken='" + getAccessToken() + "'") | ||
.toString(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/io/github/dbstarll/weixin/sdk/CodeRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.github.dbstarll.weixin.sdk; | ||
|
||
import java.io.Serializable; | ||
|
||
final class CodeRequest implements Serializable { | ||
private final String code; | ||
|
||
CodeRequest(final String code) { | ||
this.code = code; | ||
} | ||
|
||
public String getCode() { | ||
return code; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/io/github/dbstarll/weixin/sdk/SecretHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.github.dbstarll.weixin.sdk; | ||
|
||
public interface SecretHolder { | ||
/** | ||
* 根据AppId获得Secret. | ||
* | ||
* @param appId appId | ||
* @return appId对应的secret | ||
*/ | ||
String getSecret(String appId); | ||
} |
61 changes: 61 additions & 0 deletions
61
src/main/java/io/github/dbstarll/weixin/sdk/SessionResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package io.github.dbstarll.weixin.sdk; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
|
||
import java.io.Serializable; | ||
import java.util.StringJoiner; | ||
|
||
@JsonIgnoreProperties({"errcode", "errmsg"}) | ||
public final class SessionResponse implements Serializable { | ||
private String sessionKey; | ||
private String unionid; | ||
private String openid; | ||
|
||
/** | ||
* 获得会话密钥. | ||
* | ||
* @return 会话密钥 | ||
*/ | ||
public String getSessionKey() { | ||
return sessionKey; | ||
} | ||
|
||
void setSessionKey(final String sessionKey) { | ||
this.sessionKey = sessionKey; | ||
} | ||
|
||
/** | ||
* 获得用户在开放平台的唯一标识符,若当前小程序已绑定到微信开放平台帐号下会返回. | ||
* | ||
* @return 用户在开放平台的唯一标识符 | ||
*/ | ||
public String getUnionid() { | ||
return unionid; | ||
} | ||
|
||
void setUnionid(final String unionid) { | ||
this.unionid = unionid; | ||
} | ||
|
||
/** | ||
* 获得用户唯一标识. | ||
* | ||
* @return 用户唯一标识 | ||
*/ | ||
public String getOpenid() { | ||
return openid; | ||
} | ||
|
||
void setOpenid(final String openid) { | ||
this.openid = openid; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new StringJoiner(", ", SessionResponse.class.getSimpleName() + "[", "]") | ||
.add("openid='" + getOpenid() + "'") | ||
.add("sessionKey='" + getSessionKey() + "'") | ||
.add("unionid='" + getUnionid() + "'") | ||
.toString(); | ||
} | ||
} |
Oops, something went wrong.