mirror of
https://gitee.com/bookshelfplus/bookshelfplus
synced 2025-09-22 01:30:40 +08:00
删除独立的作者、出版社、缩略图表;修正部分字段;实现部分Service以及Controller;项目框架基本建立
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package plus.bookshelf.Service.Impl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import plus.bookshelf.Dao.DO.BookDO;
|
||||
import plus.bookshelf.Dao.Mapper.BookDOMapper;
|
||||
import plus.bookshelf.Service.Model.BookModel;
|
||||
import plus.bookshelf.Service.Model.CategoryModel;
|
||||
import plus.bookshelf.Service.Service.BookService;
|
||||
import plus.bookshelf.Service.Service.CategoryService;
|
||||
|
||||
@Service
|
||||
public class BookServiceImpl implements BookService {
|
||||
|
||||
@Autowired
|
||||
private BookDOMapper bookDOMapper;
|
||||
|
||||
@Autowired
|
||||
private CategoryService categoryService;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public BookModel getBookById(Integer id) {
|
||||
// 查询得到bookDO
|
||||
BookDO bookDO = bookDOMapper.selectByPrimaryKey(id);
|
||||
// 查询得到categoryModel
|
||||
CategoryModel categoryModel = categoryService.getCategoryById(bookDO.getCategoryId());
|
||||
|
||||
BookModel bookModel = convertFromDataObjecct(bookDO, categoryModel);
|
||||
return bookModel;
|
||||
}
|
||||
|
||||
private BookModel convertFromDataObjecct(BookDO bookDO, CategoryModel categoryModel) {
|
||||
BookModel bookModel = new BookModel();
|
||||
if (bookDO == null) {
|
||||
return null;
|
||||
}
|
||||
bookModel.setId(bookDO.getId());
|
||||
bookModel.setBookName(bookDO.getBookName());
|
||||
bookModel.setDescription(bookDO.getDescription());
|
||||
bookModel.setAuthor(bookDO.getAuthor());
|
||||
bookModel.setCategory(categoryModel);
|
||||
bookModel.setPublishingHouse(bookDO.getPublishingHouse());
|
||||
bookModel.setCopyright(bookDO.getCopyright());
|
||||
bookModel.setIsDelete(bookDO.getIsDelete());
|
||||
bookModel.setThumbnail(bookDO.getThumbnail());
|
||||
return bookModel;
|
||||
}
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
package plus.bookshelf.Service.Impl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import plus.bookshelf.Dao.DO.CategoryDO;
|
||||
import plus.bookshelf.Dao.Mapper.CategoryDOMapper;
|
||||
import plus.bookshelf.Service.Model.CategoryModel;
|
||||
import plus.bookshelf.Service.Service.CategoryService;
|
||||
|
||||
@Service
|
||||
public class CategoryServiceImpl implements CategoryService {
|
||||
|
||||
@Autowired
|
||||
private CategoryDOMapper categoryDOMapper;
|
||||
|
||||
@Override
|
||||
public CategoryModel getCategoryById(Integer id) {
|
||||
CategoryDO categoryDO = categoryDOMapper.selectByPrimaryKey(id);
|
||||
CategoryModel categoryModel = convertFromDataObject(categoryDO);
|
||||
|
||||
// // 获得儿子
|
||||
// CategoryDO[] childrenDO = categoryDOMapper.selectChildrenByCategoryId(categoryDO.getId());
|
||||
// CategoryModel[] children = new CategoryModel[childrenDO.length];
|
||||
// int index = 0;
|
||||
// for (CategoryDO childDO : childrenDO) {
|
||||
// children[index++] = convertFromDataObject(childDO);
|
||||
// }
|
||||
//
|
||||
// categoryModel.setChildren(children);
|
||||
|
||||
return categoryModel;
|
||||
}
|
||||
|
||||
// 转换时不转换父亲与儿子,否则会陷入死循环
|
||||
private CategoryModel convertFromDataObject(CategoryDO categoryDO) {
|
||||
if (categoryDO == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//设置属性
|
||||
CategoryModel categoryModel = new CategoryModel();
|
||||
categoryModel.setId(categoryDO.getId());
|
||||
categoryModel.setName(categoryDO.getName());
|
||||
categoryModel.setDescription(categoryDO.getDescription());
|
||||
categoryModel.setIsShow(categoryDO.getIsShow());
|
||||
categoryModel.setOrder(categoryDO.getOrder());
|
||||
categoryModel.setLevel(categoryDO.getLevel());
|
||||
categoryModel.setParentId(categoryDO.getParentId());
|
||||
|
||||
return categoryModel;
|
||||
}
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
package plus.bookshelf.Service.Model.Book;
|
||||
|
||||
public class AuthorModel {
|
||||
// 作者Id
|
||||
Integer id;
|
||||
|
||||
// 作者姓名
|
||||
String name;
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
package plus.bookshelf.Service.Model.Book;
|
||||
|
||||
public class PublishingHouseModel {
|
||||
// 出版社Id
|
||||
Integer id;
|
||||
|
||||
// 出版社名称
|
||||
String name;
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
package plus.bookshelf.Service.Model.Book;
|
||||
|
||||
public class ThumbnailModel {
|
||||
|
||||
// 书籍缩略图Id
|
||||
Integer id;
|
||||
|
||||
// 缩略图路径
|
||||
String path;
|
||||
}
|
@@ -1,8 +1,9 @@
|
||||
package plus.bookshelf.Service.Model.Book;
|
||||
package plus.bookshelf.Service.Model;
|
||||
|
||||
import lombok.Data;
|
||||
import plus.bookshelf.Common.Enum.Language;
|
||||
import plus.bookshelf.Service.Model.Category.CategoryModel;
|
||||
|
||||
@Data
|
||||
public class BookModel {
|
||||
|
||||
// 书籍id
|
||||
@@ -15,13 +16,13 @@ public class BookModel {
|
||||
String description;
|
||||
|
||||
// 作者姓名
|
||||
AuthorModel[] author;
|
||||
String author;
|
||||
|
||||
//书籍所属分类
|
||||
CategoryModel category;
|
||||
|
||||
// 出版社
|
||||
PublishingHouseModel publishingHouse;
|
||||
String publishingHouse;
|
||||
|
||||
// 语言
|
||||
Language language;
|
||||
@@ -31,4 +32,7 @@ public class BookModel {
|
||||
|
||||
// 是否删除
|
||||
Boolean isDelete;
|
||||
|
||||
// 缩略图
|
||||
String thumbnail;
|
||||
}
|
@@ -1,15 +1,18 @@
|
||||
package plus.bookshelf.Service.Model.Category;
|
||||
package plus.bookshelf.Service.Model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CategoryModel {
|
||||
|
||||
// 分类名称
|
||||
Integer id;
|
||||
|
||||
// 分类名称
|
||||
Integer name;
|
||||
String name;
|
||||
|
||||
// 分类简介
|
||||
Integer description;
|
||||
String description;
|
||||
|
||||
|
||||
Boolean isShow;
|
||||
@@ -20,12 +23,9 @@ public class CategoryModel {
|
||||
// 分类级别 0为一级分类, 1为二级分类...
|
||||
Integer level;
|
||||
|
||||
// 所属父分类Id
|
||||
// 父分类
|
||||
Integer parentId;
|
||||
|
||||
// 父分类
|
||||
CategoryModel parent;
|
||||
|
||||
// 子分类集合
|
||||
CategoryModel[] children;
|
||||
// // 子分类集合
|
||||
// Integer[] childrenId;
|
||||
}
|
@@ -1,10 +1,11 @@
|
||||
package plus.bookshelf.Service.Model.File;
|
||||
package plus.bookshelf.Service.Model;
|
||||
|
||||
import lombok.Data;
|
||||
import org.joda.time.DateTime;
|
||||
import plus.bookshelf.Common.Enum.BookOrigin;
|
||||
import plus.bookshelf.Common.Enum.FileFormatEnum;
|
||||
import plus.bookshelf.Service.Model.Book.ThumbnailModel;
|
||||
|
||||
@Data
|
||||
public class FileModel {
|
||||
|
||||
// 文件Id
|
||||
@@ -34,9 +35,6 @@ public class FileModel {
|
||||
// 文件来源 电子版/扫描版
|
||||
BookOrigin bookOrigin;
|
||||
|
||||
// 缩略图
|
||||
ThumbnailModel thumbnail;
|
||||
|
||||
// 文件创建时间
|
||||
DateTime fileCreateAt;
|
||||
|
@@ -1,7 +1,9 @@
|
||||
package plus.bookshelf.Service.Model.File;
|
||||
package plus.bookshelf.Service.Model;
|
||||
|
||||
import lombok.Data;
|
||||
import plus.bookshelf.Common.Enum.FileStorageMediumEnum;
|
||||
|
||||
@Data
|
||||
public class FileObjectModel {
|
||||
|
||||
// 文件存储介质Id
|
@@ -0,0 +1,12 @@
|
||||
package plus.bookshelf.Service.Service;
|
||||
|
||||
import plus.bookshelf.Service.Model.BookModel;
|
||||
|
||||
public interface BookService {
|
||||
/**
|
||||
* 通过书籍Id获取书籍
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
BookModel getBookById(Integer id);
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package plus.bookshelf.Service.Service;
|
||||
|
||||
import plus.bookshelf.Service.Model.CategoryModel;
|
||||
|
||||
public interface CategoryService {
|
||||
/**
|
||||
* 通过分类Id获取分类
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
CategoryModel getCategoryById(Integer id);
|
||||
}
|
Reference in New Issue
Block a user