-- Active: 1764662388986@@127.0.0.1@3306
CREATE DATABASE IF NOT EXISTS dudainfo DEFAULT CHARACTER SET "utf8mb4";

use dudainfo;

DROP Table if EXISTS admin;

CREATE Table admin (
    id INT PRIMARY KEY AUTO_INCREMENT COMMENT "管理员ID",
    username VARCHAR(60) COMMENT "管理员姓名",
    email VARCHAR(60) COMMENT "管理员邮箱",
    password VARCHAR(255) COMMENT "管理员密码",
    action_list TEXT COMMENT "管理员行为列表",
    add_time DATETIME COMMENT "创建时间",
    last_login DATETIME COMMENT "最后登录时间",
    last_ip VARCHAR(15) COMMENT "最后登录IP"
) COMMENT "管理员表";

INSERT INTO
    admin
VALUES (
        1,
        "admin",
        "123456@qq.com",
        "e10adc3949ba59abbe56e057f20f883e",
        'ALL',
        "2025-11-20 8:00:00",
        "2025-11-20 8:00:00",
        '127.0.0.1'
    );

drop Table if EXISTS product_category;

CREATE Table product_category (
    id SMALLINT(5) PRIMARY KEY AUTO_INCREMENT COMMENT "类型ID",
    name VARCHAR(255) COMMENT "类型名字",
    keywords VARCHAR(255) COMMENT "关键词",
    description VARCHAR(255) COMMENT "描述信息",
    parent_id SMALLINT(5) COMMENT "父类型ID",
    sort TINYINT(1) COMMENT "排序值"
) COMMENT "产品类型表";

DROP Table if EXISTS product;

CREATE Table product (
    id INT PRIMARY KEY AUTO_INCREMENT COMMENT "商品ID",
    name VARCHAR(100) COMMENT "商品名称",
    cat_id SMALLINT(5) COMMENT "商品类型ID",
    size VARCHAR(20) COMMENT "商品尺寸",
    price DECIMAL(10, 2) DEFAULT 0.0 COMMENT "商品价格",
    image VARCHAR(100) COMMENT "商品图片",
    content TEXT COMMENT "商品内容",
    keywords VARCHAR(255) COMMENT "商品关键词",
    add_time DATETIME COMMENT "新增时间",
    sort TINYINT(3) COMMENT "排序值"
) COMMENT "商品表";

DROP Table if EXISTS news_category;

CREATE Table news_category (
    id SMALLINT(5) PRIMARY KEY AUTO_INCREMENT COMMENT "类型ID",
    name VARCHAR(255) COMMENT "类型名字",
    keywords VARCHAR(255) COMMENT "关键词",
    description VARCHAR(255) COMMENT "描述信息",
    parent_id SMALLINT(5) COMMENT "父类型ID",
    sort TINYINT(1) COMMENT "排序值"
) COMMENT "新闻类型表";

DROP Table IF EXISTS news;

CREATE Table news (
    id INT PRIMARY KEY AUTO_INCREMENT COMMENT "新闻ID",
    cat_id SMALLINT(5) COMMENT "新闻类型ID",
    title VARCHAR(150) COMMENT "新闻标题",
    defined TEXT COMMENT "新闻定义",
    content LONGText COMMENT "新闻内容",
    image VARCHAR(255) COMMENT "新闻图片",
    click SMALLINT(5) COMMENT "点击数量",
    keywords VARCHAR(50) COMMENT "关键词",
    description VARCHAR(255) COMMENT "新闻描述",
    add_time DATETIME COMMENT "新增时间",
    sort TINYINT(3) COMMENT "排序值"
) COMMENT "新闻表";

DROP Table if EXISTS page;

CREATE Table page (
    id INT PRIMARY KEY AUTO_INCREMENT COMMENT "页面ID",
    name VARCHAR(150) COMMENT "页面名称",
    parent_id INT COMMENT "父页面ID",
    content LONGTEXT COMMENT "内容",
    keywords VARCHAR(255) COMMENT "关键词",
    description VARCHAR(255) COMMENT "页面描述"
) COMMENT "页面表";

DROP Table IF EXISTS config;

CREATE Table config (
    id INT PRIMARY KEY AUTO_INCREMENT COMMENT "配置ID",
    name VARCHAR(80) COMMENT "配置名称",
    value TEXT COMMENT "配置信息",
    type VARCHAR(10) COMMENT "配置类型",
    sort TINYINT(3) COMMENT "排序"
) COMMENT "配置表";