You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
273 lines
11 KiB
273 lines
11 KiB
create table ImageFiles
|
|
(
|
|
id int auto_increment
|
|
primary key,
|
|
user_id varchar(10) not null comment '上传用户',
|
|
filepath varchar(50) not null comment '文件相对路径',
|
|
md5 varchar(32) not null comment '文件hash',
|
|
create_time datetime(6) default CURRENT_TIMESTAMP(6) not null comment '文件创建时间'
|
|
)
|
|
comment '图片文件信息';
|
|
|
|
create table Managers
|
|
(
|
|
id int auto_increment
|
|
primary key,
|
|
name varchar(10) not null,
|
|
password varchar(32) not null,
|
|
`desc` varchar(20) not null,
|
|
img_id int null,
|
|
account varchar(10) not null comment '帐号',
|
|
duty varchar(32) not null comment '职务',
|
|
constraint fk_Managers_img_id_id
|
|
foreign key (img_id) references ImageFiles (id)
|
|
)
|
|
comment '后台管理员';
|
|
|
|
create table ManagerTokens
|
|
(
|
|
id int auto_increment
|
|
primary key,
|
|
token varchar(32) not null,
|
|
ip varchar(32) not null,
|
|
create_time datetime(6) default CURRENT_TIMESTAMP(6) not null,
|
|
device varchar(256) not null,
|
|
manager_id int not null comment '授权管理员',
|
|
constraint fk_ManagerTokens_manager_id_id
|
|
foreign key (manager_id) references Managers (id)
|
|
)
|
|
comment '管理员授权令牌';
|
|
|
|
create table Notifications
|
|
(
|
|
id int auto_increment
|
|
primary key,
|
|
title varchar(10) not null comment '通知标题',
|
|
content varchar(256) not null comment '通知内容',
|
|
receiver_id int not null comment '接收者',
|
|
receiver_client varchar(10) not null comment '接收客户端',
|
|
`read` tinyint(1) default 0 not null comment '阅读状态',
|
|
pull tinyint(1) default 0 not null comment '拉取状态',
|
|
create_time datetime(6) default CURRENT_TIMESTAMP(6) not null comment '通知创建时间'
|
|
)
|
|
comment '通知记录';
|
|
|
|
create table Users
|
|
(
|
|
id int auto_increment
|
|
primary key,
|
|
name varchar(10) not null,
|
|
password varchar(32) not null,
|
|
`desc` varchar(20) not null,
|
|
img_id int null,
|
|
student_id varchar(8) not null comment '学号',
|
|
association_id int null comment '社团id',
|
|
constraint Users_student_id_unique
|
|
unique (student_id),
|
|
constraint fk_Users_img_id_id
|
|
foreign key (img_id) references ImageFiles (id)
|
|
)
|
|
comment '用户';
|
|
|
|
create table AuditLeggings
|
|
(
|
|
id int auto_increment
|
|
primary key,
|
|
user_id int not null comment '申请人',
|
|
apply_time datetime(6) default CURRENT_TIMESTAMP(6) not null comment '申请时间',
|
|
manager_id int null comment '负责人',
|
|
accept_time datetime(6) null comment '受理时间',
|
|
cause varchar(30) null comment '审核理由',
|
|
result tinyint(1) null comment '审核结果',
|
|
audit_time datetime(6) null comment '审核时间',
|
|
next_audit int null comment '复审记录',
|
|
constraint fk_AuditLeggings_manager_id_id
|
|
foreign key (manager_id) references Managers (id),
|
|
constraint fk_AuditLeggings_next_audit_id
|
|
foreign key (next_audit) references AuditLeggings (id),
|
|
constraint fk_AuditLeggings_user_id_id
|
|
foreign key (user_id) references Users (id)
|
|
)
|
|
comment '审核记录';
|
|
|
|
create table Associations
|
|
(
|
|
id int auto_increment
|
|
primary key,
|
|
name varchar(10) not null comment '社团名称',
|
|
`desc` varchar(30) not null comment '社团介绍',
|
|
logo int not null comment '社团logo',
|
|
level varchar(1) null comment '社团级别',
|
|
faculty varchar(32) not null comment '所属院系',
|
|
audit_id int not null comment '审核信息',
|
|
constraint fk_Associations_audit_id_id
|
|
foreign key (audit_id) references AuditLeggings (id),
|
|
constraint fk_Associations_logo_id
|
|
foreign key (logo) references ImageFiles (id)
|
|
)
|
|
comment '社团信息';
|
|
|
|
create table Activities
|
|
(
|
|
id int auto_increment
|
|
primary key,
|
|
activity_name varchar(10) not null comment '活动名称',
|
|
activity_time datetime(6) not null comment '活动时间',
|
|
activity_address varchar(30) not null comment '活动地点',
|
|
activity_desc varchar(30) not null comment '活动介绍',
|
|
activity_size int not null comment '活动人数',
|
|
audit_id int not null comment '审核信息',
|
|
association_id int not null comment '活动社团',
|
|
constraint fk_Activities_association_id_id
|
|
foreign key (association_id) references Associations (id),
|
|
constraint fk_Activities_audit_id_id
|
|
foreign key (audit_id) references AuditLeggings (id)
|
|
)
|
|
comment '社团活动';
|
|
|
|
create table ActivityComments
|
|
(
|
|
id int auto_increment
|
|
primary key,
|
|
content varchar(80) not null comment '评论内容',
|
|
create_time datetime(6) default CURRENT_TIMESTAMP(6) not null comment '评论时间',
|
|
user_id int not null comment '评论用户',
|
|
activity_id int not null comment '评论活动',
|
|
constraint fk_ActivityComments_activity_id_id
|
|
foreign key (activity_id) references Activities (id),
|
|
constraint fk_ActivityComments_user_id_id
|
|
foreign key (user_id) references Users (id)
|
|
)
|
|
comment '活动评论';
|
|
|
|
create table AssociationMembers
|
|
(
|
|
id int auto_increment
|
|
primary key,
|
|
user_id int not null comment '社团成员id',
|
|
association_id int not null comment '社团Id',
|
|
is_head tinyint(1) not null comment '是否团长',
|
|
constraint fk_AssociationMembers_association_id_id
|
|
foreign key (association_id) references Associations (id),
|
|
constraint fk_AssociationMembers_user_id_id
|
|
foreign key (user_id) references Users (id)
|
|
)
|
|
comment '社团成员信息';
|
|
|
|
create table JoinAssociations
|
|
(
|
|
id int auto_increment
|
|
primary key,
|
|
user_id int not null comment '申请人',
|
|
association_id int not null comment '申请社团',
|
|
create_time datetime(6) default CURRENT_TIMESTAMP(6) not null comment '申请时间',
|
|
audit_time datetime(6) null comment '审核时间',
|
|
result tinyint(1) null comment '申请结果',
|
|
constraint fk_JoinAssociations_association_id_id
|
|
foreign key (association_id) references Associations (id),
|
|
constraint fk_JoinAssociations_user_id_id
|
|
foreign key (user_id) references Users (id)
|
|
)
|
|
comment '入团申请记录';
|
|
|
|
create table LeaveMessages
|
|
(
|
|
id int auto_increment
|
|
primary key,
|
|
user_id int not null comment '留言用户',
|
|
message varchar(20) not null comment '留言内容',
|
|
create_time datetime(6) default CURRENT_TIMESTAMP(6) not null comment '留言创建时间',
|
|
constraint fk_LeaveMessages_user_id_id
|
|
foreign key (user_id) references Users (id)
|
|
)
|
|
comment '留言';
|
|
|
|
create table PhotoAlbums
|
|
(
|
|
id int auto_increment
|
|
primary key,
|
|
activity_id int not null comment '所属活动',
|
|
photo_id int not null comment '照片',
|
|
name varchar(10) not null comment '照片名',
|
|
constraint fk_PhotoAlbums_activity_id_id
|
|
foreign key (activity_id) references Activities (id),
|
|
constraint fk_PhotoAlbums_photo_id_id
|
|
foreign key (photo_id) references ImageFiles (id)
|
|
)
|
|
comment '相册';
|
|
|
|
create table Questions
|
|
(
|
|
id int auto_increment
|
|
primary key,
|
|
question varchar(30) not null comment '问题',
|
|
optionsA varchar(15) not null comment '选项A',
|
|
optionsB varchar(15) not null comment '选项B',
|
|
optionsC varchar(15) not null comment '选项C',
|
|
optionsD varchar(15) not null comment '选项D',
|
|
answer int not null comment '答案',
|
|
association_id int not null comment '所属社团',
|
|
constraint fk_Questions_association_id_id
|
|
foreign key (association_id) references Associations (id)
|
|
)
|
|
comment '题库';
|
|
|
|
create table Answers
|
|
(
|
|
id int auto_increment
|
|
primary key,
|
|
question_id int not null comment '问题',
|
|
answer int not null comment '答案',
|
|
join_id int not null comment '入团申请记录',
|
|
constraint fk_Answers_join_id_id
|
|
foreign key (join_id) references JoinAssociations (id),
|
|
constraint fk_Answers_question_id_id
|
|
foreign key (question_id) references Questions (id)
|
|
)
|
|
comment '试题';
|
|
|
|
create table Renames
|
|
(
|
|
id int auto_increment
|
|
primary key,
|
|
new_name varchar(10) not null comment '新名称',
|
|
cause varchar(30) not null comment '换名理由',
|
|
association_id int not null comment '重命名社团',
|
|
audit_id int not null comment '审核信息',
|
|
constraint fk_Renames_association_id_id
|
|
foreign key (association_id) references Associations (id),
|
|
constraint fk_Renames_audit_id_id
|
|
foreign key (audit_id) references AuditLeggings (id)
|
|
)
|
|
comment '社团重命名记录';
|
|
|
|
create table Tendencies
|
|
(
|
|
id int auto_increment
|
|
primary key,
|
|
user_id int not null comment '点赞用户',
|
|
activity_id int not null comment '点赞活动',
|
|
create_time datetime(6) default CURRENT_TIMESTAMP(6) not null comment '点赞时间',
|
|
type int not null comment '倾向类型',
|
|
constraint fk_Tendencies_activity_id_id
|
|
foreign key (activity_id) references Activities (id),
|
|
constraint fk_Tendencies_user_id_id
|
|
foreign key (user_id) references Users (id)
|
|
)
|
|
comment '用户倾向';
|
|
|
|
create table UserTokens
|
|
(
|
|
id int auto_increment
|
|
primary key,
|
|
token varchar(32) not null,
|
|
ip varchar(32) not null,
|
|
create_time datetime(6) default CURRENT_TIMESTAMP(6) not null,
|
|
device varchar(256) not null,
|
|
user_id int not null comment '授权用户',
|
|
constraint fk_UserTokens_user_id_id
|
|
foreign key (user_id) references Users (id)
|
|
)
|
|
comment '用户授权令牌';
|
|
|
|
|
|
|