<?php
/**
 * 应用的数据表结构文件
 * structure.php
 */

return "
CREATE TABLE IF NOT EXISTS `oa_education_category` (
  `ca_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `ca_name` varchar(80) NOT NULL DEFAULT '' COMMENT '分类名称',
  `ca_desc` varchar(450) NOT NULL DEFAULT '' COMMENT '分类描述',
  `ca_status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '分类状态(0:禁用,1:启用)',
  `ca_order` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '排序,数字越小越靠前',
  `domain` varchar(32) NOT NULL DEFAULT '' COMMENT '企业域名',
  `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:初始化,2:已更新,3:已删除)',
  `created` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间(单位:毫秒)',
  `updated` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '最后更新时间(单位:毫秒)',
  `deleted` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '删除时间(单位:毫秒)',
  PRIMARY KEY (`ca_id`),
  KEY `ca_order` (`ca_order`),
  KEY `ca_status` (`ca_status`),
  KEY `domain_status` (`domain`,`status`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='培训分类表';

CREATE TABLE IF NOT EXISTS `oa_education_education` (
  `ed_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `ca_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '培训分类id,oa_education_category表主键',
  `ca_status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '分类状态(0:禁用,1:启用)',
  `ed_name` varchar(200) NOT NULL DEFAULT '' COMMENT '培训名称',
  `ed_begin_time` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '开始时间(单位:毫秒)',
  `ed_end_time` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '结束时间(单位:毫秒)',
  `ed_address` varchar(200) NOT NULL DEFAULT '' COMMENT '培训地点',
  `ed_cover_id` char(32) NOT NULL DEFAULT '' COMMENT '封面图id',
  `ed_introductions` text NOT NULL COMMENT '培训简介',
  `ed_is_sign_up` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否开启报名(0:否,1:是)',
  `ed_sign_deadline` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '报名截止时间(单位:毫秒)',
  `ed_is_charge` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否收费(0:否,1:是)',
  `ed_charge_type` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '收费类型(1=积分;2=学分)',
  `ed_charge_score` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '收费积分、学分数量',
  `ed_is_check` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否审核(0:否,1:是)',
  `ed_sign_up_number` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '报名人数(0:不限制人数)',
  `ed_is_recommend` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否开启首页推荐(0:否,1:是)',
  `ed_is_push_msg` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否开启消息通知(0:否,1:是)',
  `ed_joined_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '已参加人数',
  `ed_join_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '应参加人数',
  `ed_stop_time` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '终止时间(单位:毫秒)',
  `ed_status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '培训状态(0:初始化,1:草稿,2:已发布,3:已终止)',
  `ed_tags` varchar(105) NOT NULL DEFAULT '' COMMENT '标签,多个以分号分隔',
  `ed_comment_show_self` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '评论可见范围(0:所有人,1:本人)',
  `domain` varchar(32) NOT NULL DEFAULT '' COMMENT '企业域名',
  `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:初始化,2:已更新,3:已删除)',
  `created` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间(单位:毫秒)',
  `updated` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '最后更新时间(单位:毫秒)',
  `deleted` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '删除时间(单位:毫秒)',
  PRIMARY KEY (`ed_id`),
  KEY `ca_id` (`ca_id`),
  KEY `ed_status` (`ed_status`),
  KEY `domain_status` (`domain`,`status`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='培训基础信息表';

CREATE TABLE IF NOT EXISTS `oa_education_right` (
  `right_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `ed_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '培训id,oa_education表主键',
  `obj_type` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '权限类型(1:全公司,2:部门,3:标签,4:人员,5:职位,6:角色)',
  `obj_id` char(32) NOT NULL DEFAULT '' COMMENT '部门ID、标签ID、人员ID、职位ID、角色ID',
  `uid_is_import` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否导入用户(0:否,1:是)',
  `domain` varchar(32) NOT NULL DEFAULT '' COMMENT '企业域名',
  `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:初始化,2:已更新,3:已删除)',
  `created` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间(单位:毫秒)',
  `updated` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '最后更新时间(单位:毫秒)',
  `deleted` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '删除时间(单位:毫秒)',
  PRIMARY KEY (`right_id`),
  KEY `ed_id` (`ed_id`),
  KEY `obj_type` (`obj_type`),
  KEY `uid_is_import` (`uid_is_import`),
  KEY `domain_status` (`domain`,`status`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='培训权限表';

CREATE TABLE IF NOT EXISTS `oa_education_right_users` (
  `ru_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `ru_uid` char(32) NOT NULL DEFAULT '' COMMENT '员工id',
  `ru_sign_up_time` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '报名时间(单位:毫秒)',
  `ru_sign_status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '报名状态(0:初始化,1:已报名,2:未报名)',
  `ru_pay_status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '支付状态(0:初始化,1:已支付,2:未支付)',
  `ru_check_status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '审核状态(0:初始化,1:审核通过,2:审核不通过)',
  `ru_comments` varchar(420) NOT NULL DEFAULT '' COMMENT '备注',
  `milId` char(32) NOT NULL DEFAULT '' COMMENT '积分兑换id,用于业务做数据绑定',
  `ed_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '培训id,oa_education表主键',
  `domain` varchar(32) NOT NULL DEFAULT '' COMMENT '企业域名',
  `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:初始化,2:已更新,3:已删除)',
  `created` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间(单位:毫秒)',
  `updated` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '最后更新时间(单位:毫秒)',
  `deleted` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '删除时间(单位:毫秒)',
  PRIMARY KEY (`ru_id`),
  KEY `ed_id` (`ed_id`),
  KEY `ru_sign_status` (`ru_sign_status`),
  KEY `ru_pay_status` (`ru_pay_status`),
  KEY `ru_check_status` (`ru_check_status`),
  KEY `domain_status` (`domain`,`status`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='员工名单表';

CREATE TABLE IF NOT EXISTS `oa_education_sign` (
  `sign_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `sign_uid` char(32) NOT NULL DEFAULT '' COMMENT '签到人id',
  `sign_on_time` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '签到时间(单位:毫秒)',
  `ed_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '培训id,oa_education表主键',
  `plan_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '培训计划id,oa_education_plan表主键',
  `article_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '线下课程ID',
  `domain` varchar(32) NOT NULL DEFAULT '' COMMENT '企业域名',
  `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:初始化,2:已更新,3:已删除)',
  `created` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间(单位:毫秒)',
  `updated` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '最后更新时间(单位:毫秒)',
  `deleted` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '删除时间(单位:毫秒)',
  PRIMARY KEY (`sign_id`),
  KEY `ed_id` (`ed_id`),
  KEY `plan_id` (`plan_id`),
  KEY `domain_status` (`domain`,`status`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='考勤签到表';

CREATE TABLE IF NOT EXISTS `oa_education_plan` (
  `plan_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `plan_name` varchar(200) NOT NULL DEFAULT '' COMMENT '名称',
  `plan_type` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '类型(1=签到;2=线上课程;3=问卷;4=考试;5=照片墙;6=线下课程)',
  `plan_sign_begin` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '签到开始时间(单位:毫秒)',
  `plan_sign_end` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '签到结束时间(单位:毫秒)',
  `plan_sign_comments` varchar(420) NOT NULL DEFAULT '' COMMENT '签到提示信息',
  `plan_allow_upload` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'plan_type=5时,是否允许员工上传照片(0:否,1:是),默认为0',
  `plan_obj_id` int(10) NOT NULL DEFAULT '0' COMMENT '素材id、问卷id、考试id,plan_type=1或plan_type=5时为0',
  `plan_use_status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '启用状态(0:失效,1:启用),默认为1,启用时间默认为当前时间',
  `plan_use_time` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '启用时间(单位:毫秒)',
  `plan_order` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '排序,数字越小越靠前',
  `ed_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '培训id,oa_education表主键,一个类型最多添加10个',
  `stage_id` int(11) NOT NULL DEFAULT '0' COMMENT '培训阶段ID',
  `domain` varchar(32) NOT NULL DEFAULT '' COMMENT '企业域名',
  `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:初始化,2:已更新,3:已删除)',
  `created` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间(单位:毫秒)',
  `updated` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '最后更新时间(单位:毫秒)',
  `deleted` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '删除时间(单位:毫秒)',
  PRIMARY KEY (`plan_id`),
  KEY `ed_id` (`ed_id`),
  KEY `plan_type` (`plan_type`),
  KEY `plan_order` (`plan_order`),
  KEY `domain_status` (`domain`,`status`),
  KEY `stage_id` (`stage_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='培训计划表';

CREATE TABLE IF NOT EXISTS `oa_education_plan_do` (
  `pd_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `pd_uid` char(32) NOT NULL DEFAULT '' COMMENT '员工id',
  `plan_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '培训计划id,oa_education_plan表主键',
  `ed_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '培训id,oa_education表主键',
  `domain` varchar(32) NOT NULL DEFAULT '' COMMENT '企业域名',
  `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:初始化,2:已更新,3:已删除)',
  `created` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间(单位:毫秒)',
  `updated` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '最后更新时间(单位:毫秒)',
  `deleted` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '删除时间(单位:毫秒)',
  PRIMARY KEY (`pd_id`),
  KEY `ed_id` (`ed_id`),
  KEY `domain_status` (`domain`,`status`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='培训计划员工操作状态表';

CREATE TABLE IF NOT EXISTS `oa_education_plan_pic` (
  `pic_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `pic_name` varchar(420) NOT NULL DEFAULT '' COMMENT '照片名称',
  `pic_at_id` char(32) NOT NULL DEFAULT '' COMMENT '照片附件id',
  `pic_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '照片上传类型标识(0:手机端用户上传,1:后台管理员上传)',
  `pic_uid` char(32) NOT NULL DEFAULT '' COMMENT '上传用户id(pic_type=1时,管理员有关联员工,存关联的memUid,没有关联则为空)',
  `pic_likes` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '点赞量',
  `plan_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '培训计划id,oa_education_plan表主键',
  `ed_id` int(10) unsigned NOT NULL DEFAULT '0',
  `domain` varchar(32) NOT NULL DEFAULT '' COMMENT '企业域名',
  `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:初始化,2:已更新,3:已删除)',
  `created` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间(单位:毫秒)',
  `updated` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '最后更新时间(单位:毫秒)',
  `deleted` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '删除时间(单位:毫秒)',
  PRIMARY KEY (`pic_id`),
  KEY `ed_id` (`ed_id`),
  KEY `plan_id` (`plan_id`),
  KEY `domain_status` (`domain`,`status`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='照片墙照片表';

CREATE TABLE IF NOT EXISTS `oa_education_comment_options` (
  `option_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `option_type` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '评价类型(1:培训过程,2:培训内容,3:培训讲师)',
  `option_name` varchar(60) NOT NULL DEFAULT '' COMMENT '评价选项名称',
  `option_score` int(10) unsigned NOT NULL DEFAULT '1' COMMENT '分值,范围1-10',
  `option_order` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '排序,数字越小越靠前',
  `ed_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '培训id,oa_education表主键,限制添加总数为9个',
  `domain` varchar(32) NOT NULL DEFAULT '' COMMENT '企业域名',
  `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:初始化,2:已更新,3:已删除)',
  `created` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间(单位:毫秒)',
  `updated` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '最后更新时间(单位:毫秒)',
  `deleted` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '删除时间(单位:毫秒)',
  PRIMARY KEY (`option_id`),
  KEY `ed_id` (`ed_id`),
  KEY `option_order` (`option_order`),
  KEY `domain_status` (`domain`,`status`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='评价选项表';

CREATE TABLE IF NOT EXISTS `oa_education_comment` (
  `c_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `c_uid` char(32) NOT NULL DEFAULT '' COMMENT '评价人id',
  `c_avg_option1` decimal(5,1) NOT NULL DEFAULT '0.0' COMMENT '培训过程均分',
  `c_avg_option2` decimal(5,1) NOT NULL DEFAULT '0.0' COMMENT '培训内容均分',
  `c_avg_option3` decimal(5,1) NOT NULL DEFAULT '0.0' COMMENT '培训讲师均分',
  `c_content` varchar(420) NOT NULL DEFAULT '' COMMENT '意见反馈',
  `c_likes` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '点赞量',
  `c_is_anonymous` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否匿名(0:否,1:是)',
  `ed_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '培训id,oa_education表主键',
  `domain` varchar(32) NOT NULL DEFAULT '' COMMENT '企业域名',
  `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:初始化,2:已更新,3:已删除)',
  `created` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间(单位:毫秒)',
  `updated` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '最后更新时间(单位:毫秒)',
  `deleted` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '删除时间(单位:毫秒)',
  PRIMARY KEY (`c_id`),
  KEY `ed_id` (`ed_id`),
  KEY `domain_status` (`domain`,`status`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='培训评价表';

CREATE TABLE IF NOT EXISTS `oa_education_comment_score` (
  `cs_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `cs_score` decimal(5,1) NOT NULL DEFAULT '0.0' COMMENT '分值,以0.5分为一个刻度',
  `ed_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '培训id,oa_education表主键',
  `c_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '培训评价id,oa_education_comment表主键',
  `option_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '评价选项id,oa_education_comment_options表主键',
  `domain` varchar(32) NOT NULL DEFAULT '' COMMENT '企业域名',
  `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:初始化,2:已更新,3:已删除)',
  `created` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间(单位:毫秒)',
  `updated` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '最后更新时间(单位:毫秒)',
  `deleted` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '删除时间(单位:毫秒)',
  PRIMARY KEY (`cs_id`),
  KEY `ed_id` (`ed_id`),
  KEY `c_id` (`c_id`),
  KEY `option_id` (`option_id`),
  KEY `domain_status` (`domain`,`status`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='培训评价评分表';

CREATE TABLE IF NOT EXISTS `oa_education_composite_score` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `score` decimal(5,1) NOT NULL DEFAULT '0.0' COMMENT '综合分值,以0.5分为一个刻度',
  `ed_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '培训id,oa_education表主键',
  `option_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '评价选项id,oa_education_comment_options表主键',
  `domain` varchar(32) NOT NULL DEFAULT '' COMMENT '企业域名',
  `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:初始化,2:已更新,3:已删除)',
  `created` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间(单位:毫秒)',
  `updated` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '最后更新时间(单位:毫秒)',
  `deleted` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '删除时间(单位:毫秒)',
  PRIMARY KEY (`id`),
  KEY `ed_id` (`ed_id`),
  KEY `domain_status` (`domain`,`status`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='培训综合评分表';

CREATE TABLE IF NOT EXISTS `oa_education_incentives` (
  `sr_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `sr_uid` char(32) NOT NULL DEFAULT '' COMMENT '员工id',
  `sr_medal` text NOT NULL COMMENT '勋章,多个以分号分隔',
  `sr_score` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '积分',
  `sr_credit` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '学分',
  `sr_give_status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '激励发放状态(0:未发放,1:已发放)',
  `ed_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '培训id,oa_education表主键',
  `domain` varchar(32) NOT NULL DEFAULT '' COMMENT '企业域名',
  `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:初始化,2:已更新,3:已删除)',
  `created` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间(单位:毫秒)',
  `updated` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '最后更新时间(单位:毫秒)',
  `deleted` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '删除时间(单位:毫秒)',
  PRIMARY KEY (`sr_id`),
  KEY `ed_id` (`ed_id`),
  KEY `sr_give_status` (`sr_give_status`),
  KEY `domain_status` (`domain`,`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='员工培训激励表';

CREATE TABLE IF NOT EXISTS `oa_education_like` (
  `like_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `like_type` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '点赞类型(1:评价点赞,2:照片点赞)',
  `like_obj_id` int(10) NOT NULL DEFAULT '0' COMMENT 'pic_id或c_id',
  `like_uid` char(32) NOT NULL DEFAULT '' COMMENT '点赞人id',
  `ed_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '培训id,oa_education表主键',
  `domain` varchar(32) NOT NULL DEFAULT '' COMMENT '企业域名',
  `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:初始化,2:已更新,3:已删除)',
  `created` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间(单位:毫秒)',
  `updated` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '最后更新时间(单位:毫秒)',
  `deleted` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '删除时间(单位:毫秒)',
  PRIMARY KEY (`like_id`),
  KEY `ed_id` (`ed_id`),
  KEY `like_type` (`like_type`),
  KEY `domain_status` (`domain`,`status`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='点赞表';

CREATE TABLE IF NOT EXISTS `oa_education_setting` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `key` varchar(255) NOT NULL DEFAULT '' COMMENT '键',
  `value` text NOT NULL COMMENT '值',
  `type` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '类型(0:非数组, 1:数组)',
  `comment` text NOT NULL COMMENT '说明',
  `domain` varchar(32) NOT NULL DEFAULT '' COMMENT '企业域名',
  `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:初始化,2:已更新,3:已删除)',
  `created` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间(单位:毫秒)',
  `updated` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间(单位:毫秒)',
  `deleted` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '删除时间(单位:毫秒)',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='培训设置表';

CREATE TABLE IF NOT EXISTS `oa_education_syscache` (
  `name` varchar(255) NOT NULL COMMENT '缓存文件名',
  `type` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '缓存类型(0:非数组,1:数组)',
  `data` mediumblob NOT NULL COMMENT '数据',
  `domain` varchar(32) NOT NULL DEFAULT '' COMMENT '企业域名',
  `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:初始化,2:已更新,3:已删除)',
  `created` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间(单位:毫秒)',
  `updated` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间(单位:毫秒)',
  `deleted` bigint(13) unsigned NOT NULL DEFAULT '0' COMMENT '删除时间(单位:毫秒)'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='培训缓存表';

CREATE TABLE IF NOT EXISTS `oa_education_course_article` (
  `article_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `ed_id` int(10) unsigned NOT NULL COMMENT '培训id',
  `plan_id` int(10) unsigned NOT NULL COMMENT '培训安排id',
  `article_title` varchar(64) NOT NULL COMMENT '课程名称',
  `start_time` bigint(20) NOT NULL COMMENT '授课开始时间',
  `end_time` bigint(20) NOT NULL COMMENT '授课结束时间',
  `cover_id` char(32) NOT NULL COMMENT '封面图片ID',
  `cover_url` varchar(500) NOT NULL COMMENT '封面图片URL',
  `content` text NOT NULL COMMENT '系列课程介绍',
  `credit` int(11) NOT NULL COMMENT '学分',
  `teacher_id` int(10) unsigned NOT NULL COMMENT '讲师ID',
  `teacher_task_id` int(10) unsigned NOT NULL COMMENT '讲师授课任务ID',
  `address` varchar(64) NOT NULL COMMENT '授课地址',
  `class_hour` float NOT NULL COMMENT '讲师授课课时',
  `is_notice` tinyint(4) unsigned NOT NULL COMMENT '消息通知(1=不开启;2=开启)',
  `is_score` tinyint(4) NOT NULL DEFAULT '1' COMMENT '是否启用评分(1=不启用;2=启用)',
  `is_sign` tinyint(4) NOT NULL COMMENT '是否启用签到(1=不启用;2=启用)',
  `domain` char(32) NOT NULL COMMENT '企业域名',
  `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '数据状态:1=新创建;2=已更新;3=已删除',
  `created` bigint(20) NOT NULL DEFAULT '0' COMMENT '创建时间',
  `updated` bigint(20) NOT NULL DEFAULT '0' COMMENT '更新时间',
  `deleted` bigint(20) NOT NULL DEFAULT '0' COMMENT '删除时间',
  PRIMARY KEY (`article_id`),
  KEY `domain` (`domain`) USING BTREE,
  KEY `article_title` (`article_title`) USING BTREE,
  KEY `teacher_id` (`teacher_id`),
  KEY `teacher_task_id` (`teacher_task_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='线下课程表';

CREATE TABLE IF NOT EXISTS `oa_education_course_item` (
  `item_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `article_id` int(10) NOT NULL COMMENT '课程ID',
  `content` varchar(15) NOT NULL COMMENT '评分内容',
  `score_type` tinyint(1) NOT NULL COMMENT '评分类型(1=课程内容;2=课程讲师)',
  `score_total` int(10) unsigned NOT NULL COMMENT '总得分',
  `user_total` int(10) unsigned NOT NULL COMMENT '总人数',
  `score_order` int(10) NOT NULL COMMENT '排序',
  `domain` char(32) NOT NULL COMMENT '企业域名',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '数据状态(1=新创建;2=已更新;3=已删除)',
  `created` bigint(20) NOT NULL DEFAULT '0' COMMENT '创建时间',
  `updated` bigint(20) NOT NULL DEFAULT '0' COMMENT '更新时间',
  `deleted` bigint(20) NOT NULL DEFAULT '0' COMMENT '删除时间',
  PRIMARY KEY (`item_id`),
  KEY `domain` (`domain`) USING BTREE,
  KEY `status` (`status`) USING BTREE,
  KEY `article_id` (`article_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='线下课程评分项';

CREATE TABLE IF NOT EXISTS `oa_education_course_score_detail` (
  `score_detail_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `article_id` int(11) NOT NULL COMMENT '课程ID',
  `uid` char(32) NOT NULL COMMENT '用户ID',
  `username` varchar(64) NOT NULL COMMENT '姓名',
  `content_score` float NOT NULL COMMENT '内容平均分',
  `teacher_score` float NOT NULL COMMENT '讲师平均分',
  `domain` char(32) NOT NULL COMMENT '企业域名',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '数据状态(1=新创建;2=已更新;3=已删除)',
  `created` bigint(20) NOT NULL DEFAULT '0' COMMENT '创建时间',
  `updated` bigint(20) NOT NULL DEFAULT '0' COMMENT '更新时间',
  `deleted` bigint(20) NOT NULL DEFAULT '0' COMMENT '删除时间',
  PRIMARY KEY (`score_detail_id`),
  KEY `domain` (`domain`) USING BTREE,
  KEY `uid` (`uid`) USING BTREE,
  KEY `article_id` (`article_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='线下课程评分个人平均分数表';

CREATE TABLE IF NOT EXISTS `oa_education_course_score_record` (
  `score_record_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `article_id` int(11) NOT NULL COMMENT '课程ID',
  `uid` char(32) NOT NULL COMMENT '用户ID',
  `username` varchar(64) NOT NULL COMMENT '姓名',
  `item_id` int(11) NOT NULL COMMENT '设置项ID',
  `score_type` tinyint(1) NOT NULL COMMENT '评分类型(1=课程内容;2=课程讲师)',
  `score_value` int(11) NOT NULL COMMENT '分数',
  `domain` char(32) NOT NULL COMMENT '企业域名',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '数据状态(1=新创建;2=已更新;3=已删除)',
  `created` bigint(20) NOT NULL DEFAULT '0' COMMENT '创建时间',
  `updated` bigint(20) NOT NULL DEFAULT '0' COMMENT '更新时间',
  `deleted` bigint(20) NOT NULL DEFAULT '0' COMMENT '删除时间',
  PRIMARY KEY (`score_record_id`),
  KEY `domain` (`domain`) USING BTREE,
  KEY `article_id` (`article_id`) USING BTREE,
  KEY `uid` (`uid`) USING BTREE,
  KEY `item_id` (`item_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='线下课程评分记录表';

CREATE TABLE IF NOT EXISTS `oa_education_cron` (
  `education_cron_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `article_id` int(10) NOT NULL COMMENT '线下课程id',
  `cron_id` char(32) NOT NULL COMMENT '计划任务ID',
  `domain` char(32) NOT NULL COMMENT '企业域名',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '数据状态(1=新创建;2=已更新;3=已删除)',
  `created` bigint(20) NOT NULL DEFAULT '0' COMMENT '创建时间',
  `updated` bigint(20) NOT NULL DEFAULT '0' COMMENT '更新时间',
  `deleted` bigint(20) NOT NULL DEFAULT '0' COMMENT '删除时间',
  PRIMARY KEY (`education_cron_id`),
  KEY `cron_id` (`cron_id`),
  KEY `domain` (`domain`),
  KEY `article_id` (`article_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='计划任务表';

CREATE TABLE IF NOT EXISTS `oa_education_stage` (
  `stage_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `ed_id` int(11) NOT NULL COMMENT '培训ID',
  `stage_name` varchar(64) NOT NULL COMMENT '培训阶段名称',
  `stage_order` int(11) NOT NULL COMMENT '排序',
  `domain` char(32) NOT NULL COMMENT '企业域名',
  `status` tinyint(4) NOT NULL COMMENT '状态(1=初始化;2=已更新;3=已删除)',
  `created` bigint(13) NOT NULL COMMENT '创建时间',
  `updated` bigint(13) NOT NULL COMMENT '更新时间',
  `deleted` bigint(13) NOT NULL COMMENT '删除时间',
  PRIMARY KEY (`stage_id`),
  KEY `ed_id` (`ed_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='培训阶段表';

CREATE TABLE IF NOT EXISTS `oa_education_reward` (
  `reward_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `uid` char(32) NOT NULL COMMENT '人员id',
  `article_id` int(11) NOT NULL COMMENT '线下课程id',
  `reward_type` tinyint(4) NOT NULL COMMENT '奖励类型(1=积分;2=学分)',
  `amount` int(11) NOT NULL COMMENT '奖励数量',
  `domain` char(32) NOT NULL COMMENT '企业域名',
  `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '数据状态(1=新创建;2=已更新;3=已删除)',
  `created` bigint(20) NOT NULL DEFAULT '0' COMMENT '创建时间',
  `updated` bigint(20) NOT NULL DEFAULT '0' COMMENT '更新时间',
  `deleted` bigint(20) NOT NULL DEFAULT '0' COMMENT '删除时间',
  PRIMARY KEY (`reward_id`),
  KEY `article_id` (`article_id`),
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='线下课程发放学分记录';
";