-- 协助采购 — 通知公告（执行一次；也可由后台首次访问自动建表）
-- 菜单需在「权限管理」中手动添加，或访问 purchasecontent/install（超级管理员）

CREATE TABLE IF NOT EXISTS `purchase_content` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `creator_id` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '创建人',
  `sender_id` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '投递人',
  `subject` varchar(255) NOT NULL DEFAULT '' COMMENT '主题',
  `content` mediumtext COMMENT '内容',
  `createtime` datetime DEFAULT NULL COMMENT '投递时间',
  `updatetime` datetime DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`),
  KEY `idx_creator` (`creator_id`),
  KEY `idx_sender` (`sender_id`),
  KEY `idx_ct` (`createtime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='协助采购通知公告';

CREATE TABLE IF NOT EXISTS `purchase_content_recipient` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `content_id` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '公告ID',
  `admin_id` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '接收人',
  `read_time` datetime DEFAULT NULL COMMENT '首次阅读时间',
  `createtime` datetime DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_content_admin` (`content_id`,`admin_id`),
  KEY `idx_admin` (`admin_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='通知公告接收人';
