Compare commits

..

3 Commits

33 changed files with 542 additions and 767 deletions

8
.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

9
.idea/compiler.xml generated
View File

@ -7,18 +7,9 @@
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="wechat-j-open" />
<module name="wechat-j-pay" />
<module name="wechat-j-common" />
<module name="wechat-j-work" />
<module name="wechat-official-account-spring" />
<module name="wechat-j-mp" />
<module name="wechat-j-oa" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="wechat-j-wecom" target="11" />
</bytecodeTargetLevel>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">

12
.idea/dataSources.xml generated
View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="0@localhost" uuid="35480a1b-ac1d-4732-bd65-fa58075ee6de">
<driver-ref>redis</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>jdbc.RedisDriver</jdbc-driver>
<jdbc-url>jdbc:redis://localhost:6379/0</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

17
.idea/encodings.xml generated
View File

@ -1,22 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/../WeChat-J/common/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../WeChat-J/common/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../WeChat-J/mp/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../WeChat-J/mp/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../WeChat-J/oa/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../WeChat-J/oa/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../WeChat-J/open/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../WeChat-J/open/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../WeChat-J/pay/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../WeChat-J/pay/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../WeChat-J/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../WeChat-J/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../WeChat-J/wecom/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../WeChat-J/wecom/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../WeChat-J/work/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../WeChat-J/work/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

1
.idea/jpa-buddy.xml generated
View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JpaBuddyIdeaProjectConfig">
<option name="defaultUnitInitialized" value="true" />
<option name="renamerInitialized" value="true" />
</component>
</project>

6
.idea/misc.xml generated
View File

@ -5,15 +5,11 @@
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
<option value="$PROJECT_DIR$/../WeChat-J/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="ibm-11" project-jdk-type="JavaSDK" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK" />
<component name="ProjectType">
<option name="id" value="jpab" />
</component>
<component name="ThriftCompiler">
<compilers />
</component>
</project>

7
.idea/sqldialects.xml generated
View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SqlDialectMappings">
<file url="file://$PROJECT_DIR$/src/main/resources/data.sql" dialect="H2" />
<file url="file://$PROJECT_DIR$/src/main/resources/schema.sql" dialect="H2" />
</component>
</project>

124
.idea/uiDesigner.xml generated Normal file
View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

37
pom.xml
View File

@ -61,7 +61,6 @@
<scope>compile</scope>
</dependency>
<!-- SPRING -->
<dependency>
<groupId>org.springframework.boot</groupId>
@ -81,39 +80,15 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>3.0.1</version>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<!-- TEST -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.24.1</version>
<scope>test</scope>
</dependency>
<!--/ TEST -->
</dependencies>
<build>
<pluginManagement>

View File

@ -1,12 +0,0 @@
package com.ossez.wechat.demo.common.enums;
/**
* User different http client to make api call.
* We should only keep OK_HTTP, this enough for package
*
* @author YuCheng Hu
*/
public enum HttpClientCategory {
OK_HTTP, HTTP_CLIENT
}

View File

@ -1,13 +0,0 @@
package com.ossez.wechat.demo.common.enums;
/**
* WeChat's Storage Category
*
* We provide implement for MEM(RAM) and REDIS
*
* @author YuCheng Hu
*/
@Deprecated
public enum StorageCategory {
MEM, REDIS
}

View File

@ -1,58 +0,0 @@
package com.ossez.wechat.demo.config;
import com.ossez.wechat.common.config.ConfigStorage;
import com.ossez.wechat.common.exception.WxErrorException;
import com.ossez.wechat.demo.common.enums.HttpClientCategory;
import com.ossez.wechat.demo.properties.WeChatOfficialAccountProperties;
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
import com.ossez.wechat.oa.api.impl.okhttp.WeChatMsgService;
import com.ossez.wechat.oa.api.impl.okhttp.WeChatPlatformService;
import com.ossez.wechat.oa.api.impl.okhttp.WeChatOfficialAccountServiceOkHttp;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Scope;
/**
* .
*
* @author someone
*/
@Configuration
@EnableConfigurationProperties(WeChatOfficialAccountProperties.class)
@Import({WeChatStorageAutoConfiguration.class})
public class WeChatConfiguration {
/**
* weChat Service Inject
*/
@Bean
@ConditionalOnMissingBean
public WeChatOfficialAccountService weChatOfficialAccountService(ConfigStorage configStorage, WeChatOfficialAccountProperties weChatOfficialAccountProperties) {
HttpClientCategory httpClientCategory = weChatOfficialAccountProperties.getWeChatDataStorage().getHttpClientCategory();
WeChatOfficialAccountService weChatOfficialAccountService = new WeChatOfficialAccountServiceOkHttp();
weChatOfficialAccountService.setWxMpConfigStorage(configStorage);
return weChatOfficialAccountService;
}
@Bean
@ConditionalOnMissingBean
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public WeChatPlatformService weChatPlatformService(WeChatOfficialAccountService weChatOfficialAccountService) throws WxErrorException {
weChatOfficialAccountService.getAccessToken();
return new WeChatPlatformService(weChatOfficialAccountService);
}
//
// @Bean
// @ConditionalOnMissingBean
// @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
// public WeChatMsgService weChatMsgService(WeChatOfficialAccountService weChatOfficialAccountService) throws WxErrorException {
// return new WeChatMsgService(weChatOfficialAccountService);
//
// }
}

