Commit 304dc686 by Simon Cheng

Merge remote-tracking branch 'origin/dev'

parents aae25e49 f4f661a5
package com.yd.rmi.tencent.wechat;
import com.yd.api.result.JsonResult;
import com.yd.rmi.cache.SystemConfigService;
import com.yd.rmi.tencent.wechat.service.WechatService;
import com.yd.rmi.tencent.wechatinterf.pojo.ticket.TicketRequest;
import com.yd.rmi.tencent.wechatinterf.pojo.token.TokenRequest;
import com.yd.rmi.tencent.wechatinterf.pojo.wechatpay.WxConfigRequestVO;
import com.yd.rmi.tencent.wechatinterf.pojo.wechatpay.WxConfigResponseVO;
import com.yd.util.SpringContextUtil;
import com.yd.util.config.ZHBErrorConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Map;
@Controller
@CrossOrigin(origins = "*")
public class WechatController {
@Autowired
private WechatService wechatService;
@Autowired
private SystemConfigService systemConfigService;
/**
* 微信分享时授权
* @param wxConfigRequestVO
* @return
*/
@RequestMapping("/wxConfig")
@ResponseBody
public Object wxConfig(@RequestBody WxConfigRequestVO wxConfigRequestVO){
String accessToken = wechatService.obtainToken(new TokenRequest());
TicketRequest ticketRequest = new TicketRequest();
ticketRequest.setAccessToken(accessToken);
String jsapiTicket = wechatService.obtainTicket(ticketRequest);
String url = wxConfigRequestVO.getUrl();
try {url = URLDecoder.decode(wxConfigRequestVO.getUrl(), "utf-8");} catch (UnsupportedEncodingException e) {}
Map<String, String> ret = wechatService.jsapiTicketSign(jsapiTicket,url);
JsonResult result = new JsonResult();
WxConfigResponseVO wxConfigResponseVO = new WxConfigResponseVO();
if(SpringContextUtil.isProd()){
wxConfigResponseVO.setAppId(systemConfigService.getSingleConfigValue("YD-TENCENT_WECHAT_APPID"));
}else {
wxConfigResponseVO.setAppId(systemConfigService.getSingleConfigValue("TENCENT_WECHAT_APPID"));
}
wxConfigResponseVO.setTimestamp(ret.get("timestamp"));
wxConfigResponseVO.setNonceStr(ret.get("nonceStr"));
wxConfigResponseVO.setSignature(ret.get("signature"));
wxConfigResponseVO.setJsApiList(new String[]{"updateAppMessageShareData","updateTimelineShareData","onMenuShareTimeline","onMenuShareAppMessage","onMenuShareQQ","onMenuShareWeibo","onMenuShareQZone","chooseImage","uploadImage","downloadImage","getLocalImgData"});
result.setData(wxConfigResponseVO);
result.setSuccess(true);
result.setMessage(ZHBErrorConfig.getErrorInfo("800000"));
return result;
}
}
package com.yd.rmi.tencent.wechat.vo; package com.yd.api.wechat.vo;
public class WxConfigRequestVO { public class WxConfigRequestVO {
private String url; private String url;
......
package com.yd.rmi.tencent.wechat.vo; package com.yd.api.wechat.vo;
public class WxConfigResponseVO { public class WxConfigResponseVO {
private String appId;// 必填,公众号的唯一标识 private String appId;// 必填,公众号的唯一标识
......
/*
Navicat Premium Data Transfer
Source Server : 本地库
Source Server Type : MySQL
Source Server Version : 50720
Source Host : localhost:3306
Source Schema : db_master
Target Server Type : MySQL
Target Server Version : 50720
File Encoding : 65001
Date: 19/01/2018 18:38:11
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(512) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`password` varchar(512) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`create_time` datetime(0) NOT NULL,
`update_time` datetime(0) DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1002 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of user
-- ----------------------------
INSERT INTO `user` VALUES (1000, 'admin', 'admin', '2018-01-19 16:43:38', '2018-01-19 16:43:40');
INSERT INTO `user` VALUES (1001, 'rocliu', 'rocliu', '2018-01-19 16:43:58', '2018-01-19 16:44:00');
SET FOREIGN_KEY_CHECKS = 1;
/*
Navicat Premium Data Transfer
Source Server : 本地库
Source Server Type : MySQL
Source Server Version : 50720
Source Host : localhost:3306
Source Schema : db_other
Target Server Type : MySQL
Target Server Version : 50720
File Encoding : 65001
Date: 19/01/2018 18:38:18
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for user_info
-- ----------------------------
DROP TABLE IF EXISTS `user_info`;
CREATE TABLE `user_info` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`email` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1001 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of user_info
-- ----------------------------
INSERT INTO `user_info` VALUES (1000, 'admin', 'admin@apedad.com');
SET FOREIGN_KEY_CHECKS = 1;
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