mirror of
https://gitee.com/bookshelfplus/bookshelfplus
synced 2025-09-14 20:41:38 +08:00
建立项目与数据库
This commit is contained in:
27
bookshelfplus/src/main/java/plus/bookshelf/App.java
Normal file
27
bookshelfplus/src/main/java/plus/bookshelf/App.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package plus.bookshelf;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*
|
||||
*/
|
||||
@SpringBootApplication(scanBasePackages = { "plus.bookshelf" })
|
||||
@RestController
|
||||
@MapperScan("plus.bookshelf.mapper")
|
||||
public class App
|
||||
{
|
||||
public static void main( String[] args )
|
||||
{
|
||||
System.out.println( "Hello World!" );
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping("/")
|
||||
public String Home() {
|
||||
return "首页";
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
package plus.bookshelf.Common.Enum;
|
||||
|
||||
public enum BookOrigin {
|
||||
ORIGIN("原版电子书"),
|
||||
SCAN("扫描版"),
|
||||
WORD("文字版"), // 大部分是手机版的电子书重新制作成为PDF的
|
||||
HEELP_DOCUMENT("帮助文档"),
|
||||
OTHER("其他");
|
||||
|
||||
private BookOrigin(String intro) {
|
||||
this.intro = intro;
|
||||
}
|
||||
|
||||
private String intro;
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
package plus.bookshelf.Common.Enum;
|
||||
|
||||
public enum FileFormatEnum {
|
||||
PDF("pdf", "PDF文件"),
|
||||
MOBI("mobi", "mobi文件"),
|
||||
EPUB("epub", "epub电子书文件"),
|
||||
TXT("txt", "文本文档"),
|
||||
CHM("chm", "CHM帮助文档"),
|
||||
AZW3("azw3", "azw3文件"),
|
||||
DOC("doc", "Word文档"),
|
||||
DOCX("docx", "Word文档");
|
||||
|
||||
private FileFormatEnum(String ext, String extIntro) {
|
||||
this.ext = ext;
|
||||
this.extIntro = extIntro;
|
||||
}
|
||||
|
||||
private String ext;
|
||||
private String extIntro;
|
||||
|
||||
public String getExt() {
|
||||
return ext;
|
||||
}
|
||||
|
||||
public String getExtIntro() {
|
||||
return extIntro;
|
||||
}
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
package plus.bookshelf.Common.Enum;
|
||||
|
||||
public enum FileStorageMediumEnum {
|
||||
LOCAL (10000, "本地"),
|
||||
BAIDU_NETDISK (20001, "百度网盘"),
|
||||
ALIYUN_DRIVE (20002, "阿里网盘");
|
||||
|
||||
private FileStorageMediumEnum(int storageMediumIndex, String storageMediumDisplayName) {
|
||||
this.storageMediumIndex = storageMediumIndex;
|
||||
this.storageMediumDisplayName = storageMediumDisplayName;
|
||||
}
|
||||
private Integer storageMediumIndex;
|
||||
private String storageMediumDisplayName;
|
||||
|
||||
public Integer getStorageMediumIndex() {
|
||||
return storageMediumIndex;
|
||||
}
|
||||
|
||||
public String getStorageMediumDisplayName() {
|
||||
return storageMediumDisplayName;
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
package plus.bookshelf.Common.Enum;
|
||||
|
||||
public enum Language {
|
||||
SIMPLIFIED_CHINESE(1000, "简体中文"),
|
||||
ENGLISH(1001, "English"),
|
||||
TRADITIONAL_CHINESE(1001, "繁体中文");
|
||||
|
||||
private Language(Integer langId, String langName) {
|
||||
this.langId = langId;
|
||||
this.langName = langName;
|
||||
}
|
||||
|
||||
private Integer langId;
|
||||
private String langName;
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
package plus.bookshelf.Service.Model.Book;
|
||||
|
||||
public class AuthorModel {
|
||||
// 作者Id
|
||||
Integer id;
|
||||
|
||||
// 作者姓名
|
||||
String name;
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package plus.bookshelf.Service.Model.Book;
|
||||
|
||||
import plus.bookshelf.Common.Enum.Language;
|
||||
import plus.bookshelf.Service.Model.Category.CategoryModel;
|
||||
|
||||
public class BookModel {
|
||||
|
||||
// 书籍id
|
||||
Integer id;
|
||||
|
||||
// 书名
|
||||
String bookName;
|
||||
|
||||
// 书籍简介
|
||||
String description;
|
||||
|
||||
// 作者姓名
|
||||
AuthorModel[] author;
|
||||
|
||||
//书籍所属分类
|
||||
CategoryModel category;
|
||||
|
||||
// 出版社
|
||||
PublishingHouseModel publishingHouse;
|
||||
|
||||
// 语言
|
||||
Language language;
|
||||
|
||||
// 来源(版权)信息
|
||||
String copyright;
|
||||
|
||||
// 是否删除
|
||||
Boolean isDelete;
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
package plus.bookshelf.Service.Model.Book;
|
||||
|
||||
public class PublishingHouseModel {
|
||||
// 出版社Id
|
||||
Integer id;
|
||||
|
||||
// 出版社名称
|
||||
String name;
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package plus.bookshelf.Service.Model.Book;
|
||||
|
||||
public class ThumbnailModel {
|
||||
|
||||
// 书籍缩略图Id
|
||||
Integer id;
|
||||
|
||||
// 缩略图路径
|
||||
String path;
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
package plus.bookshelf.Service.Model.Category;
|
||||
|
||||
public class CategoryModel {
|
||||
|
||||
// 分类名称
|
||||
Integer id;
|
||||
|
||||
// 分类名称
|
||||
Integer name;
|
||||
|
||||
// 分类简介
|
||||
Integer description;
|
||||
|
||||
|
||||
Boolean isShow;
|
||||
|
||||
// 分类显示顺序
|
||||
Integer order;
|
||||
|
||||
// 分类级别 0为一级分类, 1为二级分类...
|
||||
Integer level;
|
||||
|
||||
// 所属父分类Id
|
||||
Integer parentId;
|
||||
|
||||
// 父分类
|
||||
CategoryModel parent;
|
||||
|
||||
// 子分类集合
|
||||
CategoryModel[] children;
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
package plus.bookshelf.Service.Model.File;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import plus.bookshelf.Common.Enum.BookOrigin;
|
||||
import plus.bookshelf.Common.Enum.FileFormatEnum;
|
||||
import plus.bookshelf.Service.Model.Book.ThumbnailModel;
|
||||
|
||||
public class FileModel {
|
||||
|
||||
// 文件Id
|
||||
Integer id;
|
||||
|
||||
// 关联的书籍Id
|
||||
Integer bookId;
|
||||
|
||||
// 文件名 (用于展示给用户的文件名,不含扩展名)
|
||||
String fileDisplayName;
|
||||
|
||||
// 文件存储名称 (文件的实际文件名,含扩展名)
|
||||
String fileName;
|
||||
|
||||
// 文件格式
|
||||
FileFormatEnum fileFormat;
|
||||
|
||||
// 总页数
|
||||
Integer numberOfPages;
|
||||
|
||||
// 是否含有水印
|
||||
Boolean watermark;
|
||||
|
||||
// 是否有广告
|
||||
Boolean advertising;
|
||||
|
||||
// 文件来源 电子版/扫描版
|
||||
BookOrigin bookOrigin;
|
||||
|
||||
// 缩略图
|
||||
ThumbnailModel thumbnail;
|
||||
|
||||
// 文件创建时间
|
||||
DateTime fileCreateAt;
|
||||
|
||||
// 文件修改时间
|
||||
DateTime fileModifiedAt;
|
||||
|
||||
// 文件大小
|
||||
long fileSize;
|
||||
|
||||
// 文件哈希 - MD5
|
||||
String hashMd5;
|
||||
|
||||
// 文件哈希 - SHA1
|
||||
String hashSha1;
|
||||
|
||||
// 文件哈希 - SHA256
|
||||
String hashSha256;
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
package plus.bookshelf.Service.Model.File;
|
||||
|
||||
import plus.bookshelf.Common.Enum.FileStorageMediumEnum;
|
||||
|
||||
public class FileObjectModel {
|
||||
|
||||
// 文件存储介质Id
|
||||
private Integer id;
|
||||
|
||||
// 存储的文件Id
|
||||
private Integer fileId;
|
||||
|
||||
// 文件存储介质类型
|
||||
FileStorageMediumEnum storageMediumType;
|
||||
|
||||
// 文件地址
|
||||
// 如果是网盘就是分享链接,如果是本地存储就是文件路径
|
||||
String filePath;
|
||||
|
||||
// 如果文件有压缩,那么就是压缩包密码
|
||||
String filePwd;
|
||||
|
||||
// 文件提取码
|
||||
String fileShareCode;
|
||||
|
||||
// 附加字段(JSON存储)
|
||||
Object additionalFields;
|
||||
}
|
51
bookshelfplus/src/main/resources/mybatis-generator.xml
Normal file
51
bookshelfplus/src/main/resources/mybatis-generator.xml
Normal file
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE generatorConfiguration
|
||||
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
|
||||
<generatorConfiguration>
|
||||
|
||||
<context id="DB2Tables" targetRuntime="MyBatis3">
|
||||
<!-- 数据库链接地址账号密码 -->
|
||||
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
|
||||
connectionURL="jdbc:mysql://127.0.0.1:3306/bookshelfplus?serverTimezone=Asia/Shanghai&useSSL=false"
|
||||
userId="root"
|
||||
password="111111">
|
||||
</jdbcConnection>
|
||||
|
||||
<!-- 生成 DataObject 类存放位置 -->
|
||||
<javaModelGenerator targetPackage="plus.bookshelf.Dao.DO" targetProject="src/main/java">
|
||||
<property name="enableSubPackages" value="true"/>
|
||||
<property name="trimStrings" value="true"/>
|
||||
</javaModelGenerator>
|
||||
|
||||
<!-- 生成映射文件存放位置 -->
|
||||
<sqlMapGenerator targetPackage="mapping" targetProject="src/main/resources">
|
||||
<property name="enableSubPackages" value="true"/>
|
||||
</sqlMapGenerator>
|
||||
|
||||
<!-- 生成Dao类存放位置 -->
|
||||
<!-- 客户端代码,生成易于使用的针对Mode L对象和XML配置文件的代码
|
||||
type="ANNOTATEDMAPPER",生成Java Model和基于注解的Mapper对象
|
||||
type="MIXEDMAPPER",生成基于注解的Java Model和相应的Mapper对象
|
||||
type="XM1LMAPPER",生成SQLMap XML文件和独立的Mapper接口
|
||||
-->
|
||||
<javaClientGenerator type="XMLMAPPER" targetPackage="plus.bookshelf.Dao.Mapper" targetProject="src/main/java">
|
||||
<property name="enableSubPackages" value="true"/>
|
||||
</javaClientGenerator>
|
||||
|
||||
<!--去除复杂操作语句-->
|
||||
<!--enableCountByExample="false"-->
|
||||
<!--enableUpdateByExample="false" -->
|
||||
<!--enableDeleteByExample="false" -->
|
||||
<!--enableSelectByExample="false"-->
|
||||
<!--selectByExampleQueryId="false"-->
|
||||
|
||||
<!-- 生成对应表及其类名 -->
|
||||
<table tableName="book_author_info" domainObjectName="AuthorDO" enableCountByExample="false"
|
||||
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
|
||||
selectByExampleQueryId="false"></table>
|
||||
<table tableName="book_publishing_house_info" domainObjectName="PublishingHouseDO" enableCountByExample="false"
|
||||
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
|
||||
selectByExampleQueryId="false"></table>
|
||||
</context>
|
||||
</generatorConfiguration>
|
20
bookshelfplus/src/test/java/plus/bookshelf/AppTest.java
Normal file
20
bookshelfplus/src/test/java/plus/bookshelf/AppTest.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package plus.bookshelf;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest
|
||||
{
|
||||
/**
|
||||
* Rigorous Test :-)
|
||||
*/
|
||||
@Test
|
||||
public void shouldAnswerWithTrue()
|
||||
{
|
||||
assertTrue( true );
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user