src/main/java/com/hx/other/service/api/ai/SqlAiApi.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/hx/other/service/config/DataSourceConfig.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/hx/other/service/config/JdbcTemplateConfig.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/hx/other/service/controller/SqlQueryController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/hx/other/service/controller/TestController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/application-local.properties | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/application-prod.properties | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/hx/other/service/api/ai/SqlAiApi.java
@@ -15,7 +15,7 @@ JSONObject getSql(@JSONBody String param); @Post( url = "http://chatgpt.phiskin.com/chat/msg/short", url = "http://chatgpt.phiskin.com/chat/msg/short/ai", headers = { "Content-Type: application/json" } src/main/java/com/hx/other/service/config/DataSourceConfig.java
New file @@ -0,0 +1,36 @@ package com.hx.other.service.config; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import javax.sql.DataSource; /** * 数据源配置 * @Author: cmg * @Date: 2023/5/5 10:56 */ @Configuration public class DataSourceConfig { @Bean(name = "readDataSource") @Qualifier("readDataSource") @ConfigurationProperties(prefix = "spring.datasource.read") public DataSource readDataSource() { return DataSourceBuilder.create().build(); } @Bean(name = "writeDataSource") @Qualifier("writeDataSource") @ConfigurationProperties(prefix = "spring.datasource.write") @Primary public DataSource writeDataSource() { return DataSourceBuilder.create().build(); } } src/main/java/com/hx/other/service/config/JdbcTemplateConfig.java
New file @@ -0,0 +1,23 @@ package com.hx.other.service.config; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.core.JdbcTemplate; import javax.sql.DataSource; /** * jdbc数据源配置 * @Author: cmg * @Date: 2023/5/5 10:59 */ @Configuration public class JdbcTemplateConfig { @Bean(name = "readJdbcTemplate") public JdbcTemplate readJdbTemplate(@Qualifier("readDataSource") DataSource dataSource) { return new JdbcTemplate(dataSource); } } src/main/java/com/hx/other/service/controller/SqlQueryController.java
@@ -12,6 +12,8 @@ import com.hx.other.service.vo.ai.SqlVo; import com.hx.resultTool.Result; import com.hx.util.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -36,7 +38,8 @@ @Resource private SqlQueryTempService sqlQueryTempService; @Resource @Autowired @Qualifier("readJdbcTemplate") private JdbcTemplate jdbcTemplate; @Resource src/main/java/com/hx/other/service/controller/TestController.java
New file @@ -0,0 +1,21 @@ package com.hx.other.service.controller; import com.hx.resultTool.Result; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * @Author: cmg * @Date: 2023/5/5 11:43 */ @RestController @RequestMapping("/ai/test") public class TestController { @RequestMapping("test") public Result test() { return Result.success("test"); } } src/main/resources/application-local.properties
@@ -2,23 +2,39 @@ logging.config=classpath:log4j2-local.xml spring.datasource.url=jdbc:mysql://localhost:3306/phi_other_service?useUnicode=true&characterEncoding=UTF-8 spring.datasource.username=root spring.datasource.password=root spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.write.jdbc-url=jdbc:mysql://localhost:3306/phi_other_service?useUnicode=true&characterEncoding=UTF-8 spring.datasource.write.username=root spring.datasource.write.password=root spring.datasource.write.driver-class-name=com.mysql.jdbc.Driver spring.datasource.read.jdbc-url=jdbc:mysql://localhost:3306/phi_other_service_read?useUnicode=true&characterEncoding=UTF-8 spring.datasource.read.username=root spring.datasource.read.password=root spring.datasource.read.driver-class-name=com.mysql.jdbc.Driver logging.level.org.springframework.boot.autoconfigure = error spring.datasource.type=com.alibaba.druid.pool.DruidDataSource spring.datasource.druid.filters=stat,wall,log4j spring.datasource.druid.initial-size=10 spring.datasource.druid.max-active=50 spring.datasource.druid.min-idle=10 spring.datasource.druid.max-wait=20 spring.datasource.druid.time-between-eviction-runs-millis=60000 spring.datasource.druid.min-evictable-idle-time-millis=300000 spring.datasource.druid.test-on-borrow=true spring.datasource.druid.test-while-idle=false spring.datasource.write.type=com.alibaba.druid.pool.DruidDataSource spring.datasource.write.druid.filters=stat,wall,log4j spring.datasource.write.druid.initial-size=10 spring.datasource.write.druid.max-active=50 spring.datasource.write.druid.min-idle=10 spring.datasource.write.druid.max-wait=20 spring.datasource.write.druid.time-between-eviction-runs-millis=60000 spring.datasource.write.druid.min-evictable-idle-time-millis=300000 spring.datasource.write.druid.test-on-borrow=true spring.datasource.write.druid.test-while-idle=false spring.datasource.read.type=com.alibaba.druid.pool.DruidDataSource spring.datasource.read.druid.filters=stat,wall,log4j spring.datasource.read.druid.initial-size=10 spring.datasource.read.druid.max-active=50 spring.datasource.read.druid.min-idle=10 spring.datasource.read.druid.max-wait=20 spring.datasource.read.druid.time-between-eviction-runs-millis=60000 spring.datasource.read.druid.min-evictable-idle-time-millis=300000 spring.datasource.read.druid.test-on-borrow=true spring.datasource.read.druid.test-while-idle=false mybatis.type-aliases-package=com.hx.other.servcie.model mybatis.mapperLocations=com/hx/other/service/dao/mapper/xml/*.xml,classpath*:com/gitee/sunchenbin/mybatis/actable/mapping/*/*.xml,classpath*:mapper/*.xml @@ -36,4 +52,4 @@ pagehelper.reasonable=true pagehelper.support-methods-arguments=true forest.timeout=10000 forest.timeout=10000 src/main/resources/application-prod.properties
@@ -2,23 +2,41 @@ logging.config=classpath:log4j2-local.xml spring.datasource.url=jdbc:mysql://localhost:3306/phi_other_service?useUnicode=true&characterEncoding=UTF-8 spring.datasource.username=root spring.datasource.password=root spring.datasource.driver-class-name=com.mysql.jdbc.Driver #ai? spring.datasource.write.jdbc-url=jdbc:mysql://172.17.0.2:3306/ai_data?useUnicode=true&characterEncoding=UTF-8 spring.datasource.write.username=phiskin_ai spring.datasource.write.password=phiskin985AI6DATAfvrg spring.datasource.write.driver-class-name=com.mysql.cj.jdbc.Driver #bi?? spring.datasource.read.jdbc-url=jdbc:mysql://172.17.0.45:3306/phiskin_bi?useUnicode=true&characterEncoding=UTF-8 spring.datasource.read.username=phiskin_bi spring.datasource.read.password=phiskinBI33W6854#% spring.datasource.read.driver-class-name=com.mysql.cj.jdbc.Driver logging.level.org.springframework.boot.autoconfigure = error spring.datasource.type=com.alibaba.druid.pool.DruidDataSource spring.datasource.druid.filters=stat,wall,log4j spring.datasource.druid.initial-size=10 spring.datasource.druid.max-active=50 spring.datasource.druid.min-idle=10 spring.datasource.druid.max-wait=20 spring.datasource.druid.time-between-eviction-runs-millis=60000 spring.datasource.druid.min-evictable-idle-time-millis=300000 spring.datasource.druid.test-on-borrow=true spring.datasource.druid.test-while-idle=false spring.datasource.write.type=com.alibaba.druid.pool.DruidDataSource spring.datasource.write.druid.filters=stat,wall,log4j spring.datasource.write.druid.initial-size=10 spring.datasource.write.druid.max-active=50 spring.datasource.write.druid.min-idle=10 spring.datasource.write.druid.max-wait=20 spring.datasource.write.druid.time-between-eviction-runs-millis=60000 spring.datasource.write.druid.min-evictable-idle-time-millis=300000 spring.datasource.write.druid.test-on-borrow=true spring.datasource.write.druid.test-while-idle=false spring.datasource.read.type=com.alibaba.druid.pool.DruidDataSource spring.datasource.read.druid.filters=stat,wall,log4j spring.datasource.read.druid.initial-size=10 spring.datasource.read.druid.max-active=50 spring.datasource.read.druid.min-idle=10 spring.datasource.read.druid.max-wait=20 spring.datasource.read.druid.time-between-eviction-runs-millis=60000 spring.datasource.read.druid.min-evictable-idle-time-millis=300000 spring.datasource.read.druid.test-on-borrow=true spring.datasource.read.druid.test-while-idle=false mybatis.type-aliases-package=com.hx.other.servcie.model mybatis.mapperLocations=com/hx/other/service/dao/mapper/xml/*.xml,classpath*:com/gitee/sunchenbin/mybatis/actable/mapping/*/*.xml,classpath*:mapper/*.xml