后端重构
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
import { mysqlTable, int, varchar, datetime } from 'drizzle-orm/mysql-core';
|
||||
import { sql } from 'drizzle-orm';
|
||||
|
||||
export const blackLists = mysqlTable('black_list', {
|
||||
id: int('id').primaryKey().autoincrement(),
|
||||
otaId: int('ota_id').notNull(),
|
||||
mac: varchar('mac', { length: 100 }).notNull(),
|
||||
createAt: datetime('create_at').notNull().default(sql`NOW()`),
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { mysqlTable, int, varchar } from 'drizzle-orm/mysql-core';
|
||||
|
||||
export const brands = mysqlTable('brand', {
|
||||
id: int('id').primaryKey().autoincrement(),
|
||||
name: varchar('name', { length: 100 }).notNull().unique(),
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
import { mysqlTable, int, tinyint, varchar, datetime } from 'drizzle-orm/mysql-core';
|
||||
import { sql } from 'drizzle-orm';
|
||||
|
||||
export const dashboardUsers = mysqlTable('dashboard_user', {
|
||||
id: int('id').primaryKey().autoincrement(),
|
||||
username: varchar('username', { length: 64 }).notNull().unique(),
|
||||
passwordHash: varchar('password_hash', { length: 255 }).notNull(),
|
||||
isSuperAdmin: tinyint('is_super_admin').notNull().default(0),
|
||||
status: tinyint('status').notNull().default(1),
|
||||
lastLoginAt: datetime('last_login_at'),
|
||||
createAt: datetime('create_at').notNull().default(sql`NOW()`),
|
||||
updateAt: datetime('update_at').notNull().default(sql`NOW()`),
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Schemas 统一导出
|
||||
*/
|
||||
export { brands } from './brand.js';
|
||||
export { models } from './model.js';
|
||||
export { otas } from './ota.js';
|
||||
export { otaTargetDevices } from './otaTargetDevice.js';
|
||||
export { blackLists } from './blackList.js';
|
||||
export { dashboardUsers } from './dashboardUser.js';
|
||||
export { shareCodeLogs } from './shareCodeLog.js';
|
||||
export { userActives } from './userActive.js';
|
||||
export { userDevices } from './userDevice.js';
|
||||
@@ -0,0 +1,13 @@
|
||||
import { mysqlTable, int, varchar, datetime } from 'drizzle-orm/mysql-core';
|
||||
import { sql } from 'drizzle-orm';
|
||||
|
||||
export const models = mysqlTable('model', {
|
||||
id: int('id').primaryKey().autoincrement(),
|
||||
brandName: varchar('brand_name', { length: 100 }).notNull(),
|
||||
name: varchar('name', { length: 100 }).notNull(),
|
||||
form: varchar('form', { length: 100 }),
|
||||
rig: varchar('rig', { length: 100 }),
|
||||
source: varchar('source', { length: 100 }),
|
||||
eqKey: varchar('eq_key', { length: 255 }),
|
||||
createAt: datetime('create_at').notNull().default(sql`NOW()`),
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
import { mysqlTable, int, smallint, varchar, datetime } from 'drizzle-orm/mysql-core';
|
||||
import { sql } from 'drizzle-orm';
|
||||
|
||||
export const otas = mysqlTable('ota', {
|
||||
id: int('id').primaryKey().autoincrement(),
|
||||
verCode: int('verCode').notNull(),
|
||||
verName: varchar('verName', { length: 20 }).notNull(),
|
||||
url: varchar('url', { length: 255 }).notNull(),
|
||||
md5: varchar('md5', { length: 32 }).notNull(),
|
||||
force: smallint('force').notNull().default(0),
|
||||
desc: varchar('desc', { length: 255 }),
|
||||
model: varchar('model', { length: 100 }),
|
||||
hw: int('hw').notNull().default(0),
|
||||
target: smallint('target').notNull().default(0),
|
||||
beta: smallint('beta').notNull().default(0),
|
||||
startTime: datetime('startTime'),
|
||||
endTime: datetime('endTime'),
|
||||
status: smallint('status').notNull().default(1),
|
||||
createAt: datetime('create_at').notNull().default(sql`NOW()`),
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
import { mysqlTable, int, varchar, datetime } from 'drizzle-orm/mysql-core';
|
||||
import { sql } from 'drizzle-orm';
|
||||
|
||||
export const otaTargetDevices = mysqlTable('ota_target_device', {
|
||||
id: int('id').primaryKey().autoincrement(),
|
||||
otaId: int('ota_id').notNull(),
|
||||
macAddr: varchar('mac_addr', { length: 17 }).notNull(),
|
||||
createAt: datetime('create_at').notNull().default(sql`NOW()`),
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
import { mysqlTable, int, char, varchar, json, datetime, index } from 'drizzle-orm/mysql-core';
|
||||
import { sql } from 'drizzle-orm';
|
||||
|
||||
export const shareCodeLogs = mysqlTable('share_code_log', {
|
||||
id: int('id').primaryKey().autoincrement(),
|
||||
macAddr: varchar('mac_addr', { length: 17 }).notNull(),
|
||||
shareCode: char('share_code', { length: 5 }).notNull(),
|
||||
action: varchar('action', { length: 10, enum: ['export', 'import'] }).notNull(),
|
||||
ipAddr: varchar('ip_addr', { length: 45 }).notNull().default(''),
|
||||
eqData: json('eq_data').notNull(),
|
||||
expireAt: datetime('expire_at'),
|
||||
createAt: datetime('create_at').notNull().default(sql`NOW()`),
|
||||
}, (table) => [
|
||||
index('idx_mac_addr').on(table.macAddr),
|
||||
index('idx_share_code').on(table.shareCode),
|
||||
index('idx_create_at').on(table.createAt),
|
||||
]);
|
||||
@@ -0,0 +1,11 @@
|
||||
import { mysqlTable, int, varchar, date, datetime } from 'drizzle-orm/mysql-core';
|
||||
import { sql } from 'drizzle-orm';
|
||||
|
||||
export const userActives = mysqlTable('user_active', {
|
||||
id: int('id').primaryKey().autoincrement(),
|
||||
macAddr: varchar('mac_addr', { length: 30 }).notNull(),
|
||||
model: varchar('model', { length: 50 }).notNull(),
|
||||
activeDate: date('active_date').notNull(),
|
||||
ipAddr: varchar('ip_addr', { length: 45 }).notNull(),
|
||||
createAt: datetime('create_at').notNull().default(sql`NOW()`),
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
import { mysqlTable, int, varchar, datetime } from 'drizzle-orm/mysql-core';
|
||||
import { sql } from 'drizzle-orm';
|
||||
|
||||
export const userDevices = mysqlTable('user_device', {
|
||||
id: int('id').primaryKey().autoincrement(),
|
||||
macAddr: varchar('mac_addr', { length: 30 }).notNull().unique(),
|
||||
model: varchar('model', { length: 50 }).notNull(),
|
||||
addTime: datetime('add_time').notNull().default(sql`NOW()`),
|
||||
ver: varchar('ver', { length: 10 }),
|
||||
});
|
||||
Reference in New Issue
Block a user