| 1234567891011121314151617181920212223242526 |
- import { query } from '../sql/query'; // 确保路径是正确的
- class ServerModel {
- //获取
- async getServerList(tag: any) {
- return await query(`SELECT id,status,name,ip,port,tips FROM game_server WHERE tag = ?`,[tag])
- }
- async getServerListById(tag: any, id:any) {
- return await query(`SELECT id,status,name,ip,port,tips FROM game_server WHERE tag = ? and id = ? `,[tag,id])
- }
- async getAllServerList(tag: any) {
- const rows = await query(`SELECT id,status,name,ip,port,tips FROM game_server WHERE tag = ?`,[tag])
- const resultArray = (rows as any[]).map(row => {
- return {
- sid : row.id,
- id : row.id,
- name: row.name,
- server :`ws://${row.ip}:${row.port}`,
- status: row.status,
- };
- });
- return resultArray
- }
- }
- module.exports = new ServerModel()
|