diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/book/model/BookCategoryEntity.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/book/model/BookCategoryEntity.java
index 0fe793a..9b0270e 100644
--- a/tamguo-modules-core/src/main/java/com/tamguo/modules/book/model/BookCategoryEntity.java
+++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/book/model/BookCategoryEntity.java
@@ -1,17 +1,21 @@
package com.tamguo.modules.book.model;
+import java.io.Serializable;
import java.util.Date;
+import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
@TableName(value="b_book_category")
-public class BookCategoryEntity {
+public class BookCategoryEntity extends Model{
+ private static final long serialVersionUID = 1L;
+
@TableId
private String id;
- private String parentCode;
- private String parentCodes;
+ private String parentId;
+ private String parentIds;
private String treeSort;
private String treeSorts;
private String treeLeaf;
@@ -30,18 +34,6 @@ public class BookCategoryEntity {
public void setId(String id) {
this.id = id;
}
- public String getParentCode() {
- return parentCode;
- }
- public void setParentCode(String parentCode) {
- this.parentCode = parentCode;
- }
- public String getParentCodes() {
- return parentCodes;
- }
- public void setParentCodes(String parentCodes) {
- this.parentCodes = parentCodes;
- }
public String getTreeSort() {
return treeSort;
}
@@ -108,5 +100,21 @@ public class BookCategoryEntity {
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
+ public String getParentId() {
+ return parentId;
+ }
+ public void setParentId(String parentId) {
+ this.parentId = parentId;
+ }
+ public String getParentIds() {
+ return parentIds;
+ }
+ public void setParentIds(String parentIds) {
+ this.parentIds = parentIds;
+ }
+ @Override
+ protected Serializable pkVal() {
+ return getId();
+ }
}
diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/book/model/BookEntity.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/book/model/BookEntity.java
index 840a120..2e953a1 100644
--- a/tamguo-modules-core/src/main/java/com/tamguo/modules/book/model/BookEntity.java
+++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/book/model/BookEntity.java
@@ -1,13 +1,17 @@
package com.tamguo.modules.book.model;
+import java.io.Serializable;
import java.util.Date;
+import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
@TableName(value="b_book")
-public class BookEntity {
+public class BookEntity extends Model{
+ private static final long serialVersionUID = 1L;
+
@TableId
private String id;
private String categoryId;
@@ -80,5 +84,9 @@ public class BookEntity {
public void setBookImage(String bookImage) {
this.bookImage = bookImage;
}
+ @Override
+ protected Serializable pkVal() {
+ return getId();
+ }
}
diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/book/model/DocumentEntity.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/book/model/DocumentEntity.java
index db6a518..b0fa44e 100644
--- a/tamguo-modules-core/src/main/java/com/tamguo/modules/book/model/DocumentEntity.java
+++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/book/model/DocumentEntity.java
@@ -1,22 +1,49 @@
package com.tamguo.modules.book.model;
+import java.io.Serializable;
import java.util.Date;
+import java.util.List;
+import com.alibaba.fastjson.annotation.JSONField;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.baomidou.mybatisplus.activerecord.Model;
+import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
+import com.tamguo.modules.book.model.enums.DocumentStatusEnum;
@TableName(value="b_document")
-public class DocumentEntity {
+public class DocumentEntity extends Model{
+ private static final long serialVersionUID = 1L;
+
@TableId
private String id;
+ private String parentId;
private String bookId;
private String owner;
private String name;
- private String status;
+ @JSONField(serialzeFeatures= SerializerFeature.WriteEnumUsingToString)
+ private DocumentStatusEnum status;
+ @TableField(value="is_open")
+ private String isOpen;
private Date createDate;
private Date updateDate;
+ private String content;
+ private String markdown;
+
+ @TableField(exist=false)
+ private Integer level;
+ @TableField(exist=false)
+ private String rootId;
+ @TableField(exist=false)
+ private boolean leaf;
+ @TableField(exist=false)
+ private List children;
+ @TableField(exist=false)
+ private String cover;
+
public String getId() {
return id;
}
@@ -41,12 +68,6 @@ public class DocumentEntity {
public void setName(String name) {
this.name = name;
}
- public String getStatus() {
- return status;
- }
- public void setStatus(String status) {
- this.status = status;
- }
public Date getCreateDate() {
return createDate;
}
@@ -59,5 +80,69 @@ public class DocumentEntity {
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
+ public String getContent() {
+ return content;
+ }
+ public void setContent(String content) {
+ this.content = content;
+ }
+ public String getMarkdown() {
+ return markdown;
+ }
+ public void setMarkdown(String markdown) {
+ this.markdown = markdown;
+ }
+ public String getParentId() {
+ return parentId;
+ }
+ public void setParentId(String parentId) {
+ this.parentId = parentId;
+ }
+ public Integer getLevel() {
+ return level;
+ }
+ public void setLevel(Integer level) {
+ this.level = level;
+ }
+ public String getRootId() {
+ return rootId;
+ }
+ public void setRootId(String rootId) {
+ this.rootId = rootId;
+ }
+ public boolean isLeaf() {
+ return leaf;
+ }
+ public void setLeaf(boolean leaf) {
+ this.leaf = leaf;
+ }
+ public String getIsOpen() {
+ return isOpen;
+ }
+ public void setIsOpen(String isOpen) {
+ this.isOpen = isOpen;
+ }
+ public List getChildren() {
+ return children;
+ }
+ public void setChildren(List children) {
+ this.children = children;
+ }
+ @Override
+ protected Serializable pkVal() {
+ return getId();
+ }
+ public String getCover() {
+ return cover;
+ }
+ public void setCover(String cover) {
+ this.cover = cover;
+ }
+ public DocumentStatusEnum getStatus() {
+ return status;
+ }
+ public void setStatus(DocumentStatusEnum status) {
+ this.status = status;
+ }
}
diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/book/model/enums/DocumentStatusEnum.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/book/model/enums/DocumentStatusEnum.java
new file mode 100644
index 0000000..582e08b
--- /dev/null
+++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/book/model/enums/DocumentStatusEnum.java
@@ -0,0 +1,33 @@
+package com.tamguo.modules.book.model.enums;
+
+import java.io.Serializable;
+import com.baomidou.mybatisplus.enums.IEnum;
+
+/**
+ * 用户状态
+ */
+public enum DocumentStatusEnum implements IEnum {
+ NORMAL("normal", "正常"),
+ HISTORY("history", "历史版本");
+
+ private String value;
+ private String desc;
+
+ DocumentStatusEnum(final String value, final String desc) {
+ this.value = value;
+ this.desc = desc;
+ }
+
+ public Serializable getValue() {
+ return this.value;
+ }
+
+ public String getDesc(){
+ return this.desc;
+ }
+
+ @Override
+ public String toString() {
+ return this.value;
+ }
+}
diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/book/service/IBookCategoryService.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/book/service/IBookCategoryService.java
new file mode 100644
index 0000000..ee42fc6
--- /dev/null
+++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/book/service/IBookCategoryService.java
@@ -0,0 +1,8 @@
+package com.tamguo.modules.book.service;
+
+import com.baomidou.mybatisplus.service.IService;
+import com.tamguo.modules.book.model.BookCategoryEntity;
+
+public interface IBookCategoryService extends IService{
+
+}
diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/book/service/IDocumentService.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/book/service/IDocumentService.java
index 40d4991..97cfaab 100644
--- a/tamguo-modules-core/src/main/java/com/tamguo/modules/book/service/IDocumentService.java
+++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/book/service/IDocumentService.java
@@ -5,4 +5,10 @@ import com.tamguo.modules.book.model.DocumentEntity;
public interface IDocumentService extends IService{
+ /** 编辑文档*/
+ void modify(DocumentEntity document);
+
+ /** 创建文档 */
+ void create(DocumentEntity document);
+
}
diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/book/service/impl/BookCategoryServiceImpl.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/book/service/impl/BookCategoryServiceImpl.java
new file mode 100644
index 0000000..df21115
--- /dev/null
+++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/book/service/impl/BookCategoryServiceImpl.java
@@ -0,0 +1,13 @@
+package com.tamguo.modules.book.service.impl;
+
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.tamguo.modules.book.dao.BookCategoryMapper;
+import com.tamguo.modules.book.model.BookCategoryEntity;
+import com.tamguo.modules.book.service.IBookCategoryService;
+
+@Service
+public class BookCategoryServiceImpl extends ServiceImpl implements IBookCategoryService{
+
+}
diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/book/service/impl/DocumentServiceImpl.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/book/service/impl/DocumentServiceImpl.java
index 1bb1ffa..82a6ec2 100644
--- a/tamguo-modules-core/src/main/java/com/tamguo/modules/book/service/impl/DocumentServiceImpl.java
+++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/book/service/impl/DocumentServiceImpl.java
@@ -1,13 +1,63 @@
package com.tamguo.modules.book.service.impl;
+import java.util.Date;
+
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.tamguo.modules.book.dao.DocumentMapper;
import com.tamguo.modules.book.model.DocumentEntity;
+import com.tamguo.modules.book.model.enums.DocumentStatusEnum;
import com.tamguo.modules.book.service.IDocumentService;
@Service
public class DocumentServiceImpl extends ServiceImpl implements IDocumentService{
+ @Transactional(readOnly=false)
+ @Override
+ public void modify(DocumentEntity document) {
+ DocumentEntity entity = this.selectById(document.getId());
+ if("yes".equals(document.getCover())) {
+ // 覆盖修改
+ entity.setContent(document.getContent());
+ entity.setMarkdown(document.getMarkdown());
+ entity.setStatus(DocumentStatusEnum.NORMAL);
+ this.updateById(entity);
+ } else {
+ String content = entity.getContent();
+ String markdown = entity.getMarkdown();
+
+ // 更新内容
+ entity.setContent(document.getContent());
+ entity.setMarkdown(document.getMarkdown());
+ this.updateById(entity);
+
+ // 新增历史
+ document.setId(null);
+ document.setContent(content);
+ document.setMarkdown(markdown);
+ document.setBookId(entity.getBookId());
+ document.setCreateDate(new Date());
+ document.setIsOpen(entity.getIsOpen());
+ document.setName(entity.getName());
+ document.setOwner(entity.getOwner());
+ document.setParentId(entity.getParentId());
+ document.setUpdateDate(new Date());
+ document.setStatus(DocumentStatusEnum.HISTORY);
+ this.insert(document);
+
+ }
+ }
+
+ @Transactional(readOnly=false)
+ @Override
+ public void create(DocumentEntity document) {
+ document.setStatus(DocumentStatusEnum.NORMAL);
+ document.setCreateDate(new Date());
+ document.setUpdateDate(new Date());
+ document.setOwner("system");
+ this.insert(document);
+ }
+
}