Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
eb80da61
Commit
eb80da61
authored
Jul 08, 2022
by
xianjun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改微信小程序接口文档
parent
53e9c498
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
82 additions
and
15 deletions
+82
-15
pom.xml
pom.xml
+2
-2
WxXcxConfig.java
...src/main/java/com/yanzuoguang/wxxcx/base/WxXcxConfig.java
+2
-2
WxXcxRequestImpl.java
...ain/java/com/yanzuoguang/wxxcx/base/WxXcxRequestImpl.java
+6
-1
WxXcxAnalysisGetDailyRetainReq.java
...x/dataanalysis/retain/WxXcxAnalysisGetDailyRetainReq.java
+3
-1
WxXcxAnalysisGetDailyRetainRequest.java
...taanalysis/retain/WxXcxAnalysisGetDailyRetainRequest.java
+5
-2
WxXcxAuthGetAccessTokenReq.java
...m/yanzuoguang/wxxcx/token/WxXcxAuthGetAccessTokenReq.java
+3
-1
WxXcxAuthGetAccessTokenRequest.java
...nzuoguang/wxxcx/token/WxXcxAuthGetAccessTokenRequest.java
+2
-1
WxXcxAuthGetAccessTokenRes.java
...m/yanzuoguang/wxxcx/token/WxXcxAuthGetAccessTokenRes.java
+3
-1
WxXcxGetPhoneNumberReq.java
...nzuoguang/wxxcx/user/getphone/WxXcxGetPhoneNumberReq.java
+3
-1
WxXcxGetPhoneNumberRequest.java
...guang/wxxcx/user/getphone/WxXcxGetPhoneNumberRequest.java
+3
-2
WxXcxGetPhoneNumberRes.java
...nzuoguang/wxxcx/user/getphone/WxXcxGetPhoneNumberRes.java
+3
-1
WxXcxAuthCode2SessionTest.java
...om/yanzuoguang/wxxcx/login/WxXcxAuthCode2SessionTest.java
+47
-0
No files found.
pom.xml
View file @
eb80da61
...
@@ -14,11 +14,11 @@
...
@@ -14,11 +14,11 @@
<module>
yzg-util-db
</module>
<module>
yzg-util-db
</module>
<module>
yzg-util-cloud
</module>
<module>
yzg-util-cloud
</module>
<module>
yzg-util-mq
</module>
<module>
yzg-util-mq
</module>
<module>
yzg-util-image
</module
>
<!-- <module>yzg-util-image</module>--
>
<!-- <module>yzg-util-image-extend</module>-->
<!-- <module>yzg-util-image-extend</module>-->
<module>
yzg-util-print
</module>
<module>
yzg-util-print
</module>
<module>
yzg-util-chinese
</module>
<module>
yzg-util-chinese
</module>
<module>
yzg-util-file
</module
>
<!-- <module>yzg-util-file</module>--
>
<module>
yzg-util-redis
</module>
<module>
yzg-util-redis
</module>
<module>
yzg-util-wxxcx
</module>
<module>
yzg-util-wxxcx
</module>
</modules>
</modules>
...
...
yzg-util-wxxcx/src/main/java/com/yanzuoguang/wxxcx/base/WxXcxConfig.java
View file @
eb80da61
...
@@ -18,13 +18,13 @@ public class WxXcxConfig {
...
@@ -18,13 +18,13 @@ public class WxXcxConfig {
private
String
baseUrl
;
private
String
baseUrl
;
/**
/**
*
公共URI
*
appid
*/
*/
@Value
(
"${yzg.wx.xcx.appid:wxd70bc341df16d0b8}"
)
@Value
(
"${yzg.wx.xcx.appid:wxd70bc341df16d0b8}"
)
private
String
appid
;
private
String
appid
;
/**
/**
*
公共URI
*
secret
*/
*/
@Value
(
"${yzg.wx.xcx.secret:a8a4bc5f1dc5cde3c9abddf107c5598e}"
)
@Value
(
"${yzg.wx.xcx.secret:a8a4bc5f1dc5cde3c9abddf107c5598e}"
)
private
String
secret
;
private
String
secret
;
...
...
yzg-util-wxxcx/src/main/java/com/yanzuoguang/wxxcx/base/WxXcxRequestImpl.java
View file @
eb80da61
package
com
.
yanzuoguang
.
wxxcx
.
base
;
package
com
.
yanzuoguang
.
wxxcx
.
base
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yanzuoguang.util.helper.HttpHelper
;
import
com.yanzuoguang.util.helper.HttpHelper
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -15,6 +18,7 @@ import java.util.Map;
...
@@ -15,6 +18,7 @@ import java.util.Map;
*/
*/
@Component
@Component
public
class
WxXcxRequestImpl
implements
WxXcxRequest
{
public
class
WxXcxRequestImpl
implements
WxXcxRequest
{
Logger
logger
=
LoggerFactory
.
getLogger
(
WxXcxRequestImpl
.
class
);
@Value
(
"${yzg.wx.xwx.charset:utf-8}"
)
@Value
(
"${yzg.wx.xwx.charset:utf-8}"
)
private
String
defaultCharSet
;
private
String
defaultCharSet
;
...
@@ -22,7 +26,8 @@ public class WxXcxRequestImpl implements WxXcxRequest {
...
@@ -22,7 +26,8 @@ public class WxXcxRequestImpl implements WxXcxRequest {
@Override
@Override
public
<
T
>
T
request
(
WxXcxRequestUrl
req
,
WxXcxResponseConvert
<
T
>
convert
)
{
public
<
T
>
T
request
(
WxXcxRequestUrl
req
,
WxXcxResponseConvert
<
T
>
convert
)
{
String
url
=
req
.
getUrl
();
String
url
=
req
.
getUrl
();
String
charSet
=
defaultCharSet
;
// String charSet = defaultCharSet;
String
charSet
=
"utf-8"
;
Map
<
String
,
String
>
header
;
Map
<
String
,
String
>
header
;
if
(
req
instanceof
WxXcxRequestHeader
)
{
if
(
req
instanceof
WxXcxRequestHeader
)
{
// 设置header信息
// 设置header信息
...
...
yzg-util-wxxcx/src/main/java/com/yanzuoguang/wxxcx/dataanalysis/retain/WxXcxAnalysisGetDailyRetainReq.java
View file @
eb80da61
package
com
.
yanzuoguang
.
wxxcx
.
dataanalysis
.
retain
;
package
com
.
yanzuoguang
.
wxxcx
.
dataanalysis
.
retain
;
import
java.io.Serializable
;
/**
/**
* 获取用户访问小程序日留存 请求
* 获取用户访问小程序日留存 请求
*
*
* @author 李贤军
* @author 李贤军
*/
*/
public
class
WxXcxAnalysisGetDailyRetainReq
{
public
class
WxXcxAnalysisGetDailyRetainReq
implements
Serializable
{
/**
/**
* 接口调用凭证
* 接口调用凭证
*/
*/
...
...
yzg-util-wxxcx/src/main/java/com/yanzuoguang/wxxcx/dataanalysis/retain/WxXcxAnalysisGetDailyRetainRequest.java
View file @
eb80da61
package
com
.
yanzuoguang
.
wxxcx
.
dataanalysis
.
retain
;
package
com
.
yanzuoguang
.
wxxcx
.
dataanalysis
.
retain
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
com.alibaba.fastjson.TypeReference
;
import
com.yanzuoguang.util.helper.HttpHelper
;
import
com.yanzuoguang.util.helper.HttpHelper
;
import
com.yanzuoguang.util.helper.JsonHelper
;
import
com.yanzuoguang.util.helper.JsonHelper
;
...
@@ -27,7 +28,9 @@ public class WxXcxAnalysisGetDailyRetainRequest implements WxXcxRequestUrl, WxXc
...
@@ -27,7 +28,9 @@ public class WxXcxAnalysisGetDailyRetainRequest implements WxXcxRequestUrl, WxXc
@Override
@Override
public
String
getUrl
()
{
public
String
getUrl
()
{
return
wxXcxConfig
.
getBaseUrl
()
+
wxXcxConfig
.
getAnalysisGetDailyRetainUrl
()
+
"?"
+
this
.
getUrlPara
();
return
"https://api.weixin.qq.com/datacube/getweanalysisappiddailyretaininfo"
+
"?"
+
this
.
getUrlPara
();
// return wxXcxConfig.getBaseUrl() + wxXcxConfig.getAnalysisGetDailyRetainUrl() + "?" + this.getUrlPara();
}
}
@Override
@Override
...
@@ -37,7 +40,7 @@ public class WxXcxAnalysisGetDailyRetainRequest implements WxXcxRequestUrl, WxXc
...
@@ -37,7 +40,7 @@ public class WxXcxAnalysisGetDailyRetainRequest implements WxXcxRequestUrl, WxXc
@Override
@Override
public
String
getPost
()
{
public
String
getPost
()
{
return
HttpHelper
.
getUrlParameter
(
req
);
return
JSONObject
.
toJSONString
(
req
);
}
}
public
WxXcxAnalysisGetDailyRetainRes
getResponse
()
{
public
WxXcxAnalysisGetDailyRetainRes
getResponse
()
{
...
...
yzg-util-wxxcx/src/main/java/com/yanzuoguang/wxxcx/token/WxXcxAuthGetAccessTokenReq.java
View file @
eb80da61
package
com
.
yanzuoguang
.
wxxcx
.
token
;
package
com
.
yanzuoguang
.
wxxcx
.
token
;
import
java.io.Serializable
;
/**
/**
* 获取小程序全局唯一后台接口调用凭据 请求
* 获取小程序全局唯一后台接口调用凭据 请求
*
*
* @author 李贤军
* @author 李贤军
*/
*/
public
class
WxXcxAuthGetAccessTokenReq
{
public
class
WxXcxAuthGetAccessTokenReq
implements
Serializable
{
/**
/**
* 填写 client_credential
* 填写 client_credential
*/
*/
...
...
yzg-util-wxxcx/src/main/java/com/yanzuoguang/wxxcx/token/WxXcxAuthGetAccessTokenRequest.java
View file @
eb80da61
...
@@ -24,7 +24,8 @@ public class WxXcxAuthGetAccessTokenRequest implements WxXcxRequestUrl, WxXcxReq
...
@@ -24,7 +24,8 @@ public class WxXcxAuthGetAccessTokenRequest implements WxXcxRequestUrl, WxXcxReq
@Override
@Override
public
String
getUrl
()
{
public
String
getUrl
()
{
return
wxXcxConfig
.
getBaseUrl
()
+
wxXcxConfig
.
getAuthGetAccessTokenUrl
()
+
"?"
+
this
.
getUrlPara
();
return
"https://api.weixin.qq.com/cgi-bin/token"
+
"?"
+
this
.
getUrlPara
();
// return wxXcxConfig.getBaseUrl() + wxXcxConfig.getAuthGetAccessTokenUrl() + "?" + this.getUrlPara();
}
}
@Override
@Override
...
...
yzg-util-wxxcx/src/main/java/com/yanzuoguang/wxxcx/token/WxXcxAuthGetAccessTokenRes.java
View file @
eb80da61
...
@@ -2,12 +2,14 @@ package com.yanzuoguang.wxxcx.token;
...
@@ -2,12 +2,14 @@ package com.yanzuoguang.wxxcx.token;
import
com.yanzuoguang.wxxcx.base.WxXcxResponseBaseError
;
import
com.yanzuoguang.wxxcx.base.WxXcxResponseBaseError
;
import
java.io.Serializable
;
/**
/**
* 获取小程序全局唯一后台接口调用凭据 响应
* 获取小程序全局唯一后台接口调用凭据 响应
*
*
* @author 李贤军
* @author 李贤军
*/
*/
public
class
WxXcxAuthGetAccessTokenRes
extends
WxXcxResponseBaseError
{
public
class
WxXcxAuthGetAccessTokenRes
extends
WxXcxResponseBaseError
implements
Serializable
{
/**
/**
* access_token
* access_token
*/
*/
...
...
yzg-util-wxxcx/src/main/java/com/yanzuoguang/wxxcx/user/getphone/WxXcxGetPhoneNumberReq.java
View file @
eb80da61
package
com
.
yanzuoguang
.
wxxcx
.
user
.
getphone
;
package
com
.
yanzuoguang
.
wxxcx
.
user
.
getphone
;
import
java.io.Serializable
;
/**
/**
* 获取手机号 请求
* 获取手机号 请求
*
*
* @author 李贤军
* @author 李贤军
*/
*/
public
class
WxXcxGetPhoneNumberReq
{
public
class
WxXcxGetPhoneNumberReq
implements
Serializable
{
/**
/**
* 接口调用凭证
* 接口调用凭证
*/
*/
...
...
yzg-util-wxxcx/src/main/java/com/yanzuoguang/wxxcx/user/getphone/WxXcxGetPhoneNumberRequest.java
View file @
eb80da61
...
@@ -26,7 +26,8 @@ public class WxXcxGetPhoneNumberRequest implements WxXcxRequestUrl, WxXcxRequest
...
@@ -26,7 +26,8 @@ public class WxXcxGetPhoneNumberRequest implements WxXcxRequestUrl, WxXcxRequest
@Override
@Override
public
String
getUrl
()
{
public
String
getUrl
()
{
return
wxXcxConfig
.
getBaseUrl
()
+
wxXcxConfig
.
getGetPhoneNumberUrl
()
+
"?"
+
this
.
getUrlPara
();
return
"https://api.weixin.qq.com/wxa/business/getuserphonenumber"
+
"?"
+
this
.
getUrlPara
();
// return wxXcxConfig.getBaseUrl() + wxXcxConfig.getGetPhoneNumberUrl() + "?" + this.getUrlPara();
}
}
@Override
@Override
...
@@ -36,7 +37,7 @@ public class WxXcxGetPhoneNumberRequest implements WxXcxRequestUrl, WxXcxRequest
...
@@ -36,7 +37,7 @@ public class WxXcxGetPhoneNumberRequest implements WxXcxRequestUrl, WxXcxRequest
@Override
@Override
public
String
getPost
()
{
public
String
getPost
()
{
return
HttpHelper
.
getUrlParameter
(
req
);
return
JsonHelper
.
serialize
(
req
);
}
}
public
WxXcxGetPhoneNumberRes
getResponse
()
{
public
WxXcxGetPhoneNumberRes
getResponse
()
{
...
...
yzg-util-wxxcx/src/main/java/com/yanzuoguang/wxxcx/user/getphone/WxXcxGetPhoneNumberRes.java
View file @
eb80da61
...
@@ -2,12 +2,14 @@ package com.yanzuoguang.wxxcx.user.getphone;
...
@@ -2,12 +2,14 @@ package com.yanzuoguang.wxxcx.user.getphone;
import
com.yanzuoguang.wxxcx.base.WxXcxResponseBaseError
;
import
com.yanzuoguang.wxxcx.base.WxXcxResponseBaseError
;
import
java.io.Serializable
;
/**
/**
* 获取手机号 响应
* 获取手机号 响应
*
*
* @author 李贤军
* @author 李贤军
*/
*/
public
class
WxXcxGetPhoneNumberRes
extends
WxXcxResponseBaseError
{
public
class
WxXcxGetPhoneNumberRes
extends
WxXcxResponseBaseError
implements
Serializable
{
/**
/**
* 用户手机号信息
* 用户手机号信息
*/
*/
...
...
yzg-util-wxxcx/src/test/java/com/yanzuoguang/wxxcx/login/WxXcxAuthCode2SessionTest.java
View file @
eb80da61
package
com
.
yanzuoguang
.
wxxcx
.
login
;
package
com
.
yanzuoguang
.
wxxcx
.
login
;
import
com.alibaba.fastjson.JSONObject
;
import
com.sun.org.apache.bcel.internal.generic.NEW
;
import
com.yanzuoguang.wxxcx.base.WxXcxAccessToken
;
import
com.yanzuoguang.wxxcx.base.WxXcxConfig
;
import
com.yanzuoguang.wxxcx.base.WxXcxRequest
;
import
com.yanzuoguang.wxxcx.base.WxXcxRequestImpl
;
import
com.yanzuoguang.wxxcx.dataanalysis.retain.WxXcxAnalysisGetDailyRetainReq
;
import
com.yanzuoguang.wxxcx.dataanalysis.retain.service.WxXcxAnalysisGetDailyRetainService
;
import
com.yanzuoguang.wxxcx.dataanalysis.retain.service.impl.WxXcxAnalysisGetDailyRetainServiceImpl
;
import
com.yanzuoguang.wxxcx.token.WxXcxAuthGetAccessTokenReq
;
import
com.yanzuoguang.wxxcx.token.service.WxXcxAuthGetAccessTokenService
;
import
com.yanzuoguang.wxxcx.token.service.impl.WxXcxAuthGetAccessTokenServiceImpl
;
import
com.yanzuoguang.wxxcx.user.getphone.WxXcxGetPhoneNumberReq
;
import
com.yanzuoguang.wxxcx.user.getphone.service.WxXcxGetPhoneNumberService
;
import
com.yanzuoguang.wxxcx.user.getphone.service.impl.WxXcxGetPhoneNumberServiceImpl
;
import
org.junit.Test
;
import
org.junit.Test
;
/**
/**
...
@@ -7,8 +22,40 @@ import org.junit.Test;
...
@@ -7,8 +22,40 @@ import org.junit.Test;
*/
*/
public
class
WxXcxAuthCode2SessionTest
{
public
class
WxXcxAuthCode2SessionTest
{
@Test
@Test
public
void
wxXcxAuthCode2Session
()
{
public
void
wxXcxAuthCode2Session
()
{
WxXcxConfig
wxXcxConfig
=
new
WxXcxConfig
();
WxXcxRequest
wxXcxRequest
=
new
WxXcxRequestImpl
();
WxXcxAuthGetAccessTokenService
WxXcxAuthGetAccessTokenService
=
new
WxXcxAuthGetAccessTokenServiceImpl
(
wxXcxConfig
,
wxXcxRequest
);
WxXcxAuthGetAccessTokenReq
req
=
new
WxXcxAuthGetAccessTokenReq
();
req
.
setAppid
(
"wxd70bc341df16d0b8"
);
req
.
setSecret
(
"a8a4bc5f1dc5cde3c9abddf107c5598e"
);
req
.
setGrant_type
(
"client_credential"
);
System
.
out
.
println
(
WxXcxAuthGetAccessTokenService
.
getAuthGetAccessToken
(
req
).
getAccess_token
());
}
@Test
public
void
getPhoneNumber
()
{
WxXcxConfig
wxXcxConfig
=
new
WxXcxConfig
();
WxXcxRequest
wxXcxRequest
=
new
WxXcxRequestImpl
();
WxXcxAccessToken
wxXcxAccessToken
=
new
WxXcxAccessToken
();
WxXcxAuthGetAccessTokenService
wxXcxAuthGetAccessTokenService
=
new
WxXcxAuthGetAccessTokenServiceImpl
(
wxXcxConfig
,
wxXcxRequest
);
WxXcxAuthGetAccessTokenReq
req
=
new
WxXcxAuthGetAccessTokenReq
();
req
.
setAppid
(
"wxd70bc341df16d0b8"
);
req
.
setSecret
(
"a8a4bc5f1dc5cde3c9abddf107c5598e"
);
req
.
setGrant_type
(
"client_credential"
);
String
token
=
wxXcxAuthGetAccessTokenService
.
getAuthGetAccessToken
(
req
).
getAccess_token
();
System
.
out
.
println
(
token
);
wxXcxAccessToken
.
setAccess_token
(
token
);
WxXcxAnalysisGetDailyRetainService
wxXcxAnalysisGetDailyRetainService
=
new
WxXcxAnalysisGetDailyRetainServiceImpl
(
wxXcxConfig
,
wxXcxRequest
);
WxXcxAnalysisGetDailyRetainReq
retainReq
=
new
WxXcxAnalysisGetDailyRetainReq
();
retainReq
.
setAccess_token
(
token
);
retainReq
.
setBegin_date
(
"20220707"
);
retainReq
.
setEnd_date
(
"20220707"
);
System
.
out
.
println
(
JSONObject
.
toJSONString
(
wxXcxAnalysisGetDailyRetainService
.
getAnalysisGetDailyRetain
(
wxXcxAccessToken
,
retainReq
)));
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment