Commit 0301c74d by 崔彦峰

svn to git

0 parents
Showing 34 changed files with 1720 additions and 0 deletions
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.com.glsx.framework</groupId>
<artifactId>framework-webapp</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>web-dj-access</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>web-dj-access</name>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-wechat-api</artifactId>
<version>0.0.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-payment-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.oreframework.common</groupId>
<artifactId>ore-common-security</artifactId>
</dependency>
<dependency>
<groupId>org.oreframework</groupId>
<artifactId>ore-util</artifactId>
</dependency>
<dependency>
<groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-redis</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package cn.com.glsx.dj.access;
import org.oreframework.boot.main.AbsOreBootStarter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
/**
* @Title: Main.java
* @Description:
* @author zengqi
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2015
*/
@SpringBootApplication
@ServletComponentScan
public class Main extends AbsOreBootStarter {
@Override
public void run(String[] args)
{
SpringApplication.run(Main.class, args);
}
public static void main(String[] args)
{
Main main = new Main();
main.run(args);
}
}
package cn.com.glsx.dj.access.common;
/**
* @Title: Constants.java
* @Description:
* @author Alvin
* @date 2019年3月11日 下午5:07:42
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
public class Constants {
}
package cn.com.glsx.dj.access.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* 接入配置
* <P>Description: </P>
*
* @author Alvin
* @version 1.0
*/
@Configuration
@ConfigurationProperties("dj.access")
public class AccessProperty {
/**
* 嘀加平台公众号票据
*/
private String token;
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
}
package cn.com.glsx.dj.access.config;
import org.oreframework.boot.autoconfigure.dubbo.reference.ReferenceBuilderFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import cn.com.glsx.dj.payment.remote.WechatPaymentRemote;
import cn.com.glsx.dj.wechat.remote.WechatAccessRemote;
import cn.com.glsx.dj.wechat.remote.WechatComponentAccessRemote;
import cn.com.glsx.dj.wechat.remote.WechatConfigRemote;
import cn.com.glsx.dj.wechat.remote.WorkWechatAccessRemote;
import cn.com.glsx.dj.wechat.remote.WorkWechatAppConfigRemote;
/**
* @Title: DubboConfig.java
* @Description: Dubbo服务注册配置
* @author zengqi
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@Configuration
public class DubboConfig {
@Autowired
private ReferenceBuilderFactory factory;
/**
* 微信第三方平台方接入远程服务注册
* @return
* @author Alvin
* @date 2019年3月12日 下午9:48:34
*/
@Bean
public WechatComponentAccessRemote wechatComponentAccessRemote(){
return factory.builder(WechatComponentAccessRemote.class).timeout(30000).protocol("dubbo").check(false).build();
}
/**
* 微信接入远程服务注册
* @return
* @author Alvin
* @date 2019年5月5日 下午8:58:23
*/
@Bean
public WechatAccessRemote wechatAccessRemote(){
return factory.builder(WechatAccessRemote.class).timeout(30000).check(false).build();
}
/**
* 微信支付远程服务注册
* @return
* @author Alvin
* @date 2019年6月26日 上午11:44:17
*/
@Bean
public WechatPaymentRemote wechatPaymentRemote(){
return factory.builder(WechatPaymentRemote.class).timeout(30000).check(false).build();
}
/**
* 微信配置远程服务注册
* @Description:
* @return
* @author zhoulm
* @date 2019年9月12日 下午7:31:12
*/
@Bean
public WechatConfigRemote wechatConfigRemote(){
return factory.builder(WechatConfigRemote.class).timeout(30000).check(false).build();
}
/**
* 企业微信应用配置远程服务注册
* @return
* @author Alvin
* @date 2020年10月20日 下午1:49:51
*/
@Bean
public WorkWechatAppConfigRemote workWechatAppConfigRemote(){
return factory.builder(WorkWechatAppConfigRemote.class).timeout(30000).check(false).build();
}
/**
* 企业微信接入远程服务注册
* @return
* @author Alvin
* @date 2020年10月20日 下午1:58:27
*/
@Bean
public WorkWechatAccessRemote workWechatAccessRemote(){
return factory.builder(WorkWechatAccessRemote.class).timeout(30000).check(false).build();
}
}
package cn.com.glsx.dj.access.controller;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.com.glsx.dj.access.service.HuaweiPrivateNumberAccessService;
/**
* 华为云隐私号事件通知
* @author zhoulm
*
*/
@RestController
@RequestMapping("huawei/privatenumber")
public class HuaweiPrivateNumberAccessController {
@Autowired
private HuaweiPrivateNumberAccessService huaweiPrivateNumberAccessService;
/**
* 事件通知
* @param request
* @param agentId
* @return
* @throws IOException
*/
@RequestMapping("event")
public String auth(HttpServletRequest request) throws IOException{
return huaweiPrivateNumberAccessService.access(request);
}
}
package cn.com.glsx.dj.access.controller;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.com.glsx.dj.access.service.WechatAccessService;
import cn.com.glsx.framework.core.beans.ResultEntity;
/**
* 微信接入
* <P>Description: </P>
*
* @author Alvin
* @version 1.0
*/
@Controller
@RequestMapping("wechat")
public class WechatAccessController {
@Autowired
private WechatAccessService wechatAccessService;
/**
* 授权事件处理
* @param request
* @return
* @author Alvin
* @date 2019年5月5日 下午9:02:04
*/
@PostMapping("access")
@ResponseBody
public String access(HttpServletRequest request){
wechatAccessService.access(request);
return "success";
}
/**
* 消息与事件处理
* @param request
* @param bizAppId
* @return
* @author Alvin
* @date 2019年5月5日 下午9:02:19
*/
@PostMapping("{appid}/event")
@ResponseBody
public String event(HttpServletRequest request, @PathVariable("appid") String bizAppId){
return wechatAccessService.access(request, bizAppId);
}
/**
* 微信服务认证
* @param request
* @param bizAppId
* @return
* @author Alvin
* @date 2019年5月5日 下午9:02:19
*/
@GetMapping("{appid}/event")
@ResponseBody
public String auth(HttpServletRequest request, @PathVariable("appid") String bizAppId){
return wechatAccessService.auth(request, bizAppId);
}
/**
* 跳转到授权页面
* @return
* @author Alvin
* @date 2019年5月6日 下午2:07:06
*/
@GetMapping("auth/pc")
public String authPC(){
return "auth";
}
/**
* PC端授权回调
* @param authCode
* @param authType 要授权的帐号类型, 1则商户扫码后,手机端仅展示公众号、2表示仅展示小程序,3表示公众号和小程序都展示
* @param merchantId
* @return
* @author Alvin
* @date 2019年5月6日 下午2:07:25
*/
@GetMapping("auth_{authType}_pc/callback/{merchantId}")
public String pcAuthCallback(@RequestParam("auth_code")String authCode
, @PathVariable(required = true, name = "authType")Integer authType
, @PathVariable(required = true, name = "merchantId")Integer merchantId
, Model model){
ResultEntity<Boolean> result = wechatAccessService.authCallback(merchantId, authType, authCode);
if(ResultEntity.ERROR.equals(result.getReturnCode())){
model.addAttribute("msg", result.getMessage());
}
return "callback/pc";
}
/**
* 移动端授权回调
* @param authCode
* @param authType 要授权的帐号类型, 1则商户扫码后,手机端仅展示公众号、2表示仅展示小程序,3表示公众号和小程序都展示
* @param merchantId
* @return
* @author Alvin
* @date 2019年5月6日 下午2:08:12
*/
@GetMapping("auth_{authType}_h5/callback/{merchantId}")
public String h5AuthCallback(@RequestParam("auth_code")String authCode
, @PathVariable(required = true, name = "authType")Integer authType
, @PathVariable(required = true, name = "merchantId") Integer merchantId){
wechatAccessService.authCallback(merchantId, authType, authCode);
return "callback/h5";
}
/**
* 快速注册小程序回调
* @param ticket
* @param merchantId
* @param authorizerAppId
* @return
* @author Alvin
* @date 2019年5月6日 下午2:08:24
*/
@GetMapping("fastregister/callback/{merchantId}/{authorizerAppId}")
public String fastRegisterCallback(@RequestParam("ticket")String ticket
, @PathVariable(required = true, name = "merchantId") Integer merchantId
, @PathVariable(required = true, name = "authorizerAppId") String authorizerAppId
, Model model){
ResultEntity<Boolean> result = wechatAccessService.fastRegisterCallback(merchantId, authorizerAppId, ticket);
if(ResultEntity.ERROR.equals(result.getReturnCode())){
model.addAttribute("msg", result.getMessage());
}
return "callback/fastregister";
}
/**
* 获取移动端授权链接
* @param merchantId
* @param authType 要授权的帐号类型, 1则商户扫码后,手机端仅展示公众号、2表示仅展示小程序,3表示公众号和小程序都展示
* @return
* @author Alvin
* @date 2019年5月6日 下午2:08:43
*/
@GetMapping("auth/h5/{merchantId}_{authType}")
@ResponseBody
public ResultEntity<String> authH5(@PathVariable(required = true, name = "merchantId") Integer merchantId
, @PathVariable(required = true, name = "authType") Integer authType){
return wechatAccessService.getH5AuthPath(merchantId, authType);
}
/**
* PC端授权跳转
* @param merchantId
* @param authType 要授权的帐号类型, 1则商户扫码后,手机端仅展示公众号、2表示仅展示小程序,3表示公众号和小程序都展示
* @return
* @author Alvin
* @date 2019年5月6日 下午2:09:01
*/
@GetMapping("wxauth/agent/{merchantId}_{authType}")
public String authAgent(@PathVariable(required = true, name = "merchantId") Integer merchantId
, @PathVariable(required = true, name = "authType") Integer authType){
return "redirect:".concat(wechatAccessService.getPCAuthPath(merchantId, authType));
}
/**
* 快速注册小程序授权跳转
* @param merchantId
* @param authorizerAppId
* @return
* @author Alvin
* @date 2019年5月6日 下午2:09:42
*/
@GetMapping("fastregister/auth/agent/{merchantId}/{authorizerAppId}")
public String fastRegisterAuthAgent(@PathVariable(required = true, name = "merchantId") Integer merchantId
, @PathVariable(required = true, name = "authorizerAppId") String authorizerAppId){
return "redirect:".concat(wechatAccessService.getFastRegisterAuthPath(merchantId, authorizerAppId).getData());
}
/**
* 跳转到升级提示页面
* @return
* @author Alvin
* @date 2019年6月6日 上午10:24:44
*/
@GetMapping("upgrade")
public String upgrade(){
return "upgrade";
}
}
package cn.com.glsx.dj.access.controller;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.com.glsx.dj.access.service.WechatPaymentService;
/**
* @Title: WechatPaymentController.java
* @Description: 微信支付
* @author Alvin
* @date 2019年6月25日 下午5:18:29
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@RestController
@RequestMapping("wechat/pay")
public class WechatPaymentController {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private WechatPaymentService wechatPaymentService;
/**
* 退款结果通知
* @param request
* @return
* @author Alvin
* @date 2019年6月25日 下午5:29:34
*/
@RequestMapping("refund/notify")
public String refundNotify(HttpServletRequest request){
try {
String notifyXml = IOUtils.toString(request.getInputStream());
return wechatPaymentService.refundNotify(notifyXml);
} catch (IOException e) {
logger.error(e.getMessage(), e);
return null;
}
}
}
package cn.com.glsx.dj.access.controller;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.com.glsx.dj.access.service.WorkWechatAccessService;
/**
* @Title: WorkWechatAccessController.java
* @Description:
* @author Alvin
* @date 2020年10月20日 上午11:25:07
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2020
*/
@Controller
@RequestMapping("work/wechat")
public class WorkWechatAccessController {
@Autowired
private WorkWechatAccessService workWechatAccessService;
/**
* 消息与事件处理
* @param request
* @param bizAppId
* @return
* @author Alvin
* @date 2019年5月5日 下午9:02:19
*/
@PostMapping("{agentId}/event")
@ResponseBody
public String event(HttpServletRequest request, @PathVariable("agentId") String agentId){
return workWechatAccessService.access(request, agentId);
}
/**
* 微信服务认证
* @param request
* @param bizAppId
* @return
* @author Alvin
* @date 2019年5月5日 下午9:02:19
*/
@GetMapping("{agentId}/event")
@ResponseBody
public String auth(HttpServletRequest request, @PathVariable("agentId") String agentId){
return workWechatAccessService.auth(request, agentId);
}
}
package cn.com.glsx.dj.access.service;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.io.IOUtils;
import org.oreframework.boot.autoconfigure.rop.metadata.RopProperty;
import org.oreframework.boot.autoconfigure.rop.util.RopClientUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
@Component
public class HuaweiPrivateNumberAccessService {
private Logger logger = LoggerFactory.getLogger(getClass());
private static final String ROP_CAR_BOUTIQUE_SERVER = "CBROP";
@Autowired
private RopProperty ropProperty;
@Autowired
private RopClientUtils ropClient;
public String access(HttpServletRequest request){
try{
String postData = IOUtils.toString(request.getInputStream());
logger.info("HuaweiPrivateNumberAccess.body:{}",postData);
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<String, String>();
paramsMap.add("body",postData);
return ropClient.builder(ropProperty.getServerConfig().get(ROP_CAR_BOUTIQUE_SERVER)).post(paramsMap, "dj.api.smartcarlife.privatenumber.access", "1.0.0");
}catch(Exception e){
logger.error("access failed:" + e.getMessage(), e);
}
return "fail";
}
}
package cn.com.glsx.dj.access.service;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import cn.com.glsx.dj.access.config.AccessProperty;
import cn.com.glsx.dj.access.util.WechatCore;
import cn.com.glsx.dj.wechat.enums.WechatAuthCategoryEnum;
import cn.com.glsx.dj.wechat.model.WechatConfig;
import cn.com.glsx.dj.wechat.remote.WechatAccessRemote;
import cn.com.glsx.dj.wechat.remote.WechatComponentAccessRemote;
import cn.com.glsx.dj.wechat.remote.WechatConfigRemote;
import cn.com.glsx.framework.core.beans.ResultEntity;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
/**
* @Title: WechatAccessService.java
* @Description: 微信接入消息服务
* @author Alvin.zengqi
* @date 2017年11月30日 下午3:14:37
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2015
*/
@Component
public class WechatAccessService{
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private WechatComponentAccessRemote wechatComponentAccessRemote;
@Autowired
private WechatAccessRemote wechatAccessRemote;
@Autowired
private AccessProperty property;
@Autowired
private WechatConfigRemote wechatConfigRemote;
/**
* 授权事件处理
* @param request
* @return
* @author Alvin.zengqi
* @date 2018年5月22日 下午6:20:08
*/
public boolean access(HttpServletRequest request){
try{
Map<String, String> requestParams = WechatCore.parseRequest(request);
String postData = IOUtils.toString(request.getInputStream());
RpcResponse<Boolean> response = wechatComponentAccessRemote.accessEventProcessor(requestParams, postData);
if(response.isSuccess()){
return response.getResult();
}
}catch(Exception e){
logger.error("access failed:" + e.getMessage(), e);
}
return false;
}
/**
* 消息与事件处理
* @param request
* @param appId
* @return
* @author Alvin
* @date 2019年5月5日 下午9:01:15
*/
public String access(HttpServletRequest request, String appId){
try{
Map<String, String> requestParams = WechatCore.parseRequest(request);
String postData = IOUtils.toString(request.getInputStream());
RpcResponse<String> response = wechatAccessRemote.eventProcessor(requestParams, postData, appId);
if(response.isSuccess()){
return response.getResult();
}
}catch(Exception e){
logger.error("access failed:" + e.getMessage(), e);
}
return "fail";
}
/**
* 微信服务认证
* @param request
* @param appId
* @return
* @author Alvin
* @date 2019年8月29日 上午11:30:33
*/
public String auth(HttpServletRequest request, String appId){
String token = property.getToken();
WechatConfig config = wechatConfigRemote.getByAppid(appId).getResult();
if(config != null && StringUtils.isNotBlank(config.getWechatToken())){
token = config.getWechatToken();
}
Map<String, String> requestParams = WechatCore.parseRequest(request);
boolean authFlag = WechatCore.verify(requestParams, token);
if(authFlag){
return request.getParameter("echostr");
}
return "401 Unauthorized";
}
/**
* 获取PC端授权路径
* @return
* @author Alvin
* @date 2019年3月12日 下午4:59:03
*/
public String getPCAuthPath(Integer merchantId, Integer authType){
RpcResponse<String> response = wechatComponentAccessRemote.getAuthPath(merchantId, authType, WechatAuthCategoryEnum.PC);
if(response.isSuccess()){
return response.getResult();
}
return null;
}
/**
* 获取移动端授权路径
* @return
* @author Alvin
* @date 2019年3月12日 下午4:59:10
*/
public ResultEntity<String> getH5AuthPath(Integer merchantId, Integer authType){
RpcResponse<String> response = wechatComponentAccessRemote.getAuthPath(merchantId, authType, WechatAuthCategoryEnum.H5);
return ResultEntity.result(response);
}
/**
* 授权回调
* @param authCode
* @param authType 1:公众号;2:小程序;3:公众号和小程序
* @param expiresIn
* @author Alvin
* @date 2019年3月12日 下午4:59:20
*/
public ResultEntity<Boolean> authCallback(Integer merchantId, Integer authType, String authCode){
RpcResponse<Boolean> response = wechatComponentAccessRemote.authCallback(merchantId, authType, authCode);
logger.info("merchantId:{}, authType:{}, authCode:{} auth callback response:{}", merchantId, authType, authCode, response);
return ResultEntity.result(response);
}
/**
* 获取快速注册小程序授权路径
* @param merchantId
* @param authorizerAppId
* @return
* @author Alvin
* @date 2019年3月23日 下午5:41:39
*/
public ResultEntity<String> getFastRegisterAuthPath(Integer merchantId, String authorizerAppId){
RpcResponse<String> response = wechatComponentAccessRemote.getFastRegisterAuthPath(merchantId, authorizerAppId);
return ResultEntity.result(response);
}
/**
* 快速注册小程序回调
* @param merchantId
* @param authorizerAppId
* @param ticket
* @return
* @author Alvin
* @date 2019年3月23日 下午7:17:39
*/
public ResultEntity<Boolean> fastRegisterCallback(Integer merchantId, String authorizerAppId, String ticket){
RpcResponse<Boolean> response = wechatComponentAccessRemote.fastRegisterAuthCallback(merchantId, authorizerAppId, ticket);
logger.info("merchantId:{}, authorizerAppId:{}, ticket:{} fast register callback response:{}", merchantId, authorizerAppId, ticket, response);
return ResultEntity.result(response);
}
}
\ No newline at end of file
package cn.com.glsx.dj.access.service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import cn.com.glsx.dj.payment.remote.WechatPaymentRemote;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
/**
* @Title: WechatPaymentService.java
* @Description: 微信支付
* @author Alvin
* @date 2019年6月25日 下午5:21:39
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@Component
public class WechatPaymentService {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private WechatPaymentRemote wechatPaymentRemote;
/**
* 退款结果通知
* @return
* @param requestContent 请求内容
* @author Alvin
* @date 2019年6月25日 下午5:30:31
*/
public String refundNotify(String notifyXml){
logger.info("refund notify xml:{}", notifyXml);
RpcResponse<String> response = wechatPaymentRemote.refundNotify(notifyXml);
logger.info("refund notify response:{}", response);
return response.getResult();
}
}
package cn.com.glsx.dj.access.service;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import cn.com.glsx.dj.access.util.WechatCore;
import cn.com.glsx.dj.wechat.model.WorkWechatAppConfig;
import cn.com.glsx.dj.wechat.remote.WorkWechatAccessRemote;
import cn.com.glsx.dj.wechat.remote.WorkWechatAppConfigRemote;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
/**
* @Title: WorkWechatAccessService.java
* @Description: 企业微信接入服务
* @author Alvin
* @date 2020年10月20日 上午11:26:03
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2020
*/
@Component
public class WorkWechatAccessService {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private WorkWechatAppConfigRemote workWechatAppConfigRemote;
@Autowired
private WorkWechatAccessRemote workWechatAccessRemote;
/**
* 消息与事件处理
* @param request
* @param agentId
* @return
* @author Alvin
* @date 2019年5月5日 下午9:01:15
*/
public String access(HttpServletRequest request, String agentId){
try{
Map<String, String> requestParams = WechatCore.parseRequest(request);
String postData = IOUtils.toString(request.getInputStream());
RpcResponse<String> response = workWechatAccessRemote.eventProcessor(requestParams, postData, agentId);
if(response.isSuccess()){
return response.getResult();
}
}catch(Exception e){
logger.error("access failed:" + e.getMessage(), e);
}
return "fail";
}
/**
* 企业微信服务认证
* @param request
* @param agentId
* @return
* @author Alvin
* @date 2019年8月29日 上午11:30:33
*/
public String auth(HttpServletRequest request, String agentId){
WorkWechatAppConfig config = workWechatAppConfigRemote.getByAgentId(agentId).getResult();
if(config == null || StringUtils.isEmpty(config.getAppToken())){
return "404 Config is null";
}
Map<String, String> requestParams = WechatCore.parseRequest(request);
boolean authFlag = WechatCore.verify(requestParams, config.getAppToken());
if(authFlag){
String echostr = request.getParameter("echostr");
RpcResponse<String> response = workWechatAccessRemote.decryptMsg(agentId, echostr);
if(response.hasResult()){
return response.getResult();
}
}
return "401 Unauthorized";
}
}
package cn.com.glsx.dj.access.util;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Formatter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.oreframework.commons.security.sign.SHA;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @Title: WechatCore.java
* @Description: 微信核心业务处理
* @author Alvin.zengqi
* @date 2015年9月28日 下午12:56:03
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2015
*/
public class WechatCore {
private static Logger logger = LoggerFactory.getLogger(WechatCore.class);
/**
* @Description: 验证请求来源是否为微信
* @param params
* @return
* @author Alvin.zengqi
* @date 2015年9月28日 下午1:06:38
*/
public static boolean verify(Map<String, String> params, String token) {
String signature = params.get("signature"), msgSignature = params.get("msg_signature"), timestamp = params
.get("timestamp"), nonce = params.get("nonce"), sign = "", echostr = params.get("echostr");
List<String> values = new ArrayList<String>();
if (StringUtils.isNotEmpty(timestamp)) {
values.add(timestamp);
}
if (StringUtils.isNotEmpty(nonce)) {
values.add(nonce);
}
// 企业微信加密签名参数为“msg_signature”,且echostr需要参与签名验证
if (StringUtils.isNotEmpty(echostr) && StringUtils.isNotEmpty(msgSignature)){
values.add(echostr);
}
values.add(token);
Collections.sort(values);
for (String value : values) {
sign += value;
}
signature = Optional.ofNullable(signature).orElse(msgSignature);
if (StringUtils.isNotEmpty(signature)
&& signature.equals(SHA.sign(sign))) {
return true;
}
return false;
}
/**
* 解析请求参数
* @Description:
* @param request
* @return
* @author Alvin.zengqi
* @date 2015年9月28日 下午1:06:24
*/
public static Map<String, String> parseRequest(HttpServletRequest request) {
Map<String, String> params = new HashMap<String, String>(16);
Enumeration<String> paramNames = request.getParameterNames();
String paramName;
while (paramNames.hasMoreElements()) {
paramName = paramNames.nextElement();
params.put(paramName, request.getParameter(paramName));
}
return params;
}
/**
* 生成微信JSSDK签名
* @param jsapi_ticket
* @param url
* @return
*/
public static Map<String, String> sign(String jsapiTicket, String url) {
Map<String, String> ret = new HashMap<String, String>(16);
String nonceStr = createNonceStr();
String timestamp = createTimestamp();
String string1;
String signature = "";
/*1.对所有待签名参数按照字段名的ASCII 码从小到大排序(字典序)后,使用URL键值对的格式
(即key1=value1&key2=value2…)拼接成字符串string1:*/
string1 = "jsapi_ticket=" + jsapiTicket + "&noncestr=" + nonceStr
+ "&timestamp=" + timestamp + "&url=" + url;
logger.info("string1=" + string1);
try {
//2.对string1进行sha1签名
MessageDigest crypt = MessageDigest.getInstance("SHA-1");
crypt.reset();
crypt.update(string1.getBytes("UTF-8"));
//3.生成签名
signature = byteToHex(crypt.digest());
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
//返回
ret.put("nonceStr", nonceStr);
ret.put("timestamp", timestamp);
ret.put("signature", signature);
logger.info("ret:{}", ret);
return ret;
}
/**
* 随机加密
* @param hash
* @return
*/
private static String byteToHex(final byte[] hash) {
Formatter formatter = new Formatter();
for (byte b : hash) {
formatter.format("%02x", b);
}
String result = formatter.toString();
formatter.close();
return result;
}
/**
* 产生随机串--由程序自己随机产生
* @return
*/
private static String createNonceStr() {
return UUID.randomUUID().toString();
}
/**
* 由程序自己获取当前时间
* @return
*/
private static String createTimestamp() {
return Long.toString(System.currentTimeMillis() / 1000);
}
}
# framework-archetype-webapp
运营平台项目骨架
一、项目结构说明:
└─src
├─main
├─java
├─cn.com.glsx.dj.access.config 配置层
├─cn.com.glsx.dj.access.controller 控制层
├─cn.com.glsx.dj.access.vo 视图对象
├─cn.com.glsx.dj.access.service 业务层
├─cn.com.glsx.dj.access.Main.java 程序入口
└─cn.com.glsx.dj.access.WebMvcConfigurer.java MVC拦截器配置类
├─resources 资源文件目录
├─config
├─application.properties 应用配置文件
├─templates 模板目录
└─*.flt freemarker模板,(可用于邮件模板)
└─logback.xml 日志配置文件
└─webapp web前端文件目录
├─static 静态文件
├─css 样式文件
├─images 图片文件
└─js JavaScript文件
└─common 公共js文件
├─views
└─model 模块文件夹
└─*.html 视图文件
└─WEB-INF
└─bin shell脚本文件(包含启动、停止、重启等)
└─test 测试目录
├─java
└─cn.com.glsx.dj.access/service 测试代码
└─resources 测试资源目录
└─pom.xml pom文件
二、使用说明:
1、运行项目前需在配置中心创建配置信息,配置内容参考三配置说明:
1.1> dataId : application.properties --> ore.diamond.dataId + ore.diamond.env
1.2> group : application.properties --> ore.diamond.group
1.3> content : 参考三配置说明
三、配置说明:
#----------------------------------------------------------------------------------------------------------
# 适配器配置
ore.adapter.enabled=true
# 是否开启请求日志拦截器
ore.adapter.request-log-interceptor=enabled
# 是否开启跨域访问
ore.adapter.cross-domain=enabled
#----------------------------------------------------------------------------------------------------------
# dubbo配置
# dubbo应用名称
ore.dubbo.application.name=web-dj-access
# dubbo应用所有者
ore.dubbo.application.owner=zengqi
# dubbo服务注册地址
ore.dubbo.registry.address=zookeeper://192.168.3.206:2181
# dubbo服务注册超时时间
ore.dubbo.registry.timeout=30000
# 默认协议:dubbo
ore.dubbo.protocol.name=dubbo
# dubbo服务扫描包路径
ore.dubbo.scan=cn.com.glsx.dj.access
#----------------------------------------------------------------------------------------------------------
# Freemarker模板配置
# 模板存放路径
spring.freemarker.template-loader-path=classpath:/templates/
# 是否开启模板缓存,默认是开启,开发时请关闭
spring.freemarker.cache=false
# 模板的编码设置,默认UTF-8
spring.freemarker.charset=UTF-8
# 是否检测模板已存在本地
spring.freemarker.check-template-location=true
# 模板的媒体类型设置,默认为text/html
spring.freemarker.content-type=text/html
spring.freemarker.expose-request-attributes=true
spring.freemarker.expose-session-attributes=true
spring.freemarker.request-context-attribute=request
# 后缀设置,默认为.ftl
spring.freemarker.suffix=.ftl
┌------------------------------------------------------------┐
注:如需使用freemarker需在pom中添加如下依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
└------------------------------------------------------------┘
#----------------------------------------------------------------------------------------------------------
# Thymeleaf模板配置
# 是否开启模板缓存,默认是开启,开发时请关闭
spring.thymeleaf.cache=true
# 是否检测模板已存在本地
spring.thymeleaf.check-template-location=true
# 模板的媒体类型设置,默认为text/html
spring.thymeleaf.content-type=text/html
# 模板开关
spring.thymeleaf.enabled=true
# 模板的编码设置,默认UTF-8
spring.thymeleaf.encoding=UTF-8
# 排除的视图
spring.thymeleaf.excluded-view-names=
# 模板模式设置,默认为HTML5严格检查;LEGACYHTML5更友好的格式,适用于Vue.js和AngularJs等js库
spring.thymeleaf.mode=HTML5
# 前缀设置,SpringBoot默认模板放置在classpath:/templates/目录下
spring.thymeleaf.prefix=/views/
# 后缀设置,默认为.html
spring.thymeleaf.suffix=.html
┌----------------------------------------------------------------------------------------┐
注:如需使用thymeleaf需在pom中添加如下依赖,且需排除thymelear对springboot的依赖,否则引起包冲突,导致diamond配置不加载
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
注:如模板模式设置为LEGACYHTML5,则需在pom中添加如下依赖
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
</dependency>
└----------------------------------------------------------------------------------------┘
#----------------------------------------------------------------------------------------------------------
# 上传文件大小配置
spring.http.multipart.max-file-size=5MB
spring.http.multipart.max-request-size=5MB
server.port=7001
server.display-name=web-dj-access
server.servlet.context-path=/web-dj-access
server.servlet.application-display-name=web-dj-access
logging.config=classpath:logback.xml
logging.path=/data/java_log/jetty/web-dj-access/web-dj-access.log
logging.level.root=INFO
ore.starter.class-name=Main
# diamond config
ore.diamond.group=dijia
ore.diamond.dataId=web-dj-access
ore.diamond.env=release
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<property resource="config/application.properties" />
<property name="APP_NAME" value="${server.display-name}" />
<property name="LOG_PATH" value="${logging.path}" />
<property name="LOG_LEVEL" value="${logging.level}" />
<contextName>${APP_NAME}</contextName>
<turboFilter class="org.oreframework.boot.logging.logback.OreBootTurboFilter">
<Marker>oreframework</Marker>
</turboFilter>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [${APP_NAME}] [%thread] %-5level [%logger{36}.%method %line] - %msg%n</pattern>
</pattern>
</layout>
</appender>
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- <Encoding> Label Old version of this label can not be used -->
<!-- <Encoding>UTF-8</Encoding> -->
<File>${LOG_PATH}</File>
<!-- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> -->
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<FileNamePattern>${LOG_PATH}.%d{yyyy-MM-dd}.%i</FileNamePattern>
<MaxHistory>15</MaxHistory>
<maxFileSize>200MB</maxFileSize>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} ${APP_NAME}] [%thread] %-5level [%logger{36}.%method %line] - %msg%n</pattern>
</layout>
<!-- 根据文件大小滚动,不支持 SizeBasedTriggeringPolicy 这种配置-->
<!-- <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>200MB</MaxFileSize>
</triggeringPolicy> -->
</appender>
<root level="${LOG_LEVEL}">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>
\ No newline at end of file
#!/bin/bash
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/classes
SERVER_NAME=`sed '/application.name/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
#LOGS_FILE=`sed '/log4j.appender.logToFile.File/!d;s/.*=//' classes/log4j.properties | tr -d '\r'`
LOGS_FILE=`sed '/name="LOG_PATH"/!d;s/.*value="\(.*\)".*/\1/g' classes/logback.xml`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -z "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME does not started!"
exit 1
fi
LOGS_DIR=""
if [ -n "$LOGS_FILE" ]; then
LOGS_DIR=`dirname $LOGS_FILE`
else
LOGS_DIR=$DEPLOY_DIR/logs
fi
if [ ! -d $LOGS_DIR ]; then
mkdir $LOGS_DIR
fi
DUMP_DIR=$LOGS_DIR/dump
if [ ! -d $DUMP_DIR ]; then
mkdir $DUMP_DIR
fi
DUMP_DATE=`date +%Y%m%d%H%M%S`
DATE_DIR=$DUMP_DIR/$DUMP_DATE
if [ ! -d $DATE_DIR ]; then
mkdir $DATE_DIR
fi
echo -e "Dumping the $SERVER_NAME ...\c"
for PID in $PIDS ; do
jstack $PID > $DATE_DIR/jstack-$PID.dump 2>&1
echo -e ".\c"
jinfo $PID > $DATE_DIR/jinfo-$PID.dump 2>&1
echo -e ".\c"
jstat -gcutil $PID > $DATE_DIR/jstat-gcutil-$PID.dump 2>&1
echo -e ".\c"
jstat -gccapacity $PID > $DATE_DIR/jstat-gccapacity-$PID.dump 2>&1
echo -e ".\c"
jmap $PID > $DATE_DIR/jmap-$PID.dump 2>&1
echo -e ".\c"
jmap -heap $PID > $DATE_DIR/jmap-heap-$PID.dump 2>&1
echo -e ".\c"
jmap -histo $PID > $DATE_DIR/jmap-histo-$PID.dump 2>&1
echo -e ".\c"
if [ -r /usr/sbin/lsof ]; then
/usr/sbin/lsof -p $PID > $DATE_DIR/lsof-$PID.dump
echo -e ".\c"
fi
done
if [ -r /bin/netstat ]; then
/bin/netstat -an > $DATE_DIR/netstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/iostat ]; then
/usr/bin/iostat > $DATE_DIR/iostat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/mpstat ]; then
/usr/bin/mpstat > $DATE_DIR/mpstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/vmstat ]; then
/usr/bin/vmstat > $DATE_DIR/vmstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/free ]; then
/usr/bin/free -t > $DATE_DIR/free.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/sar ]; then
/usr/bin/sar > $DATE_DIR/sar.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/uptime ]; then
/usr/bin/uptime > $DATE_DIR/uptime.dump 2>&1
echo -e ".\c"
fi
echo "OK!"
echo "DUMP: $DATE_DIR"
#!/bin/bash
ENV=$1
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
cd `dirname $0`
./stop.sh
./start.sh $ENV
\ No newline at end of file
#!/bin/bash
cd `dirname $0`
if [ "$1" = "start" ]; then
ENV=$2
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
./start.sh $ENV
else
if [ "$1" = "stop" ]; then
./stop.sh
else
if [ "$1" = "debug" ]; then
ENV=$2
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
./start.sh $ENV debug
else
if [ "$1" = "restart" ]; then
ENV=$2
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
./restart.sh $ENV
else
if [ "$1" = "dump" ]; then
./dump.sh
else
echo "ERROR: Please input argument: start or stop or debug or restart or dump"
exit 1
fi
fi
fi
fi
fi
#!/bin/bash
JAVA_HOME="/app/soft/jdk1.8.0_20"
ENV=$1
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/classes
SERVER_NAME=`sed '/server.display-name/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
SERVER_PORT=`sed '/server.port/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
#LOGS_FILE=`sed '/log4j.appender.logToFile.File/!d;s/.*=//' classes/log4j.properties | tr -d '\r'`
LOGS_FILE=`sed '/logging.path/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
echo "server name is $SERVER_NAME"
echo "server port is $SERVER_PORT"
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -n "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME already started!"
echo "PID: $PIDS"
exit 1
fi
if [ -n "$SERVER_PORT" ]; then
SERVER_PORT_COUNT=`netstat -tln | grep $SERVER_PORT | wc -l`
if [ $SERVER_PORT_COUNT -gt 0 ]; then
echo "ERROR: The $SERVER_NAME port $SERVER_PORT already used!"
exit 1
fi
fi
LOGS_DIR=""
if [ -n "$LOGS_FILE" ]; then
LOGS_DIR=`dirname $LOGS_FILE`
else
LOGS_DIR=$DEPLOY_DIR/logs
fi
if [ ! -d $LOGS_DIR ]; then
mkdir $LOGS_DIR
fi
STDOUT_FILE=$LOGS_DIR/stdout.log
LIB_DIR=$DEPLOY_DIR/lib
LIB_JARS=`ls $LIB_DIR|grep .jar|awk '{print "'$LIB_DIR'/"$0}'|tr "\n" ":"`
JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
JAVA_DEBUG_OPTS=""
if [ "$2" = "debug" ]; then
JAVA_DEBUG_OPTS=" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n "
fi
JAVA_JMX_OPTS=""
if [ "$2" = "jmx" ]; then
JAVA_JMX_OPTS=" -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "
fi
JAVA_MEM_OPTS=""
BITS=`file $JAVA_HOME/bin/java | grep 64-bit`
if [ -n "$BITS" ]; then
JAVA_MEM_OPTS=" -server -Xmx1g -Xms1g -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
else
JAVA_MEM_OPTS=" -server -Xms1024m -Xmx1024m -XX:PermSize=128m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
fi
echo -e "Starting the $SERVER_NAME ...\c"
nohup $JAVA_HOME/bin/java $JAVA_OPTS $JAVA_MEM_OPTS $JAVA_DEBUG_OPTS $JAVA_JMX_OPTS -classpath $CONF_DIR:$LIB_JARS org.oreframework.boot.bootstrap.OreBootApplication env=$ENV > $STDOUT_FILE 2>&1 &
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
if [ -n "$SERVER_PORT" ]; then
COUNT=`netstat -an | grep $SERVER_PORT | wc -l`
else
COUNT=`ps --no-heading -C java -f --width 1000 | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l`
fi
if [ $COUNT -gt 0 ]; then
break
fi
done
echo "OK!"
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$DEPLOY_DIR" | awk '{print $2}'`
echo "PID: $PIDS"
echo "STDOUT: $STDOUT_FILE"
#!/bin/bash
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/classes
SERVER_NAME=`sed '/application.name/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -z "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME does not started!"
exit 1
fi
#if [ "$1" != "skip" ]; then
#$BIN_DIR/dump.sh
#fi
echo -e "Stopping the $SERVER_NAME ...\c"
for PID in $PIDS ; do
kill $PID > /dev/null 2>&1
done
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
COUNT=1
for PID in $PIDS ; do
PID_EXIST=`ps --no-heading -p $PID`
if [ -n "$PID_EXIST" ]; then
COUNT=0
break
fi
done
done
echo "OK!"
echo "PID: $PIDS"
No preview for this file type
No preview for this file type
function rem(win, option) {
var count = 0,
designWidth = option.designWidth,
designHeight = option.designHeight || 0,
designFontSize = option.designFontSize || 20,
callback = option.callback || null,
root = document.documentElement,
body = document.body,
rootWidth, newSize, t, self;
//返回root元素字体计算结果
function _getNewFontSize() {
var scale = designHeight !== 0 ? Math.min(win.innerWidth / designWidth, win.innerHeight / designHeight) : win.innerWidth / designWidth;
return parseInt( scale * 10000 * designFontSize ) / 10000;
}
!function () {
rootWidth = root.getBoundingClientRect().width;
self = self ? self : arguments.callee;
//如果此时屏幕宽度不准确,就尝试再次获取分辨率,只尝试20次,否则使用win.innerWidth计算
if( rootWidth !== win.innerWidth && count < 20 ) {
win.setTimeout(function () {
count++;
self();
}, 0);
} else {
newSize = _getNewFontSize();
//如果css已经兼容当前分辨率就不管了
if( newSize + 'px' !== getComputedStyle(root)['font-size'] ) {
root.style.fontSize = newSize + "px";
return callback && callback(newSize);
};
};
}();
//横竖屏切换的时候改变fontSize,根据需要选择使用
win.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", function() {
clearTimeout(t);
t = setTimeout(function () {
self();
}, 200);
}, false);
}(window, {
designWidth: 750,
designHeight: 667,
designFontSize: 200,
callback: function (argument) {
//console.log(argument)
}
})
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="context-path" th:content="@{/}" />
<title>微信授权</title>
</head>
<body>
<a href="/wechat/wxauth/agent/10000_1" th:href="@{/wechat/wxauth/agent/10000_1}" target="_blank">点击进行公众号授权</a>
<br><br><br>
<a href="/wechat/wxauth/agent/10000_2" th:href="@{/wechat/wxauth/agent/10000_2}" target="_blank">点击进行小程序授权</a>
<br><br><br>
<a href="/wechat/fastregister/auth/agent/10000/wx08a8455485543f1a" th:href="@{/wechat/fastregister/auth/agent/10000/wx08a8455485543f1a}" target="_blank">嘀嘀虎无忧宝快速注册小程序授权</a>
<a href="/wechat/fastregister/auth/agent/10001/wx08a8455485543f1a" th:href="@{/wechat/fastregister/auth/agent/10001/wx08a8455485543f1a}" target="_blank">嘀嘀虎无忧宝快速注册小程序授权</a>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="context-path" th:content="@{/}" />
<title>微信授权成功</title>
<script th:inline="javascript">
var msg = [[${msg}]];
if(msg && msg.length > 0){
alert(msg);
}
window.close();
</script>
</head>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="context-path" th:content="@{/}" />
<title>微信授权成功</title>
</head>
<script type="text/javascript">
window.close();
</script>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="context-path" th:content="@{/}" />
<title>微信授权成功</title>
<script th:inline="javascript">
var msg = [[${msg}]];
if(msg && msg.length > 0){
alert(msg);
}
window.close();
</script>
</head>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="context-path" th:content="@{/}" />
<script src="/static/js/common/rem.js" th:src="@{/static/js/common/rem.js}"></script>
<script src="/static/js/common/jquery.min.js" th:src="@{/static/js/common/jquery.min.js}"></script>
<title>升级提示</title>
</head>
<body>
<div class="layout">
<div class="img">
<img src="/static/images/err.png" th:attr="src=@{/static/images/err.png}"/>
</div>
<div>您当前的微信版本过低,无法访问小程序</div>
<div>请对微信进行升级!</div>
</div>
</body>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
.layout {
text-align: center;
padding-top: 0.4rem;
}
.layout .img {
margin-bottom: 0;
}
.layout img {
width: 0.8rem;
height: 0.8rem;
margin-bottom: 0.2rem;
vertical-align: top;
}
.layout div {
margin-bottom: 0.06rem;
font-size: 0.14rem;
color: #999999;
}
</style>
<script type="text/javascript">
$(function() {
rem(window, {
designWidth : 750,
designHeight : 667,
designFontSize : 200
})
})
</script>
</html>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!