class Blog(Model): """ 博客表 create table blogs ( `id` varchar(50) not null, `user_id` varchar(50) not null, `user_name` varchar(50) not null, `user_image` varchar(500) not null, `name` varchar(50) not null, `cover_image` varchar(500) NOT NULL DEFAULT '', `summary` varchar(200) not null, `content` mediumtext not null, `read_times` bigint(20) unsigned zerofill NOT NULL DEFAULT '00000000000000000000', `type` varchar(50) not null, `created_at` real not null, key `idx_created_at` (`created_at`), primary key (`id`) ) engine=innodb default charset=utf8; """ __table__ = 'blogs' id = StringField(primary_key=True, default=generate_id, ddl='varchar(50)') user_id = StringField(ddl='varchar(50)') user_name = StringField(ddl='varchar(50)') user_image = StringField(ddl='varchar(500)') name = StringField(ddl='varchar(50)') cover_image = StringField(ddl='varchar(500)') summary = StringField(ddl='varchar(200)') content = TextField() read_times = IntegerField() type = StringField(ddl='varchar(50)') created_at = FloatField(default=time.time)
class BlogType(Model): """ 博客类型表 CREATE TABLE `blog_type` ( `id` varchar(50) NOT NULL, `name` varchar(50) NOT NULL, `level` bigint(20) unsigned NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; """ __table__ = 'blog_type' id = StringField(primary_key=True, default=generate_id, ddl='varchar(50)') name = StringField(ddl='varchar(50)') level = IntegerField()
class Image(Model): """ 图片表 create table images ( `id` varchar(50) not null, `url` varchar(500) not null, `created_at` real not null, key `idx_created_at` (`created_at`), primary key (`id`) ) engine=innodb default charset=utf8; """ __table__ = 'images' id = StringField(primary_key=True, default=generate_id, ddl='varchar(50)') url = StringField(ddl='varchar(500)') created_at = FloatField(default=time.time)
class UserAuth(Model): """ 用户验证表类 create table user_auth ( `id` varchar(50) not null, `email` varchar(50) not null, `password` varchar(50) not null, unique key `idx_email` (`email`), primary key (`id`) ) engine=innodb default charset=utf8; """ # 定义表名称 __table__ = 'user_auth' id = StringField(primary_key=True, default=generate_id, ddl='varchar(50)') email = StringField(primary_key=False, default=None, ddl='varchar(50)') password = StringField(primary_key=False, default=None, ddl='varchar(50)')
class Comment(Model): """ 评论表 CREATE TABLE `comments` ( `id` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, `blog_id` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, `user_id` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, `user_name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, `user_image` varchar(500) COLLATE utf8mb4_unicode_ci NOT NULL, `target_user_id` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, `target_user_name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, `content` mediumtext COLLATE utf8mb4_unicode_ci, `created_at` double NOT NULL, PRIMARY KEY (`id`), KEY `idx_created_at` (`created_at`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; """ __table__ = 'comments' id = StringField(primary_key=True, default=generate_id, ddl='varchar(50)') blog_id = StringField(ddl='varchar(50)') user_id = StringField(ddl='varchar(50)') user_name = StringField(ddl='varchar(50)') user_image = StringField(ddl='varchar(500)') target_user_id = StringField(ddl='varchar(50)') target_user_name = StringField(ddl='varchar(50)') content = TextField() created_at = FloatField(default=time.time)
class UserInfo(Model): """ 用户信息表类 create table user_info ( `id` varchar(50) not null, `admin` bool not null, `name` varchar(50) not null, `image` varchar(500) not null, `created_at` real not null, key `idx_created_at` (`created_at`), primary key (`id`) ) engine=innodb default charset=utf8; """ # 定义表名称 __table__ = 'user_info' id = StringField(primary_key=True, default=generate_id, ddl='varchar(50)') admin = BooleanField(default=False) name = StringField(primary_key=False, default=None, ddl='varchar(50)') image = StringField(primary_key=False, default=None, ddl='varchar(500)') created_at = FloatField(primary_key=False, default=time.time)