Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dd_school
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangqi
dd_school
Commits
20351551
Commit
20351551
authored
Aug 25, 2023
by
baochunxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#G:上传过去config配置文件
parent
715a8267
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
3 deletions
+95
-3
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
+1
-1
smart-campus/src/main/java/yangtz/cs/liu/wechat/controller/api/WxApiController.java
+94
-2
No files found.
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
View file @
20351551
...
...
@@ -119,7 +119,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
// 静态资源,可匿名访问
.
antMatchers
(
HttpMethod
.
GET
,
"/"
,
"/*.html"
,
"/**/*.html"
,
"/**/*.css"
,
"/**/*.js"
,
"/profile/**"
).
permitAll
()
.
antMatchers
(
"/swagger-ui.html"
,
"/swagger-resources/**"
,
"/webjars/**"
,
"/*/api-docs"
,
"/druid/**"
).
permitAll
()
.
antMatchers
(
"/wx/wxchat"
,
"/wx/getCode"
,
"/wx/callback"
,
"/wx/getAccessToken"
,
"/wx/sendTemplate"
).
permitAll
()
.
antMatchers
(
"/wx/wxchat"
,
"/wx/getCode"
,
"/wx/callback"
,
"/wx/getAccessToken"
,
"/wx/sendTemplate"
,
"/wx/getsignature"
).
permitAll
()
//activiti相关接口放行
.
antMatchers
(
"/modeler/**"
).
anonymous
()
.
antMatchers
(
"/activiti/definition/upload"
).
anonymous
()
...
...
smart-campus/src/main/java/yangtz/cs/liu/wechat/controller/api/WxApiController.java
View file @
20351551
...
...
@@ -10,6 +10,9 @@ import com.ruoyi.common.core.domain.AjaxResult;
import
com.ruoyi.common.core.redis.RedisCache
;
import
com.ruoyi.common.exception.ServiceException
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.http.HttpUtils
;
import
java.util.concurrent.TimeUnit
;
import
javax.servlet.http.HttpServletRequest
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -17,6 +20,7 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.*
;
import
yangtz.cs.liu.campus.util.VxTemlateSendApi
;
import
yangtz.cs.liu.wechat.conf.AesException
;
import
yangtz.cs.liu.wechat.conf.SHA1
;
import
yangtz.cs.liu.wechat.domain.*
;
...
...
@@ -290,6 +294,94 @@ public class WxApiController extends BaseController {
// }
}
/*
* 发送发膜
* toUserOpenId 微信用户id applyTime 申请时间 remark 备注 applyUser 用户名字 content 内容 first 标题
*/
// @GetMapping("/sendTemlp")
// private AjaxResult sendTemlp(){
// Map<String,Object> map = new HashMap();
// map.put("toUserOpenId","oTrVl6iMzcAET3T-T_c3jdULe9YM");
// map.put("applyTime","2023-05-20 15:20:30");
// map.put("remark","测试");
// map.put("applyUser","测试");
// map.put("content","1111111");
// map.put("first","测试标题");
// VxTemlateSendApi.sendVxTemlate(map);
// return AjaxResult.success();
// }
/**
* 获取签名 noncestr timestamp signature
* @return
*/
@GetMapping
(
"/getsignature"
)
@ResponseBody
public
AjaxResult
getsignature
(
String
url
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
//获取accesToken
String
token
=
accessTokenUtil
.
getToken
();
//获取jsapi_ticket
String
ticket
=
null
;
ticket
=
redisCache
.
getCacheObject
(
"ticket"
);
if
(
StringUtils
.
isEmpty
(
ticket
)){
String
ticketss
=
HttpUtils
.
sendGet
(
"https://api.weixin.qq.com/cgi-bin/ticket/getticket?"
+
"access_token="
+
token
+
"&type=jsapi"
);
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
ticketss
);
ticket
=
jsonObject
.
get
(
"ticket"
).
toString
();
redisCache
.
setCacheObject
(
"ticket"
,
ticket
,
5
,
TimeUnit
.
MINUTES
);
}
//生成JS-SDK权限验证的签名
//1.生成随机字符串
String
uuid
=
UUID
.
randomUUID
().
toString
();
//去掉“-”符号
String
noncester
=
uuid
.
replaceAll
(
"-"
,
""
);
//2获取时间戳
long
timestamp
=
System
.
currentTimeMillis
();
//3.
Map
<
String
,
String
>
maps
=
new
TreeMap
<
String
,
String
>();
maps
.
put
(
"noncestr"
,
noncester
);
maps
.
put
(
"jsapi_ticket"
,
ticket
);
maps
.
put
(
"timestamp"
,
String
.
valueOf
(
timestamp
));
maps
.
put
(
"url"
,
url
);
String
createLinkString
=
createLinkString
(
maps
);
log
.
info
(
createLinkString
);
//sha1签名,得到signature
String
signature
=
Sha1Util
.
sha1
(
createLinkString
);
map
.
put
(
"noncestr"
,
noncester
);
map
.
put
(
"jsapi_ticket"
,
ticket
);
map
.
put
(
"timestamp"
,
String
.
valueOf
(
timestamp
));
map
.
put
(
"url"
,
url
);
map
.
put
(
"signature"
,
signature
);
return
AjaxResult
.
success
(
map
);
}
/**
* a把数组所有元素排序,并按照“参数=参数值”的模式用“&”字符拼接成字符串
* @param params 需要排序并参与字符拼接的参数组
* @return 拼接后字符串
*/
public
static
String
createLinkString
(
Map
<
String
,
String
>
params
)
{
List
<
String
>
keys
=
new
ArrayList
<
String
>(
params
.
keySet
());
Collections
.
sort
(
keys
);
String
prestr
=
""
;
for
(
int
i
=
0
;
i
<
keys
.
size
();
i
++)
{
String
key
=
keys
.
get
(
i
);
String
value
=
params
.
get
(
key
);
if
(
i
==
keys
.
size
()
-
1
)
{
// 拼接时,不包括最后一个&字符
prestr
=
prestr
+
key
+
"="
+
value
;
}
else
{
prestr
=
prestr
+
key
+
"="
+
value
+
"&"
;
}
}
return
prestr
;
}
/**
{
"button": [
...
...
@@ -500,10 +592,10 @@ public class WxApiController extends BaseController {
+
code
+
"&grant_type=authorization_code"
;
String
result
=
HttpUtil
.
get
(
url
);
log
.
info
(
"urlRespons:"
+
result
);
// 将结果解析为json
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
result
);
System
.
out
.
println
(
result
);
//
System.out.println(result);
String
openId
=
jsonObject
.
getStr
(
"openid"
);
// if (StringUtils.isEmpty(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