Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8bd22c4634 |
@@ -3,6 +3,8 @@ package com.zyplayer.doc.data.service.manage;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiSpace;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
@@ -12,5 +14,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
* @since 2019-03-13
|
||||
*/
|
||||
public interface WikiSpaceService extends IService<WikiSpace> {
|
||||
|
||||
|
||||
List<Long> getViewAuthSpaceIds();
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.zyplayer.doc.data.service.manage.WikiSpaceService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
@@ -16,5 +18,9 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Service
|
||||
public class WikiSpaceServiceImpl extends ServiceImpl<WikiSpaceMapper, WikiSpace> implements WikiSpaceService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<Long> getViewAuthSpaceIds() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,11 @@ public class WikiSpaceController {
|
||||
LambdaQueryWrapper<WikiSpace> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(WikiSpace::getDelFlag, 0);
|
||||
wrapper.eq(wikiSpace.getId() != null, WikiSpace::getId, wikiSpace.getId());
|
||||
wrapper.and(con -> con.and(conSub -> conSub.eq(WikiSpace::getType, 3).eq(WikiSpace::getCreateUserId, currentUser.getUserId())).or().in(WikiSpace::getType, 1, 2));
|
||||
wrapper.and(con ->
|
||||
con.and(conSub -> conSub.eq(WikiSpace::getType, 3).eq(WikiSpace::getCreateUserId, currentUser.getUserId()))
|
||||
.or(conSub -> conSub.eq(WikiSpace::getType, 3).eq(WikiSpace::getCreateUserId, currentUser.getUserId()))
|
||||
.or().in(WikiSpace::getType, 1, 2)
|
||||
);
|
||||
// 收藏的空间
|
||||
List<WikiSpaceFavorite> favoriteList = wikiSpaceFavoriteService.myFavoriteSpaceList();
|
||||
Set<Long> favoriteSpaceIds = favoriteList.stream().map(WikiSpaceFavorite::getSpaceId).collect(Collectors.toSet());
|
||||
|
||||
@@ -9,6 +9,7 @@ package com.zyplayer.doc.wiki.framework.consts;
|
||||
public enum WikiAuthType {
|
||||
@Deprecated
|
||||
CREATE_PAGE(1, "WIKI_CREATE_PAGE_"),
|
||||
VIEW_PAGE(2, "WIKI_VIEW_PAGE_"),
|
||||
EDIT_PAGE(2, "WIKI_EDIT_PAGE_"),
|
||||
@Deprecated
|
||||
COMMENT_PAGE(3, "WIKI_COMMENT_PAGE_"),
|
||||
|
||||
@@ -23,6 +23,31 @@ import java.util.Objects;
|
||||
public class WikiPageAuthService {
|
||||
|
||||
private final UserGroupAuthMapper userGroupAuthMapper;
|
||||
|
||||
/**
|
||||
* 是否具有查看权限
|
||||
*/
|
||||
public String canView(WikiSpace wikiSpaceSel, Integer editType, Long pageId, Long currentUserId) {
|
||||
if (wikiSpaceSel == null || Objects.equals(editType, 1)) {
|
||||
return "当前页面不允许查看!";
|
||||
}
|
||||
// 私人空间不允许调用接口获取文章
|
||||
if (SpaceType.isOthersPrivate(wikiSpaceSel.getType(), currentUserId, wikiSpaceSel.getCreateUserId())) {
|
||||
return "您没有权限修改该空间的文章!";
|
||||
}
|
||||
// 空间不是自己的,也没有权限
|
||||
if (SpaceType.isOthersPersonal(wikiSpaceSel.getType(), currentUserId, wikiSpaceSel.getCreateUserId())) {
|
||||
boolean pageAuth = DocUserUtil.haveCustomAuth(WikiAuthType.VIEW_PAGE.getCode(), DocSysType.WIKI.getType(), DocSysModuleType.Wiki.PAGE.getType(), pageId);
|
||||
if (!pageAuth) {
|
||||
// 在空间上直接授权了分组的权限,在这个分组里就具有权限
|
||||
Long authId = userGroupAuthMapper.haveAuth(wikiSpaceSel.getId(), DocSysType.WIKI.getType(), WikiAuthType.VIEW_PAGE.getType(), currentUserId);
|
||||
if (authId == null) {
|
||||
return "您没有查看该文章的权限!";
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否具有编辑权限
|
||||
|
||||
Reference in New Issue
Block a user