Skip to content

Commit bf0324f

Browse files
committed
Optz wx-apps add gatewayy service
1 parent cf89e34 commit bf0324f

File tree

120 files changed

+9216
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+9216
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.settings/
2+
/.project

pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,8 @@
147147
</dependency>
148148
</dependencies>
149149

150+
<modules>
151+
<module>wx-app-gateway</module>
152+
<module>wx-app-service</module>
153+
</modules>
150154
</project>

wx-app-core/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
/target/
2+
/.settings/
3+
/.classpath
4+
/.project

wx-app-gateway/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#IGNORED by JASON
2+
/target/
3+
/.settings/
4+
/.classpath
5+
/.project

wx-app-gateway/pom.xml

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
<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">
2+
<modelVersion>4.0.0</modelVersion>
3+
4+
<!-- PARENT PROJECT -->
5+
<parent>
6+
<groupId>cn.ucaner</groupId>
7+
<artifactId>wx-app</artifactId>
8+
<version>1.0.1-TINA</version>
9+
</parent>
10+
11+
<!-- WX-APP-GATEWAY -->
12+
<artifactId>wx-app-gateway</artifactId>
13+
<name>wx-app-gateway</name>
14+
<description>对外和对内提供api接口服务基于 service 层的逻辑controller层 提供RESTful接口</description>
15+
16+
<!-- PROPERTIES -->
17+
<properties>
18+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
20+
<!--PROPERTIES节点中设置docker镜像的前缀 'wx-app' -->
21+
<docker.image.prefix>wx-app-gateway</docker.image.prefix>
22+
</properties>
23+
24+
25+
<!-- PROJECT DEPENDENCIES -->
26+
<dependencies>
27+
<!-- wx-apps-service 包含core -->
28+
<dependency>
29+
<groupId>cn.ucaner</groupId>
30+
<artifactId>wx-app-service</artifactId>
31+
<version>1.0.1-TINA</version>
32+
</dependency>
33+
34+
<!-- jwt https://github.com/jwtk/jjwt -->
35+
<dependency>
36+
<groupId>com.auth0</groupId>
37+
<artifactId>java-jwt</artifactId>
38+
<version>3.3.0</version>
39+
</dependency>
40+
41+
<!-- shiro 权限控制 -->
42+
<dependency>
43+
<groupId>org.apache.shiro</groupId>
44+
<artifactId>shiro-spring</artifactId>
45+
<version>1.4.0</version>
46+
<exclusions>
47+
<exclusion>
48+
<artifactId>slf4j-api</artifactId>
49+
<groupId>org.slf4j</groupId>
50+
</exclusion>
51+
</exclusions>
52+
</dependency>
53+
<!-- shiro ehcache (shiro缓存)-->
54+
<dependency>
55+
<groupId>org.apache.shiro</groupId>
56+
<artifactId>shiro-ehcache</artifactId>
57+
<version>1.4.0</version>
58+
<exclusions>
59+
<exclusion>
60+
<artifactId>slf4j-api</artifactId>
61+
<groupId>org.slf4j</groupId>
62+
</exclusion>
63+
</exclusions>
64+
</dependency>
65+
66+
<!-- javax.mail 邮件推送 -->
67+
<dependency>
68+
<groupId>org.springframework.boot</groupId>
69+
<artifactId>spring-boot-starter-mail</artifactId>
70+
</dependency>
71+
72+
<!-- looging 日志 -->
73+
<dependency>
74+
<groupId>org.springframework.boot</groupId>
75+
<artifactId>spring-boot-starter-logging</artifactId>
76+
</dependency>
77+
78+
<!-- 小程序支付
79+
<dependency>
80+
<groupId>com.github.binarywang</groupId>
81+
<artifactId>weixin-java-pay</artifactId>
82+
</dependency>
83+
84+
<dependency>
85+
<groupId>com.github.binarywang</groupId>
86+
<artifactId>weixin-java-miniapp</artifactId>
87+
</dependency> -->
88+
89+
<!-- 导入后配置可以实现提示功能 -->
90+
<dependency>
91+
<groupId>org.springframework.boot</groupId>
92+
<artifactId>spring-boot-configuration-processor</artifactId>
93+
<optional>true</optional>
94+
</dependency>
95+
96+
</dependencies>
97+
98+
99+
<!-- BUILD PROJECT -->
100+
<build>
101+
<!-- PACKAGE SOURCE LOCATION -->
102+
<resources>
103+
<resource>
104+
<directory>src/main/resources</directory>
105+
</resource>
106+
<resource>
107+
<directory>src/main/java</directory>
108+
<includes>
109+
<include>**/*.properties</include>
110+
<include>**/*.xml</include>
111+
</includes>
112+
<filtering>false</filtering>
113+
</resource>
114+
</resources>
115+
116+
<!-- SpringBoot 打包插件 web[war]应用打包为exec.jar 加入application主线程的jar包 -->
117+
<!-- Linux 启动 nohup java -jar xxx.exec.jar & -->
118+
<!-- 后期计划结合Jenkins SonarQube 实现持续化集成环境 + 代码质量检测 by WanGuo -->
119+
<plugins>
120+
121+
<plugin>
122+
<groupId>org.springframework.boot</groupId>
123+
<artifactId>spring-boot-maven-plugin</artifactId>
124+
<configuration>
125+
<executable>true</executable>
126+
</configuration>
127+
<executions>
128+
<execution>
129+
<goals>
130+
<goal>repackage</goal>
131+
</goals>
132+
<configuration>
133+
<classifier>exec</classifier>
134+
</configuration>
135+
</execution>
136+
</executions>
137+
</plugin>
138+
139+
<!-- docker-maven-plugin -->
140+
<plugin>
141+
<groupId>com.spotify</groupId>
142+
<artifactId>docker-maven-plugin</artifactId>
143+
<version>0.4.13</version>
144+
<configuration>
145+
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
146+
<dockerDirectory>src/main/docker</dockerDirectory>
147+
<resources>
148+
<resource>
149+
<targetPath>/</targetPath>
150+
<directory>${project.build.directory}</directory>
151+
<include>${project.build.finalName}.jar</include>
152+
</resource>
153+
</resources>
154+
</configuration>
155+
</plugin>
156+
</plugins>
157+
</build>
158+
</project>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package cn.ucaner.wx.app.gateway;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.scheduling.annotation.EnableScheduling;
6+
import org.springframework.transaction.annotation.EnableTransactionManagement;
7+
8+
/**
9+
* @Package:cn.ucaner.wx.app.gateway
10+
* @ClassName:Application
11+
* @Description: <p> Application </p>
12+
* @Author: - Jason
13+
* @CreatTime:2018年11月2日 上午10:55:00
14+
* @Modify By:
15+
* @ModifyTime: 2018年11月2日
16+
* @Modify marker:
17+
* @version V1.0
18+
*/
19+
@SpringBootApplication(scanBasePackages={"cn.ucaner.wx.app.core","cn.ucaner.wx.app.service" ,"cn.ucaner.wx.app.gateway"})
20+
@EnableTransactionManagement
21+
@EnableScheduling
22+
public class Application {
23+
24+
public static void main(String[] args) {
25+
SpringApplication.run(Application.class, args);
26+
}
27+
28+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package cn.ucaner.wx.app.gateway.annotation;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
/**
9+
* @Package:cn.ucaner.wx.app.gateway.annotation
10+
* @ClassName:LoginUser
11+
* @Description: <p> LoginUser </p>
12+
* @Author: - Jason
13+
* @CreatTime:2018年11月2日 上午9:26:46
14+
* @Modify By:
15+
* @ModifyTime: 2018年11月2日
16+
* @Modify marker:
17+
* @version V1.0
18+
*/
19+
@Target(ElementType.PARAMETER)
20+
@Retention(RetentionPolicy.RUNTIME)
21+
public @interface LoginUser {
22+
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package cn.ucaner.wx.app.gateway.annotation.support;
2+
3+
import org.springframework.core.MethodParameter;
4+
import org.springframework.web.bind.support.WebDataBinderFactory;
5+
import org.springframework.web.context.request.NativeWebRequest;
6+
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
7+
import org.springframework.web.method.support.ModelAndViewContainer;
8+
9+
import cn.ucaner.wx.app.gateway.annotation.LoginUser;
10+
11+
/**
12+
* @Package:cn.ucaner.wx.app.gateway.annotation.support
13+
* @ClassName:LoginUserHandlerMethodArgumentResolver
14+
* @Description: <p> SpringMVC3.1引入了HandlerMethodArgumentResolver接口,Spring调用该接口实现Controller的参数装配 </p>
15+
* <code> 对参数进行判断,达到鉴权的效果 or 考虑采用 filter的方式 判断 是否放行 SpringMvc </code>
16+
* @Author: - Jason
17+
* @CreatTime:2018年11月2日 上午9:27:27
18+
* @Modify By:
19+
* @ModifyTime: 2018年11月2日
20+
* @Modify marker:
21+
* @version V1.0
22+
*/
23+
public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver {
24+
25+
/**
26+
* 登录的cookie标志位
27+
*/
28+
public static final String LOGIN_TOKEN_KEY = "loginToken";
29+
30+
31+
@Override
32+
public boolean supportsParameter(MethodParameter parameter) {
33+
return parameter.getParameterType().isAssignableFrom(String.class) && parameter.hasParameterAnnotation(LoginUser.class);
34+
}
35+
36+
@Override
37+
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer container,NativeWebRequest request, WebDataBinderFactory factory) throws Exception {
38+
39+
//这里做是否登录的逻辑判断
40+
41+
return "wubin@wanguo.com";
42+
}
43+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
//package cn.ucaner.wx.app.gateway.config;
2+
//
3+
//import org.apache.catalina.Context;
4+
//import org.apache.catalina.connector.Connector;
5+
//import org.apache.tomcat.util.descriptor.web.SecurityCollection;
6+
//import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
7+
//import org.springframework.beans.factory.annotation.Value;
8+
//import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
9+
//import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
10+
//import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
11+
//import org.springframework.boot.context.embedded.Ssl;
12+
//import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
13+
//import org.springframework.context.annotation.Bean;
14+
//
15+
///**
16+
//* @Package:cn.ucaner.wx.app.gateway.config
17+
//* @ClassName:HttpsConfiguration
18+
//* @Description: <p> HttpsConfiguration 配置https ssl if 网站需要用https的话 配合nginx使用 </p>
19+
//* @Author: - Jason
20+
//* @CreatTime:2018年11月2日 上午9:27:58
21+
//* @Modify By:
22+
//* @ModifyTime: 2018年11月2日
23+
//* @Modify marker:
24+
//* @version V1.0
25+
// */
26+
////@Configuration
27+
////havingValue 相同时候才加载配置文件
28+
////@ConditionalOnProperty(name = "enable", havingValue = "true",prefix="https",matchIfMissing=false)
29+
//public class HttpsConfiguration {
30+
//
31+
// /**
32+
// * http 端口
33+
// */
34+
// @Value("${https.httpPort}")
35+
// private Integer httpPort;
36+
//
37+
// /**
38+
// * https端口
39+
// */
40+
// @Value("${https.httpsPort}")
41+
// private Integer httpsPort;
42+
//
43+
// /**
44+
// * 证书密码配置
45+
// */
46+
// @Value("${https.cerPwd}")
47+
// private String cerPwd;
48+
//
49+
// /**
50+
// * 证书路径配置 /data/cer/server.jks
51+
// */
52+
// @Value("${https.cerPath}")
53+
// private String cerPath;
54+
//
55+
// /**
56+
// * @Description: containerCustomizer
57+
// * @return EmbeddedServletContainerCustomizer
58+
// * @Autor: Jason
59+
// */
60+
// @Bean
61+
// public EmbeddedServletContainerCustomizer containerCustomizer() {
62+
// return new EmbeddedServletContainerCustomizer() {
63+
// @Override
64+
// public void customize(ConfigurableEmbeddedServletContainer container) {
65+
// Ssl ssl = new Ssl();
66+
// // Server.jks中包含服务器私钥和证书
67+
// ssl.setKeyStore(cerPath);
68+
// ssl.setKeyStorePassword(cerPwd);
69+
// container.setSsl(ssl);
70+
// container.setPort(8443);
71+
// }
72+
// };
73+
// }
74+
//
75+
// /**
76+
// * @Description: servletContainerFactory
77+
// * @return EmbeddedServletContainerFactory
78+
// * @Autor: Jason
79+
// */
80+
// @Bean
81+
// public EmbeddedServletContainerFactory servletContainerFactory() {
82+
// TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory() {
83+
// @Override
84+
// protected void postProcessContext(Context context) {
85+
// SecurityConstraint securityConstraint = new SecurityConstraint();
86+
// securityConstraint.setUserConstraint("CONFIDENTIAL");//Confidential 保密
87+
// SecurityCollection collection = new SecurityCollection();
88+
// collection.addPattern("/*");
89+
// securityConstraint.addCollection(collection);
90+
// context.addConstraint(securityConstraint);
91+
// }
92+
// };
93+
// factory.addAdditionalTomcatConnectors(createHttpConnector());
94+
// return factory;
95+
// }
96+
//
97+
// /**
98+
// * @Description: createHttpConnector
99+
// * @return Connector
100+
// * @Autor: Jason
101+
// */
102+
// private Connector createHttpConnector() {
103+
// Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
104+
// connector.setScheme("http");
105+
// connector.setSecure(false);
106+
// connector.setPort(httpPort);
107+
// connector.setRedirectPort(httpsPort);
108+
// return connector;
109+
// }
110+
//}

0 commit comments

Comments
 (0)