
-- 创建 sys_user 表
CREATE TABLE IF NOT EXISTS sys_user (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    username TEXT NOT NULL,
    nickname TEXT,
    password TEXT NOT NULL,
    avatar TEXT,
    role INTEGER,
    is_deleted INTEGER DEFAULT 0,
    create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 插入测试数据
INSERT INTO sys_user (username, nickname, password, avatar, role, is_deleted)
VALUES
    ('admin', 'Admin', '12345', 'admin.png', 0, 0),
    ('john_doe', 'John Doe', 'password123', 'avatar1.png', 1, 0),
    ('jane_smith', 'Jane Smith', 'password456', 'avatar2.png', 2, 0);


-- 创建 sys_role 表
CREATE TABLE IF NOT EXISTS sys_role (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL,
    code TEXT NOT NULL,
    create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 插入角色数据
INSERT INTO sys_role (name, code)
VALUES
    ('管理员', 'ADMIN'),
    ('普通用户', 'USER');

-- 创建 系统配置 表
CREATE TABLE IF NOT EXISTS sys_settings (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    parent_id INTEGER NOT NULL,
    name TEXT NOT NULL,
    code TEXT,
    value1 TEXT,
    value2 TEXT,
    value3 TEXT
);
INSERT INTO sys_settings (id, parent_id, name, code, value1, value2, value3)
VALUES
    (1, -1, '加热区域配置', 'heat_area', '坐标', '硬件代号', '' ),
    (2, 1, 'A1', 'heat_area_A1', '1,1,1', '', ''),
    (3, 1, 'A2', 'heat_area_A2', '2,2,2', '', ''),
    (4, 1, 'A3', 'heat_area_A3', '3,3,3', '', ''),
    (5, 1, 'A4', 'heat_area_A4', '4,4,4', '', ''),
    (6, 1, 'A5', 'heat_area_A5', '5,5,5', '', ''),
    (7, 1, 'A6', 'heat_area_A6', '6,6,6', '', ''),
    (8, -1, '加液区域配置', 'solution_area', '坐标', '硬件代号', '' ),
    (9, 8, '加液区', 'solution_area_A7', '7,7,7', '', '' ),
    (10, -1, '拍子区域配置', 'lid_area', '坐标', '硬件代号', '' ),
    (11, 10, '拍子存放区', 'lid_area_A8', '8,8,8', '', '' ),
    (12, -1, '其他系统配置', 'sys_setting', '系统配置的值', '', '' ),
    (13, 12, '溶液量低提示', 'sys_setting_volume', '300', '', '' ),
    (14, 12, '异常处理区', 'sys_setting_abnormal_area', '7' , '', ''),
    (15, 12, '设备信息', 'sys_setting_info', '12345' , '', '');


-- 创建 solutions 溶液 表
CREATE TABLE IF NOT EXISTS solutions (
     id INTEGER PRIMARY KEY AUTOINCREMENT,
     name VARCHAR NOT NULL,
     create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
     update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 创建 ores 矿石 表
CREATE TABLE IF NOT EXISTS ores (
     id INTEGER PRIMARY KEY AUTOINCREMENT,
     name VARCHAR NOT NULL,
     create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
     update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 创建 crafts 工艺 表
CREATE TABLE IF NOT EXISTS crafts (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      name VARCHAR NOT NULL,
      steps TEXT,
      ores_id INTEGER,
      create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
      update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
