Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
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
fangxinjiang
yifu-mvp
Commits
529de816
Commit
529de816
authored
Jan 16, 2025
by
chenyuxi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 发消息
parent
49299532
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
37 deletions
+2
-37
WxConfig.java
...a/com/yifu/cloud/plus/v1/yifu/salary/config/WxConfig.java
+2
-37
No files found.
yifu-salary/yifu-salary-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/salary/config/WxConfig.java
View file @
529de816
...
...
@@ -124,11 +124,11 @@ public class WxConfig {
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON_UTF8
);
Gson
gson
=
new
Gson
();
log
.
info
(
gson
.
toJson
(
requestMap
));
log
.
info
(
"发企业微信===请求:{}"
,
gson
.
toJson
(
requestMap
));
HttpEntity
<
String
>
requestEntity
=
new
HttpEntity
<>(
gson
.
toJson
(
requestMap
),
headers
);
String
accessToken
=
getAccessToken
(
restTemplate
);
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
postForEntity
(
String
.
format
(
SecurityConstants
.
WX_SEND_MESSAGE
,
accessToken
),
requestEntity
,
String
.
class
);
log
.
info
(
JSON
.
toJSONString
(
responseEntity
));
log
.
info
(
"发企业微信===返回:{}"
,
JSON
.
toJSONString
(
responseEntity
));
JSONObject
jsonObject
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
responseEntity
));
JSONObject
jsonBody
=
jsonObject
.
getJSONObject
(
"body"
);
if
(
jsonBody
!=
null
)
{
...
...
@@ -147,41 +147,6 @@ public class WxConfig {
return
true
;
}
/**
* @param restTemplate
* @param requestMap 请求内容
* @Author: huyc
* @Date: 2023/7/28 14:50
* @Description: 发送卡片消息
* @return: java.lang.String
**/
public
boolean
sendAppTextCard
(
RestTemplate
restTemplate
,
Map
<
String
,
Object
>
requestMap
)
{
// 必须加上header说明
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON_UTF8
);
Gson
gson
=
new
Gson
();
log
.
info
(
"发企业微信===请求:{}"
,
gson
.
toJson
(
requestMap
));
HttpEntity
<
String
>
requestEntity
=
new
HttpEntity
<>(
gson
.
toJson
(
requestMap
),
headers
);
String
accessToken
=
getAppAccessToken
(
restTemplate
);
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
postForEntity
(
String
.
format
(
SecurityConstants
.
WX_SEND_MESSAGE
,
accessToken
),
requestEntity
,
String
.
class
);
log
.
info
(
"发企业微信===返回:{}"
,
JSON
.
toJSONString
(
responseEntity
));
JSONObject
jsonObject
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
responseEntity
));
JSONObject
jsonBody
=
jsonObject
.
getJSONObject
(
"body"
);
if
(
jsonBody
!=
null
)
{
String
errcode
=
jsonBody
.
getString
(
"errcode"
);
if
(
accossTokenInvliad
.
equals
(
errcode
))
{
//删除accossToken缓存
removeAccessToken
();
return
false
;
}
if
(!
CommonConstants
.
ZERO_STRING
.
equals
(
errcode
))
{
//非正常,则打印错误日志
log
.
info
(
jsonObject
.
toJSONString
());
}
}
else
{
log
.
info
(
jsonObject
.
toJSONString
());
}
return
true
;
}
/**
* 功能描述: 获取微信accos_token
* @Author: huyc
...
...
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