1.添加pom依赖
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.xiaoguan</groupId>
<artifactId>myproject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>myproject</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.7.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestones</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestones</url>
</pluginRepository>
</pluginRepositories>
</project>
2.application.yml
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/class?useUnicode=true&characterEncoding=utf-8&useSSL=false
username: root
password: 123456
#开启控制台打印sql
mybatis:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#配置扫描
mapper-locations: classpath:mapper/*.xml
#配置xml的结果别名
type-aliases-package: com.xiaoguan.myproject.model.entity
3.创建实体类
目录结构
1)Chapter
package com.xiaoguan.myproject.model.entity;
import java.util.Date;
import java.util.List;
public class Chapter {
private Integer id;
private Integer videoId;
private String title;
private Integer ordered;
private Date createTime;
private List<Episode> episodeList;
public List<Episode> getEpisodeList() {
return episodeList;
}
public void setEpisodeList(List<Episode> episodeList) {
this.episodeList = episodeList;
}
//省略getter、setter、toString
}
2)Episode
package com.xiaoguan.myproject.model.entity;
import java.util.Date;
public class Episode {
private Integer id;
private String title;
private Integer num;
private Integer ordered;
private String playUrl;
private Integer chapterId;
private Integer free;
private Integer videoId;
private Date createTime;
//省略getter、setter、toString
}
3)User
package com.xiaoguan.myproject.model.entity;
import java.util.Date;
public class User {
private Integer id;
private String name;
private String pwd;
private String headImg;
private String phone;
private Date createTime;
//省略getter、setter、toString
}
4)Video
package com.xiaoguan.myproject.model.entity;
import java.util.Date;
import java.util.List;
public class Video {
private Integer id;
private String title;
private String summary;
private String coverImg;
private Integer price;
private Date createTime;
private Double point;
private List<Chapter> chapterList;
public List<Chapter> getChapterList() {
return chapterList;
}
public void setChapterList(List<Chapter> chapterList) {
this.chapterList = chapterList;
}
//省略getter、setter、toString
}
5)VideoBanner
package com.xiaoguan.myproject.model.entity;
import java.util.Date;
public class VideoBanner {
private Integer id;
private String url;
private String img;
private Date createTime;
private Integer weight;
//省略getter、setter、toString
}
6)VideoOrder
package com.xiaoguan.myproject.model.entity;
import java.util.Date;
public class VideoOrder {
private Integer id;
private String outTradeNo;
private Integer state;
private Date createTime;
private Integer totalFee;
private Integer videoId;
private String videoTitle;
private String videoImg;
private Integer userId;
//省略getter、setter、toString
}
tring outTradeNo;
private Integer state;
private Date createTime;
private Integer totalFee;
private Integer videoId;
private String videoTitle;
private String videoImg;
private Integer userId;
//省略getter、setter、toString
}