Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
tianjin-cement
Project
Project
Details
Activity
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
竹天卫
tianjin-cement
Commits
2570bf6c
Commit
2570bf6c
authored
Oct 20, 2020
by
竹天卫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
委托优化
parent
1097cf30
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
6 deletions
+54
-6
WeiXinController.java
.../wise/sc/cement/business/controller/WeiXinController.java
+17
-4
WeiXinService.java
...n/wise/sc/cement/business/service/impl/WeiXinService.java
+35
-2
application.yml
cement-business/src/main/resources/application.yml
+2
-0
No files found.
cement-business/src/main/java/cn/wise/sc/cement/business/controller/WeiXinController.java
View file @
2570bf6c
...
...
@@ -25,17 +25,30 @@ public class WeiXinController {
@Autowired
private
WeiXinService
weiXinService
;
@ApiOperation
(
value
=
"获取登录token"
)
@GetMapping
(
"/getToken"
)
public
BaseResponse
getToken
(
String
code
){
@ApiOperation
(
value
=
"获取登录token
-小程序端
"
)
@GetMapping
(
"/get
XCX
Token"
)
public
BaseResponse
get
XCX
Token
(
String
code
){
try
{
return
weiXinService
.
getToken
(
code
);
return
weiXinService
.
getToken
(
code
,
"APP"
);
}
catch
(
Exception
e
){
log
.
debug
(
"获取登录token{}"
,
e
);
}
return
BaseResponse
.
errorMsg
(
"失败!"
);
}
@ApiOperation
(
value
=
"获取登录token-管理端"
)
@GetMapping
(
"/getPCToken"
)
public
BaseResponse
getPCToken
(
String
code
){
try
{
return
weiXinService
.
getToken
(
code
,
"PC"
);
}
catch
(
Exception
e
){
log
.
debug
(
"获取登录token{}"
,
e
);
}
return
BaseResponse
.
errorMsg
(
"失败!"
);
}
@ApiOperation
(
value
=
"当前登录用户"
)
@GetMapping
(
"/getLoginUser"
)
public
BaseResponse
getLoginUser
(){
...
...
cement-business/src/main/java/cn/wise/sc/cement/business/service/impl/WeiXinService.java
View file @
2570bf6c
...
...
@@ -29,6 +29,8 @@ public class WeiXinService {
private
String
corpid
;
@Value
(
"${weixin.corpsecret}"
)
private
String
corpsecret
;
@Value
(
"${weixin.corpsecretPC}"
)
private
String
corpsecretPC
;
@Autowired
private
ISysUserService
userService
;
@Autowired
...
...
@@ -37,16 +39,24 @@ public class WeiXinService {
/**
* 获取登录token
* @param code
* @param type PC管理端 APP小程序端
* @return
*/
public
BaseResponse
<
String
>
getToken
(
String
code
)
{
public
BaseResponse
<
String
>
getToken
(
String
code
,
String
type
)
{
if
(
StrUtil
.
isEmpty
(
code
))
{
return
BaseResponse
.
errorMsg
(
"code为必填项!"
);
}
System
.
out
.
println
(
"==================code==================="
);
System
.
out
.
println
(
code
);
try
{
// String accessToken = getAccessToken();
// String accessToken = null;
// if(type.equals("PC")){
// accessToken = getAccessToken();
// }else if(type.equals("APP")){
// accessToken = getPCAccessToken();
// }else{
// return BaseResponse.errorMsg("参数错误");
// }
// String param = "access_token=%s&code=%s";
// param = String.format(param, accessToken, code);
// JSONObject jsonObject = WeixinInterfaceUtil.doGet(Global.USERINFOURL, param);
...
...
@@ -96,6 +106,29 @@ public class WeiXinService {
}
}
public
String
getPCAccessToken
()
{
try
{
String
param
=
"corpid=%s&corpsecret=%s"
;
param
=
String
.
format
(
param
,
corpid
,
corpsecretPC
);
JSONObject
jsonObject
=
WeixinInterfaceUtil
.
doGet
(
Global
.
ACCESSTOKENURL
,
param
);
String
accessToken
=
jsonObject
.
getString
(
"access_token"
);
System
.
out
.
println
(
"==================accessToken==================="
);
System
.
out
.
println
(
accessToken
);
return
accessToken
;
}
catch
(
Exception
e
)
{
return
null
;
}
}
//获取用户信息
public
JSONObject
getUser
(
String
accessToken
,
String
userId
)
{
try
{
...
...
cement-business/src/main/resources/application.yml
View file @
2570bf6c
...
...
@@ -9,6 +9,7 @@ spring:
datasource
:
# 192.168.110.85 admin!@#123
url
:
jdbc:mysql://192.168.110.85:3306/sinoma_tcdri?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false
# url: jdbc:mysql://81.68.92.175:3306/sinoma_tcdri?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username
:
root
password
:
admin!@#123
driverClassName
:
com.mysql.cj.jdbc.Driver
...
...
@@ -40,4 +41,5 @@ mybatis-plus:
weixin
:
corpsecret
:
gFa_7XvXtCaoeAYERzjRwwz_OTJkJfgBb8weOKjmI3o
corpsecretPC
:
itCLYcwl9ggA9VfZam_iz96Ikp9StDFfVr4Adb0yY7A
corpid
:
ww348f91b2573c1867
\ No newline at end of file
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