记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
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
董敬伟
liquidnet-bus-v1
Commits
1f74c37a
Commit
1f74c37a
authored
Jul 14, 2021
by
张国柄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:config:adam wechat;
parent
1f9e3da0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
9 deletions
+72
-9
AdamWechatConst.java
.../com/liquidnet/service/adam/constant/AdamWechatConst.java
+44
-0
application-dev.yml
liquidnet-bus-config/liquidnet-config/application-dev.yml
+8
-0
application-test.yml
liquidnet-bus-config/liquidnet-config/application-test.yml
+8
-0
AdamLoginController.java
...iquidnet/service/adam/controller/AdamLoginController.java
+12
-9
No files found.
liquidnet-bus-api/liquidnet-service-adam-api/src/main/java/com/liquidnet/service/adam/constant/AdamWechatConst.java
0 → 100644
View file @
1f74c37a
package
com
.
liquidnet
.
service
.
adam
.
constant
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
public
class
AdamWechatConst
{
/* =============================================================== | 变量配置 */
public
static
String
zhengzaiAppletAppid
;
public
static
String
zhengzaiAppletSecret
;
public
static
String
zhengzaiServiceAppid
;
public
static
String
zhengzaiServiceSecret
;
/* =============================================================== | API常量配置 */
public
static
final
String
API_URL_JS_CODE2SESSION
=
"https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code"
;
public
static
final
String
API_URL_OAUTH2_ACCESS_TOKEN
=
"https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code"
;
/* =============================================================== | */
/* =============================================================== | */
@Value
(
"${liquidnet.wechat.zhengzai.applet.appid}"
)
public
void
setZhengzaiAppletAppid
(
String
zhengzaiAppletAppid
)
{
AdamWechatConst
.
zhengzaiAppletAppid
=
zhengzaiAppletAppid
;
}
@Value
(
"${liquidnet.wechat.zhengzai.applet.secret}"
)
public
void
setZhengzaiAppletSecret
(
String
zhengzaiAppletSecret
)
{
AdamWechatConst
.
zhengzaiAppletSecret
=
zhengzaiAppletSecret
;
}
@Value
(
"${liquidnet.wechat.zhengzai.service.appid}"
)
public
void
setZhengzaiServiceAppid
(
String
zhengzaiServiceAppid
)
{
AdamWechatConst
.
zhengzaiServiceAppid
=
zhengzaiServiceAppid
;
}
@Value
(
"${liquidnet.wechat.zhengzai.service.secret}"
)
public
void
setZhengzaiServiceSecret
(
String
zhengzaiServiceSecret
)
{
AdamWechatConst
.
zhengzaiServiceSecret
=
zhengzaiServiceSecret
;
}
}
liquidnet-bus-config/liquidnet-config/application-dev.yml
View file @
1f74c37a
...
@@ -87,6 +87,14 @@ liquidnet:
...
@@ -87,6 +87,14 @@ liquidnet:
dysms
:
dysms
:
accessKeyId
:
LTAI5tHt7yvm97G8zxackcMK
accessKeyId
:
LTAI5tHt7yvm97G8zxackcMK
accessKeySecret
:
xC3i5qEptJ3JIIRaYLaKvhk4gVASfl
accessKeySecret
:
xC3i5qEptJ3JIIRaYLaKvhk4gVASfl
wechat
:
zhengzai
:
applet
:
appid
:
wx4732efeaa2b08086
secret
:
94562c1f92da1b6cb3f1327c8842c6d3
service
:
appid
:
wx3498304dda39c5a1
secret
:
a1307fab0a5f2380086a7c636f7339ea
#application-dev-end
#application-dev-end
liquidnet-bus-config/liquidnet-config/application-test.yml
View file @
1f74c37a
...
@@ -87,6 +87,14 @@ liquidnet:
...
@@ -87,6 +87,14 @@ liquidnet:
dysms
:
dysms
:
accessKeyId
:
LTAI5tHt7yvm97G8zxackcMK
accessKeyId
:
LTAI5tHt7yvm97G8zxackcMK
accessKeySecret
:
xC3i5qEptJ3JIIRaYLaKvhk4gVASfl
accessKeySecret
:
xC3i5qEptJ3JIIRaYLaKvhk4gVASfl
wechat
:
zhengzai
:
applet
:
appid
:
wx4732efeaa2b08086
secret
:
94562c1f92da1b6cb3f1327c8842c6d3
service
:
appid
:
wx3498304dda39c5a1
secret
:
a1307fab0a5f2380086a7c636f7339ea
#application-test-end
#application-test-end
\ No newline at end of file
liquidnet-bus-service/liquidnet-service-adam/liquidnet-service-adam-impl/src/main/java/com/liquidnet/service/adam/controller/AdamLoginController.java
View file @
1f74c37a
...
@@ -16,6 +16,7 @@ import com.liquidnet.commons.lang.constant.LnsEnum;
...
@@ -16,6 +16,7 @@ import com.liquidnet.commons.lang.constant.LnsEnum;
import
com.liquidnet.commons.lang.core.JwtValidator
;
import
com.liquidnet.commons.lang.core.JwtValidator
;
import
com.liquidnet.commons.lang.util.*
;
import
com.liquidnet.commons.lang.util.*
;
import
com.liquidnet.service.adam.constant.AdamRedisConst
;
import
com.liquidnet.service.adam.constant.AdamRedisConst
;
import
com.liquidnet.service.adam.constant.AdamWechatConst
;
import
com.liquidnet.service.adam.dto.AdamThirdPartParam
;
import
com.liquidnet.service.adam.dto.AdamThirdPartParam
;
import
com.liquidnet.service.adam.dto.vo.AdamLoginInfoVo
;
import
com.liquidnet.service.adam.dto.vo.AdamLoginInfoVo
;
import
com.liquidnet.service.adam.dto.vo.AdamUserInfoVo
;
import
com.liquidnet.service.adam.dto.vo.AdamUserInfoVo
;
...
@@ -331,13 +332,14 @@ public class AdamLoginController {
...
@@ -331,13 +332,14 @@ public class AdamLoginController {
}
}
@ApiOperationSupport
(
order
=
9
)
@ApiOperationSupport
(
order
=
9
)
@ApiOperation
(
value
=
"微信
登录凭证校验"
,
notes
=
"
登录凭证校验。通过 wx.login 接口获得临时登录凭证 code 后传到开发者服务器调用此接口完成登录流程。更多使用方法详见 https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/login/auth.code2Session.html"
)
@ApiOperation
(
value
=
"微信
小程序登录凭证校验"
,
notes
=
"这里仅用于获取OPENID使用。
登录凭证校验。通过 wx.login 接口获得临时登录凭证 code 后传到开发者服务器调用此接口完成登录流程。更多使用方法详见 https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/login/auth.code2Session.html"
)
@GetMapping
(
value
=
{
"wxa/code2session"
})
@GetMapping
(
value
=
{
"wxa/code2session"
})
public
ResponseDto
<
Object
>
wxaCode2Session
(
@RequestParam
String
jsCode
)
{
public
ResponseDto
<
String
>
wxaCode2Session
(
@RequestParam
String
jsCode
)
{
String
openId
=
null
;
String
openId
=
null
;
try
{
try
{
String
url
=
"https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code"
;
// String url = "https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code";
url
=
url
.
replace
(
"APPID"
,
"wx4732efeaa2b08086"
).
replace
(
"SECRET"
,
"94562c1f92da1b6cb3f1327c8842c6d3"
).
replace
(
"JSCODE"
,
jsCode
);
String
url
=
AdamWechatConst
.
API_URL_JS_CODE2SESSION
.
replace
(
"APPID"
,
AdamWechatConst
.
zhengzaiAppletAppid
)
.
replace
(
"SECRET"
,
AdamWechatConst
.
zhengzaiAppletSecret
).
replace
(
"JSCODE"
,
jsCode
);
String
respJStr
=
HttpUtil
.
get
(
url
,
null
);
String
respJStr
=
HttpUtil
.
get
(
url
,
null
);
JsonNode
respJNode
=
JsonUtils
.
fromJson
(
respJStr
,
JsonNode
.
class
);
JsonNode
respJNode
=
JsonUtils
.
fromJson
(
respJStr
,
JsonNode
.
class
);
if
(
null
==
respJNode
)
{
if
(
null
==
respJNode
)
{
...
@@ -345,19 +347,20 @@ public class AdamLoginController {
...
@@ -345,19 +347,20 @@ public class AdamLoginController {
}
}
openId
=
respJNode
.
get
(
"openid"
).
asText
();
openId
=
respJNode
.
get
(
"openid"
).
asText
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"WX.API调用异常
"
,
e
);
log
.
error
(
"WX.API调用异常
[jsCode:{}]"
,
jsCode
,
e
);
}
}
return
ResponseDto
.
success
(
openId
);
return
ResponseDto
.
success
(
openId
);
}
}
@ApiOperationSupport
(
order
=
10
)
@ApiOperationSupport
(
order
=
10
)
@ApiOperation
(
value
=
"微信网站应用登录"
,
notes
=
"方法详见 https://developers.weixin.qq.com/doc/oplatform/Website_App/WeChat_Login/Wechat_Login.html"
)
@ApiOperation
(
value
=
"微信网站应用登录"
,
notes
=
"
这里仅用于获取OPENID使用。
方法详见 https://developers.weixin.qq.com/doc/oplatform/Website_App/WeChat_Login/Wechat_Login.html"
)
@GetMapping
(
value
=
{
"wx/oauth2/access_token"
})
@GetMapping
(
value
=
{
"wx/oauth2/access_token"
})
public
ResponseDto
<
String
>
wxOauth2AccessToken
(
@RequestParam
String
code
)
{
public
ResponseDto
<
String
>
wxOauth2AccessToken
(
@RequestParam
String
code
)
{
String
openId
=
null
;
String
openId
=
null
;
try
{
try
{
String
url
=
"https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code"
;
// String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code";
url
=
url
.
replace
(
"APPID"
,
"wx3498304dda39c5a1"
).
replace
(
"SECRET"
,
"a1307fab0a5f2380086a7c636f7339ea"
).
replace
(
"CODE"
,
code
);
String
url
=
AdamWechatConst
.
API_URL_OAUTH2_ACCESS_TOKEN
.
replace
(
"APPID"
,
AdamWechatConst
.
zhengzaiServiceAppid
)
.
replace
(
"SECRET"
,
AdamWechatConst
.
zhengzaiServiceSecret
).
replace
(
"CODE"
,
code
);
String
respJStr
=
HttpUtil
.
get
(
url
,
null
);
String
respJStr
=
HttpUtil
.
get
(
url
,
null
);
JsonNode
respJNode
=
JsonUtils
.
fromJson
(
respJStr
,
JsonNode
.
class
);
JsonNode
respJNode
=
JsonUtils
.
fromJson
(
respJStr
,
JsonNode
.
class
);
if
(
null
==
respJNode
||
!
respJNode
.
get
(
"errcode"
).
isEmpty
())
{
if
(
null
==
respJNode
||
!
respJNode
.
get
(
"errcode"
).
isEmpty
())
{
...
@@ -365,7 +368,7 @@ public class AdamLoginController {
...
@@ -365,7 +368,7 @@ public class AdamLoginController {
}
}
openId
=
respJNode
.
get
(
"openid"
).
asText
();
openId
=
respJNode
.
get
(
"openid"
).
asText
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"WX.API调用异常
"
,
e
);
log
.
error
(
"WX.API调用异常
[code:{}]"
,
code
,
e
);
}
}
return
ResponseDto
.
success
(
openId
);
return
ResponseDto
.
success
(
openId
);
}
}
...
...
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