-- 培训签到：动态令牌 + 打卡记录
-- 执行环境：lqerp_dev / 生产库按需执行

CREATE TABLE IF NOT EXISTS `lq_training_checkin_token` (
  `F_Id` varchar(50) NOT NULL COMMENT '主键',
  `token_hash` varchar(64) NOT NULL COMMENT '令牌哈希(SHA256)',
  `plain_token` varchar(128) NOT NULL COMMENT '令牌明文(短生命周期,投屏展示)',
  `expire_time` datetime NOT NULL COMMENT '过期时间',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  PRIMARY KEY (`F_Id`),
  KEY `idx_token_hash` (`token_hash`),
  KEY `idx_expire_time` (`expire_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='培训签到动态令牌';

CREATE TABLE IF NOT EXISTS `lq_training_checkin_record` (
  `F_Id` varchar(50) NOT NULL COMMENT '主键',
  `real_name` varchar(50) NOT NULL COMMENT '姓名',
  `mobile_phone` varchar(20) NOT NULL COMMENT '手机号',
  `checkin_type` int NOT NULL COMMENT '类型：1签到 2签退',
  `checkin_time` datetime NOT NULL COMMENT '打卡时间',
  `submit_ip` varchar(64) DEFAULT NULL COMMENT '提交IP',
  `token_id` varchar(50) DEFAULT NULL COMMENT '关联令牌ID',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  PRIMARY KEY (`F_Id`),
  KEY `idx_checkin_time` (`checkin_time`),
  KEY `idx_mobile` (`mobile_phone`),
  KEY `idx_type` (`checkin_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='培训签到记录';
