Skip to content

Commit

Permalink
依赖升级
Browse files Browse the repository at this point in the history
  • Loading branch information
fayu.nie committed Dec 15, 2020
1 parent 070682a commit 6fd68f8
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 117 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- wx-api是一个轻量级的公众号开发种子项目,可快速接入微信公众号管理功能
- 管理后台前端项目wx-manage:https://github.com/niefy/wx-manage
- 移动端示例wx-client: https://github.com/niefy/wx-client
- swagger文档(启动wx-api后查看):http://localhost:8088/wx/swagger-ui.html
- swagger文档(启动wx-api后查看):http://localhost:8088/wx/swagger-ui/index.html

## [开发环境启动文档](https://www.yuque.com/nifury/wx/guobb7)
## [生产环境部署步骤](https://www.yuque.com/nifury/wx/ofehhv)
Expand Down
37 changes: 13 additions & 24 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,32 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.niefy</groupId>
<artifactId>wx-api</artifactId>
<version>0.7.1</version>
<version>0.8.1</version>
<packaging>jar</packaging>
<description>wx-api</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<version>2.4.1</version>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<mybatisplus.version>3.3.2</mybatisplus.version>
<mybatisplus.version>3.4.1</mybatisplus.version>
<mysql.version>8.0.17</mysql.version>
<druid.version>1.1.22</druid.version>
<shiro.version>1.5.3</shiro.version>
<shiro.version>1.7.0</shiro.version>
<jwt.version>0.9.1</jwt.version>
<kaptcha.version>0.0.9</kaptcha.version>
<qiniu.version>7.2.29</qiniu.version>
<aliyun.oss.version>3.9.1</aliyun.oss.version>
<qcloud.cos.version>5.6.24</qcloud.cos.version>
<swagger.version>2.9.2</swagger.version>
<fastjson.version>1.2.70</fastjson.version>
<lombok.version>1.18.10</lombok.version>
<weixin-java.version>3.8.0</weixin-java.version>
<swagger.version>3.0.0</swagger.version>
<fastjson.version>1.2.75</fastjson.version>
<lombok.version>1.18.16</lombok.version>
<weixin-java.version>4.0.0</weixin-java.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -72,11 +71,6 @@
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
Expand All @@ -99,12 +93,7 @@
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<artifactId>springfox-boot-starter</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
Expand Down Expand Up @@ -181,9 +170,9 @@

<repositories>
<repository>
<id>public</id>
<name>aliyun nexus</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<id>aliyunmaven</id>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
Expand All @@ -193,7 +182,7 @@
<pluginRepository>
<id>public</id>
<name>aliyun nexus</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/github/niefy/common/utils/IPUtils.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.github.niefy.common.utils;

import com.alibaba.druid.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;

import javax.servlet.http.HttpServletRequest;

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/github/niefy/config/MybatisPlusConfig.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.niefy.config;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

Expand All @@ -15,8 +15,8 @@ public class MybatisPlusConfig {
* 分页插件
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
public MybatisPlusInterceptor paginationInterceptor() {
return new MybatisPlusInterceptor();
}

}
15 changes: 4 additions & 11 deletions src/main/java/com/github/niefy/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,29 @@
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.ApiKey;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.List;

import static com.google.common.collect.Lists.newArrayList;

@Configuration
@EnableSwagger2
@EnableOpenApi
public class SwaggerConfig implements WebMvcConfigurer {

@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
return new Docket(DocumentationType.OAS_30)
.apiInfo(apiInfo())
.select()
//加了ApiOperation注解的类,才生成接口文档
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
.paths(PathSelectors.any())
.build()
.securitySchemes(security());
.build();
}

