数据库

视频数据库

视频表

CREATE TABLE `tb_video` (
`id` char(19) NOT NULL COMMENT '视频ID',
`video_type` int(2) NOT NULL COMMENT '课程类型,0:单视频,1:系列',
`video_title` varchar(50) NOT NULL COMMENT '视频名称',
`video_cover` varchar(255) DEFAULT NULL COMMENT '视频封面',
`video_url` varchar(255) DEFAULT NULL COMMENT '视频连接',
`video_status` int(2) NOT NULL COMMENT '发布状态,0:未发布,1:已发布',
`video_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '视频点击次数',
`version` bigint(20) unsigned NOT NULL DEFAULT '1' COMMENT '乐观锁',
`is_deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT '逻辑删除 1(true)已删除, 0(false)未删除',
`gmt_create` datetime NOT NULL COMMENT '创建时间',
`gmt_modified` datetime NOT NULL COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='视频';

视频系列表

CREATE TABLE `tb_video_set` (
`id` char(19) NOT NULL COMMENT 'ID',
`video_id` char(19) NOT NULL COMMENT '所属系列ID',
`video_sort` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '系列位置',
`video_url` varchar(255) DEFAULT NULL COMMENT '视频地址',
`version` bigint(20) unsigned NOT NULL DEFAULT '1' COMMENT '乐观锁',
`gmt_create` datetime NOT NULL COMMENT '创建时间',
`gmt_modified` datetime NOT NULL COMMENT '更新时间',
PRIMARY KEY (`id`),
KEY `idx_vdeio` (`video_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='视频系列';

视频收藏表

CREATE TABLE `tb_collection` (
`id` char(19) NOT NULL COMMENT 'ID',
`video_id` char(19) NOT NULL COMMENT '视频ID',
`member_collection_id` char(19) NOT NULL COMMENT '收藏者ID',
`gmt_create` datetime NOT NULL COMMENT '创建时间',
`gmt_modified` datetime NOT NULL COMMENT '更新时间',
PRIMARY KEY (`id`),
KEY `idx_vdeio` (`video_id`),
KEY `idx_member` (`member_collection_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='视频收藏';

用户数据库

用户表

CREATE TABLE `tb_member` (
`id` char(19) NOT NULL COMMENT '会员id',
`openid` varchar(128) DEFAULT NULL COMMENT '微信openid',
`mobile` varchar(11) DEFAULT '' COMMENT '手机号',
`password` varchar(255) DEFAULT NULL COMMENT '密码',
`nickname` varchar(50) DEFAULT NULL COMMENT '昵称',
`sex` tinyint(2) unsigned DEFAULT NULL COMMENT '性别 1 男,2 女',
`age` tinyint(3) unsigned DEFAULT NULL COMMENT '年龄',
`avatar` varchar(255) DEFAULT NULL COMMENT '用户头像',
`sign` varchar(100) DEFAULT NULL COMMENT '用户签名',
`follow_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '关注数量',
`fans_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '粉丝数量',
`is_deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT '逻辑删除 1(true)已删除, 0(false)未删除',
`gmt_create` datetime NOT NULL COMMENT '创建时间',
`gmt_modified` datetime NOT NULL COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员表';

关注粉丝表

CREATE TABLE `tb_follow_fans` (
`id` char(19) NOT NULL COMMENT 'ID',
`member_fans_id` char(19) NOT NULL COMMENT '关注者ID',
`member_follow_id` char(19) NOT NULL COMMENT '被关注者ID',
`gmt_create` datetime NOT NULL COMMENT '创建时间',
`gmt_modified` datetime NOT NULL COMMENT '更新时间',
PRIMARY KEY (`id`),
KEY `idx_fans` (`member_fans_id`),
KEY `idx_follow` (`member_follow_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='用户关注';

代码生成器

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class BaseEntity implements Serializable {

private static final long serialVersionUID=1L;

@ApiModelProperty(value = "表id")
@TableId(value = "id", type = IdType.ASSIGN_ID)
private String id;

@ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT)
private Date gmtCreate;

@ApiModelProperty(value = "更新时间")
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date gmtModified;

}
public class CodeGenerator {

@Test
public void genCode() {

String database = "likeever_video";
String moduleName = "video";

// 1、创建代码生成器
AutoGenerator mpg = new AutoGenerator();

// 2、全局配置
GlobalConfig gc = new GlobalConfig();
String projectPath = System.getProperty("user.dir");
gc.setOutputDir(projectPath + "/src/main/java");
gc.setAuthor("Kuang");
gc.setOpen(false); //生成后是否打开资源管理器
// gc.setFileOverride(false); //重新生成时文件是否覆盖
gc.setServiceName("%sService"); //去掉Service接口的首字母I
gc.setIdType(IdType.ASSIGN_ID); //主键策略
gc.setDateType(DateType.ONLY_DATE);//定义生成的实体类中日期类型
gc.setSwagger2(true);//开启Swagger2模式
mpg.setGlobalConfig(gc);

// 3、数据源配置
DataSourceConfig dsc = new DataSourceConfig();
dsc.setUrl("jdbc:mysql://localhost:3306/" + database + "?serverTimezone=GMT%2B8");
dsc.setDriverName("com.mysql.cj.jdbc.Driver");
dsc.setUsername("root");
dsc.setPassword("123456");
dsc.setDbType(DbType.MYSQL);
mpg.setDataSource(dsc);

// 4、包配置
PackageConfig pc = new PackageConfig();
pc.setModuleName(moduleName); //模块名
pc.setParent("com.kuang.service");
pc.setController("controller");
pc.setEntity("entity");
pc.setService("service");
pc.setMapper("mapper");
mpg.setPackageInfo(pc);

// 5、策略配置
StrategyConfig strategy = new StrategyConfig();
strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略
strategy.setTablePrefix(moduleName + "_");//设置表前缀不生成

strategy.setColumnNaming(NamingStrategy.underline_to_camel);//数据库表字段映射到实体的命名策略
strategy.setEntityLombokModel(true); // lombok 模型 @Accessors(chain = true) setter链式操作

strategy.setLogicDeleteFieldName("is_deleted");//逻辑删除字段名
strategy.setEntityBooleanColumnRemoveIsPrefix(true);//去掉布尔值的is_前缀

//自动填充
TableFill gmtCreate = new TableFill("gmt_create", FieldFill.INSERT);
TableFill gmtModified = new TableFill("gmt_modified", FieldFill.INSERT_UPDATE);
ArrayList<TableFill> tableFills = new ArrayList<>();
tableFills.add(gmtCreate);
tableFills.add(gmtModified);
strategy.setTableFillList(tableFills);

strategy.setRestControllerStyle(true); //restful api风格控制器
strategy.setControllerMappingHyphenStyle(true); //url中驼峰转连字符
mpg.setStrategy(strategy);

//设置BaseEntity
strategy.setSuperEntityClass("com.kuang.service.base.model.BaseEntity");
// 填写BaseEntity中的公共字段
strategy.setSuperEntityColumns("id", "gmt_create", "gmt_modified");

// 6、执行
mpg.execute();
}
}

微服务

网关


视频微服务

server:
port: 8120 # 服务端口

spring:
profiles:
active: dev # 环境设置
application:
name: service-video # 服务名
datasource: # mysql数据库连接
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/likeever_video?serverTimezone=GMT%2B8
username: root
password: 123456
cloud:
nacos:
discovery:
server-addr: localhost:8848

#mybatis日志
mybatis-plus:
configuration:
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl

用户微服务

server:
port: 8110 # 服务端口

spring:
profiles:
active: dev # 环境设置
application:
name: service-member # 服务名
datasource: # mysql数据库连接
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/likeever_member?serverTimezone=GMT%2B8
username: root
password: 123456
cloud:
nacos:
discovery:
server-addr: localhost:8848
#mybatis日志
mybatis-plus:
configuration:
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
mapper-locations: classpath:com/kuang/service/member/mapper/xml/*.xml