Commit 50240b4e393f0792609e3843c98735fbe5fce82c

Authored by 648540858
1 parent 5a152791

移除手动配置mybatis下划线转驼峰

doc/_content/introduction/config.md
... ... @@ -58,9 +58,7 @@ spring:
58 58 url: jdbc:postgresql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&serverTimezone=PRC&useSSL=false&allowMultiQueries=true&allowPublicKeyRetrieval=true
59 59 username: root
60 60 password: 12345678
61   -mybatis:
62   - configuration:
63   - map-underscore-to-camel-case: true
  61 +
64 62 pagehelper:
65 63 helper-dialect: postgresql
66 64 ```
... ... @@ -74,9 +72,7 @@ spring:
74 72 url: jdbc:kingbase8://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=utf8
75 73 username: root
76 74 password: 12345678
77   -mybatis:
78   - configuration:
79   - map-underscore-to-camel-case: true
  75 +
80 76 pagehelper:
81 77 helper-dialect: postgresql
82 78 ```
... ...
src/main/java/com/genersoft/iot/vmp/conf/MybatisConfig.java 0 → 100644
  1 +package com.genersoft.iot.vmp.conf;
  2 +
  3 +import org.apache.ibatis.logging.stdout.StdOutImpl;
  4 +import org.apache.ibatis.session.SqlSessionFactory;
  5 +import org.mybatis.spring.SqlSessionFactoryBean;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.context.annotation.Bean;
  8 +import org.springframework.context.annotation.Configuration;
  9 +import org.springframework.core.annotation.Order;
  10 +
  11 +import javax.sql.DataSource;
  12 +
  13 +/**
  14 + * 配置mybatis
  15 + */
  16 +@Configuration
  17 +@Order(value=1)
  18 +public class MybatisConfig {
  19 +
  20 + @Autowired
  21 + private UserSetting userSetting;
  22 +
  23 + @Bean
  24 + public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
  25 + final SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean();
  26 + sqlSessionFactory.setDataSource(dataSource);
  27 + org.apache.ibatis.session.Configuration config = new org.apache.ibatis.session.Configuration();
  28 + if (userSetting.getSqlLog()){
  29 + config.setLogImpl(StdOutImpl.class);
  30 + }
  31 + config.setMapUnderscoreToCamelCase(true);
  32 + sqlSessionFactory.setConfiguration(config);
  33 + return sqlSessionFactory.getObject();
  34 + }
  35 +
  36 +}
... ...
src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
... ... @@ -48,6 +48,7 @@ public class UserSetting {
48 48 private Boolean syncChannelOnDeviceOnline = Boolean.FALSE;
49 49  
50 50 private Boolean sipLog = Boolean.FALSE;
  51 + private Boolean sqlLog = Boolean.FALSE;
51 52 private Boolean sendToPlatformsWhenIdLost = Boolean.FALSE;
52 53  
53 54 private Boolean refuseChannelStatusChannelFormNotify = Boolean.FALSE;
... ... @@ -286,4 +287,12 @@ public class UserSetting {
286 287 public void setUseCustomSsrcForParentInvite(Boolean useCustomSsrcForParentInvite) {
287 288 this.useCustomSsrcForParentInvite = useCustomSsrcForParentInvite;
288 289 }
  290 +
  291 + public Boolean getSqlLog() {
  292 + return sqlLog;
  293 + }
  294 +
  295 + public void setSqlLog(Boolean sqlLog) {
  296 + this.sqlLog = sqlLog;
  297 + }
289 298 }
... ...
src/main/resources/all-application.yml
... ... @@ -194,6 +194,8 @@ user-settings:
194 194 sip-use-source-ip-as-remote-address: false
195 195 # 是否开启sip日志
196 196 sip-log: true
  197 + # 是否开启sql日志
  198 + sql-log: true
197 199 # 消息通道功能-缺少国标ID是否给所有上级发送消息
198 200 send-to-platforms-when-id-lost: true
199 201 # 保持通道状态,不接受notify通道状态变化, 兼容海康平台发送错误消息
... ...