private ApiInfo apiInfo() {
Expand All @@ -41,10 +40,4 @@ private ApiInfo apiInfo() {
.build();
}

private List<ApiKey> security() {
return newArrayList(
new ApiKey("token", "token", "header")
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.common.bean.WxOAuth2UserInfo;
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -51,7 +52,7 @@ public R codeToOpenid(HttpServletRequest request, HttpServletResponse response,
@CookieValue String appid, @RequestBody WxH5OuthrizeForm form) {
try {
this.wxMpService.switchoverTo(appid);
WxMpOAuth2AccessToken token = wxMpService.oauth2getAccessToken(form.getCode());
WxOAuth2AccessToken token = wxMpService.getOAuth2Service().getAccessToken(form.getCode());
String openid = token.getOpenId();
CookieUtil.setCookie(response, "openid", openid, 365 * 24 * 60 * 60);
String openidToken = MD5Util.getMd5AndSalt(openid);
Expand All @@ -78,9 +79,9 @@ public R codeToUserInfo(HttpServletRequest request, HttpServletResponse response
@CookieValue String appid, @RequestBody WxH5OuthrizeForm form) {
try {
this.wxMpService.switchoverTo(appid);
WxMpOAuth2AccessToken token = wxMpService.oauth2getAccessToken(form.getCode());
WxMpUser userInfo = wxMpService.oauth2getUserInfo(token,"zh_CN");
String openid = userInfo.getOpenId();
WxOAuth2AccessToken token = wxMpService.getOAuth2Service().getAccessToken(form.getCode());
WxOAuth2UserInfo userInfo = wxMpService.getOAuth2Service().getUserInfo(token,"zh_CN");
String openid = userInfo.getOpenid();
CookieUtil.setCookie(response, "openid", openid, 365 * 24 * 60 * 60);
String openidToken = MD5Util.getMd5AndSalt(openid);
CookieUtil.setCookie(response, "openidToken", openidToken, 365 * 24 * 60 * 60);
Expand Down
31 changes: 23 additions & 8 deletions src/main/java/com/github/niefy/modules/wx/entity/WxUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.baomidou.mybatisplus.annotation.IdType;
import com.github.niefy.common.utils.Json;
import lombok.Data;
import me.chanjar.weixin.common.bean.WxOAuth2UserInfo;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.springframework.util.StringUtils;

Expand Down Expand Up @@ -52,20 +53,34 @@ public WxUser(String openid) {
public WxUser(WxMpUser wxMpUser,String appid) {
this.openid = wxMpUser.getOpenId();
this.appid = appid;
this.subscribe=wxMpUser.getSubscribe();
if(wxMpUser.getSubscribe()){
this.subscribe=wxMpUser.getSubscribe();
if(wxMpUser.getSubscribe()){
this.nickname = wxMpUser.getNickname();
this.sex = wxMpUser.getSex();
this.city = wxMpUser.getCity();
this.province = wxMpUser.getProvince();
this.headimgurl = wxMpUser.getHeadImgUrl();
this.subscribeTime = new Date(wxMpUser.getSubscribeTime()*1000);
this.unionid=wxMpUser.getUnionId();
this.remark=wxMpUser.getRemark();
this.tagidList=JSONArray.parseArray(JSONObject.toJSONString(wxMpUser.getTagIds()));
this.subscribeScene=wxMpUser.getSubscribeScene();
String qrScene = wxMpUser.getQrScene();
this.qrSceneStr= StringUtils.isEmpty(qrScene) ? wxMpUser.getQrSceneStr() : qrScene;
}
}

public WxUser(WxOAuth2UserInfo wxMpUser, String appid) {
this.openid = wxMpUser.getOpenid();
this.appid = appid;
this.subscribe=wxMpUser.getNickname()!=null;
if(this.subscribe){
this.nickname = wxMpUser.getNickname();
this.sex = wxMpUser.getSex();
this.city = wxMpUser.getCity();
this.province = wxMpUser.getProvince();
this.headimgurl = wxMpUser.getHeadImgUrl();
this.subscribeTime = new Date(wxMpUser.getSubscribeTime()*1000);
this.unionid=wxMpUser.getUnionId();
this.remark=wxMpUser.getRemark();
this.tagidList=JSONArray.parseArray(JSONObject.toJSONString(wxMpUser.getTagIds()));
this.subscribeScene=wxMpUser.getSubscribeScene();
String qrScene = wxMpUser.getQrScene();
this.qrSceneStr= StringUtils.isEmpty(qrScene) ? wxMpUser.getQrSceneStr() : qrScene;
}
}

Expand Down
41 changes: 9 additions & 32 deletions src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,11 @@
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/wx?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: 123456
initial-size: 10
max-active: 100
min-idle: 10
max-wait: 60000
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
#Oracle需要打开注释
#validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
stat-view-servlet:
enabled: false
# url-pattern: /druid/*
# login-username: admin
# login-password: admin
filter:
stat:
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: false
wall:
config:
multi-statement-allow: true
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/wx?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: root

springfox:
documentation:
swagger-ui:
enabled: true
41 changes: 9 additions & 32 deletions src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,11 @@
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/wx?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: 123456
initial-size: 10
max-active: 100
min-idle: 10
max-wait: 60000
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
#Oracle需要打开注释
#validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
stat-view-servlet:
enabled: false
# url-pattern: /druid/*
# login-username: admin
# login-password: admin
filter:
stat:
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: false
wall:
config:
multi-statement-allow: true
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/wx?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: 123456

springfox:
documentation:
swagger-ui:
enabled: false

0 comments on commit 6fd68f8

Please sign in to comment.