View File

@ -1,109 +0,0 @@
package com.ossez.wechat.demo.config;
import com.ossez.wechat.common.config.ConfigStorage;
import com.ossez.wechat.demo.common.enums.StorageCategory;
import com.ossez.wechat.demo.model.entity.WeChatDataStorage;
import com.ossez.wechat.demo.properties.WeChatOfficialAccountProperties;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.ossez.wechat.common.redis.RedisTemplateWxRedisOps;
import com.ossez.wechat.common.redis.WxRedisOps;
import com.ossez.wechat.common.config.WxMpHostConfig;
import com.ossez.wechat.common.config.DefaultConfigStorage;
import com.ossez.wechat.common.config.RedisConfigStorage;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;
/**
* 微信公众号存储策略自动配置.
*
* @author Luo
*/
@Slf4j
@Configuration
@RequiredArgsConstructor
public class WeChatStorageAutoConfiguration {
private final ApplicationContext applicationContext;
private final WeChatOfficialAccountProperties weChatOfficialAccountProperties;
@Bean
@ConditionalOnMissingBean(ConfigStorage.class)
public ConfigStorage wxMpConfigStorage() {
StorageCategory type = weChatOfficialAccountProperties.getWeChatDataStorage().getType();
ConfigStorage config;
switch (type) {
case REDIS:
config = redisTemplateConfigStorage();
break;
default:
config = defaultConfigStorage();
break;
}
// wx host config
if (null != weChatOfficialAccountProperties.getHosts() && StringUtils.isNotEmpty(weChatOfficialAccountProperties.getHosts().getApiHost())) {
WxMpHostConfig hostConfig = new WxMpHostConfig();
hostConfig.setApiHost(weChatOfficialAccountProperties.getHosts().getApiHost());
hostConfig.setMpHost(weChatOfficialAccountProperties.getHosts().getMpHost());
hostConfig.setOpenHost(weChatOfficialAccountProperties.getHosts().getOpenHost());
config.setHostConfig(hostConfig);
}
return config;
}
private ConfigStorage defaultConfigStorage() {
DefaultConfigStorage config = new DefaultConfigStorage();
configWeChatServer(config);
return config;
}
private ConfigStorage redisTemplateConfigStorage() {
StringRedisTemplate redisTemplate = null;
try {
redisTemplate = applicationContext.getBean(StringRedisTemplate.class);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
try {
if (null == redisTemplate) {
redisTemplate = (StringRedisTemplate) applicationContext.getBean("stringRedisTemplate");
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
if (null == redisTemplate) {
redisTemplate = (StringRedisTemplate) applicationContext.getBean("redisTemplate");
}
WxRedisOps redisOps = new RedisTemplateWxRedisOps(redisTemplate);
RedisConfigStorage redisConfigStorage = new RedisConfigStorage(redisOps,
weChatOfficialAccountProperties.getWeChatDataStorage().getKeyPrefix());
configWeChatServer(redisConfigStorage);
return redisConfigStorage;
}
private void configWeChatServer(DefaultConfigStorage defaultConfigStorage) {
WeChatOfficialAccountProperties properties = weChatOfficialAccountProperties;
WeChatDataStorage weChatDataStorage = weChatOfficialAccountProperties.getWeChatDataStorage();
defaultConfigStorage.setAppId(properties.getAppId());
defaultConfigStorage.setSecret(properties.getSecret());
defaultConfigStorage.setToken(properties.getToken());
defaultConfigStorage.setAesKey(properties.getAesKey());
defaultConfigStorage.setHttpProxyHost(weChatDataStorage.getHttpProxyHost());
defaultConfigStorage.setHttpProxyUsername(weChatDataStorage.getHttpProxyUsername());
defaultConfigStorage.setHttpProxyPassword(weChatDataStorage.getHttpProxyPassword());
if (weChatDataStorage.getHttpProxyPort() != null) {
defaultConfigStorage.setHttpProxyPort(weChatDataStorage.getHttpProxyPort());
}
}
}

View File

@ -0,0 +1,17 @@
package com.ossez.wechat.demo.config;
import com.ossez.wechat.demo.properties.WeChatOfficialAccountProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
/**
* .
*
* @author someone
*/
@Configuration
@EnableConfigurationProperties(WeChatOfficialAccountProperties.class)
@Import({ WxMpStorageAutoConfiguration.class, WxMpServiceAutoConfiguration.class })
public class WxMpAutoConfiguration {
}

View File

@ -0,0 +1,63 @@
package com.ossez.wechat.demo.config;
import com.ossez.wechat.demo.enums.HttpClientType;
import com.ossez.wechat.demo.properties.WeChatOfficialAccountProperties;
import com.ossez.wechat.oa.api.WxMpService;
import com.ossez.wechat.oa.api.impl.WxMpServiceHttpClientImpl;
import com.ossez.wechat.oa.api.impl.WxMpServiceImpl;
import com.ossez.wechat.oa.api.impl.WxMpServiceJoddHttpImpl;
import com.ossez.wechat.oa.api.impl.WxMpServiceOkHttpImpl;
import com.ossez.wechat.oa.config.WxMpConfigStorage;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 微信公众号相关服务自动注册.
*
* @author someone
*/
@Configuration
public class WxMpServiceAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public WxMpService wxMpService(WxMpConfigStorage configStorage, WeChatOfficialAccountProperties wxMpProperties) {
HttpClientType httpClientType = wxMpProperties.getConfigStorage().getHttpClientType();
WxMpService wxMpService;
switch (httpClientType) {
case OkHttp:
wxMpService = newWxMpServiceOkHttpImpl();
break;
case JoddHttp:
wxMpService = newWxMpServiceJoddHttpImpl();
break;
case HttpClient:
wxMpService = newWxMpServiceHttpClientImpl();
break;
default:
wxMpService = newWxMpServiceImpl();
break;
}
wxMpService.setWxMpConfigStorage(configStorage);
return wxMpService;
}
private WxMpService newWxMpServiceImpl() {
return new WxMpServiceImpl();
}
private WxMpService newWxMpServiceHttpClientImpl() {
return new WxMpServiceHttpClientImpl();
}
private WxMpService newWxMpServiceOkHttpImpl() {
return new WxMpServiceOkHttpImpl();
}
private WxMpService newWxMpServiceJoddHttpImpl() {
return new WxMpServiceJoddHttpImpl();
}
}

View File

@ -0,0 +1,159 @@
package com.ossez.wechat.demo.config;
import com.ossez.wechat.demo.enums.StorageType;
import com.ossez.wechat.demo.properties.RedisProperties;
import com.ossez.wechat.demo.properties.WeChatOfficialAccountProperties;
import com.google.common.collect.Sets;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.ossez.wechat.common.redis.JedisWxRedisOps;
import com.ossez.wechat.common.redis.RedisTemplateWxRedisOps;
import com.ossez.wechat.common.redis.WxRedisOps;
import com.ossez.wechat.oa.config.WxMpHostConfig;
import com.ossez.wechat.oa.config.WxMpConfigStorage;
import com.ossez.wechat.oa.config.impl.WxMpDefaultConfigImpl;
import com.ossez.wechat.oa.config.impl.WxMpRedisConfigImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolAbstract;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.JedisSentinelPool;
import java.util.Set;
/**
* 微信公众号存储策略自动配置.
*
* @author Luo
*/
@Slf4j
@Configuration
@RequiredArgsConstructor
public class WxMpStorageAutoConfiguration {
private final ApplicationContext applicationContext;
private final WeChatOfficialAccountProperties wxMpProperties;
@Bean
@ConditionalOnMissingBean(WxMpConfigStorage.class)
public WxMpConfigStorage wxMpConfigStorage() {
StorageType type = wxMpProperties.getConfigStorage().getType();
WxMpConfigStorage config;
switch (type) {
case Jedis:
config = jedisConfigStorage();
break;
case RedisTemplate:
config = redisTemplateConfigStorage();
break;
default:
config = defaultConfigStorage();
break;
}
// wx host config
if (null != wxMpProperties.getHosts() && StringUtils.isNotEmpty(wxMpProperties.getHosts().getApiHost())) {
WxMpHostConfig hostConfig = new WxMpHostConfig();
hostConfig.setApiHost(wxMpProperties.getHosts().getApiHost());
hostConfig.setMpHost(wxMpProperties.getHosts().getMpHost());
hostConfig.setOpenHost(wxMpProperties.getHosts().getOpenHost());
config.setHostConfig(hostConfig);
}
return config;
}
private WxMpConfigStorage defaultConfigStorage() {
WxMpDefaultConfigImpl config = new WxMpDefaultConfigImpl();
setWxMpInfo(config);
return config;
}
private WxMpConfigStorage jedisConfigStorage() {
JedisPoolAbstract jedisPool;
if (wxMpProperties.getConfigStorage() != null && wxMpProperties.getConfigStorage().getRedis() != null
&& StringUtils.isNotEmpty(wxMpProperties.getConfigStorage().getRedis().getHost())) {
jedisPool = getJedisPool();
} else {
jedisPool = applicationContext.getBean(JedisPool.class);
}
WxRedisOps redisOps = new JedisWxRedisOps(jedisPool);
WxMpRedisConfigImpl wxMpRedisConfig = new WxMpRedisConfigImpl(redisOps,
wxMpProperties.getConfigStorage().getKeyPrefix());
setWxMpInfo(wxMpRedisConfig);
return wxMpRedisConfig;
}
private WxMpConfigStorage redisTemplateConfigStorage() {
StringRedisTemplate redisTemplate = null;
try {
redisTemplate = applicationContext.getBean(StringRedisTemplate.class);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
try {
if (null == redisTemplate) {
redisTemplate = (StringRedisTemplate) applicationContext.getBean("stringRedisTemplate");
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
if (null == redisTemplate) {
redisTemplate = (StringRedisTemplate) applicationContext.getBean("redisTemplate");
}
WxRedisOps redisOps = new RedisTemplateWxRedisOps(redisTemplate);
WxMpRedisConfigImpl wxMpRedisConfig = new WxMpRedisConfigImpl(redisOps,
wxMpProperties.getConfigStorage().getKeyPrefix());
setWxMpInfo(wxMpRedisConfig);
return wxMpRedisConfig;
}
private void setWxMpInfo(WxMpDefaultConfigImpl config) {
WeChatOfficialAccountProperties properties = wxMpProperties;
WeChatOfficialAccountProperties.ConfigStorage configStorageProperties = properties.getConfigStorage();
config.setAppId(properties.getAppId());
config.setSecret(properties.getSecret());
config.setToken(properties.getToken());
config.setAesKey(properties.getAesKey());
config.setHttpProxyHost(configStorageProperties.getHttpProxyHost());
config.setHttpProxyUsername(configStorageProperties.getHttpProxyUsername());
config.setHttpProxyPassword(configStorageProperties.getHttpProxyPassword());
if (configStorageProperties.getHttpProxyPort() != null) {
config.setHttpProxyPort(configStorageProperties.getHttpProxyPort());
}
}
private JedisPoolAbstract getJedisPool() {
RedisProperties redis = wxMpProperties.getConfigStorage().getRedis();
JedisPoolConfig config = new JedisPoolConfig();
if (redis.getMaxActive() != null) {
config.setMaxTotal(redis.getMaxActive());
}
if (redis.getMaxIdle() != null) {
config.setMaxIdle(redis.getMaxIdle());
}
if (redis.getMaxWaitMillis() != null) {
config.setMaxWaitMillis(redis.getMaxWaitMillis());
}
if (redis.getMinIdle() != null) {
config.setMinIdle(redis.getMinIdle());
}
config.setTestOnBorrow(true);
config.setTestWhileIdle(true);
if (StringUtils.isNotEmpty(redis.getSentinelIps())) {
Set<String> sentinels = Sets.newHashSet(redis.getSentinelIps().split(","));
return new JedisSentinelPool(redis.getSentinelName(), sentinels);
}
return new JedisPool(config, redis.getHost(), redis.getPort(), redis.getTimeout(), redis.getPassword(),
redis.getDatabase());
}
}

View File

@ -1,13 +1,8 @@
package com.ossez.wechat.demo.controller;
import com.ossez.wechat.common.exception.WxErrorException;
import com.ossez.wechat.common.model.res.NetworkCheckResponse;
import com.ossez.wechat.common.model.res.QueryQuotaResponse;
import com.ossez.wechat.demo.data.repository.redis.StudentRepository;
import com.ossez.wechat.demo.service.WeChatService;
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
import com.ossez.wechat.oa.api.impl.okhttp.WeChatPlatformService;
import lombok.extern.slf4j.Slf4j;
import com.ossez.wechat.oa.api.WxMpService;
import com.ossez.wechat.common.exception.WxErrorException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -24,16 +19,8 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
public class WeChatController {
private final WeChatOfficialAccountService weChatOfficialAccountService;
private final WeChatService weChatService;
private final StudentRepository studentRepository;
@Autowired
public WeChatController(WeChatOfficialAccountService weChatOfficialAccountService, WeChatService weChatService, StudentRepository studentRepository) {
this.weChatOfficialAccountService = weChatOfficialAccountService;
this.weChatService = weChatService;
this.studentRepository = studentRepository;
}
private WxMpService mpService;
/**
* Get weChat access token
@ -44,36 +31,9 @@ public class WeChatController {
@GetMapping("/token")
@ResponseBody
public String getAccessToken() throws WxErrorException {
log.debug("Get access token from WeChat");
return weChatOfficialAccountService.getAccessToken(true);
return this.mpService.getAccessToken();
}
@GetMapping("/ip")
@ResponseBody
public String getDomainIPs() throws WxErrorException {
log.debug("Get access token from WeChat");
return weChatService.getDomainIPs();
}
// @GetMapping("/networkcheck")
// @ResponseBody
// public NetworkCheckResponse checkNetwork() throws WxErrorException {
// log.debug("Get access token from WeChat");
// return weChatPlatformService.checkNetwork();
// }
//
@GetMapping("/query/quota")
@ResponseBody
public QueryQuotaResponse queryQuota() throws WxErrorException {
log.debug("Get access token from WeChat");
return weChatService.queryQuota();
}
@GetMapping("/message/send")
@ResponseBody
public String sendMessage() throws WxErrorException {
log.debug("Get access token from WeChat");
return weChatService.sendMessage();
}
}

View File

@ -1,9 +0,0 @@
package com.ossez.wechat.demo.data.repository.redis;
import com.ossez.wechat.demo.model.entity.Student;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface StudentRepository extends CrudRepository<Student, String> {}

View File

@ -0,0 +1,22 @@
package com.ossez.wechat.demo.enums;
/**
* httpclient类型.
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
* created on 2020-08-30
*/
public enum HttpClientType {
/**
* HttpClient.
*/
HttpClient,
/**
* OkHttp.
*/
OkHttp,
/**
* JoddHttp.
*/
JoddHttp,
}

View File

@ -0,0 +1,26 @@
package com.ossez.wechat.demo.enums;
/**
* storage类型.
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
* created on 2020-08-30
*/
public enum StorageType {
/**
* 内存.
*/
Memory,
/**
* redis(JedisClient).
*/
Jedis,
/**
* redis(Redisson).
*/
Redisson,
/**
* redis(RedisTemplate).
*/
RedisTemplate
}

View File

@ -1,62 +0,0 @@
package com.ossez.wechat.demo.model.entity;
import org.springframework.data.redis.core.RedisHash;
import java.io.Serializable;
@RedisHash("Student")
public class Student implements Serializable {
public enum Gender {
MALE, FEMALE
}
private String id;
private String name;
private Gender gender;
private int grade;
public Student(String id, String name, Gender gender, int grade) {
this.id = id;
this.name = name;
this.gender = gender;
this.grade = grade;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Gender getGender() {
return gender;
}
public void setGender(Gender gender) {
this.gender = gender;
}
public int getGrade() {
return grade;
}
public void setGrade(int grade) {
this.grade = grade;
}
@Override
public String toString() {
return "Student{" + "id='" + id + '\'' + ", name='" + name + '\'' + ", gender=" + gender + ", grade=" + grade + '}';
}
}

View File

@ -1,30 +0,0 @@
package com.ossez.wechat.demo.model.entity;
import com.ossez.wechat.demo.common.enums.HttpClientCategory;
import com.ossez.wechat.demo.common.enums.StorageCategory;
import com.ossez.wechat.demo.properties.RedisProperties;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import java.io.Serializable;
import static com.ossez.wechat.demo.common.enums.StorageCategory.MEM;
@Getter
@Setter
@Accessors(chain = true)
public class WeChatDataStorage implements Serializable {
private static final long serialVersionUID = -94405301936095366L;
private StorageCategory type = MEM;
private String keyPrefix = "wx";
@NestedConfigurationProperty
private final RedisProperties redis = new RedisProperties();
private HttpClientCategory httpClientCategory = HttpClientCategory.OK_HTTP;
private String httpProxyHost;
private Integer httpProxyPort;
private String httpProxyUsername;
private String httpProxyPassword;
}

View File

@ -1,16 +0,0 @@
package com.ossez.wechat.demo.model.entity;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
@Data
@Accessors(chain = true)
public class WeChatHost implements Serializable {
private static final long serialVersionUID = -7648920647310280817L;
private String apiHost;
private String openHost;
private String mpHost;
}

View File

@ -0,0 +1,18 @@
package com.ossez.wechat.demo.properties;
import lombok.Data;
import java.io.Serializable;
@Data
public class HostConfig implements Serializable {
private static final long serialVersionUID = -4172767630740346001L;
private String apiHost;
private String openHost;
private String mpHost;
}

View File

@ -1,25 +1,99 @@
package com.ossez.wechat.demo.properties;
import com.ossez.wechat.demo.model.entity.WeChatDataStorage;
import com.ossez.wechat.demo.model.entity.WeChatHost;
import com.ossez.wechat.demo.enums.HttpClientType;
import com.ossez.wechat.demo.enums.StorageType;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import java.io.Serializable;
import static com.ossez.wechat.demo.enums.StorageType.Memory;
/**
* WeChat Official Account Config
* 微信接入相关配置属性.
*
* @author YuCheng Hu
* @author someone
*/
@Data
@ConfigurationProperties(prefix = "wechat.official-account")
public class WeChatOfficialAccountProperties {
private String appId; //微信公众号 appId
private String secret; //微信公众号 secret
private String token; //微信公众号 token
private String aesKey; //微信公众号 aesKey
private WeChatHost hosts; //自定义 host 配置
private final WeChatDataStorage weChatDataStorage = new WeChatDataStorage();
/**
* 设置微信公众号的appid.
*/
private String appId;
/**
* 设置微信公众号的app secret.
*/
private String secret;
/**
* 设置微信公众号的token.
*/
private String token;
/**
* 设置微信公众号的EncodingAESKey.
*/
private String aesKey;
/**
* 自定义host配置
*/
private HostConfig hosts;
/**
* 存储策略
*/
private final ConfigStorage configStorage = new ConfigStorage();
@Data
public static class ConfigStorage implements Serializable {
private static final long serialVersionUID = 4815731027000065434L;
/**
* 存储类型.
*/
private StorageType type = Memory;
/**
* 指定key前缀.
*/
private String keyPrefix = "wx";
/**
* redis连接配置.
*/
@NestedConfigurationProperty
private final RedisProperties redis = new RedisProperties();
/**
* http客户端类型.
*/
private HttpClientType httpClientType = HttpClientType.HttpClient;
/**
* http代理主机.
*/
private String httpProxyHost;
/**
* http代理端口.
*/
private Integer httpProxyPort;
/**
* http代理用户名.
*/
private String httpProxyUsername;
/**
* http代理密码.
*/
private String httpProxyPassword;
}
}

View File

@ -1,60 +0,0 @@
package com.ossez.wechat.demo.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ossez.wechat.common.exception.WxErrorException;
import com.ossez.wechat.common.model.req.CustomMessage;
import com.ossez.wechat.common.model.res.QueryQuotaResponse;
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
import com.ossez.wechat.oa.api.impl.okhttp.WeChatMsgService;
import com.ossez.wechat.oa.api.impl.okhttp.WeChatOfficialAccountServiceOkHttp;
import com.ossez.wechat.oa.api.impl.okhttp.WeChatPlatformService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Created with IntelliJ IDEA.
*
* @author XieYang, YuCheng
* @Date: 2022/10/14/16:17
* @Description:
*/
@Service
@Slf4j
public class WeChatService {
private final WeChatOfficialAccountService weChatOfficialAccountService;
private final ObjectMapper objectMapper;
@Autowired
public WeChatService(WeChatOfficialAccountService weChatOfficialAccountService, ObjectMapper objectMapper) throws WxErrorException {
this.weChatOfficialAccountService = weChatOfficialAccountService;
this.objectMapper = objectMapper;
}
/**
* Get WeChatLoginQRUrl
*
* @return
*/
public String getDomainIPs() throws WxErrorException {
return new WeChatPlatformService(weChatOfficialAccountService).getDomainIPs();
}
public QueryQuotaResponse queryQuota() throws WxErrorException {
return new WeChatPlatformService(weChatOfficialAccountService).queryQuota();
}
public String sendMessage() throws WxErrorException {
CustomMessage.KfText kfText = new CustomMessage.KfText("微信异步消息发送");
CustomMessage customMessage = new CustomMessage();
customMessage.setToUser("o9phd5jz_We8mPs1ovmyjud97Ock");
customMessage.setMsgType("text");
customMessage.setText(kfText);
return new WeChatMsgService(weChatOfficialAccountService).sendMessage(customMessage);
}
}

View File

@ -10,18 +10,10 @@ spring.jpa.show-sql=false
spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.use-new-id-generator-mappings=false
#spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
#spring.datasource.url=
#spring.datasource.username=
#spring.datasource.password=
spring.datasource.url=jdbc:h2:mem:test
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=password
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.datasource.url=
spring.datasource.username=
spring.datasource.password=
spring.datasource.hikari.connection-timeout=50000
spring.datasource.hikari.idle-timeout=300000
@ -42,13 +34,9 @@ spring.datasource.hikari.data-source-properties.cacheServerConfiguration=true
spring.datasource.hikari.data-source-properties.elideSetAutoCommits=true
spring.datasource.hikari.data-source-properties.maintainTimeStats=false
# REDIS
spring.redis.host=localhost
spring.redis.port=6379
# KEY
wechat.official-account.app-id = wx637b82a7f94123ef
wechat.official-account.secret = 343cecbc44d69e45367a65cc9b4d3925
wechat.official-account.token = 0b01a700891d4a2f93a4323771c32455
wechat.official-account.app-id = appId
wechat.official-account.secret = secret
wechat.official-account.token = token
wechat.official-account.aes-key = aesKey

View File

@ -1,3 +0,0 @@
INSERT INTO CITY VALUES (11, 'Delhi', 110001);
INSERT INTO CITY VALUES (12, 'Kanpur', 208001);
INSERT INTO CITY VALUES (13, 'Lucknow', 226001);

View File

@ -1,7 +0,0 @@
DROP TABLE IF EXISTS CITY;
CREATE TABLE CITY
(
city_code INT AUTO_INCREMENT PRIMARY KEY,
city_name VARCHAR NOT NULL,
city_pincode INT NOT NULL
);

View File

@ -1,47 +0,0 @@
package com.ossez.wechat.demo;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* Email Testing
*
* @author YuCheng
*/
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Slf4j
class DataTest {
@Test
public void testStartAndEndDateTime() {
List<Integer> reqIds = Arrays.asList(1, 2);
List<Integer> reqs = Arrays.asList(1);
Map<Integer, Boolean> map1 = reqIds.stream().collect(Collectors.toMap(Function.identity(), item -> reqs.contains(item)));
Map<Integer, Boolean> map2 = reqIds.stream().collect(Collectors.toMap(Function.identity(), reqs::contains));
log.debug("Map Size {}",11+20);
log.debug("Map Size {}", map2);
List<Integer> shiftIds = Arrays.asList(1, 2);
Map<Integer, Boolean> shiftIdMaps = new HashMap<Integer, Boolean>();
shiftIdMaps.put(1, Boolean.TRUE);
List<Integer> reponse = shiftIds.stream().filter(item -> shiftIdMaps.get(item) == Boolean.TRUE).collect(Collectors.toList());
log.debug("Map Size {}", reponse);
log.debug("Map Size {}",map2);
}
}

View File

@ -1,68 +0,0 @@
package com.ossez.wechat.demo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.SAXReader;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import java.nio.charset.StandardCharsets;
/**
* Email Testing
*
* @author YuCheng
*/
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Slf4j
class WeChatTest {
private String wechatMessageStr = StringUtils.EMPTY;
@BeforeEach
protected void setUp() throws Exception {
this.wechatMessageStr = (" <xml>\n" +
" <ToUserName><![CDATA[toUser]]></ToUserName>\n" +
" <FromUserName><![CDATA[fromUser]]></FromUserName>\n" +
" <CreateTime>1348831860</CreateTime>\n" +
" <MsgType><![CDATA[text]]></MsgType>\n" +
" <Content><![CDATA[this is a test - 您好]]></Content>\n" +
" <MsgId>1234567890123456</MsgId>\n" +
" <MsgDataId>xxxx</MsgDataId>\n" +
" <Idx>xxxx</Idx>\n" +
"</xml>");
}
@AfterEach
protected void tearDown() throws Exception {
}
@Test
public void testToWeChatMessage() {
SAXReader xmlReader = new SAXReader();
Document document = null;
try {
document = xmlReader.read(IOUtils.toInputStream(wechatMessageStr, StandardCharsets.UTF_8));
// log.debug("WeChat Message Content - [{}]", weChatMessage.getContent());
} catch (DocumentException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -1,42 +0,0 @@
server.port=8080
spring.batch.job.enabled = false
spring.batch.jdbc.initialize-schema=ALWAYS
logging.level.org.springframework=INFO
logging.level.root=DEBUG
spring.jpa.show-sql=false
spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.use-new-id-generator-mappings=false
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.datasource.url=
spring.datasource.username=
spring.datasource.password=
spring.datasource.hikari.connection-timeout=50000
spring.datasource.hikari.idle-timeout=300000
spring.datasource.hikari.max-lifetime=900000
spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.minimum-idle=10
spring.datasource.hikari.pool-name=ConnPool
spring.datasource.hikari.connection-test-query=select 1 from dual
spring.datasource.hikari.data-source-properties.cachePrepStmts=true
spring.datasource.hikari.data-source-properties.prepStmtCacheSize=250
spring.datasource.hikari.data-source-properties.prepStmtCacheSqlLimit=2048
spring.datasource.hikari.data-source-properties.useServerPrepStmts=true
spring.datasource.hikari.data-source-properties.useLocalSessionState=true
spring.datasource.hikari.data-source-properties.rewriteBatchedStatements=true
spring.datasource.hikari.data-source-properties.cacheResultSetMetadata=true
spring.datasource.hikari.data-source-properties.cacheServerConfiguration=true
spring.datasource.hikari.data-source-properties.elideSetAutoCommits=true
spring.datasource.hikari.data-source-properties.maintainTimeStats=false
# KEY
wechat.official-account.app-id = wx637b82a7f94123ef
wechat.official-account.secret = 343cecbc44d69e45367a65cc9b4d3925
wechat.official-account.token = 0b01a700891d4a2f93a4323771c32455
wechat.official-account.aes-key = aesKey

View File

@ -1,75 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<configuration debug="true">
<timestamp key="bySecond" datePattern="yyyyMMdd'T'HHmmss"/>
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned by default the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>
<!-- FILE-DEBUG -->
<appender name="FILE-DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<prudent>true</prudent>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>/var/log/usreio/%d{yyyy-MM-dd}/usreio-debug.log</fileNamePattern>
<!-- keep 30 days' worth of history capped at 3GB total size -->
<maxHistory>30</maxHistory>
<totalSizeCap>3GB</totalSizeCap>
</rollingPolicy>
<append>true</append>
<immediateFlush>true</immediateFlush>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!-- FILE-ERROR -->
<appender name="FILE-ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<prudent>true</prudent>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>/var/log/usreio/%d{yyyy-MM-dd}/usreio-error.log</fileNamePattern>
<!-- keep 30 days' worth of history capped at 3GB total size -->
<maxHistory>30</maxHistory>
<totalSizeCap>3GB</totalSizeCap>
</rollingPolicy>
<append>true</append>
<immediateFlush>true</immediateFlush>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!-- LOGGER -->
<logger name="com.ossez" level="DEBUG"/>
<logger name="org.apache" level="INFO"/>
<logger name="org.mariadb" level="INFO"/>
<logger name="org.hibernate" level="INFO"/>
<logger name="org.springframework" level="INFO"/>
<!-- ROOT AND APPENDER -->
<root level="debug">
<appender-ref ref="STDOUT"/>
<appender-ref ref="FILE-DEBUG"/>
<appender-ref ref="FILE-ERROR"/>
</root>
</configuration>