Commit 20351551 by baochunxin

#G:上传过去config配置文件

parent 715a8267
...@@ -119,7 +119,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter ...@@ -119,7 +119,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
// 静态资源,可匿名访问 // 静态资源,可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").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相关接口放行 //activiti相关接口放行
.antMatchers("/modeler/**").anonymous() .antMatchers("/modeler/**").anonymous()
.antMatchers("/activiti/definition/upload").anonymous() .antMatchers("/activiti/definition/upload").anonymous()
......
...@@ -10,6 +10,9 @@ import com.ruoyi.common.core.domain.AjaxResult; ...@@ -10,6 +10,9 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -17,6 +20,7 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -17,6 +20,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; 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.AesException;
import yangtz.cs.liu.wechat.conf.SHA1; import yangtz.cs.liu.wechat.conf.SHA1;
import yangtz.cs.liu.wechat.domain.*; import yangtz.cs.liu.wechat.domain.*;
...@@ -290,6 +294,94 @@ public class WxApiController extends BaseController { ...@@ -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": [ "button": [
...@@ -500,10 +592,10 @@ public class WxApiController extends BaseController { ...@@ -500,10 +592,10 @@ public class WxApiController extends BaseController {
+ code + code
+ "&grant_type=authorization_code"; + "&grant_type=authorization_code";
String result = HttpUtil.get(url); String result = HttpUtil.get(url);
log.info("urlRespons:"+result);
// 将结果解析为json // 将结果解析为json
JSONObject jsonObject = JSONUtil.parseObj(result); JSONObject jsonObject = JSONUtil.parseObj(result);
System.out.println(result); // System.out.println(result);
String openId = jsonObject.getStr("openid"); String openId = jsonObject.getStr("openid");
// if (StringUtils.isEmpty(openId)) { // if (StringUtils.isEmpty(openId)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment