权限开发,页面交互开发,增加阅读数
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.zyplayer.doc.data.aspect;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.zyplayer.doc.core.json.DocResponseJson;
|
||||
import com.zyplayer.doc.core.json.HttpConst;
|
||||
import com.zyplayer.doc.core.json.ResponseJson;
|
||||
@@ -14,9 +15,11 @@ import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
@@ -32,13 +35,16 @@ public class AuthAspect {
|
||||
RestController restController = BeanUtil.getAnnotation(pjp, RestController.class);
|
||||
boolean isResponseBody = (restController != null || responseBody != null);
|
||||
|
||||
Class<?> returnType = ((MethodSignature) pjp.getSignature()).getMethod().getReturnType();
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
if (currentUser == null) {
|
||||
String reason = "你访问的内容需要登录,请登录后再试";
|
||||
if (isResponseBody) {
|
||||
return DocResponseJson.failure(HttpConst.TOKEN_TIMEOUT, reason);
|
||||
} else {
|
||||
return authMan.authUrl();
|
||||
} else if (returnType.isAssignableFrom(ModelAndView.class)) {
|
||||
return new ModelAndView("redirect:/static/manage/login.html");
|
||||
} else if (returnType.isAssignableFrom(Map.class)) {
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
}
|
||||
// 判断权限是否足够
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.zyplayer.doc.data.repository.manage.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -11,7 +12,7 @@ import java.io.Serializable;
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-03-09
|
||||
* @since 2019-06-05
|
||||
*/
|
||||
public class WikiPage implements Serializable {
|
||||
|
||||
@@ -88,6 +89,11 @@ public class WikiPage implements Serializable {
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
/**
|
||||
* 阅读数
|
||||
*/
|
||||
private Integer viewNum;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -186,6 +192,13 @@ public class WikiPage implements Serializable {
|
||||
public void setDelFlag(Integer delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
public Integer getViewNum() {
|
||||
return viewNum;
|
||||
}
|
||||
|
||||
public void setViewNum(Integer viewNum) {
|
||||
this.viewNum = viewNum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@@ -204,6 +217,7 @@ public class WikiPage implements Serializable {
|
||||
", updateUserName=" + updateUserName +
|
||||
", updateTime=" + updateTime +
|
||||
", delFlag=" + delFlag +
|
||||
", viewNum=" + viewNum +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class CodeGenerator {
|
||||
final String moduleName = "manage";
|
||||
// final String[] tableName = { "zyplayer_storage", "auth_info", "user_auth", "user_info" };
|
||||
// final String[] tableName = { "wiki_space", "wiki_page", "wiki_page_content", "wiki_page_file", "wiki_page_comment", "wiki_page_zan" };
|
||||
final String[] tableName = { "user_auth" };
|
||||
final String[] tableName = { "wiki_page" };
|
||||
|
||||
// 代码生成器
|
||||
AutoGenerator mpg = new AutoGenerator();
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.springframework.stereotype.Service;
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-03-09
|
||||
* @since 2019-06-05
|
||||
*/
|
||||
@Service
|
||||
public class WikiPageServiceImpl extends ServiceImpl<WikiPageMapper, WikiPage> implements WikiPageService {
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.zyplayer.doc.manage.web.generator;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018-12-05
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/auth-info")
|
||||
public class GeneratorAuthInfoController {
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.zyplayer.doc.manage.web.generator;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018-12-05
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user-auth")
|
||||
public class GeneratorUserAuthController {
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.zyplayer.doc.manage.web.generator;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018-12-05
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user-info")
|
||||
public class GeneratorUserInfoController {
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.zyplayer.doc.manage.web.generator;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018-12-05
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/zyplayer-storage")
|
||||
public class GeneratorZyplayerStorageController {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.zyplayer.doc.manage.web.manage;
|
||||
|
||||
import com.zyplayer.doc.data.aspect.AuthMan;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* 使用路劲的方式访问页面
|
||||
*/
|
||||
@AuthMan
|
||||
@Controller
|
||||
public class DocSystemController {
|
||||
|
||||
@GetMapping("/doc-wiki")
|
||||
public ModelAndView wiki() {
|
||||
return new ModelAndView("/doc-wiki-v2.html");
|
||||
}
|
||||
|
||||
@GetMapping("/doc-db")
|
||||
public ModelAndView db() {
|
||||
return new ModelAndView("/doc-db.html");
|
||||
}
|
||||
|
||||
@GetMapping("/doc-swagger")
|
||||
public ModelAndView swagger() {
|
||||
return new ModelAndView("/document.html");
|
||||
}
|
||||
|
||||
@GetMapping("/doc-dubbo")
|
||||
public ModelAndView dubbo() {
|
||||
return new ModelAndView("/doc-dubbo.html");
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,11 @@ public class LoginController {
|
||||
cookie.setDomain("zyplayer.com");
|
||||
cookie.setMaxAge(60 * 60 * 24);
|
||||
response.addCookie(cookie);
|
||||
// 再搞一份当前路劲的cookie
|
||||
cookie = new Cookie("accessToken", accessToken);
|
||||
cookie.setPath("/");
|
||||
cookie.setMaxAge(60 * 60 * 24);
|
||||
response.addCookie(cookie);
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,21 @@
|
||||
-- 直接存权限名,不搞中间表了
|
||||
ALTER TABLE `user_auth` ADD COLUMN `auth_custom_suffix` varchar(100) NULL COMMENT '自定义权限结尾';
|
||||
|
||||
INSERT INTO `auth_info`(`auth_name`, `auth_desc`, `can_edit`, `create_uid`, `creation_time`)
|
||||
VALUES
|
||||
( 'WIKI_CREATE_PAGE_', '创建wiki文档', 0, 1, '2019-06-04 13:01:20')
|
||||
,('WIKI_EDIT_PAGE_', '编辑wiki文档', 0, 1, '2019-06-04 13:01:20')
|
||||
,('WIKI_COMMENT_PAGE_', '评论wiki文档', 0, 1, '2019-06-04 13:01:20')
|
||||
,('WIKI_DELETE_PAGE_', '删除wiki文档', 0, 1, '2019-06-04 13:01:20')
|
||||
,('WIKI_PAGE_FILE_UPLOAD_', '上传wiki文档附件', 0, 1, '2019-06-04 13:01:20')
|
||||
,('WIKI_PAGE_FILE_DELETE_', '删除wiki文档附件', 0, 1, '2019-06-04 13:01:20')
|
||||
,('WIKI_PAGE_AUTH_MANAGE_', 'wiki权限管理', 0, 1, '2019-06-04 13:01:20')
|
||||
;
|
||||
|
||||
ALTER TABLE `wiki_page` ADD COLUMN `view_num` int NOT NULL DEFAULT 0 COMMENT '阅读数';
|
||||
|
||||
|
||||
|
||||
|
||||
-- 权限的库:
|
||||
|
||||
|
||||
Binary file not shown.
@@ -74,16 +74,22 @@
|
||||
app.passwordError = "密码不能为空";
|
||||
return;
|
||||
}
|
||||
post(ctx + "login", param, function (result) {
|
||||
console.log(result);
|
||||
if (result.errCode == 200) {
|
||||
location.href = ctx + "static/manage/home.html";
|
||||
} else {
|
||||
app.passwordError = "登录失败," + result.errMsg;
|
||||
}
|
||||
}, function(){
|
||||
// 通过nginx代理之后没端口,但tomcat容器有端口,会跨域异常,但正常登陆了的,直接跳
|
||||
location.href = ctx + "static/manage/home.html";
|
||||
var returnUrl = common.getParam("returnUrl");
|
||||
if (!!returnUrl) {
|
||||
returnUrl = decodeURI(returnUrl);
|
||||
} else {
|
||||
returnUrl = ctx + "static/manage/home.html";
|
||||
}
|
||||
post(ctx + "login", param, function (result) {
|
||||
console.log(result);
|
||||
if (result.errCode == 200) {
|
||||
location.href = returnUrl;
|
||||
} else {
|
||||
app.passwordError = "登录失败," + result.errMsg;
|
||||
}
|
||||
}, function () {
|
||||
// 通过nginx代理之后没端口,但tomcat容器有端口,会跨域异常,但正常登陆了的,直接跳
|
||||
// location.href = returnUrl;
|
||||
});
|
||||
},
|
||||
init: function () {
|
||||
|
||||
@@ -175,28 +175,10 @@
|
||||
treePathDataMap: new Map(),
|
||||
// 搜索的输入内容
|
||||
searchKeywords: "",
|
||||
// 编辑相关
|
||||
newPageId: "",
|
||||
newPageTitle: "",
|
||||
// 页面展示相关
|
||||
wikiPageList:[],
|
||||
wikiPage: {},
|
||||
wikiPageExpandedKeys: [],
|
||||
pageContent: {},
|
||||
pageFileList: [],
|
||||
uploadFileList: [],
|
||||
uploadFormData: {pageId: 0},
|
||||
zanUserDialogVisible: false,
|
||||
zanUserList: [],
|
||||
// 评论相关
|
||||
commentTextInput: "",
|
||||
commentList: [],
|
||||
recommentInfo: {},
|
||||
// 页面跳转相关
|
||||
initOver: false,
|
||||
doNotPushState: false,
|
||||
urlParamPageId: 0,
|
||||
urlParam: {},
|
||||
// 升级信息
|
||||
upgradeInfo: {},
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var URL = {
|
||||
userLogin: '/user/login',
|
||||
userLogout: '/user/logout',
|
||||
userLogin: '/login',
|
||||
userLogout: '/logout',
|
||||
getUserInfo: '/user/getUserInfo',
|
||||
pageUpdate: '/zyplayer-doc-wiki/page/update',
|
||||
pageChangeParent: '/zyplayer-doc-wiki/page/changeParent',
|
||||
@@ -9,6 +9,8 @@ var URL = {
|
||||
pageDetail: '/zyplayer-doc-wiki/page/detail',
|
||||
spaceList: '/zyplayer-doc-wiki/space/list',
|
||||
updateSpace: '/zyplayer-doc-wiki/space/update',
|
||||
getPageUserAuthList: '/zyplayer-doc-wiki/page/auth/list',
|
||||
assignPageUserAuth: '/zyplayer-doc-wiki/page/auth/assign',
|
||||
|
||||
updatePageFile: '/zyplayer-doc-wiki/page/file/update',
|
||||
pageCommentList: '/zyplayer-doc-wiki/page/comment/list',
|
||||
@@ -17,6 +19,7 @@ var URL = {
|
||||
updatePageZan: '/zyplayer-doc-wiki/page/zan/update',
|
||||
|
||||
commonUpload: '/zyplayer-doc-wiki/common/upload',
|
||||
getUserBaseInfo: '/zyplayer-doc-wiki/common/user/base',
|
||||
};
|
||||
|
||||
var URL1 = {};
|
||||
|
||||
@@ -5,11 +5,11 @@ var href = window.location.href;
|
||||
var _fn = {
|
||||
href: href,
|
||||
// 这里设置接口域名
|
||||
// HOST: 'http://local.zyplayer.com:8083/zyplayer-doc-manage',
|
||||
// HOST1: 'http://local.zyplayer.com:8083/zyplayer-doc-manage',
|
||||
HOST: 'http://local.zyplayer.com:8083/zyplayer-doc-manage',
|
||||
HOST1: 'http://local.zyplayer.com:8083/zyplayer-doc-manage',
|
||||
// 打包时使用下面这两行,文件就放在根目录下,所以当前路劲就好
|
||||
HOST: './',
|
||||
HOST1: './',
|
||||
// HOST: './',
|
||||
// HOST1: './',
|
||||
|
||||
mixUrl: function (host, url) {
|
||||
var p;
|
||||
|
||||
@@ -23,7 +23,8 @@ export default {
|
||||
global.vue.$message('请求错误:' + res.message);
|
||||
} else if (res.data.errCode == 400) {
|
||||
global.vue.$message('请先登录');
|
||||
window.location = apimix.apilist1.HOST + "/static/manage/login.html";
|
||||
var href = encodeURI(window.location.href);
|
||||
window.location = apimix.apilist1.HOST + "/static/manage/login.html?returnUrl=" + href;
|
||||
} else if (res.data.errCode == 402) {
|
||||
global.vue.$router.push("/common/noAuth");
|
||||
} else if (res.data.errCode !== 200) {
|
||||
|
||||
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -53,7 +53,7 @@
|
||||
cancelButtonText: '继续编辑',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
|
||||
app.$router.back();
|
||||
});
|
||||
},
|
||||
createWikiSave() {
|
||||
@@ -74,7 +74,8 @@
|
||||
toast.success("保存成功!");
|
||||
// 重新加载左侧列表,跳转到展示页面
|
||||
global.vue.$app.doGetPageList(null);
|
||||
app.$router.push({path: '/page/show', query: {pageId: json.data.id}});
|
||||
app.parentPath.pageId = json.data.id;
|
||||
app.$router.push({path: '/page/show', query: app.parentPath});
|
||||
});
|
||||
},
|
||||
loadPageDetail(pageId) {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<el-button type="text" icon="el-icon-upload">上传附件</el-button>
|
||||
</el-upload>
|
||||
<el-button type="text" icon="el-icon-edit" v-on:click="editWiki">编辑</el-button>
|
||||
<el-button type="text" icon="el-icon-setting" v-on:click="editWikiAuth">访问权限</el-button>
|
||||
<el-button type="text" icon="el-icon-setting" v-on:click="editWikiAuth">权限设置</el-button>
|
||||
<el-button type="text" icon="el-icon-delete" v-on:click="deleteWikiPage">删除</el-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -52,6 +52,9 @@
|
||||
<span v-else-if="wikiPage.selfZan == 1 && wikiPage.zanNum <= 1">我赞了它</span>
|
||||
<span v-else-if="wikiPage.selfZan == 1 && wikiPage.zanNum > 1"><span class="is-link" v-on:click="showZanPageUser">我和{{wikiPage.zanNum-1}}个其他人</span>赞了它</span>
|
||||
</span>
|
||||
<span style="margin-left: 10px;">
|
||||
<i class="el-icon-view" style="font-size: 16px;color: #666;"></i> {{wikiPage.viewNum}}次阅读
|
||||
</span>
|
||||
</div>
|
||||
<div v-show="commentList.length > 0" class="comment-box" style="margin-top: 20px;">
|
||||
<div style="border-bottom: 1px solid #67C23A;padding-bottom: 10px;">评论列表:</div>
|
||||
@@ -92,6 +95,38 @@
|
||||
<el-table-column prop="createTime" label="时间"></el-table-column>
|
||||
</el-table>
|
||||
</el-dialog>
|
||||
<!--人员权限弹窗-->
|
||||
<el-dialog title="页面权限" :visible.sync="pageAuthDialogVisible" width="900px">
|
||||
<el-row>
|
||||
<el-select v-model="pageAuthNewUser" filterable remote reserve-keyword
|
||||
placeholder="请输入名字、邮箱、账号搜索用户" :remote-method="getSearchUserList"
|
||||
:loading="pageAuthUserLoading" style="width: 750px;">
|
||||
<el-option v-for="item in searchUserList" :key="item.id" :label="item.userName" :value="item.id"></el-option>
|
||||
</el-select>
|
||||
<el-button v-on:click="addPageAuthUser">添加</el-button>
|
||||
</el-row>
|
||||
<el-table :data="pageAuthUserList" border style="width: 100%; margin: 10px 0;">
|
||||
<el-table-column prop="userName" label="用户" width="150"></el-table-column>
|
||||
<el-table-column label="权限">
|
||||
<template slot-scope="scope">
|
||||
<el-checkbox :true-label="1" :false-label="0" v-model="scope.row.editPage">查看</el-checkbox>
|
||||
<el-checkbox :true-label="1" :false-label="0" v-model="scope.row.commentPage">评论</el-checkbox>
|
||||
<el-checkbox :true-label="1" :false-label="0" v-model="scope.row.deletePage">删除</el-checkbox>
|
||||
<el-checkbox :true-label="1" :false-label="0" v-model="scope.row.pageFileUpload">文件上传</el-checkbox>
|
||||
<el-checkbox :true-label="1" :false-label="0" v-model="scope.row.pageFileDelete">文件删除</el-checkbox>
|
||||
<el-checkbox :true-label="1" :false-label="0" v-model="scope.row.pageAuthManage">权限管理</el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="80">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="small" type="danger" plain v-on:click="deleteUserPageAuth(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div>
|
||||
<el-button type="primary" v-on:click="saveUserPageAuth">保存配置</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -114,43 +149,100 @@
|
||||
uploadFormData: {pageId: 0},
|
||||
zanUserDialogVisible: false,
|
||||
zanUserList: [],
|
||||
parentPath: {},
|
||||
// 评论相关
|
||||
commentTextInput: "",
|
||||
commentList: [],
|
||||
recommentInfo: {},
|
||||
// 页面权限
|
||||
pageAuthDialogVisible: false,
|
||||
pageAuthUserList: [],
|
||||
searchUserList: [],
|
||||
pageAuthNewUser: "",
|
||||
pageAuthUserLoading: false,
|
||||
};
|
||||
},
|
||||
beforeRouteUpdate(to, from, next) {
|
||||
var pageId = to.query.pageId;
|
||||
if (!!pageId) {
|
||||
this.loadPageDetail(pageId);
|
||||
}
|
||||
this.initQueryParam(to);
|
||||
next();
|
||||
},
|
||||
mounted: function () {
|
||||
app = this;
|
||||
var pageId = this.$route.query.pageId;
|
||||
if (!!pageId) {
|
||||
this.loadPageDetail(pageId);
|
||||
this.initQueryParam(this.$route);
|
||||
if (!!this.parentPath.pageId) {
|
||||
// 延迟设置展开的目录,edit比app先初始化
|
||||
setTimeout(function () {
|
||||
global.vue.$app.changeWikiPageExpandedKeys(pageId);
|
||||
}, 200);
|
||||
global.vue.$app.changeWikiPageExpandedKeys(app.parentPath.pageId);
|
||||
}, 500);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
editWiki() {
|
||||
this.$router.push({path: '/page/edit', query: {pageId: this.wikiPage.id}});
|
||||
// this.rightContentType = 2;
|
||||
// this.newPageId = app.wikiPage.id;
|
||||
// this.newPageTitle = app.wikiPage.name;
|
||||
// page.newPageContentEditor.txt.html(app.pageContent.content || "");
|
||||
this.$router.push({path: '/page/edit', query: this.parentPath});
|
||||
},
|
||||
getSearchUserList(query) {
|
||||
if (query == '') {
|
||||
return;
|
||||
}
|
||||
this.pageAuthUserLoading = true;
|
||||
var param = {search: query};
|
||||
this.common.post(this.apilist1.getUserBaseInfo, param, function (json) {
|
||||
app.searchUserList = json.data || [];
|
||||
app.pageAuthUserLoading = false;
|
||||
});
|
||||
},
|
||||
addPageAuthUser() {
|
||||
if (this.pageAuthNewUser.length <= 0) {
|
||||
toast.warn("请先选择用户");
|
||||
return;
|
||||
}
|
||||
var userName = "";
|
||||
for (var i = 0; i < this.searchUserList.length; i++) {
|
||||
if (this.pageAuthNewUser == this.searchUserList[i].id) {
|
||||
userName = this.searchUserList[i].userName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.pageAuthUserList.push({
|
||||
userName: userName,
|
||||
userId: this.pageAuthNewUser,
|
||||
editPage: 0,
|
||||
commentPage: 0,
|
||||
deletePage: 0,
|
||||
pageFileUpload: 0,
|
||||
pageFileDelete: 0,
|
||||
pageAuthManage: 0,
|
||||
});
|
||||
this.pageAuthNewUser = "";
|
||||
},
|
||||
editWikiAuth() {
|
||||
toast.notOpen();
|
||||
app.pageAuthNewUser = [];
|
||||
app.pageAuthUserList = [];
|
||||
var param = {pageId: app.wikiPage.id};
|
||||
this.common.post(this.apilist1.getPageUserAuthList, param, function (json) {
|
||||
app.pageAuthUserList = json.data || [];
|
||||
app.pageAuthDialogVisible = true;
|
||||
});
|
||||
},
|
||||
saveUserPageAuth() {
|
||||
var param = {pageId: app.wikiPage.id, authList: JSON.stringify(app.pageAuthUserList)};
|
||||
this.common.post(this.apilist1.assignPageUserAuth, param, function (json) {
|
||||
toast.success("保存成功!");
|
||||
});
|
||||
},
|
||||
notOpen() {
|
||||
toast.notOpen();
|
||||
},
|
||||
deleteUserPageAuth(row) {
|
||||
var pageAuthUserList = [];
|
||||
for (var i = 0; i < this.pageAuthUserList.length; i++) {
|
||||
var item = this.pageAuthUserList[i];
|
||||
if (item.userId != row.userId) {
|
||||
pageAuthUserList.push(this.pageAuthUserList[i]);
|
||||
}
|
||||
}
|
||||
this.pageAuthUserList = pageAuthUserList;
|
||||
},
|
||||
deleteWikiPage() {
|
||||
this.$confirm('确定要删除此页面吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
@@ -159,9 +251,9 @@
|
||||
}).then(() => {
|
||||
var param = {id: app.wikiPage.id, delFlag: 1};
|
||||
this.common.post(this.apilist1.updatePage, param, function (json) {
|
||||
app.rightContentType = 0;
|
||||
app.wikiPage = {};
|
||||
app.doGetPageList(null);
|
||||
// 重新加载左侧列表,跳转到展示页面
|
||||
global.vue.$app.doGetPageList(null);
|
||||
app.$router.push({path: '/home'});
|
||||
});
|
||||
});
|
||||
},
|
||||
@@ -268,6 +360,15 @@
|
||||
}
|
||||
return color;
|
||||
},
|
||||
initQueryParam(to) {
|
||||
this.parentPath = {
|
||||
spaceId: to.query.spaceId, pageId: to.query.pageId,
|
||||
parentId: to.query.parentId, path: to.query.path
|
||||
};
|
||||
if (!!this.parentPath.pageId) {
|
||||
this.loadPageDetail(this.parentPath.pageId);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3895,6 +3895,11 @@ vue@^2.5.16:
|
||||
version "2.5.16"
|
||||
resolved "https://registry.yarnpkg.com/vue/-/vue-2.5.16.tgz#07edb75e8412aaeed871ebafa99f4672584a0085"
|
||||
|
||||
wangeditor@^3.1.1:
|
||||
version "3.1.1"
|
||||
resolved "https://registry.npm.taobao.org/wangeditor/download/wangeditor-3.1.1.tgz#fbd3c1d4976923c9edebb85b29d30b35512ad039"
|
||||
integrity sha1-+9PB1JdpI8nt67hbKdMLNVEq0Dk=
|
||||
|
||||
watchpack@^1.3.1:
|
||||
version "1.3.1"
|
||||
resolved "http://registry.npm.taobao.org/watchpack/download/watchpack-1.3.1.tgz#7d8693907b28ce6013e7f3610aa2a1acf07dad87"
|
||||
|
||||
@@ -2,19 +2,24 @@ 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.json.DocResponseJson;
|
||||
import com.zyplayer.doc.core.json.ResponseJson;
|
||||
import com.zyplayer.doc.data.aspect.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.UserInfo;
|
||||
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.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;
|
||||
@@ -29,10 +34,7 @@ import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 文档控制器
|
||||
@@ -55,6 +57,21 @@ public class WikiCommonController {
|
||||
WikiPageService wikiPageService;
|
||||
@Resource
|
||||
WikiSpaceService wikiSpaceService;
|
||||
@Resource
|
||||
UserInfoService userInfoService;
|
||||
|
||||
@PostMapping("/user/base")
|
||||
public ResponseJson<Object> userBaseInfo(String search) {
|
||||
if (StringUtils.isBlank(search)) {
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
QueryWrapper<UserInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.like("user_name", search).or().like("user_no", search)
|
||||
.or().like("email", search);
|
||||
queryWrapper.select("id", "user_name");
|
||||
List<UserInfo> userInfoList = userInfoService.list(queryWrapper);
|
||||
return DocResponseJson.ok(userInfoList);
|
||||
}
|
||||
|
||||
@PostMapping("/wangEditor/upload")
|
||||
public Map<String, Object> wangEditorUpload(WikiPageFile wikiPageFile, @RequestParam("files") MultipartFile file) {
|
||||
@@ -67,12 +84,28 @@ public class WikiCommonController {
|
||||
|
||||
@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.havePageAuth(WikiAuthType.PAGE_FILE_UPLOAD.getName(), pageId);
|
||||
if (!pageAuth) {
|
||||
return DocResponseJson.warn("您没有修改该文章附件的权限!");
|
||||
}
|
||||
}
|
||||
}
|
||||
String fileName = file.getOriginalFilename();
|
||||
String fileSuffix = "";
|
||||
if (fileName != null && fileName.lastIndexOf(".") >= 0) {
|
||||
fileSuffix = fileName.substring(fileName.lastIndexOf("."));
|
||||
}
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
String path = uploadPath + "/" + DateTime.now().toString("yyyy/MM/dd") + "/";
|
||||
File newFile = new File(path);
|
||||
if (!newFile.exists() && !newFile.mkdirs()) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.zyplayer.doc.wiki.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.zyplayer.doc.core.json.DocResponseJson;
|
||||
import com.zyplayer.doc.core.json.ResponseJson;
|
||||
import com.zyplayer.doc.data.aspect.AuthMan;
|
||||
@@ -7,8 +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.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 org.apache.commons.collections.CollectionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -16,9 +20,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 文档控制器
|
||||
@@ -37,6 +41,8 @@ public class WikiPageAuthController {
|
||||
@Resource
|
||||
WikiSpaceService wikiSpaceService;
|
||||
@Resource
|
||||
UserInfoService userInfoService;
|
||||
@Resource
|
||||
WikiPageService wikiPageService;
|
||||
@Resource
|
||||
UserAuthService userAuthService;
|
||||
@@ -44,43 +50,133 @@ public class WikiPageAuthController {
|
||||
AuthInfoService authInfoService;
|
||||
|
||||
@PostMapping("/assign")
|
||||
public ResponseJson<List<WikiPageZan>> assign(Long pageId, Long userId, Long authId) {
|
||||
public ResponseJson<List<WikiPageZan>> assign(Long pageId, String authList) {
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
WikiPage wikiPageSel = wikiPageService.getById(pageId);
|
||||
WikiSpace wikiSpaceSel = wikiSpaceService.getById(wikiPageSel.getSpaceId());
|
||||
if (SpaceType.isPrivate(wikiSpaceSel.getType())) {
|
||||
return DocResponseJson.warn("");
|
||||
}
|
||||
if (SpaceType.isPublic(wikiSpaceSel.getType())) {
|
||||
return DocResponseJson.warn("");
|
||||
}
|
||||
// if (SpaceType.isPrivate(wikiSpaceSel.getType())) {
|
||||
// return DocResponseJson.warn("私人空间不可以编辑权限");
|
||||
// }
|
||||
// if (SpaceType.isPublic(wikiSpaceSel.getType())) {
|
||||
// return DocResponseJson.warn("公共空间不需要编辑权限");
|
||||
// }
|
||||
if (!SpaceType.isPersonal(wikiSpaceSel.getType())) {
|
||||
return DocResponseJson.warn("");
|
||||
return DocResponseJson.warn("只有个人空间才可以编辑权限");
|
||||
}
|
||||
if (!Objects.equals(currentUser.getUserId(), wikiSpaceSel.getCreateUserId())) {
|
||||
if (!DocUserUtil.havePageAuth(WikiAuthType.PAGE_AUTH_MANAGE.getName(), pageId)) {
|
||||
return DocResponseJson.warn("");
|
||||
return DocResponseJson.warn("您不是创建人或没有权限修改");
|
||||
}
|
||||
}
|
||||
AuthInfo authInfo = authInfoService.getById(authId);
|
||||
if (authInfo == null) {
|
||||
return DocResponseJson.warn("");
|
||||
List<String> authNameList = Stream.of(WikiAuthType.values()).map(WikiAuthType::getName).collect(Collectors.toList());
|
||||
QueryWrapper<AuthInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("auth_name", authNameList);
|
||||
Collection<AuthInfo> authInfoList = authInfoService.list(queryWrapper);
|
||||
Map<String, Long> authInfoMap = authInfoList.stream().collect(Collectors.toMap(AuthInfo::getAuthName, AuthInfo::getId));
|
||||
|
||||
// 先删除页面的所有用户的权限
|
||||
UserAuth userAuthDel = new UserAuth();
|
||||
userAuthDel.setDelFlag(1);
|
||||
QueryWrapper<UserAuth> updateWrapper = new QueryWrapper<>();
|
||||
updateWrapper.eq("auth_custom_suffix", pageId);
|
||||
updateWrapper.eq("del_flag", 0);
|
||||
userAuthService.update(userAuthDel, updateWrapper);
|
||||
|
||||
List<UserPageAuthVo> authVoList = JSON.parseArray(authList, UserPageAuthVo.class);
|
||||
for (UserPageAuthVo authVo : authVoList) {
|
||||
List<UserAuth> userAuthList = new LinkedList<>();
|
||||
if (Objects.equals(authVo.getEditPage(), 1)) {
|
||||
Long authId = authInfoMap.get(WikiAuthType.EDIT_PAGE.getName());
|
||||
UserAuth userAuth = this.createUserAuth(pageId, currentUser.getUserId(), authVo.getUserId(), authId);
|
||||
userAuthList.add(userAuth);
|
||||
}
|
||||
if (Objects.equals(authVo.getCommentPage(), 1)) {
|
||||
Long authId = authInfoMap.get(WikiAuthType.COMMENT_PAGE.getName());
|
||||
UserAuth userAuth = this.createUserAuth(pageId, currentUser.getUserId(), authVo.getUserId(), authId);
|
||||
userAuthList.add(userAuth);
|
||||
}
|
||||
if (Objects.equals(authVo.getDeletePage(), 1)) {
|
||||
Long authId = authInfoMap.get(WikiAuthType.DELETE_PAGE.getName());
|
||||
UserAuth userAuth = this.createUserAuth(pageId, currentUser.getUserId(), authVo.getUserId(), authId);
|
||||
userAuthList.add(userAuth);
|
||||
}
|
||||
if (Objects.equals(authVo.getPageFileUpload(), 1)) {
|
||||
Long authId = authInfoMap.get(WikiAuthType.PAGE_FILE_UPLOAD.getName());
|
||||
UserAuth userAuth = this.createUserAuth(pageId, currentUser.getUserId(), authVo.getUserId(), authId);
|
||||
userAuthList.add(userAuth);
|
||||
}
|
||||
if (Objects.equals(authVo.getPageFileDelete(), 1)) {
|
||||
Long authId = authInfoMap.get(WikiAuthType.PAGE_FILE_DELETE.getName());
|
||||
UserAuth userAuth = this.createUserAuth(pageId, currentUser.getUserId(), authVo.getUserId(), authId);
|
||||
userAuthList.add(userAuth);
|
||||
}
|
||||
if (Objects.equals(authVo.getPageAuthManage(), 1)) {
|
||||
Long authId = authInfoMap.get(WikiAuthType.PAGE_AUTH_MANAGE.getName());
|
||||
UserAuth userAuth = this.createUserAuth(pageId, currentUser.getUserId(), authVo.getUserId(), authId);
|
||||
userAuthList.add(userAuth);
|
||||
}
|
||||
if (userAuthList.size() > 0) {
|
||||
userAuthService.saveBatch(userAuthList);
|
||||
}
|
||||
}
|
||||
UserAuth userAuth = new UserAuth();
|
||||
userAuth.setAuthId(authId);
|
||||
userAuth.setCreateUid(currentUser.getUserId());
|
||||
userAuth.setCreationTime(new Date());
|
||||
userAuth.setDelFlag(0);
|
||||
userAuth.setUserId(userId);
|
||||
userAuth.setAuthCustomSuffix(String.valueOf(pageId));
|
||||
userAuthService.save(userAuth);
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public ResponseJson<Object> update(WikiPageZan wikiPageZan) {
|
||||
@PostMapping("/list")
|
||||
public ResponseJson<Object> list(Long pageId) {
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
return DocResponseJson.ok();
|
||||
WikiPage wikiPageSel = wikiPageService.getById(pageId);
|
||||
WikiSpace wikiSpaceSel = wikiSpaceService.getById(wikiPageSel.getSpaceId());
|
||||
if (!Objects.equals(currentUser.getUserId(), wikiSpaceSel.getCreateUserId())) {
|
||||
if (!DocUserUtil.havePageAuth(WikiAuthType.PAGE_AUTH_MANAGE.getName(), pageId)) {
|
||||
return DocResponseJson.warn("您没有权限管理该页面的权限");
|
||||
}
|
||||
}
|
||||
QueryWrapper<UserAuth> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("auth_custom_suffix", pageId);
|
||||
queryWrapper.eq("del_flag", 0);
|
||||
List<UserAuth> authList = userAuthService.list(queryWrapper);
|
||||
if (CollectionUtils.isEmpty(authList)) {
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
// 权限ID对应的权限名
|
||||
Collection<AuthInfo> authInfoList = authInfoService.listByIds(authList.stream().map(UserAuth::getAuthId).collect(Collectors.toList()));
|
||||
Map<Long, String> authInfoMap = authInfoList.stream().collect(Collectors.toMap(AuthInfo::getId, AuthInfo::getAuthName));
|
||||
// 查询用户信息
|
||||
Map<Long, List<UserAuth>> userAuthGroup = authList.stream().collect(Collectors.groupingBy(UserAuth::getUserId));
|
||||
Collection<UserInfo> userInfos = userInfoService.listByIds(userAuthGroup.keySet());
|
||||
Map<Long, String> userInfoMap = userInfos.stream().collect(Collectors.toMap(UserInfo::getId, UserInfo::getUserName));
|
||||
List<UserPageAuthVo> authVoList = new LinkedList<>();
|
||||
// 组装结果集
|
||||
userAuthGroup.forEach((key, value) -> {
|
||||
Set<String> authNameSet = value.stream().map(auth -> authInfoMap.get(auth.getAuthId())).collect(Collectors.toSet());
|
||||
UserPageAuthVo authVo = new UserPageAuthVo();
|
||||
authVo.setEditPage(this.haveAuth(authNameSet, WikiAuthType.EDIT_PAGE));
|
||||
authVo.setCommentPage(this.haveAuth(authNameSet, WikiAuthType.COMMENT_PAGE));
|
||||
authVo.setDeletePage(this.haveAuth(authNameSet, WikiAuthType.DELETE_PAGE));
|
||||
authVo.setPageFileUpload(this.haveAuth(authNameSet, WikiAuthType.PAGE_FILE_UPLOAD));
|
||||
authVo.setPageFileDelete(this.haveAuth(authNameSet, WikiAuthType.PAGE_FILE_DELETE));
|
||||
authVo.setPageAuthManage(this.haveAuth(authNameSet, WikiAuthType.PAGE_AUTH_MANAGE));
|
||||
authVo.setUserId(key);
|
||||
authVo.setUserName(userInfoMap.get(key));
|
||||
authVoList.add(authVo);
|
||||
});
|
||||
return DocResponseJson.ok(authVoList);
|
||||
}
|
||||
|
||||
private Integer haveAuth(Set<String> authNameSet, WikiAuthType wikiAuthType){
|
||||
return authNameSet.contains(wikiAuthType.getName()) ? 1 : 0;
|
||||
}
|
||||
|
||||
private UserAuth createUserAuth(Long pageId, Long loginUserId, Long userId, Long authId){
|
||||
UserAuth userAuth = new UserAuth();
|
||||
userAuth.setAuthCustomSuffix(String.valueOf(pageId));
|
||||
userAuth.setCreationTime(new Date());
|
||||
userAuth.setCreateUid(loginUserId);
|
||||
userAuth.setDelFlag(0);
|
||||
userAuth.setUserId(userId);
|
||||
userAuth.setAuthId(authId);
|
||||
return userAuth;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.zyplayer.doc.data.service.manage.WikiPageService;
|
||||
import com.zyplayer.doc.data.service.manage.WikiSpaceService;
|
||||
import com.zyplayer.doc.wiki.controller.vo.WikiPageCommentVo;
|
||||
import com.zyplayer.doc.wiki.framework.consts.SpaceType;
|
||||
import com.zyplayer.doc.wiki.framework.consts.WikiAuthType;
|
||||
import org.dozer.Mapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -90,6 +91,13 @@ public class WikiPageCommentController {
|
||||
if (SpaceType.isOthersPrivate(wikiSpaceSel.getType(), currentUser.getUserId(), wikiSpaceSel.getCreateUserId())) {
|
||||
return DocResponseJson.warn("您没有该空间的评论权!");
|
||||
}
|
||||
// 空间不是自己的,也没有权限
|
||||
if (SpaceType.isOthersPersonal(wikiSpaceSel.getType(), currentUser.getUserId(), wikiSpaceSel.getCreateUserId())) {
|
||||
boolean pageAuth = DocUserUtil.havePageAuth(WikiAuthType.COMMENT_PAGE.getName(), pageId);
|
||||
if (!pageAuth) {
|
||||
return DocResponseJson.warn("您没有评论该文章的权限!");
|
||||
}
|
||||
}
|
||||
if (id != null && id > 0) {
|
||||
wikiPageCommentService.updateById(pageComment);
|
||||
} else {
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.zyplayer.doc.data.service.manage.*;
|
||||
import com.zyplayer.doc.wiki.controller.vo.WikiPageContentVo;
|
||||
import com.zyplayer.doc.wiki.controller.vo.WikiPageVo;
|
||||
import com.zyplayer.doc.wiki.framework.consts.SpaceType;
|
||||
import com.zyplayer.doc.wiki.framework.consts.WikiAuthType;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dozer.Mapper;
|
||||
import org.slf4j.Logger;
|
||||
@@ -54,7 +55,7 @@ public class WikiPageController {
|
||||
WikiSpace wikiSpaceSel = wikiSpaceService.getById(wikiPage.getSpaceId());
|
||||
// 私人空间
|
||||
if (SpaceType.isOthersPrivate(wikiSpaceSel.getType(), currentUser.getUserId(), wikiSpaceSel.getCreateUserId())) {
|
||||
return DocResponseJson.warn("您没有查看该空间的文章列表!");
|
||||
return DocResponseJson.warn("您没有权限查看该空间的文章列表!");
|
||||
}
|
||||
UpdateWrapper<WikiPage> wrapper = new UpdateWrapper<>();
|
||||
wrapper.eq("del_flag", 0);
|
||||
@@ -79,13 +80,12 @@ public class WikiPageController {
|
||||
WikiSpace wikiSpaceSel = wikiSpaceService.getById(wikiPageSel.getSpaceId());
|
||||
// 私人空间
|
||||
if (SpaceType.isOthersPrivate(wikiSpaceSel.getType(), currentUser.getUserId(), wikiSpaceSel.getCreateUserId())) {
|
||||
return DocResponseJson.warn("您没有查看该空间的文章详情!");
|
||||
return DocResponseJson.warn("您没有权限查看该空间的文章详情!");
|
||||
}
|
||||
UpdateWrapper<WikiPageContent> wrapper = new UpdateWrapper<>();
|
||||
wrapper.eq("page_id", wikiPage.getId());
|
||||
WikiPageContent pageContent = wikiPageContentService.getOne(wrapper);
|
||||
|
||||
// TODO 检查space是否开放访问
|
||||
UpdateWrapper<WikiPageFile> wrapperFile = new UpdateWrapper<>();
|
||||
wrapperFile.eq("page_id", wikiPage.getId());
|
||||
wrapperFile.eq("del_flag", 0);
|
||||
@@ -103,6 +103,14 @@ public class WikiPageController {
|
||||
vo.setPageContent(pageContent);
|
||||
vo.setFileList(pageFiles);
|
||||
vo.setSelfZan((pageZan != null) ? 1 : 0);
|
||||
// 高并发下会有覆盖问题,但不重要~
|
||||
Integer viewNum = Optional.ofNullable(wikiPageSel.getViewNum()).orElse(0);
|
||||
WikiPage wikiPageUp = new WikiPage();
|
||||
wikiPageUp.setId(wikiPageSel.getId());
|
||||
wikiPageUp.setViewNum(viewNum + 1);
|
||||
wikiPageService.updateById(wikiPageUp);
|
||||
// 修改返回值里的查看数+1
|
||||
wikiPageSel.setViewNum(viewNum + 1);
|
||||
return DocResponseJson.ok(vo);
|
||||
}
|
||||
|
||||
@@ -117,7 +125,14 @@ public class WikiPageController {
|
||||
WikiSpace wikiSpaceSel = wikiSpaceService.getById(wikiPageSel.getSpaceId());
|
||||
// 私人空间不允许调用接口获取文章
|
||||
if (SpaceType.isOthersPrivate(wikiSpaceSel.getType(), currentUser.getUserId(), wikiSpaceSel.getCreateUserId())) {
|
||||
return DocResponseJson.warn("您没有修改该空间的文章权限!");
|
||||
return DocResponseJson.warn("您没有权限修改该空间的文章!");
|
||||
}
|
||||
// 空间不是自己的,也没有权限
|
||||
if (SpaceType.isOthersPersonal(wikiSpaceSel.getType(), currentUser.getUserId(), wikiSpaceSel.getCreateUserId())) {
|
||||
boolean pageAuth = DocUserUtil.havePageAuth(WikiAuthType.EDIT_PAGE.getName(), id);
|
||||
if (!pageAuth) {
|
||||
return DocResponseJson.warn("您没有修改该文章的权限!");
|
||||
}
|
||||
}
|
||||
WikiPage wikiPageUp = new WikiPage();
|
||||
wikiPageUp.setId(wikiPage.getId());
|
||||
@@ -138,17 +153,25 @@ public class WikiPageController {
|
||||
if (delFlag == 0 && StringUtils.isBlank(wikiPage.getName())) {
|
||||
return DocResponseJson.warn("标题不能为空!");
|
||||
}
|
||||
Long id = wikiPage.getId();
|
||||
if (id != null && id > 0) {
|
||||
WikiPage wikiPageSel = wikiPageService.getById(id);
|
||||
Long pageId = wikiPage.getId();
|
||||
if (pageId != null && pageId > 0) {
|
||||
WikiPage wikiPageSel = wikiPageService.getById(pageId);
|
||||
if (wikiPageSel == null || Objects.equals(wikiPageSel.getEditType(), 1)) {
|
||||
return DocResponseJson.warn("当前页面不允许编辑!");
|
||||
}
|
||||
WikiSpace wikiSpaceSel = wikiSpaceService.getById(wikiPageSel.getSpaceId());
|
||||
WikiSpace wikiSpaceSel = wikiSpaceService.getById(wikiPage.getSpaceId());
|
||||
// 私人空间不允许调用接口获取文章
|
||||
if (SpaceType.isOthersPrivate(wikiSpaceSel.getType(), currentUser.getUserId(), wikiSpaceSel.getCreateUserId())) {
|
||||
return DocResponseJson.warn("您没有修改该空间的文章权限!");
|
||||
return DocResponseJson.warn("您没有权限修改该空间的文章!");
|
||||
}
|
||||
// 空间不是自己的,也没有权限
|
||||
if (SpaceType.isOthersPersonal(wikiSpaceSel.getType(), currentUser.getUserId(), wikiSpaceSel.getCreateUserId())) {
|
||||
boolean pageAuth = DocUserUtil.havePageAuth(WikiAuthType.EDIT_PAGE.getName(), pageId);
|
||||
if (!pageAuth) {
|
||||
return DocResponseJson.warn("您没有修改该文章的权限!");
|
||||
}
|
||||
}
|
||||
wikiPage.setSpaceId(null);
|
||||
wikiPage.setEditType(null);
|
||||
wikiPage.setUpdateTime(new Date());
|
||||
wikiPage.setUpdateUserId(currentUser.getUserId());
|
||||
@@ -159,9 +182,14 @@ public class WikiPageController {
|
||||
pageContent.setUpdateUserId(currentUser.getUserId());
|
||||
pageContent.setUpdateUserName(currentUser.getUsername());
|
||||
UpdateWrapper<WikiPageContent> wrapper = new UpdateWrapper<>();
|
||||
wrapper.eq("page_id", id);
|
||||
wrapper.eq("page_id", pageId);
|
||||
wikiPageContentService.update(pageContent, wrapper);
|
||||
} else {
|
||||
WikiSpace wikiSpaceSel = wikiSpaceService.getById(wikiPage.getSpaceId());
|
||||
// 空间不是自己的
|
||||
if (SpaceType.isOthersPrivate(wikiSpaceSel.getType(), currentUser.getUserId(), wikiSpaceSel.getCreateUserId())) {
|
||||
return DocResponseJson.warn("您没有权限新增该空间的文章!");
|
||||
}
|
||||
wikiPage.setCreateTime(new Date());
|
||||
wikiPage.setCreateUserId(currentUser.getUserId());
|
||||
wikiPage.setCreateUserName(currentUser.getUsername());
|
||||
|
||||
@@ -12,6 +12,7 @@ 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.SpaceType;
|
||||
import com.zyplayer.doc.wiki.framework.consts.WikiAuthType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -72,6 +73,13 @@ public class WikiPageFileController {
|
||||
if (SpaceType.isOthersPrivate(wikiSpaceSel.getType(), currentUser.getUserId(), wikiSpaceSel.getCreateUserId())) {
|
||||
return DocResponseJson.warn("您没有该空间的文件上传权限!");
|
||||
}
|
||||
// 空间不是自己的,也没有权限
|
||||
if (SpaceType.isOthersPersonal(wikiSpaceSel.getType(), currentUser.getUserId(), wikiSpaceSel.getCreateUserId())) {
|
||||
boolean pageAuth = DocUserUtil.havePageAuth(WikiAuthType.PAGE_FILE_UPLOAD.getName(), pageId);
|
||||
if (!pageAuth) {
|
||||
return DocResponseJson.warn("您没有修改该文章附件的权限!");
|
||||
}
|
||||
}
|
||||
if (id != null && id > 0) {
|
||||
wikiPageFile.setUpdateUserId(currentUser.getUserId());
|
||||
wikiPageFile.setUpdateUserName(currentUser.getUsername());
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.zyplayer.doc.wiki.controller.vo;
|
||||
|
||||
public class UserPageAuthVo {
|
||||
private String userName;
|
||||
private Long userId;
|
||||
private Integer editPage;
|
||||
private Integer commentPage;
|
||||
private Integer deletePage;
|
||||
private Integer pageFileUpload;
|
||||
private Integer pageFileDelete;
|
||||
private Integer pageAuthManage;
|
||||
|
||||
public Integer getCommentPage() {
|
||||
return commentPage;
|
||||
}
|
||||
|
||||
public void setCommentPage(Integer commentPage) {
|
||||
this.commentPage = commentPage;
|
||||
}
|
||||
|
||||
public Integer getDeletePage() {
|
||||
return deletePage;
|
||||
}
|
||||
|
||||
public void setDeletePage(Integer deletePage) {
|
||||
this.deletePage = deletePage;
|
||||
}
|
||||
|
||||
public Integer getPageFileUpload() {
|
||||
return pageFileUpload;
|
||||
}
|
||||
|
||||
public void setPageFileUpload(Integer pageFileUpload) {
|
||||
this.pageFileUpload = pageFileUpload;
|
||||
}
|
||||
|
||||
public Integer getPageFileDelete() {
|
||||
return pageFileDelete;
|
||||
}
|
||||
|
||||
public void setPageFileDelete(Integer pageFileDelete) {
|
||||
this.pageFileDelete = pageFileDelete;
|
||||
}
|
||||
|
||||
public Integer getPageAuthManage() {
|
||||
return pageAuthManage;
|
||||
}
|
||||
|
||||
public void setPageAuthManage(Integer pageAuthManage) {
|
||||
this.pageAuthManage = pageAuthManage;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Integer getEditPage() {
|
||||
return editPage;
|
||||
}
|
||||
|
||||
public void setEditPage(Integer editPage) {
|
||||
this.editPage = editPage;
|
||||
}
|
||||
}
|
||||
@@ -11,10 +11,14 @@ public class SpaceType {
|
||||
return Objects.equals(type, publicSpace);
|
||||
}
|
||||
|
||||
public static boolean isPersonal(Integer type){
|
||||
public static boolean isPersonal(Integer type) {
|
||||
return Objects.equals(type, personalSpace);
|
||||
}
|
||||
|
||||
public static boolean isOthersPersonal(Integer type, Long loginUserId, Long spaceUserId){
|
||||
return Objects.equals(type, personalSpace) && !Objects.equals(loginUserId, spaceUserId);
|
||||
}
|
||||
|
||||
public static boolean isPrivate(Integer type){
|
||||
return Objects.equals(type, privateSpace);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.zyplayer.doc.wiki.framework.consts;
|
||||
|
||||
public enum WikiAuthType {
|
||||
CREATE_PAGE(1, "CREATE_PAGE_"),
|
||||
VIEW_PAGE(1, "VIEW_PAGE_"),
|
||||
COMMENT_PAGE(1, "COMMENT_PAGE_"),
|
||||
DELETE_PAGE(1, "DELETE_PAGE_"),
|
||||
PAGE_FILE_UPLOAD(1, "PAGE_FILE_UPLOAD_"),
|
||||
PAGE_FILE_DELETE(1, "PAGE_FILE_DELETE_"),
|
||||
PAGE_AUTH_MANAGE(1, "PAGE_AUTH_MANAGE_"),
|
||||
CREATE_PAGE(1, "WIKI_CREATE_PAGE_"),
|
||||
EDIT_PAGE(1, "WIKI_EDIT_PAGE_"),
|
||||
COMMENT_PAGE(1, "WIKI_COMMENT_PAGE_"),
|
||||
DELETE_PAGE(1, "WIKI_DELETE_PAGE_"),
|
||||
PAGE_FILE_UPLOAD(1, "WIKI_PAGE_FILE_UPLOAD_"),
|
||||
PAGE_FILE_DELETE(1, "WIKI_PAGE_FILE_DELETE_"),
|
||||
PAGE_AUTH_MANAGE(1, "WIKI_PAGE_AUTH_MANAGE_"),
|
||||
;
|
||||
private Integer type;
|
||||
private String name;
|
||||
|
||||
Reference in New Issue
Block a user