fix: 修改文件名大小写
This commit is contained in:
18
server/src/config/db.config.js
Normal file
18
server/src/config/db.config.js
Normal file
@@ -0,0 +1,18 @@
|
||||
module.exports = {
|
||||
cdkDbConfig: {
|
||||
host: '192.168.25.110', // MySQL服务器地址
|
||||
user: 'root', // 数据库用户名
|
||||
password: 'mysql_tr2Few', // 数据库密码
|
||||
database: 'cdk', // 数据库名称
|
||||
port: 23306, // MySQL端口号
|
||||
connectionLimit: 10 // 连接池大小
|
||||
},
|
||||
gameDbConfig: {
|
||||
host: '192.168.25.110', // MySQL服务器地址
|
||||
user: 'root', // 数据库用户名
|
||||
password: 'mysql_tr2Few', // 数据库密码
|
||||
database: 'tafang_game_zjy', // 数据库名称
|
||||
port: 23306, // MySQL端口号
|
||||
connectionLimit: 10 // 连接池大小
|
||||
}
|
||||
};
|
||||
@@ -1,17 +0,0 @@
|
||||
export const cdkDbConfig = {
|
||||
host: '192.168.25.110', // MySQL服务器地址
|
||||
user: 'root', // 数据库用户名
|
||||
password: 'mysql_tr2Few', // 数据库密码
|
||||
database: 'cdk', // 数据库名称
|
||||
port: 23306, // MySQL端口号
|
||||
connectionLimit: 10 // 连接池大小
|
||||
};
|
||||
|
||||
export const gameDbConfig = {
|
||||
host: '192.168.25.110', // MySQL服务器地址
|
||||
user: 'root', // 数据库用户名
|
||||
password: 'mysql_tr2Few', // 数据库密码
|
||||
database: 'tafang_game_zjy', // 数据库名称
|
||||
port: 23306, // MySQL端口号
|
||||
connectionLimit: 10 // 连接池大小
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import express from 'express';
|
||||
import roleRoutes from './routes/role.routes';
|
||||
const express = require('express');
|
||||
const roleRoutes = require('./routes/role.routes');
|
||||
|
||||
const app = express();
|
||||
const port = 3000;
|
||||
@@ -1,5 +1,5 @@
|
||||
import express from 'express';
|
||||
import { getConnection, query } from '../utils/db.util';
|
||||
const express = require('express');
|
||||
const { getConnection, query } = require('../utils/db.util');
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@@ -27,4 +27,4 @@ router.get('/recharges', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
module.exports = router;
|
||||
@@ -1,11 +1,11 @@
|
||||
import mysql from 'mysql';
|
||||
import { cdkDbConfig } from '../config/db.config';
|
||||
const mysql = require('mysql');
|
||||
const { cdkDbConfig } = require('../config/db.config');
|
||||
|
||||
// 创建连接池
|
||||
const pool = mysql.createPool(cdkDbConfig);
|
||||
|
||||
// 获取数据库连接
|
||||
export const getConnection = (): Promise<mysql.PoolConnection> => {
|
||||
exports.getConnection = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
pool.getConnection((err, connection) => {
|
||||
if (err) {
|
||||
@@ -18,9 +18,9 @@ export const getConnection = (): Promise<mysql.PoolConnection> => {
|
||||
};
|
||||
|
||||
// 执行查询
|
||||
export const query = async (sql: string, values?: any[], connection?: mysql.PoolConnection): Promise<any> => {
|
||||
exports.query = async (sql, values = [], connection) => {
|
||||
if (!connection) {
|
||||
connection = await getConnection()
|
||||
connection = await exports.getConnection();
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
connection.query(sql, values, (err, results) => {
|
||||
Reference in New Issue
Block a user