优化wiki文档上传,增加消息提醒功能
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
package com.zyplayer.doc.wiki.controller;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.zyplayer.doc.core.annotation.AuthMan;
|
||||
@@ -14,20 +12,18 @@ import com.zyplayer.doc.data.repository.manage.entity.WikiPage;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageFile;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiSpace;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.WikiPageFileMapper;
|
||||
import com.zyplayer.doc.data.repository.support.consts.DocAuthConst;
|
||||
import com.zyplayer.doc.data.service.manage.UserInfoService;
|
||||
import com.zyplayer.doc.data.service.manage.WikiPageFileService;
|
||||
import com.zyplayer.doc.data.service.manage.WikiPageService;
|
||||
import com.zyplayer.doc.data.service.manage.WikiSpaceService;
|
||||
import com.zyplayer.doc.wiki.framework.consts.Const;
|
||||
import com.zyplayer.doc.wiki.framework.consts.SpaceType;
|
||||
import com.zyplayer.doc.wiki.framework.consts.WikiAuthType;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -36,7 +32,8 @@ import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 文档控制器
|
||||
@@ -49,9 +46,6 @@ import java.util.*;
|
||||
public class WikiCommonController {
|
||||
private static Logger logger = LoggerFactory.getLogger(WikiCommonController.class);
|
||||
|
||||
@Value("${zyplayer.doc.wiki.upload-path:}")
|
||||
private String uploadPath;
|
||||
|
||||
@Resource
|
||||
WikiPageFileService wikiPageFileService;
|
||||
@Resource
|
||||
@@ -77,67 +71,6 @@ public class WikiCommonController {
|
||||
return DocResponseJson.ok(userInfoList);
|
||||
}
|
||||
|
||||
@AuthMan
|
||||
@PostMapping("/wangEditor/upload")
|
||||
public Map<String, Object> wangEditorUpload(WikiPageFile wikiPageFile, @RequestParam("files") MultipartFile file) {
|
||||
this.upload(wikiPageFile, file);
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
resultMap.put("errno", "0");
|
||||
resultMap.put("data", new String[]{wikiPageFile.getFileUrl()});
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@AuthMan
|
||||
@PostMapping("/upload")
|
||||
public ResponseJson<Object> upload(WikiPageFile wikiPageFile, @RequestParam("files") MultipartFile file) {
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
Long pageId = wikiPageFile.getPageId();
|
||||
if (pageId != null && pageId > 0) {
|
||||
WikiPage wikiPageSel = wikiPageService.getById(pageId);
|
||||
WikiSpace wikiSpaceSel = wikiSpaceService.getById(wikiPageSel.getSpaceId());
|
||||
// 私人空间
|
||||
if (SpaceType.isOthersPrivate(wikiSpaceSel.getType(), currentUser.getUserId(), wikiSpaceSel.getCreateUserId())) {
|
||||
return DocResponseJson.warn("您没有该空间的文件上传权限!");
|
||||
}
|
||||
// 空间不是自己的,也没有权限
|
||||
if (SpaceType.isOthersPersonal(wikiSpaceSel.getType(), currentUser.getUserId(), wikiSpaceSel.getCreateUserId())) {
|
||||
boolean pageAuth = DocUserUtil.haveCustomAuth(WikiAuthType.PAGE_FILE_UPLOAD.getName(), DocAuthConst.WIKI + pageId);
|
||||
if (!pageAuth) {
|
||||
return DocResponseJson.warn("您没有修改该文章附件的权限!");
|
||||
}
|
||||
}
|
||||
}
|
||||
String fileName = file.getOriginalFilename();
|
||||
String fileSuffix = "";
|
||||
if (fileName != null && fileName.lastIndexOf(".") >= 0) {
|
||||
fileSuffix = fileName.substring(fileName.lastIndexOf("."));
|
||||
}
|
||||
String path = uploadPath + "/" + DateTime.now().toString("yyyy/MM/dd") + "/";
|
||||
File newFile = new File(path);
|
||||
if (!newFile.exists() && !newFile.mkdirs()) {
|
||||
return DocResponseJson.warn("创建文件夹失败");
|
||||
}
|
||||
String simpleUUID = RandomUtil.simpleUUID();
|
||||
path += simpleUUID + fileSuffix;
|
||||
newFile = new File(path);
|
||||
try {
|
||||
file.transferTo(newFile);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return DocResponseJson.warn("保存文件失败");
|
||||
}
|
||||
wikiPageFile.setUuid(simpleUUID);
|
||||
wikiPageFile.setFileUrl(path);
|
||||
wikiPageFile.setFileName(fileName);
|
||||
wikiPageFile.setCreateTime(new Date());
|
||||
wikiPageFile.setCreateUserId(currentUser.getUserId());
|
||||
wikiPageFile.setCreateUserName(currentUser.getUsername());
|
||||
wikiPageFile.setDelFlag(0);
|
||||
wikiPageFileService.save(wikiPageFile);
|
||||
wikiPageFile.setFileUrl("zyplayer-doc-wiki/common/file?uuid=" + wikiPageFile.getUuid());
|
||||
return DocResponseJson.ok(wikiPageFile);
|
||||
}
|
||||
|
||||
@GetMapping("/file")
|
||||
public ResponseJson<Object> file(HttpServletResponse response, String uuid) {
|
||||
if (StringUtils.isBlank(uuid)) {
|
||||
|
||||
@@ -9,9 +9,10 @@ import com.zyplayer.doc.data.config.security.DocUserDetails;
|
||||
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.*;
|
||||
import com.zyplayer.doc.data.repository.support.consts.DocAuthConst;
|
||||
import com.zyplayer.doc.data.repository.support.consts.UserMsgSysType;
|
||||
import com.zyplayer.doc.data.repository.support.consts.UserMsgType;
|
||||
import com.zyplayer.doc.data.service.manage.*;
|
||||
import com.zyplayer.doc.wiki.controller.vo.UserPageAuthVo;
|
||||
import com.zyplayer.doc.wiki.framework.consts.SpaceType;
|
||||
import com.zyplayer.doc.wiki.framework.consts.WikiAuthType;
|
||||
import com.zyplayer.doc.wiki.service.WikiPageAuthService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
@@ -52,6 +53,8 @@ public class WikiPageAuthController {
|
||||
AuthInfoService authInfoService;
|
||||
@Resource
|
||||
WikiPageAuthService wikiPageAuthService;
|
||||
@Resource
|
||||
UserMessageService userMessageService;
|
||||
|
||||
@PostMapping("/assign")
|
||||
public ResponseJson<List<WikiPageZan>> assign(Long pageId, String authList) {
|
||||
@@ -118,6 +121,12 @@ public class WikiPageAuthController {
|
||||
}
|
||||
// 保存权限,重新登录后可用,后期可以考虑在这里直接修改缓存里的用户权限
|
||||
userAuthService.saveBatch(userAuthList);
|
||||
// 给相关人发送消息
|
||||
UserInfo userInfo = userInfoService.getById(authVo.getUserId());
|
||||
UserMessage userMessage = userMessageService.createUserMessage(currentUser, pageId, wikiPageSel.getName(), UserMsgSysType.WIKI, UserMsgType.WIKI_PAGE_AUTH);
|
||||
userMessage.setAffectUserId(userInfo.getId());
|
||||
userMessage.setAffectUserName(userInfo.getUserName());
|
||||
userMessageService.addWikiMessage(userMessage);
|
||||
}
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
|
||||
@@ -6,9 +6,13 @@ import com.zyplayer.doc.core.json.DocResponseJson;
|
||||
import com.zyplayer.doc.core.json.ResponseJson;
|
||||
import com.zyplayer.doc.data.config.security.DocUserDetails;
|
||||
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserMessage;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPage;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageComment;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiSpace;
|
||||
import com.zyplayer.doc.data.repository.support.consts.UserMsgSysType;
|
||||
import com.zyplayer.doc.data.repository.support.consts.UserMsgType;
|
||||
import com.zyplayer.doc.data.service.manage.UserMessageService;
|
||||
import com.zyplayer.doc.data.service.manage.WikiPageCommentService;
|
||||
import com.zyplayer.doc.data.service.manage.WikiPageService;
|
||||
import com.zyplayer.doc.data.service.manage.WikiSpaceService;
|
||||
@@ -47,6 +51,8 @@ public class WikiPageCommentController {
|
||||
@Resource
|
||||
WikiPageService wikiPageService;
|
||||
@Resource
|
||||
UserMessageService userMessageService;
|
||||
@Resource
|
||||
Mapper mapper;
|
||||
|
||||
@PostMapping("/list")
|
||||
@@ -76,9 +82,9 @@ public class WikiPageCommentController {
|
||||
@PostMapping("/delete")
|
||||
public ResponseJson<Object> delete(Long id) {
|
||||
WikiPageComment pageCommentSel = wikiPageCommentService.getById(id);
|
||||
WikiPage wikiPageSel = wikiPageService.getById(pageCommentSel.getPageId());
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
if (!Objects.equals(pageCommentSel.getCreateUserId(), currentUser.getUserId())) {
|
||||
WikiPage wikiPageSel = wikiPageService.getById(pageCommentSel.getPageId());
|
||||
if (!Objects.equals(currentUser.getUserId(), wikiPageSel.getCreateUserId())) {
|
||||
return DocResponseJson.warn("只有评论人或页面创建人才有权限删除此评论!");
|
||||
}
|
||||
@@ -87,6 +93,11 @@ public class WikiPageCommentController {
|
||||
pageComment.setId(id);
|
||||
pageComment.setDelFlag(1);
|
||||
wikiPageCommentService.updateById(pageComment);
|
||||
// 给相关人发送消息
|
||||
UserMessage userMessage = userMessageService.createUserMessage(currentUser, wikiPageSel.getId(), wikiPageSel.getName(), UserMsgSysType.WIKI, UserMsgType.WIKI_PAGE_COMMENT_DEL);
|
||||
userMessage.setAffectUserId(wikiPageSel.getCreateUserId());
|
||||
userMessage.setAffectUserName(wikiPageSel.getCreateUserName());
|
||||
userMessageService.addWikiMessage(userMessage);
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
|
||||
@@ -128,6 +139,11 @@ public class WikiPageCommentController {
|
||||
pageComment.setCreateUserName(currentUser.getUsername());
|
||||
wikiPageCommentService.save(pageComment);
|
||||
}
|
||||
// 给相关人发送消息
|
||||
UserMessage userMessage = userMessageService.createUserMessage(currentUser, wikiPageSel.getId(), wikiPageSel.getName(), UserMsgSysType.WIKI, UserMsgType.WIKI_PAGE_COMMENT);
|
||||
userMessage.setAffectUserId(wikiPageSel.getCreateUserId());
|
||||
userMessage.setAffectUserName(wikiPageSel.getCreateUserName());
|
||||
userMessageService.addWikiMessage(userMessage);
|
||||
return DocResponseJson.ok(pageComment);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ import com.zyplayer.doc.data.repository.manage.mapper.WikiPageContentMapper;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.WikiPageMapper;
|
||||
import com.zyplayer.doc.data.repository.manage.param.SearchByEsParam;
|
||||
import com.zyplayer.doc.data.repository.manage.vo.SpaceNewsVo;
|
||||
import com.zyplayer.doc.data.repository.support.consts.UserMsgSysType;
|
||||
import com.zyplayer.doc.data.repository.support.consts.UserMsgType;
|
||||
import com.zyplayer.doc.data.service.elasticsearch.entity.EsWikiPage;
|
||||
import com.zyplayer.doc.data.service.elasticsearch.service.EsWikiPageService;
|
||||
import com.zyplayer.doc.data.service.elasticsearch.support.EsPage;
|
||||
@@ -69,6 +71,8 @@ public class WikiPageController {
|
||||
@Resource
|
||||
WikiPageAuthService wikiPageAuthService;
|
||||
@Resource
|
||||
UserMessageService userMessageService;
|
||||
@Resource
|
||||
Mapper mapper;
|
||||
@Autowired(required = false)
|
||||
EsWikiPageService esWikiPageService;
|
||||
@@ -231,6 +235,9 @@ public class WikiPageController {
|
||||
UpdateWrapper<WikiPageContent> wrapper = new UpdateWrapper<>();
|
||||
wrapper.eq("page_id", pageId);
|
||||
wikiPageContentService.update(pageContent, wrapper);
|
||||
// 给相关人发送消息
|
||||
UserMessage userMessage = userMessageService.createUserMessage(currentUser, wikiPageSel.getId(), wikiPageSel.getName(), UserMsgSysType.WIKI, UserMsgType.WIKI_PAGE_UPDATE);
|
||||
userMessageService.addWikiMessage(userMessage);
|
||||
} else {
|
||||
WikiSpace wikiSpaceSel = wikiSpaceService.getById(wikiPage.getSpaceId());
|
||||
if (wikiSpaceSel == null) {
|
||||
@@ -258,6 +265,9 @@ public class WikiPageController {
|
||||
pageContent.setCreateUserId(currentUser.getUserId());
|
||||
pageContent.setCreateUserName(currentUser.getUsername());
|
||||
wikiPageContentService.save(pageContent);
|
||||
// 给相关人发送消息
|
||||
UserMessage userMessage = userMessageService.createUserMessage(currentUser, wikiPage.getId(), wikiPage.getName(), UserMsgSysType.WIKI, UserMsgType.WIKI_PAGE_CREATE);
|
||||
userMessageService.addWikiMessage(userMessage);
|
||||
}
|
||||
// 保存到es
|
||||
if (esWikiPageService.isOpen()) {
|
||||
|
||||
@@ -1,25 +1,37 @@
|
||||
package com.zyplayer.doc.wiki.controller;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.zyplayer.doc.core.annotation.AuthMan;
|
||||
import com.zyplayer.doc.core.json.DocResponseJson;
|
||||
import com.zyplayer.doc.core.json.ResponseJson;
|
||||
import com.zyplayer.doc.data.config.security.DocUserDetails;
|
||||
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserMessage;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPage;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageFile;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiSpace;
|
||||
import com.zyplayer.doc.data.repository.support.consts.UserMsgSysType;
|
||||
import com.zyplayer.doc.data.repository.support.consts.UserMsgType;
|
||||
import com.zyplayer.doc.data.service.manage.UserMessageService;
|
||||
import com.zyplayer.doc.data.service.manage.WikiPageFileService;
|
||||
import com.zyplayer.doc.data.service.manage.WikiPageService;
|
||||
import com.zyplayer.doc.data.service.manage.WikiSpaceService;
|
||||
import com.zyplayer.doc.wiki.service.WikiPageAuthService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文档控制器
|
||||
@@ -33,6 +45,9 @@ import java.util.Date;
|
||||
public class WikiPageFileController {
|
||||
private static Logger logger = LoggerFactory.getLogger(WikiPageFileController.class);
|
||||
|
||||
@Value("${zyplayer.doc.wiki.upload-path:}")
|
||||
private String uploadPath;
|
||||
|
||||
@Resource
|
||||
WikiPageFileService wikiPageFileService;
|
||||
@Resource
|
||||
@@ -41,6 +56,8 @@ public class WikiPageFileController {
|
||||
WikiPageService wikiPageService;
|
||||
@Resource
|
||||
WikiPageAuthService wikiPageAuthService;
|
||||
@Resource
|
||||
UserMessageService userMessageService;
|
||||
|
||||
// @PostMapping("/list")
|
||||
// public ResponseJson<List<WikiPageFile>> list(WikiPageFile wikiPageFile) {
|
||||
@@ -55,38 +72,91 @@ public class WikiPageFileController {
|
||||
// return DocResponseJson.ok(fileList);
|
||||
// }
|
||||
|
||||
@PostMapping("/update")
|
||||
public ResponseJson<Object> update(WikiPageFile wikiPageFile) {
|
||||
@PostMapping("/delete")
|
||||
public ResponseJson<Object> delete(WikiPageFile wikiPageFile) {
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
Long id = wikiPageFile.getId();
|
||||
Long pageId;
|
||||
if (id != null && id > 0) {
|
||||
WikiPageFile pageFileSel = wikiPageFileService.getById(wikiPageFile.getId());
|
||||
pageId = pageFileSel.getPageId();
|
||||
} else if (wikiPageFile.getPageId() != null) {
|
||||
pageId = wikiPageFile.getPageId();
|
||||
} else {
|
||||
return DocResponseJson.warn("需指定修改文件的所属页面!");
|
||||
if (id == null || id <= 0) {
|
||||
return DocResponseJson.warn("需指定删除的附件!");
|
||||
}
|
||||
WikiPageFile pageFileSel = wikiPageFileService.getById(wikiPageFile.getId());
|
||||
WikiPage wikiPageSel = wikiPageService.getById(pageFileSel.getPageId());
|
||||
WikiSpace wikiSpaceSel = wikiSpaceService.getById(wikiPageSel.getSpaceId());
|
||||
// 权限判断
|
||||
String canUploadFile = wikiPageAuthService.canUploadFile(wikiSpaceSel, pageFileSel.getPageId(), currentUser.getUserId());
|
||||
if (canUploadFile != null) {
|
||||
return DocResponseJson.warn(canUploadFile);
|
||||
}
|
||||
wikiPageFile.setDelFlag(1);
|
||||
wikiPageFile.setUpdateUserId(currentUser.getUserId());
|
||||
wikiPageFile.setUpdateUserName(currentUser.getUsername());
|
||||
wikiPageFile.setUpdateTime(new Date());
|
||||
wikiPageFileService.updateById(wikiPageFile);
|
||||
// 给相关人发送消息
|
||||
UserMessage userMessage = userMessageService.createUserMessage(currentUser, wikiPageSel.getId(), wikiPageSel.getName(), UserMsgSysType.WIKI, UserMsgType.WIKI_PAGE_FILE_DEL);
|
||||
userMessage.setAffectUserId(wikiPageSel.getCreateUserId());
|
||||
userMessage.setAffectUserName(wikiPageSel.getCreateUserName());
|
||||
userMessageService.addWikiMessage(userMessage);
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/wangEditor/upload")
|
||||
public Map<String, Object> wangEditorUpload(WikiPageFile wikiPageFile, @RequestParam("files") MultipartFile file) {
|
||||
this.upload(wikiPageFile, file);
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
resultMap.put("errno", "0");
|
||||
resultMap.put("data", new String[]{wikiPageFile.getFileUrl()});
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@PostMapping("/upload")
|
||||
public ResponseJson<Object> upload(WikiPageFile wikiPageFile, @RequestParam("files") MultipartFile file) {
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
Long pageId = wikiPageFile.getPageId();
|
||||
if (pageId == null || pageId <= 0) {
|
||||
return DocResponseJson.warn("未指定附件关联的文档");
|
||||
}
|
||||
WikiPage wikiPageSel = wikiPageService.getById(pageId);
|
||||
WikiSpace wikiSpaceSel = wikiSpaceService.getById(wikiPageSel.getSpaceId());
|
||||
// 权限判断
|
||||
String canUploadFile = wikiPageAuthService.canUploadFile(wikiSpaceSel, pageId, currentUser.getUserId());
|
||||
String canUploadFile = wikiPageAuthService.canUploadFile(wikiSpaceSel, wikiPageSel.getId(), currentUser.getUserId());
|
||||
if (canUploadFile != null) {
|
||||
return DocResponseJson.warn(canUploadFile);
|
||||
}
|
||||
if (id != null && id > 0) {
|
||||
wikiPageFile.setUpdateUserId(currentUser.getUserId());
|
||||
wikiPageFile.setUpdateUserName(currentUser.getUsername());
|
||||
wikiPageFile.setUpdateTime(new Date());
|
||||
wikiPageFileService.updateById(wikiPageFile);
|
||||
} else {
|
||||
wikiPageFile.setCreateTime(new Date());
|
||||
wikiPageFile.setCreateUserId(currentUser.getUserId());
|
||||
wikiPageFile.setCreateUserName(currentUser.getUsername());
|
||||
wikiPageFileService.save(wikiPageFile);
|
||||
String fileName = file.getOriginalFilename();
|
||||
String fileSuffix = "";
|
||||
if (fileName != null && fileName.lastIndexOf(".") >= 0) {
|
||||
fileSuffix = fileName.substring(fileName.lastIndexOf("."));
|
||||
}
|
||||
return DocResponseJson.ok();
|
||||
String path = uploadPath + "/" + DateTime.now().toString("yyyy/MM/dd") + "/";
|
||||
File newFile = new File(path);
|
||||
if (!newFile.exists() && !newFile.mkdirs()) {
|
||||
return DocResponseJson.warn("创建文件夹失败");
|
||||
}
|
||||
String simpleUUID = RandomUtil.simpleUUID();
|
||||
path += simpleUUID + fileSuffix;
|
||||
newFile = new File(path);
|
||||
try {
|
||||
file.transferTo(newFile);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return DocResponseJson.warn("保存文件失败");
|
||||
}
|
||||
wikiPageFile.setUuid(simpleUUID);
|
||||
wikiPageFile.setFileUrl(path);
|
||||
wikiPageFile.setFileName(fileName);
|
||||
wikiPageFile.setCreateTime(new Date());
|
||||
wikiPageFile.setCreateUserId(currentUser.getUserId());
|
||||
wikiPageFile.setCreateUserName(currentUser.getUsername());
|
||||
wikiPageFile.setDelFlag(0);
|
||||
wikiPageFileService.save(wikiPageFile);
|
||||
wikiPageFile.setFileUrl("zyplayer-doc-wiki/common/file?uuid=" + wikiPageFile.getUuid());
|
||||
// 给相关人发送消息
|
||||
UserMessage userMessage = userMessageService.createUserMessage(currentUser, pageId, wikiPageSel.getName(), UserMsgSysType.WIKI, UserMsgType.WIKI_PAGE_UPLOAD);
|
||||
userMessage.setAffectUserId(wikiPageSel.getCreateUserId());
|
||||
userMessage.setAffectUserName(wikiPageSel.getCreateUserName());
|
||||
userMessageService.addWikiMessage(userMessage);
|
||||
return DocResponseJson.ok(wikiPageFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
package com.zyplayer.doc.wiki.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.zyplayer.doc.core.annotation.AuthMan;
|
||||
import com.zyplayer.doc.core.json.DocResponseJson;
|
||||
import com.zyplayer.doc.core.json.ResponseJson;
|
||||
import com.zyplayer.doc.core.annotation.AuthMan;
|
||||
import com.zyplayer.doc.data.config.security.DocUserDetails;
|
||||
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserMessage;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPage;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageZan;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiSpace;
|
||||
import com.zyplayer.doc.data.repository.support.consts.UserMsgSysType;
|
||||
import com.zyplayer.doc.data.repository.support.consts.UserMsgType;
|
||||
import com.zyplayer.doc.data.service.manage.UserMessageService;
|
||||
import com.zyplayer.doc.data.service.manage.WikiPageService;
|
||||
import com.zyplayer.doc.data.service.manage.WikiPageZanService;
|
||||
import com.zyplayer.doc.data.service.manage.WikiSpaceService;
|
||||
@@ -40,6 +44,8 @@ public class WikiPageZanController {
|
||||
WikiSpaceService wikiSpaceService;
|
||||
@Resource
|
||||
WikiPageService wikiPageService;
|
||||
@Resource
|
||||
UserMessageService userMessageService;
|
||||
|
||||
@PostMapping("/list")
|
||||
public ResponseJson<List<WikiPageZan>> list(WikiPageZan wikiPageZan) {
|
||||
@@ -78,6 +84,11 @@ public class WikiPageZanController {
|
||||
return DocResponseJson.warn("您没有该空间的点赞权限!");
|
||||
}
|
||||
wikiPageZanService.zanPage(wikiPageZan);
|
||||
// 给相关人发送消息
|
||||
UserMessage userMessage = userMessageService.createUserMessage(currentUser, wikiPageSel.getId(), wikiPageSel.getName(), UserMsgSysType.WIKI, UserMsgType.WIKI_PAGE_ZAN);
|
||||
userMessage.setAffectUserId(wikiPageSel.getCreateUserId());
|
||||
userMessage.setAffectUserName(wikiPageSel.getCreateUserName());
|
||||
userMessageService.addWikiMessage(userMessage);
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user