parent
66a56894d8
commit
7cf4e9d15f
@ -0,0 +1,22 @@
|
||||
package com.tamguo.web;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* Controller - 首页
|
||||
*
|
||||
* @author tamguo
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
public class IndexController {
|
||||
|
||||
@RequestMapping(path= {"index" , "/"})
|
||||
public ModelAndView index(ModelAndView model) {
|
||||
model.setViewName("index");
|
||||
return model;
|
||||
}
|
||||
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
package com.tamguo.web.member;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.mapper.Condition;
|
||||
import com.tamguo.common.utils.Result;
|
||||
import com.tamguo.modules.book.model.BookEntity;
|
||||
import com.tamguo.modules.book.model.DocumentEntity;
|
||||
import com.tamguo.modules.book.model.enums.DocumentStatusEnum;
|
||||
import com.tamguo.modules.book.service.IBookCategoryService;
|
||||
import com.tamguo.modules.book.service.IBookService;
|
||||
import com.tamguo.modules.book.service.IDocumentService;
|
||||
|
||||
@Controller(value="memberBookController")
|
||||
@RequestMapping(value="member/book")
|
||||
public class BookController {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Autowired
|
||||
IBookService iBookService;
|
||||
@Autowired
|
||||
IBookCategoryService iBookCategoryService;
|
||||
@Autowired
|
||||
IDocumentService iDocumentService;
|
||||
|
||||
@RequestMapping(value="list.html" , method = RequestMethod.GET)
|
||||
public ModelAndView bookList(ModelAndView model) {
|
||||
model.setViewName("member/book/list");
|
||||
return model;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping(value="getBookList" , method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Result getBookList(Integer pageNo , Integer pageSize) {
|
||||
try {
|
||||
List<BookEntity> bookList = iBookService.selectList(Condition.create().eq("owner", "tamguo"));
|
||||
return Result.result(0, bookList, "查询成功!");
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage() , e );
|
||||
return Result.failResult("查询失败");
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "edit", method = RequestMethod.GET)
|
||||
public ModelAndView edit(String bookId , ModelAndView model) {
|
||||
model.setViewName("member/book/edit");
|
||||
model.addObject("bookId", bookId);
|
||||
return model;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping(value = "getDocumentList", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Result getDocumentList(String id) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
try {
|
||||
BookEntity book = iBookService.selectById(id);
|
||||
List<DocumentEntity> documentList = iDocumentService.selectList(Condition.create().eq("book_id", id).eq("status", DocumentStatusEnum.NORMAL.getValue()));
|
||||
|
||||
map.put("documentList", this.processDocumentList(documentList));
|
||||
map.put("book", book);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage() , e );
|
||||
return Result.failResult("查询失败");
|
||||
}
|
||||
return Result.successResult(map);
|
||||
}
|
||||
|
||||
private JSONArray processDocumentList(List<DocumentEntity> documentList) {
|
||||
JSONArray entitys = new JSONArray();
|
||||
for(int i=0 ; i<documentList.size() ; i ++) {
|
||||
DocumentEntity doc = documentList.get(i);
|
||||
JSONObject entity = new JSONObject();
|
||||
|
||||
entity.put("id", doc.getId());
|
||||
entity.put("text", doc.getName());
|
||||
entity.put("parent", "0".equals(doc.getParentId()) ? "#" : doc.getParentId());
|
||||
entity.put("identify", doc.getId());
|
||||
entity.put("version", doc.getCreateDate().getTime());
|
||||
JSONObject attr = new JSONObject();
|
||||
attr.put("is_open", "0".equals(doc.getIsOpen()) ? false : true);
|
||||
entity.put("a_attr", attr);
|
||||
entitys.add(entity);
|
||||
}
|
||||
return entitys;
|
||||
}
|
||||
}
|
@ -1,211 +0,0 @@
|
||||
package com.tamguo.web.member;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.baomidou.mybatisplus.mapper.Condition;
|
||||
import com.tamguo.common.utils.DateUtil;
|
||||
import com.tamguo.common.utils.Result;
|
||||
import com.tamguo.modules.book.model.DocumentEntity;
|
||||
import com.tamguo.modules.book.model.FileEntity;
|
||||
import com.tamguo.modules.book.model.FileUploadEntity;
|
||||
import com.tamguo.modules.book.model.enums.BizTypeEnum;
|
||||
import com.tamguo.modules.book.model.enums.FileUploadStatusEnum;
|
||||
import com.tamguo.modules.book.service.IDocumentService;
|
||||
import com.tamguo.modules.book.service.IFileEntityService;
|
||||
import com.tamguo.modules.book.service.IFileUploadService;
|
||||
import com.tamguo.utils.FileMd5Utils;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value="member/document")
|
||||
public class DocumentController {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Autowired
|
||||
IDocumentService iDocumentService;
|
||||
@Autowired
|
||||
IFileEntityService iFileEntityService;
|
||||
@Autowired
|
||||
IFileUploadService iFileUploadService;
|
||||
|
||||
@Value("${file.storage.path}")
|
||||
private String fileStoragePath;
|
||||
@Value("${domain.name}")
|
||||
private String domainName;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping(value = "{id}" , method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Result getDocument(@PathVariable String id) {
|
||||
DocumentEntity document = null;
|
||||
try {
|
||||
document = iDocumentService.selectById(id);
|
||||
// 查询附件
|
||||
List<FileUploadEntity> fileUploads = iFileUploadService.selectList(Condition.create().eq("biz_key", document.getId()).eq("biz_type", BizTypeEnum.DOCUMENT.getValue()));
|
||||
if(!CollectionUtils.isEmpty(fileUploads)) {
|
||||
for(int i=0 ; i<fileUploads.size() ; i++) {
|
||||
FileUploadEntity fileUpload = fileUploads.get(i);
|
||||
FileEntity fileEntity = iFileEntityService.selectOne(Condition.create().eq("file_id", fileUpload.getFileId()));
|
||||
fileUpload.setFilePath(domainName + "files/" + fileEntity.getFilePath());
|
||||
fileUpload.setFileSize(fileEntity.getFileSize());
|
||||
}
|
||||
document.setFileUploads(fileUploads);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage() , e );
|
||||
return Result.failResult("查询失败");
|
||||
}
|
||||
return Result.successResult(document);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑内容
|
||||
*/
|
||||
@RequestMapping(value = "modify" , method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Result modify(DocumentEntity document) {
|
||||
try {
|
||||
iDocumentService.modify(document);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage() , e );
|
||||
return Result.failResult("保存失败");
|
||||
}
|
||||
return Result.successResult("保存成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建文档
|
||||
*/
|
||||
@RequestMapping(value = "create" , method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Result create(DocumentEntity document) {
|
||||
try {
|
||||
iDocumentService.create(document);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage() , e );
|
||||
return Result.failResult("保存失败");
|
||||
}
|
||||
return Result.successResult(document);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping(value = "uploadImage" , method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Result uploadImage(@RequestParam("editormd-image-file") MultipartFile file, String bookId , HttpServletRequest request) {
|
||||
try {
|
||||
String fileMd5 = FileMd5Utils.getMD5((FileInputStream)file.getInputStream());
|
||||
FileEntity sysFile = iFileEntityService.selectOne(Condition.create().eq("file_md5", fileMd5));
|
||||
if(sysFile != null) {
|
||||
sysFile.setFilePath(domainName + "files/" + sysFile.getFilePath());
|
||||
return Result.successResult(sysFile);
|
||||
}
|
||||
String filePath = fileStoragePath + "book/" + DateUtil.fomatDate(new Date(), "yyyyMM") + "/" + bookId;
|
||||
File dest = new File(filePath);
|
||||
if(!dest.exists()) {
|
||||
dest.mkdirs();
|
||||
}
|
||||
// save 文件
|
||||
FileUtils.writeByteArrayToFile(new File(filePath + "/" + file.getOriginalFilename()) , file.getBytes());
|
||||
|
||||
FileEntity fileEntity = new FileEntity();
|
||||
fileEntity.setFileContentType(file.getContentType());
|
||||
fileEntity.setFileExtension(file.getOriginalFilename());
|
||||
fileEntity.setFileMd5(FileMd5Utils.getMD5((FileInputStream)file.getInputStream()));
|
||||
fileEntity.setFileSize(file.getSize());
|
||||
fileEntity.setFilePath("book/" + DateUtil.fomatDate(new Date(), "yyyyMM") + "/" + bookId + "/" + file.getOriginalFilename());
|
||||
iFileEntityService.insert(fileEntity);
|
||||
|
||||
fileEntity.setFilePath(domainName + "files/" + fileEntity.getFilePath());
|
||||
|
||||
return Result.successResult(fileEntity);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return Result.failResult("上传失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传附件
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping(value = "uploadFile" , method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Result uploadFile(@RequestParam("editormd-file-file") MultipartFile file , String documentId , String bookId , HttpServletRequest request) {
|
||||
try {
|
||||
String fileMd5 = FileMd5Utils.getMD5((FileInputStream)file.getInputStream());
|
||||
FileEntity sysFile = iFileEntityService.selectOne(Condition.create().eq("file_md5", fileMd5));
|
||||
// 文件不存在
|
||||
if(sysFile == null) {
|
||||
String filePath = fileStoragePath + "book/" + DateUtil.fomatDate(new Date(), "yyyyMM") + "/" + bookId;
|
||||
File dest = new File(filePath);
|
||||
if(!dest.exists()) {
|
||||
dest.mkdirs();
|
||||
}
|
||||
// save 文件
|
||||
FileUtils.writeByteArrayToFile(new File(filePath + "/" + file.getOriginalFilename()) , file.getBytes());
|
||||
sysFile = new FileEntity();
|
||||
sysFile.setFileContentType(file.getContentType());
|
||||
sysFile.setFileExtension(file.getOriginalFilename());
|
||||
sysFile.setFileMd5(FileMd5Utils.getMD5((FileInputStream)file.getInputStream()));
|
||||
sysFile.setFileSize(file.getSize());
|
||||
sysFile.setFilePath("book/" + DateUtil.fomatDate(new Date(), "yyyyMM") + "/" + bookId + "/" + file.getOriginalFilename());
|
||||
iFileEntityService.insert(sysFile);
|
||||
}
|
||||
// 创建上传记录
|
||||
FileUploadEntity fileUpload = new FileUploadEntity();
|
||||
fileUpload.setBizKey(documentId);
|
||||
fileUpload.setBizType(BizTypeEnum.DOCUMENT);
|
||||
fileUpload.setCreateBy("system");
|
||||
fileUpload.setCreateDate(new Date());
|
||||
fileUpload.setFileId(sysFile.getFileId());
|
||||
fileUpload.setFileName(sysFile.getFileExtension());
|
||||
fileUpload.setFileType(file.getContentType());
|
||||
fileUpload.setUpdateBy("system");
|
||||
fileUpload.setUpdateDate(new Date());
|
||||
fileUpload.setStatus(FileUploadStatusEnum.NORMAL);
|
||||
iFileUploadService.insert(fileUpload);
|
||||
|
||||
fileUpload.setFilePath(domainName + "files/" + sysFile.getFilePath());
|
||||
fileUpload.setFileSize(sysFile.getFileSize());
|
||||
return Result.successResult(fileUpload);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return Result.failResult("上传失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除文件
|
||||
*/
|
||||
@RequestMapping(value = "removeFile" , method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Result removeFile(String id) {
|
||||
try {
|
||||
iFileUploadService.deleteById(id);
|
||||
} catch (Exception e) {
|
||||
return Result.result(1, null, "删除失败");
|
||||
}
|
||||
return Result.result(0, null, "删除成功");
|
||||
}
|
||||
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
package com.tamguo.web.member;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.baomidou.mybatisplus.mapper.Condition;
|
||||
import com.tamguo.common.utils.Result;
|
||||
import com.tamguo.modules.book.model.DocumentEntity;
|
||||
import com.tamguo.modules.book.model.enums.DocumentStatusEnum;
|
||||
import com.tamguo.modules.book.service.IDocumentService;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value="member/document")
|
||||
public class HistoryDocController {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
@Autowired
|
||||
private IDocumentService iDocumentService;
|
||||
|
||||
/**
|
||||
* 历史记录
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping(value = "history" , method = RequestMethod.POST)
|
||||
public ModelAndView history(String id , ModelAndView model) {
|
||||
model.setViewName("member/book/history");
|
||||
DocumentEntity document = iDocumentService.selectById(id);
|
||||
model.addObject("document", document);
|
||||
model.addObject("historyList", iDocumentService.selectList(Condition.create().eq("batch_no", document.getBatchNo()).eq("status", DocumentStatusEnum.HISTORY.getValue()).orderDesc(Arrays.asList("create_date"))));
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping(value = "history/delete" , method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Result delete(String id) {
|
||||
try {
|
||||
iDocumentService.deleteById(id);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage() , e);
|
||||
return Result.failResult("删除失败!");
|
||||
}
|
||||
return Result.successResult("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping(value = "history/restore" , method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Result restore(String id) {
|
||||
try {
|
||||
DocumentEntity history = iDocumentService.selectById(id);
|
||||
|
||||
String content = history.getContent();
|
||||
String markdown = history.getMarkdown();
|
||||
DocumentEntity document = iDocumentService.selectOne(Condition.create().eq("batch_no", history.getBatchNo()).eq("status", DocumentStatusEnum.NORMAL.getValue()));
|
||||
document.setContent(content);
|
||||
document.setMarkdown(markdown);
|
||||
document.setCover("no");
|
||||
iDocumentService.modify(document);
|
||||
return Result.successResult(document);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage() , e);
|
||||
return Result.failResult("恢复失败!");
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping(value = "history/compare/{id}" , method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public ModelAndView compare(@PathVariable String id , ModelAndView model) {
|
||||
model.setViewName("member/book/compare");
|
||||
DocumentEntity history = iDocumentService.selectById(id);
|
||||
model.addObject("history", history);
|
||||
model.addObject("document", iDocumentService.selectOne(Condition.create().eq("status", DocumentStatusEnum.NORMAL.getValue()).eq("batch_no", history.getBatchNo())));
|
||||
return model;
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package com.tamguo.web.member;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.tamguo.modules.member.model.MemberEntity;
|
||||
import com.tamguo.modules.member.service.IMemberService;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value="member")
|
||||
public class MemberController {
|
||||
|
||||
@Autowired
|
||||
IMemberService iMemberService;
|
||||
|
||||
@RequestMapping("index.html")
|
||||
public ModelAndView index(HttpServletRequest request , ModelAndView model) {
|
||||
model.setViewName("member/index");
|
||||
MemberEntity currMember = (MemberEntity) request.getSession().getAttribute("currMember");
|
||||
MemberEntity member = iMemberService.selectById(currMember.getId());
|
||||
model.addObject("member", member);
|
||||
return model;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.tamguo.web;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.tamguo.common.utils.Result;
|
||||
import com.tamguo.modules.sys.service.ISmsService;
|
||||
|
||||
@Controller
|
||||
public class SmsController {
|
||||
|
||||
@Autowired
|
||||
ISmsService iSmsService;
|
||||
|
||||
@RequestMapping(value = {"sendFindPasswordSms"}, method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Result sendFindPasswordSms(String mobile){
|
||||
try {
|
||||
return iSmsService.sendFindPasswordSms(mobile);
|
||||
} catch (ClientException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return Result.result(500, null, "");
|
||||
}
|
||||
|
||||
}
|
After Width: | Height: | Size: 7.7 KiB |
Loading…
Reference in new issue