文档添加和修改问题

main
tamguo 7 years ago
parent 0d88dc0248
commit a9e63155d6

@ -51,10 +51,10 @@ function openLastSelectedNode() {
function setLastSelectNode($node) { function setLastSelectNode($node) {
if(window.localStorage) { if(window.localStorage) {
if (typeof $node === "undefined" || !$node) { if (typeof $node === "undefined" || !$node) {
window.sessionStorage.removeItem("MinDoc::LastLoadDocument:" + window.book.identify); window.sessionStorage.removeItem("MinDoc::LastLoadDocument:" + window.book.id);
} else { } else {
var nodeId = $node.id ? $node.id : $node.node.id; var nodeId = $node.id ? $node.id : $node.node.id;
window.sessionStorage.setItem("MinDoc::LastLoadDocument:" + window.book.identify, nodeId); window.sessionStorage.setItem("MinDoc::LastLoadDocument:" + window.book.id, nodeId);
} }
} }
} }

@ -34,13 +34,13 @@ public class PaperCrawler {
// 140000 山西 | 350000 福建 | 340000 安徽 | 220000 吉林 | 150000 内蒙古 | 640000 宁夏 | 650000 新疆 | 广西 450000 | 210000 辽宁 // 140000 山西 | 350000 福建 | 340000 安徽 | 220000 吉林 | 150000 内蒙古 | 640000 宁夏 | 650000 新疆 | 广西 450000 | 210000 辽宁
// 230000 黑龙江 | 610000 陕西 | 360000 江西 | 440000 广东 | 430000 湖南 | 460000 海南 | 530000 云南 | 510000 四川 | 630000 青海 // 230000 黑龙江 | 610000 陕西 | 360000 江西 | 440000 广东 | 430000 湖南 | 460000 海南 | 530000 云南 | 510000 四川 | 630000 青海
// 620000 甘肃 | 130000 河北 | 540000 西藏 | 贵州 520000 // 620000 甘肃 | 130000 河北 | 540000 西藏 | 贵州 520000
private final String AREA_ID = "150000"; private final String AREA_ID = "450000";
// 年份 // 年份
private final String YEAR = "2016"; private final String YEAR = "2017";
// 真题试卷 类型(1:真题试卷,2:模拟试卷,3:押题预测,4:名校精品) // 真题试卷 类型(1:真题试卷,2:模拟试卷,3:押题预测,4:名校精品)
private final String PAPER_TYPE = "2"; private final String PAPER_TYPE = "2";
// 开始采集的URL // 开始采集的URL
private final String START_URL = "https://tiku.baidu.com/tikupc/paperlist/1bfd700abb68a98271fefa04-20-4-2016-965-1-download"; private final String START_URL = "https://tiku.baidu.com/tikupc/paperlist/1bfd700abb68a98271fefa04-20-4-2017-1111-1-download";
private RunData runData; private RunData runData;

@ -207,4 +207,17 @@ public class DocumentController {
} }
return Result.result(0, null, "删除成功"); return Result.result(0, null, "删除成功");
} }
@SuppressWarnings("unchecked")
@RequestMapping(value="delete" , method = RequestMethod.POST)
@ResponseBody
public Result delete(String id) {
try {
DocumentEntity document = iDocumentService.selectById(id);
iDocumentService.delete(Condition.create().eq("batch_no", document.getBatchNo()));
} catch (Exception e) {
return Result.result(1, null, "删除失败");
}
return Result.result(0, null, "删除成功");
}
} }

@ -12,7 +12,7 @@ function openLastSelectedNode() {
} }
var $isSelected = false; var $isSelected = false;
if(window.localStorage){ if(window.localStorage){
var $selectedNodeId = window.sessionStorage.getItem("MinDoc::LastLoadDocument:" + window.book.identify); var $selectedNodeId = window.sessionStorage.getItem("MinDoc::LastLoadDocument:" + window.book.id);
try{ try{
if($selectedNodeId){ if($selectedNodeId){
//遍历文档树判断是否存在节点 //遍历文档树判断是否存在节点
@ -51,10 +51,10 @@ function openLastSelectedNode() {
function setLastSelectNode($node) { function setLastSelectNode($node) {
if(window.localStorage) { if(window.localStorage) {
if (typeof $node === "undefined" || !$node) { if (typeof $node === "undefined" || !$node) {
window.sessionStorage.removeItem("MinDoc::LastLoadDocument:" + window.book.identify); window.sessionStorage.removeItem("MinDoc::LastLoadDocument:" + window.book.id);
} else { } else {
var nodeId = $node.id ? $node.id : $node.node.id; var nodeId = $node.id ? $node.id : $node.node.id;
window.sessionStorage.setItem("MinDoc::LastLoadDocument:" + window.book.identify, nodeId); window.sessionStorage.setItem("MinDoc::LastLoadDocument:" + window.book.id, nodeId);
} }
} }
} }

@ -2,6 +2,7 @@ package com.tamguo.modules.book.service.impl;
import java.util.Date; import java.util.Date;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -55,12 +56,19 @@ public class DocumentServiceImpl extends ServiceImpl<DocumentMapper, DocumentEnt
@Transactional(readOnly=false) @Transactional(readOnly=false)
@Override @Override
public void create(DocumentEntity document) { public void create(DocumentEntity document) {
if(StringUtils.isEmpty(document.getId())) {
document.setStatus(DocumentStatusEnum.NORMAL); document.setStatus(DocumentStatusEnum.NORMAL);
document.setCreateDate(new Date()); document.setCreateDate(new Date());
document.setUpdateDate(new Date()); document.setUpdateDate(new Date());
document.setOwner("system"); document.setOwner("system");
document.setBatchNo(new com.baomidou.mybatisplus.toolkit.IdWorker().getIdStr()); document.setBatchNo(new com.baomidou.mybatisplus.toolkit.IdWorker().getIdStr());
this.insert(document); this.insert(document);
}else {
DocumentEntity entity = this.selectById(document.getId());
entity.setName(document.getName());
entity.setIsOpen(document.getIsOpen());
this.updateById(entity);
}
} }
} }

Loading…
Cancel
Save