Browse Source
Merge branch 'milestone-20250702-金币重构一期' of http://39.101.133.168:8807/huangqizhen/gold-java into milestone-20250702-金币重构一期
lihuilin/hotfix-20250810160509-余额地区传参
Merge branch 'milestone-20250702-金币重构一期' of http://39.101.133.168:8807/huangqizhen/gold-java into milestone-20250702-金币重构一期
lihuilin/hotfix-20250810160509-余额地区传参
25 changed files with 328 additions and 81 deletions
-
4src/main/java/com/example/demo/Export/ExportServiceImpl.java
-
32src/main/java/com/example/demo/Mysql/MysqlController.java
-
9src/main/java/com/example/demo/Mysql/MysqlService.java
-
64src/main/java/com/example/demo/Mysql/MysqlServiceImpl.java
-
13src/main/java/com/example/demo/config/Mysql1DataSourceConfig.java
-
63src/main/java/com/example/demo/config/SqlServer1DataSourceConfig.java
-
24src/main/java/com/example/demo/controller/WorkbenchController.java
-
14src/main/java/com/example/demo/domain/DTO/ConsumeDTO.java
-
16src/main/java/com/example/demo/domain/DTO/GoldDetailDTO.java
-
16src/main/java/com/example/demo/domain/DTO/GoldUserDTO.java
-
16src/main/java/com/example/demo/domain/DTO/RechargeDTO.java
-
16src/main/java/com/example/demo/domain/DTO/RefundDTO.java
-
1src/main/java/com/example/demo/domain/vo/ConsumeUser.java
-
1src/main/java/com/example/demo/domain/vo/RechargeAudit.java
-
1src/main/java/com/example/demo/domain/vo/RechargeUser.java
-
2src/main/java/com/example/demo/service/AdminService.java
-
4src/main/java/com/example/demo/service/StatisticsService.java
-
6src/main/java/com/example/demo/serviceImpl/AdminServiceImpl.java
-
1src/main/java/com/example/demo/serviceImpl/AuditServiceImpl.java
-
77src/main/java/com/example/demo/serviceImpl/ExportExcelServiceImpl.java
-
3src/main/java/com/example/demo/serviceImpl/GoldDetailServiceImpl.java
-
9src/main/java/com/example/demo/serviceImpl/RefundServiceImpl.java
-
11src/main/resources/application.yml
-
3src/main/resources/mapper/AuditMapper.xml
-
3src/main/resources/mapper/ConsumeMapper.xml
@ -0,0 +1,32 @@ |
|||||
|
//package com.example.demo.Mysql; |
||||
|
// |
||||
|
//import com.example.demo.domain.vo.Result; |
||||
|
//import lombok.RequiredArgsConstructor; |
||||
|
//import lombok.extern.slf4j.Slf4j; |
||||
|
//import org.springframework.beans.factory.annotation.Autowired; |
||||
|
//import org.springframework.web.bind.annotation.CrossOrigin; |
||||
|
//import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
//import org.springframework.web.bind.annotation.RestController; |
||||
|
// |
||||
|
///** |
||||
|
// * @program: GOLD |
||||
|
// * @ClassName MysqlController |
||||
|
// * @description: |
||||
|
// * @author: huangqizhen |
||||
|
// * @create: 2025−07-08 15:50 |
||||
|
// * @Version 1.0 |
||||
|
// **/ |
||||
|
//@RestController |
||||
|
//@RequestMapping("/Mysql") |
||||
|
//@RequiredArgsConstructor |
||||
|
//@Slf4j |
||||
|
//@CrossOrigin |
||||
|
//public class MysqlController { |
||||
|
// @Autowired |
||||
|
// MysqlService mysqlService; |
||||
|
// @RequestMapping |
||||
|
// public Result Mysql () throws Exception { |
||||
|
// mysqlService.getSqlserverData(); |
||||
|
// return Result.success(); |
||||
|
// } |
||||
|
//} |
@ -0,0 +1,9 @@ |
|||||
|
package com.example.demo.Mysql;/** |
||||
|
@program: GOLD |
||||
|
@ClassName MysqlService |
||||
|
@description: |
||||
|
@author: huangqizhen |
||||
|
@create: 2025−07-08 15:52 |
||||
|
@Version 1.0 |
||||
|
**/public interface MysqlService { |
||||
|
} |
@ -0,0 +1,64 @@ |
|||||
|
//package com.example.demo.Mysql; |
||||
|
// |
||||
|
//import com.example.demo.Mysql.MysqlService; |
||||
|
//import org.slf4j.Logger; |
||||
|
//import org.slf4j.LoggerFactory; |
||||
|
//import org.springframework.beans.factory.annotation.Qualifier; |
||||
|
//import org.springframework.scheduling.annotation.Scheduled; |
||||
|
//import org.springframework.stereotype.Service; |
||||
|
// |
||||
|
//import javax.sql.DataSource; |
||||
|
//import java.sql.*; |
||||
|
//import java.time.LocalDateTime; |
||||
|
// |
||||
|
//@Service |
||||
|
//public class MysqlServiceImpl implements MysqlService { |
||||
|
// |
||||
|
// private static final Logger logger = LoggerFactory.getLogger(MysqlServiceImpl.class); |
||||
|
// |
||||
|
// private final DataSource sqlServerDataSource; |
||||
|
// private final DataSource mysqlDataSource; |
||||
|
// |
||||
|
// public MysqlServiceImpl(@Qualifier("sqlServerDataSource") DataSource sqlServerDataSource, |
||||
|
// @Qualifier("mysqlDataSource") DataSource mysqlDataSource) { |
||||
|
// this.sqlServerDataSource = sqlServerDataSource; |
||||
|
// this.mysqlDataSource = mysqlDataSource; |
||||
|
// } |
||||
|
// |
||||
|
// @Override |
||||
|
// @Scheduled(cron = "0 0 * * * ?") // 每小时执行一次 |
||||
|
// public void getSqlserverData() { |
||||
|
// logger.info("开始从 SQL Server 同步数据到 MySQL..."); |
||||
|
// try (Connection sqlServerConn = sqlServerDataSource.getConnection(); |
||||
|
// Connection mysqlConn = mysqlDataSource.getConnection()) { |
||||
|
// |
||||
|
// // 从 SQL Server 查询数据 |
||||
|
// String querySql = "SELECT gtype,jwcode, created_at FROM user_gold_records WHERE created_at > ?"; |
||||
|
// try (PreparedStatement sqlServerStmt = sqlServerConn.prepareStatement(querySql)) { |
||||
|
// sqlServerStmt.setTimestamp(1, Timestamp.valueOf(LocalDateTime.now().minusHours(1))); // 获取最近一小时的数据 |
||||
|
// ResultSet resultSet = sqlServerStmt.executeQuery(); |
||||
|
// |
||||
|
// // 插入到 MySQL |
||||
|
// String insertSql = "INSERT INTO target_table (id, name, created_at) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE name = ?"; |
||||
|
// try (PreparedStatement mysqlStmt = mysqlConn.prepareStatement(insertSql)) { |
||||
|
// while (resultSet.next()) { |
||||
|
// int id = resultSet.getInt("id"); |
||||
|
// String name = resultSet.getString("name"); |
||||
|
// Timestamp createdAt = resultSet.getTimestamp("created_at"); |
||||
|
// |
||||
|
// mysqlStmt.setInt(1, id); |
||||
|
// mysqlStmt.setString(2, name); |
||||
|
// mysqlStmt.setTimestamp(3, createdAt); |
||||
|
// mysqlStmt.setString(4, name); // 更新时的值 |
||||
|
// mysqlStmt.addBatch(); |
||||
|
// } |
||||
|
// mysqlStmt.executeBatch(); // 批量插入 |
||||
|
// } |
||||
|
// } |
||||
|
// logger.info("数据同步完成"); |
||||
|
// } catch (SQLException e) { |
||||
|
// logger.error("数据同步失败", e); |
||||
|
// throw new RuntimeException("数据同步失败", e); |
||||
|
// } |
||||
|
// } |
||||
|
//} |
@ -0,0 +1,63 @@ |
|||||
|
//package com.example.demo.config; |
||||
|
// |
||||
|
//import com.zaxxer.hikari.HikariDataSource; |
||||
|
//import lombok.extern.slf4j.Slf4j; |
||||
|
//import org.apache.ibatis.session.SqlSessionFactory; |
||||
|
//import org.mybatis.spring.SqlSessionFactoryBean; |
||||
|
//import org.mybatis.spring.SqlSessionTemplate; |
||||
|
//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.core.io.support.PathMatchingResourcePatternResolver; |
||||
|
// |
||||
|
//import javax.sql.DataSource; |
||||
|
// |
||||
|
//@Slf4j |
||||
|
//@Configuration |
||||
|
//public class SqlServer1DataSourceConfig { |
||||
|
// |
||||
|
// /** |
||||
|
// * 定义 SQL Server 数据源 |
||||
|
// */ |
||||
|
// @Bean(name = "sqlserver1DataSource") |
||||
|
// @ConfigurationProperties(prefix = "spring.datasource.sqlserver1") |
||||
|
// public DataSource sqlserver1DataSource() { |
||||
|
// log.info("Initializing SQL Server data source..."); |
||||
|
// return DataSourceBuilder.create().type(HikariDataSource.class).build(); |
||||
|
// } |
||||
|
// |
||||
|
// /** |
||||
|
// * 定义 SQL Server 的 SqlSessionFactory |
||||
|
// */ |
||||
|
// @Bean(name = "sqlserver1SqlSessionFactory") |
||||
|
// public SqlSessionFactory sqlserver1SqlSessionFactory(@Qualifier("sqlserver1DataSource") DataSource dataSource, |
||||
|
// @Qualifier("globalConfiguration1") org.apache.ibatis.session.Configuration globalConfiguration) throws Exception { |
||||
|
// log.info("Initializing SQL Server SqlSessionFactory..."); |
||||
|
// SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); |
||||
|
// sessionFactory.setDataSource(dataSource); |
||||
|
// sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/sqlserver/*.xml")); |
||||
|
// sessionFactory.setConfiguration(globalConfiguration); |
||||
|
// return sessionFactory.getObject(); |
||||
|
// } |
||||
|
// |
||||
|
// /** |
||||
|
// * 定义 SQL Server 的 SqlSessionTemplate |
||||
|
// */ |
||||
|
// @Bean(name = "sqlserver1SqlSessionTemplate") |
||||
|
// public SqlSessionTemplate sqlserver1SqlSessionTemplate(@Qualifier("sqlserver1SqlSessionFactory") SqlSessionFactory sqlSessionFactory) { |
||||
|
// log.info("Initializing SQL Server SqlSessionTemplate..."); |
||||
|
// return new SqlSessionTemplate(sqlSessionFactory); |
||||
|
// } |
||||
|
// |
||||
|
// /** |
||||
|
// * 定义全局 MyBatis 配置 |
||||
|
// */ |
||||
|
// @Bean |
||||
|
// @ConfigurationProperties(prefix = "mybatis.configuration.sqlserver1") |
||||
|
// public org.apache.ibatis.session.Configuration globalConfiguration() { |
||||
|
// log.info("Initializing SQL Server MyBatis global configuration..."); |
||||
|
// return new org.apache.ibatis.session.Configuration(); |
||||
|
// } |
||||
|
//} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue