1、用户文件表增删查改业务接口增加访问权限字段;

2、修改文件访问权限API接口实现;
3、获取对应角色文件树列表接口实现;
4、修改角色文件数据权限接口实现;
5、删除多余类及TreeSelect树状类构造方法
This commit is contained in:
liangwen 2025-09-11 14:40:08 +08:00
parent 127ab9eefa
commit 0dd09dec1b
19 changed files with 649 additions and 532 deletions

View File

@ -3,7 +3,13 @@ package com.ruoyi.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.ruoyi.common.utils.lang.LangUnit;
import com.ruoyi.file.api.ISysRoleUserFileService;
import com.ruoyi.file.api.IUserFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
@ -39,6 +45,8 @@ import com.ruoyi.system.service.ISysUserService;
*
* @author ruoyi
*/
@Api(tags = "6 角色信息接口")
@ApiSupport(order = 6)
@RestController
@RequestMapping("/system/role")
public class SysRoleController extends BaseController
@ -61,6 +69,12 @@ public class SysRoleController extends BaseController
@Autowired
private LangUnit langUnit;
@Autowired
private IUserFileService userFileService;
@Autowired
private ISysRoleUserFileService sysRoleUserFileService;
@PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/list")
public TableDataInfo list(SysRole role)
@ -274,4 +288,35 @@ public class SysRoleController extends BaseController
ajax.put("depts", deptService.selectDeptTreeList(new SysDept()));
return ajax;
}
/**
* 获取对应角色文件树列表
*/
@ApiOperation(value = "6.1 获取对应角色文件树列表")
@ApiOperationSupport(order = 1)
@PreAuthorize("@ss.hasPermi('system:role:query')")
@GetMapping(value = "/fileTree/{roleId}")
public AjaxResult fileTree(@PathVariable("roleId") Long roleId)
{
AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", sysRoleUserFileService.selectUserFileIdListByRoleId(roleId));
ajax.put("files", userFileService.selectUserFileTreeList());
return ajax;
}
/**
* 修改保存文件数据权限
*/
@ApiOperation(value = "6.2 修改保存文件数据权限")
@ApiOperationSupport(order = 2)
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping("/fileScope")
public AjaxResult fileScope(@RequestBody SysRole role)
{
roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId());
return toAjax(sysRoleUserFileService.authDataScope(role));
}
}

View File

@ -0,0 +1,18 @@
package com.ruoyi.file.api;
import com.ruoyi.common.core.domain.entity.SysRole;
import java.util.List;
public interface ISysRoleUserFileService {
List<String> selectUserFileIdListByRoleId(Long roleId);
/**
* 修改数据权限信息
*
* @param role 角色信息
* @return 结果
*/
public int authDataScope(SysRole role);
}

View File

@ -3,6 +3,7 @@ package com.ruoyi.file.api;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.file.domain.UserFile;
import com.ruoyi.file.util.FileTreeSelect;
import com.ruoyi.file.vo.file.FileListVO;
import org.apache.ibatis.annotations.Param;
@ -23,4 +24,10 @@ public interface IUserFileService extends IService<UserFile> {
List<UserFile> selectUserFileByLikeRightFilePath(@Param("filePath") String filePath, @Param("userId") Long userId);
/**
* 查询文件树结构信息
*
* @return 文件树结构信息
*/
public List<FileTreeSelect> selectUserFileTreeList();
}

View File

@ -9,6 +9,8 @@ import co.elastic.clients.elasticsearch.core.search.Hit;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.qiwenshare.common.anno.MyLog;
import com.qiwenshare.common.exception.QiwenException;
import com.qiwenshare.common.result.RestResult;
@ -32,9 +34,9 @@ import com.ruoyi.file.util.TreeNode;
import com.ruoyi.file.vo.file.FileDetailVO;
import com.ruoyi.file.vo.file.FileListVO;
import com.ruoyi.file.vo.file.SearchFileVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.jetty.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
@ -52,7 +54,9 @@ import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.regex.Pattern;
@Tag(name = "file", description = "该接口为文件接口,主要用来做一些文件的基本操作,如创建目录,删除,移动,复制等。")
//@Tag(name = "file", description = "该接口为文件接口,主要用来做一些文件的基本操作,如创建目录,删除,移动,复制等。")
@Api(tags = "5 文件接口")
@ApiSupport(order = 5)
@RestController
@Slf4j
@RequestMapping("/file")
@ -77,7 +81,7 @@ public class FileController {
public static final String CURRENT_MODULE = "文件接口";
@Operation(summary = "创建文件", description = "创建文件", tags = {"file"})
//@Operation(summary = "创建文件", description = "创建文件", tags = {"file"})
@ResponseBody
@RequestMapping(value = "/createFile", method = RequestMethod.POST)
public RestResult<Object> createFile(@Valid @RequestBody CreateFileDTO createFileDTO) {
@ -156,7 +160,7 @@ public class FileController {
}
}
@Operation(summary = "创建文件夹", description = "目录(文件夹)的创建", tags = {"file"})
//@Operation(summary = "创建文件夹", description = "目录(文件夹)的创建", tags = {"file"})
@RequestMapping(value = "/createFold", method = RequestMethod.POST)
@MyLog(operation = "创建文件夹", module = CURRENT_MODULE)
@ResponseBody
@ -179,7 +183,9 @@ public class FileController {
return RestResult.success();
}
@Operation(summary = "文件搜索", description = "文件搜索", tags = {"file"})
//@Operation(summary = "文件搜索", description = "文件搜索", tags = {"file"})
@ApiOperation(value = "5.1 文件搜索")
@ApiOperationSupport(order = 1)
@GetMapping(value = "/search")
@MyLog(operation = "文件搜索", module = CURRENT_MODULE)
@ResponseBody
@ -245,7 +251,7 @@ public class FileController {
}
@Operation(summary = "文件重命名", description = "文件重命名", tags = {"file"})
//@Operation(summary = "文件重命名", description = "文件重命名", tags = {"file"})
@RequestMapping(value = "/renamefile", method = RequestMethod.POST)
@MyLog(operation = "文件重命名", module = CURRENT_MODULE)
@ResponseBody
@ -278,7 +284,9 @@ public class FileController {
return RestResult.success();
}
@Operation(summary = "获取文件列表", description = "用来做前台列表展示", tags = {"file"})
//@Operation(summary = "获取文件列表", description = "用来做前台列表展示", tags = {"file"})
@ApiOperation(value = "5.2 获取文件列表")
@ApiOperationSupport(order = 2)
@RequestMapping(value = "/getfilelist", method = RequestMethod.GET)
@ResponseBody
public RestResult<FileListVO> getFileList(
@ -296,7 +304,7 @@ public class FileController {
}
@Operation(summary = "批量删除文件", description = "批量删除文件", tags = {"file"})
//@Operation(summary = "批量删除文件", description = "批量删除文件", tags = {"file"})
@RequestMapping(value = "/batchdeletefile", method = RequestMethod.POST)
@MyLog(operation = "批量删除文件", module = CURRENT_MODULE)
@ResponseBody
@ -315,7 +323,7 @@ public class FileController {
return RestResult.success().message("批量删除文件成功");
}
@Operation(summary = "删除文件", description = "可以删除文件或者目录", tags = {"file"})
//@Operation(summary = "删除文件", description = "可以删除文件或者目录", tags = {"file"})
@RequestMapping(value = "/deletefile", method = RequestMethod.POST)
@MyLog(operation = "删除文件", module = CURRENT_MODULE)
@ResponseBody
@ -329,7 +337,7 @@ public class FileController {
}
@Operation(summary = "解压文件", description = "解压文件。", tags = {"file"})
//@Operation(summary = "解压文件", description = "解压文件。", tags = {"file"})
@RequestMapping(value = "/unzipfile", method = RequestMethod.POST)
@MyLog(operation = "解压文件", module = CURRENT_MODULE)
@ResponseBody
@ -345,7 +353,7 @@ public class FileController {
}
@Operation(summary = "文件复制", description = "可以复制文件或者目录", tags = {"file"})
//@Operation(summary = "文件复制", description = "可以复制文件或者目录", tags = {"file"})
@RequestMapping(value = "/copyfile", method = RequestMethod.POST)
@MyLog(operation = "文件复制", module = CURRENT_MODULE)
@ResponseBody
@ -373,7 +381,7 @@ public class FileController {
}
@Operation(summary = "文件移动", description = "可以移动文件或者目录", tags = {"file"})
//@Operation(summary = "文件移动", description = "可以移动文件或者目录", tags = {"file"})
@RequestMapping(value = "/movefile", method = RequestMethod.POST)
@MyLog(operation = "文件移动", module = CURRENT_MODULE)
@ResponseBody
@ -399,7 +407,7 @@ public class FileController {
}
@Operation(summary = "批量移动文件", description = "可以同时选择移动多个文件或者目录", tags = {"file"})
//@Operation(summary = "批量移动文件", description = "可以同时选择移动多个文件或者目录", tags = {"file"})
@RequestMapping(value = "/batchmovefile", method = RequestMethod.POST)
@MyLog(operation = "批量移动文件", module = CURRENT_MODULE)
@ResponseBody
@ -428,7 +436,7 @@ public class FileController {
}
@Operation(summary = "获取文件树", description = "文件移动的时候需要用到该接口,用来展示目录树", tags = {"file"})
//@Operation(summary = "获取文件树", description = "文件移动的时候需要用到该接口,用来展示目录树", tags = {"file"})
@RequestMapping(value = "/getfiletree", method = RequestMethod.GET)
@ResponseBody
public RestResult<TreeNode> getFileTree() {
@ -474,7 +482,7 @@ public class FileController {
}
@Operation(summary = "修改文件", description = "支持普通文本类文件的修改", tags = {"file"})
//@Operation(summary = "修改文件", description = "支持普通文本类文件的修改", tags = {"file"})
@RequestMapping(value = "/update", method = RequestMethod.POST)
@ResponseBody
public RestResult<String> updateFile(@RequestBody UpdateFileDTO updateFileDTO) {
@ -509,7 +517,7 @@ public class FileController {
return RestResult.success().message("修改文件成功");
}
@Operation(summary = "查询文件详情", description = "查询文件详情", tags = {"file"})
//@Operation(summary = "查询文件详情", description = "查询文件详情", tags = {"file"})
@RequestMapping(value = "/detail", method = RequestMethod.GET)
@ResponseBody
public RestResult<FileDetailVO> queryFileDetail(
@ -518,7 +526,25 @@ public class FileController {
return RestResult.success().data(vo);
}
//@Operation(summary = "修改文件访问权限", description = "修改文件访问权限", tags = {"file"})
@ApiOperation(value = "5.4 修改文件访问权限")
@ApiOperationSupport(order = 4)
@RequestMapping(value = "/updateaccesspermission", method = RequestMethod.GET)
@ResponseBody
public RestResult<String> updateAccessPermission(
@Parameter(description = "用户文件Id", required = true) String userFileId,
@Parameter(description = "访问权限 0禁止其他用户访问 1登录后可访问 2具备权限可访问", required = true) String accessPermission){
try {
UserFile userFile = new UserFile();
userFile.setUserFileId(userFileId);
userFile.setAccessPermission(accessPermission);
userFile.setModifyUserId(SecurityUtils.getUserId());
userFile.setModifyTime(DateUtil.getCurrentTime());
userFileService.updateById(userFile);
} catch (Exception e) {
throw new QiwenException(999999, "修改文件访问权限异常");
}
return RestResult.success().message("修改文件访问权限成功");
}
}

View File

@ -66,6 +66,9 @@ public class UserFile {
@TableField(exist = false)
private Long fileSize;
@Column(columnDefinition="char(1) comment '修改用户id'")
private String accessPermission;
public UserFile() {};
public UserFile(QiwenFile qiwenFile, Long userId, String fileId) {
this.userFileId = IdUtil.getSnowflakeNextIdStr();

View File

@ -0,0 +1,182 @@
package com.ruoyi.file.dto.file;
import java.util.ArrayList;
import java.util.List;
public class UserFileDTO {
private String userFileId;
private Long userId;
private String fileId;
private String fileName;
private String filePath;
private String extendName;
private Integer isDir;
private String uploadTime;
private Integer deleteFlag;
private String deleteTime;
private String deleteBatchNum;
private String createTime;
private Long createUserId;
private String modifyTime;
private Long modifyUserId;
private Long fileSize;
private String accessPermission;
private List<UserFileDTO> children = new ArrayList<UserFileDTO>();
public String getUserFileId() {
return userFileId;
}
public void setUserFileId(String userFileId) {
this.userFileId = userFileId;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getFileId() {
return fileId;
}
public void setFileId(String fileId) {
this.fileId = fileId;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public String getExtendName() {
return extendName;
}
public void setExtendName(String extendName) {
this.extendName = extendName;
}
public Integer getIsDir() {
return isDir;
}
public void setIsDir(Integer isDir) {
this.isDir = isDir;
}
public String getUploadTime() {
return uploadTime;
}
public void setUploadTime(String uploadTime) {
this.uploadTime = uploadTime;
}
public Integer getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
public String getDeleteTime() {
return deleteTime;
}
public void setDeleteTime(String deleteTime) {
this.deleteTime = deleteTime;
}
public String getDeleteBatchNum() {
return deleteBatchNum;
}
public void setDeleteBatchNum(String deleteBatchNum) {
this.deleteBatchNum = deleteBatchNum;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public Long getCreateUserId() {
return createUserId;
}
public void setCreateUserId(Long createUserId) {
this.createUserId = createUserId;
}
public String getModifyTime() {
return modifyTime;
}
public void setModifyTime(String modifyTime) {
this.modifyTime = modifyTime;
}
public Long getModifyUserId() {
return modifyUserId;
}
public void setModifyUserId(Long modifyUserId) {
this.modifyUserId = modifyUserId;
}
public Long getFileSize() {
return fileSize;
}
public void setFileSize(Long fileSize) {
this.fileSize = fileSize;
}
public String getAccessPermission() {
return accessPermission;
}
public void setAccessPermission(String accessPermission) {
this.accessPermission = accessPermission;
}
public List<UserFileDTO> getChildren() {
return children;
}
public void setChildren(List<UserFileDTO> children) {
this.children = children;
}
}

View File

@ -3,9 +3,9 @@ package com.ruoyi.file.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.file.dto.file.UserFileDTO;
import com.ruoyi.file.domain.UserFile;
import com.ruoyi.file.vo.file.FileListVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -17,4 +17,6 @@ public interface UserFileMapper extends BaseMapper<UserFile> {
Long selectStorageSizeByUserId(@Param("userId") Long userId);
List<UserFile> selectByUserFileId(String userFileId);
List<UserFileDTO> selectFileTreeByUserId(Long userId);
}

View File

@ -0,0 +1,74 @@
package com.ruoyi.file.service;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.file.api.ISysRoleUserFileService;
import com.ruoyi.file.domain.SysRoleUserFile;
import com.ruoyi.file.mapper.SysRoleUserFileMapper;
import com.ruoyi.system.domain.SysRoleDept;
import com.ruoyi.system.mapper.SysRoleMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class SysRoleUserFileService implements ISysRoleUserFileService {
@Autowired
SysRoleUserFileMapper roleUserFileMapper;
@Autowired
SysRoleMapper roleMapper;
@Override
public List<String> selectUserFileIdListByRoleId(Long roleId) {
return roleUserFileMapper.selectUserFileIdListByRoleId(roleId);
}
/**
* 修改数据权限信息
*
* @param role 角色信息
* @return 结果
*/
@Override
@Transactional
public int authDataScope(SysRole role)
{
// 修改角色信息
roleMapper.updateRole(role);
// 删除角色与部门关联
roleUserFileMapper.deleteRoleUserFileByRoleId(role.getRoleId());
// 新增角色和部门信息数据权限
return insertRoleUserFile(role);
}
/**
* 新增角色部门信息(数据权限)
*
* @param role 角色对象
*/
public int insertRoleUserFile(SysRole role)
{
int rows = 1;
// 新增角色与部门数据权限管理
List<SysRoleUserFile> list = new ArrayList<SysRoleUserFile>();
for (String userFileId : role.getUserFileIds())
{
SysRoleUserFile ru = new SysRoleUserFile();
ru.setRoleId(role.getRoleId());
ru.setUserFileId(userFileId);
list.add(ru);
}
if (list.size() > 0)
{
rows = roleUserFileMapper.batchRoleUserFile(list);
}
return rows;
}
}

View File

@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiwenshare.common.constant.FileConstant;
import com.qiwenshare.common.util.DateUtil;
import com.ruoyi.file.dto.file.UserFileDTO;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.file.api.IUserFileService;
@ -18,7 +19,9 @@ import com.ruoyi.file.domain.RecoveryFile;
import com.ruoyi.file.domain.UserFile;
import com.ruoyi.file.io.QiwenFile;
import com.ruoyi.file.mapper.RecoveryFileMapper;
import com.ruoyi.file.mapper.SysRoleUserFileMapper;
import com.ruoyi.file.mapper.UserFileMapper;
import com.ruoyi.file.util.FileTreeSelect;
import com.ruoyi.file.vo.file.FileListVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
@ -27,8 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.UUID;
import java.util.*;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
@ -43,6 +45,9 @@ public class UserFileService extends ServiceImpl<UserFileMapper, UserFile> imple
RecoveryFileMapper recoveryFileMapper;
@Resource
FileDealComp fileDealComp;
@Resource
SysRoleUserFileMapper roleUserFileMapper;
public static Executor executor = Executors.newFixedThreadPool(20);
@ -197,7 +202,6 @@ public class UserFileService extends ServiceImpl<UserFileMapper, UserFile> imple
return userFileMapper.selectList(lambdaQueryWrapper);
}
@Override
public void deleteUserFile(String userFileId, Long sessionUserId) {
UserFile userFile = userFileMapper.selectById(userFileId);
@ -241,7 +245,7 @@ public class UserFileService extends ServiceImpl<UserFileMapper, UserFile> imple
List<UserFile> fileList = selectUserFileByLikeRightFilePath(filePath, userId);
List<String> userFileIds = fileList.stream().map(UserFile::getUserFileId).collect(Collectors.toList());
//标记删除标志
//标记删除标志
if (CollectionUtils.isNotEmpty(userFileIds)) {
LambdaUpdateWrapper<UserFile> userFileLambdaUpdateWrapper1 = new LambdaUpdateWrapper<>();
userFileLambdaUpdateWrapper1.set(UserFile::getDeleteFlag, RandomUtil.randomInt(FileConstant.deleteFileRandomSize))
@ -257,5 +261,96 @@ public class UserFileService extends ServiceImpl<UserFileMapper, UserFile> imple
});
}
/**
* 查询文件树结构信息递归获取
*/
@Override
public List<FileTreeSelect> selectUserFileTreeList() {
LoginUser sessionUserBean = SecurityUtils.getLoginUser();
List<UserFileDTO> userFileList = userFileMapper.selectFileTreeByUserId(sessionUserBean.getUserId());
List<FileTreeSelect> treeSelectList = new ArrayList<>();
// 根节点
FileTreeSelect rootNode = new FileTreeSelect();
rootNode.setLabel(QiwenFile.separator);
rootNode.setId("0");
rootNode.setChildren(new ArrayList<>());
for (UserFileDTO userFile : userFileList) {
QiwenFile qiwenFile = new QiwenFile(userFile.getFilePath(), userFile.getFileName(), false);
String filePath = qiwenFile.getPath();
Queue<String> queue = new LinkedList<>();
String[] strArr = filePath.split(QiwenFile.separator);
for (String s : strArr) {
if (s != null && !"".equals(s)) {
queue.add(s);
}
}
if (queue.isEmpty()) {
continue;
}
rootNode = insertTreeNode(rootNode, QiwenFile.separator, queue, userFile);
}
// 排序
List<FileTreeSelect> treeNodeList = rootNode.getChildren();
//treeNodeList.sort(Comparator.comparingLong(FileTreeSelect::getId));
treeSelectList.addAll(treeNodeList);
return treeSelectList;
}
/**
* 递归插入节点所有节点 id 都取自 UserFile.userFileId
*/
public FileTreeSelect insertTreeNode(FileTreeSelect treeNode, String filePath, Queue<String> nodeNameQueue, UserFileDTO userFile) {
List<FileTreeSelect> childrenTreeNodes = treeNode.getChildren();
String currentNodeName = nodeNameQueue.peek();
if (currentNodeName == null) {
return treeNode;
}
QiwenFile qiwenFile = new QiwenFile(filePath, currentNodeName, true);
filePath = qiwenFile.getPath();
FileTreeSelect childNode = findChild(childrenTreeNodes, currentNodeName);
if (childNode == null) { // 没有该子节点 -> 插入
childNode = new FileTreeSelect();
childNode.setLabel(nodeNameQueue.poll());
childNode.setChildren(new ArrayList<>());
// 所有节点都绑定 userFileId目录/文件都在 UserFile 表里
childNode.setId(userFile.getUserFileId());
childrenTreeNodes.add(childNode);
} else {
nodeNameQueue.poll();
}
if (!nodeNameQueue.isEmpty()) {
insertTreeNode(childNode, filePath, nodeNameQueue, userFile);
}
return treeNode;
}
/**
* 查找已有子节点
*/
private FileTreeSelect findChild(List<FileTreeSelect> children, String label) {
for (FileTreeSelect child : children) {
if (label.equals(child.getLabel())) {
return child;
}
}
return null;
}
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.file.util;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.io.Serializable;
import java.util.List;
/**
* Treeselect树结构实体类
*
* @author ruoyi
*/
public class FileTreeSelect implements Serializable
{
private static final long serialVersionUID = 1L;
/** 节点ID */
private String id;
/** 节点名称 */
private String label;
/** 子节点 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<FileTreeSelect> children;
public FileTreeSelect()
{
}
public String getId()
{
return id;
}
public void setId(String id)
{
this.id = id;
}
public String getLabel()
{
return label;
}
public void setLabel(String label)
{
this.label = label;
}
public List<FileTreeSelect> getChildren()
{
return children;
}
public void setChildren(List<FileTreeSelect> children)
{
this.children = children;
}
}

View File

@ -42,4 +42,6 @@ public class FileListVO {
private Integer imageWidth;
private Integer imageHeight;
private String accessPermission;
}

View File

@ -6,22 +6,44 @@
<mapper namespace="com.ruoyi.file.mapper.UserFileMapper">
<resultMap id="UserFileWithSizeMap" type="com.ruoyi.file.domain.UserFile">
<resultMap id="UserFileMap" type="com.ruoyi.file.domain.UserFile">
<id property="userFileId" column="userFileId"/>
<result property="createTime" column="createTime"/>
<result property="createUserId" column="createUserId"/>
<result property="deleteBatchNum" column="deleteBatchNum"/>
<result property="deleteFlag" column="deleteFlag"/>
<result property="deleteTime" column="deleteTime"/>
<result property="extendName" column="extendName"/>
<result property="fileId" column="fileId"/>
<result property="fileName" column="fileName"/>
<result property="filePath" column="filePath"/>
<result property="extendName" column="extendName"/>
<result property="isDir" column="isDir"/>
<result property="uploadTime" column="uploadTime"/>
<result property="deleteFlag" column="deleteFlag"/>
<result property="deleteTime" column="deleteTime"/>
<result property="deleteBatchNum" column="deleteBatchNum"/>
<result property="createTime" column="createTime"/>
<result property="createUserId" column="createUserId"/>
<result property="modifyTime" column="modifyTime"/>
<result property="modifyUserId" column="modifyUserId"/>
<result property="uploadTime" column="uploadTime"/>
<result property="fileSize" column="fileSize"/>
<result property="userId" column="userId"/>
<result property="accessPermission" column="accessPermission"/>
</resultMap>
<resultMap id="UserFileDtoMap" type="com.ruoyi.file.dto.file.UserFileDTO">
<id property="userFileId" column="userFileId"/>
<result property="createTime" column="createTime"/>
<result property="createUserId" column="createUserId"/>
<result property="deleteBatchNum" column="deleteBatchNum"/>
<result property="deleteFlag" column="deleteFlag"/>
<result property="deleteTime" column="deleteTime"/>
<result property="extendName" column="extendName"/>
<result property="fileId" column="fileId"/>
<result property="fileName" column="fileName"/>
<result property="filePath" column="filePath"/>
<result property="isDir" column="isDir"/>
<result property="modifyTime" column="modifyTime"/>
<result property="modifyUserId" column="modifyUserId"/>
<result property="uploadTime" column="uploadTime"/>
<result property="fileSize" column="fileSize"/>
<result property="userId" column="userId"/>
<result property="accessPermission" column="accessPermission"/>
</resultMap>
<select id="selectPageVo" resultType="com.ruoyi.file.vo.file.FileListVO">
@ -71,10 +93,16 @@
WHERE userfile.userId = #{userId}
</select>
<select id="selectByUserFileId" resultMap="UserFileWithSizeMap" parameterType="java.lang.String">
<select id="selectByUserFileId" resultMap="UserFileMap" parameterType="java.lang.String">
SELECT userfile.*, file.fileSize as fileSize FROM userfile
LEFT JOIN file ON file.fileId = userfile.fileId
WHERE userfile.userFileId = #{userFileId}
</select>
<select id="selectFileTreeByUserId" resultMap="UserFileDtoMap" parameterType="java.lang.Long">
SELECT userfile.*, file.fileSize as fileSize FROM userfile
LEFT JOIN file ON file.fileId = userfile.fileId
WHERE userfile.userId = #{userId}
</select>
</mapper>

View File

@ -44,27 +44,6 @@ public class TreeSelect implements Serializable
this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
}
public TreeSelect(KnowledgeCategory category)
{
this.id = category.getCategoryId();
this.label = category.getCategoryName();
this.children = category.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
}
public TreeSelect(SysFacility facility)
{
this.id = facility.getFacilityId();
this.label = facility.getFacilityName();
this.children = facility.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
}
public TreeSelect(WorkOrderCategory category)
{
this.id = category.getCategoryId();
this.label = category.getCategoryName();
this.children = category.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
}
public Long getId()
{
return id;

View File

@ -1,122 +0,0 @@
package com.ruoyi.common.core.domain.entity;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import java.util.ArrayList;
import java.util.List;
/**
* 知识分类对象 knowledge_category
*
* @author liangwen
* @date 2024-03-26
*/
public class KnowledgeCategory extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 分类id */
@Excel(name = "分类id")
private Long categoryId;
/** 分类名 */
@Excel(name = "分类名")
private String categoryName;
/** 父ID */
@Excel(name = "父ID")
private Long parentId;
/** 祖级列表 */
private String ancestors;
/** 显示顺序 */
@Excel(name = "显示顺序")
private Integer orderNum;
/** 状态 */
@Excel(name = "状态")
private String status;
/** 删除标志 */
private String delFlag;
/** 部门id */
private Long deptId;
/** 子分类 */
private List<KnowledgeCategory> children = new ArrayList<KnowledgeCategory>();
public Long getCategoryId() {
return categoryId;
}
public void setCategoryId(Long categoryId) {
this.categoryId = categoryId;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public Integer getOrderNum() {
return orderNum;
}
public void setOrderNum(Integer orderNum) {
this.orderNum = orderNum;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public List<KnowledgeCategory> getChildren() {
return children;
}
public void setChildren(List<KnowledgeCategory> children) {
this.children = children;
}
public String getAncestors() {
return ancestors;
}
public void setAncestors(String ancestors) {
this.ancestors = ancestors;
}
public Long getDeptId() {
return deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
}

View File

@ -1,122 +0,0 @@
package com.ruoyi.common.core.domain.entity;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import java.util.ArrayList;
import java.util.List;
/**
* 厂房信息对象 sys_facility
*
* @author liangwen
* @date 2024-07-11
*/
public class SysFacility extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 厂房ID */
private Long facilityId;
/** 父ID */
@Excel(name = "父ID")
private Long parentId;
/** 祖级列表 */
private String ancestors;
/** 厂房名称 */
@Excel(name = "厂房名称")
private String facilityName;
/** 厂房位置 */
@Excel(name = "厂房位置")
private String facilityLocation;
/** 厂房面积 */
@Excel(name = "厂房面积")
private Double facilityArea;
/** 厂房状态 */
@Excel(name = "厂房状态")
private String status;
/** 删除标志 */
private String delFlag;
/** 子厂房 */
private List<SysFacility> children = new ArrayList<SysFacility>();
public Long getFacilityId() {
return facilityId;
}
public void setFacilityId(Long facilityId) {
this.facilityId = facilityId;
}
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public String getAncestors() {
return ancestors;
}
public void setAncestors(String ancestors) {
this.ancestors = ancestors;
}
public String getFacilityName() {
return facilityName;
}
public void setFacilityName(String facilityName) {
this.facilityName = facilityName;
}
public String getFacilityLocation() {
return facilityLocation;
}
public void setFacilityLocation(String facilityLocation) {
this.facilityLocation = facilityLocation;
}
public Double getFacilityArea() {
return facilityArea;
}
public void setFacilityArea(Double facilityArea) {
this.facilityArea = facilityArea;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public List<SysFacility> getChildren() {
return children;
}
public void setChildren(List<SysFacility> children) {
this.children = children;
}
}

View File

@ -35,10 +35,14 @@ public class SysRole extends BaseEntity
@Excel(name = "角色排序")
private Integer roleSort;
/** 数据范围1所有数据权限2自定义数据权限3本部门数据权限4本部门及以下数据权限5仅本人数据权限) */
@Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限")
/** 数据范围1全部数据权限 2自定数据权限 3本部门数据权限 4本部门及以下数据权限) */
@Excel(name = "数据范围", readConverterExp = "1:全部数据权限 2自定数据权限 3本部门数据权限 4本部门及以下数据权限")
private String dataScope;
/** 文件权限范围1全部文件权限 2自定义文件权限 3仅限公开文件权限 4仅本人文件权限 */
@Excel(name = "文件权限", readConverterExp = "1全部文件权限 2自定义文件权限 3仅公开文件权限 4仅本人文件权限")
private String fileScope;
/** 菜单树选择项是否关联显示( 0父子不互相关联显示 1父子互相关联显示 */
private boolean menuCheckStrictly;
@ -61,6 +65,9 @@ public class SysRole extends BaseEntity
/** 部门组(数据权限) */
private Long[] deptIds;
/** 用户文件组(数据权限) */
private String[] userFileIds;
/** 角色菜单权限 */
private Set<String> permissions;
@ -139,6 +146,14 @@ public class SysRole extends BaseEntity
this.dataScope = dataScope;
}
public String getFileScope() {
return fileScope;
}
public void setFileScope(String fileScope) {
this.fileScope = fileScope;
}
public boolean isMenuCheckStrictly()
{
return menuCheckStrictly;
@ -209,6 +224,14 @@ public class SysRole extends BaseEntity
this.deptIds = deptIds;
}
public String[] getUserFileIds() {
return userFileIds;
}
public void setUserFileIds(String[] userFileIds) {
this.userFileIds = userFileIds;
}
public Set<String> getPermissions()
{
return permissions;

View File

@ -1,188 +0,0 @@
package com.ruoyi.common.core.domain.entity;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import java.util.ArrayList;
import java.util.List;
/**
* 工单类型对象 work_order_category
*
* @author liangwen
* @date 2025-05-24
*/
public class WorkOrderCategory extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 类型id */
private Long categoryId;
private String categoryName;
/** 工单类型 */
@Excel(name = "工单类型")
private String workOrderType;
/** 父ID */
@Excel(name = "父ID")
private Long parentId;
/** 祖级列表 */
private String ancestors;
/** 显示顺序 */
@Excel(name = "显示顺序")
private Integer orderNum;
/** 处理人账号 */
@Excel(name = "处理人id")
private Long handlerUserId;
@Excel(name = "处理人账号")
private String handlerUser;
@Excel(name = "处理人账号昵称")
private String handlerUserNickName;
/** 对应知识库分类Id */
private Long relKnowledgeCategoryId;
/** 提醒周期 */
@Excel(name = "提醒周期")
private String remindCycle;
/** 状态 */
@Excel(name = "状态")
private String status;
/** 删除标志0代表存在 2代表删除 */
private String delFlag;
/** 部门id */
private Long deptId;
/** 子分类 */
private List<WorkOrderCategory> children = new ArrayList<WorkOrderCategory>();
public Long getCategoryId() {
return categoryId;
}
public void setCategoryId(Long categoryId) {
this.categoryId = categoryId;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public String getWorkOrderType() {
return workOrderType;
}
public void setWorkOrderType(String workOrderType) {
this.workOrderType = workOrderType;
}
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public String getAncestors() {
return ancestors;
}
public void setAncestors(String ancestors) {
this.ancestors = ancestors;
}
public Integer getOrderNum() {
return orderNum;
}
public void setOrderNum(Integer orderNum) {
this.orderNum = orderNum;
}
public Long getHandlerUserId() {
return handlerUserId;
}
public void setHandlerUserId(Long handlerUserId) {
this.handlerUserId = handlerUserId;
}
public String getHandlerUser() {
return handlerUser;
}
public void setHandlerUser(String handlerUser) {
this.handlerUser = handlerUser;
}
public String getHandlerUserNickName() {
return handlerUserNickName;
}
public void setHandlerUserNickName(String handlerUserNickName) {
this.handlerUserNickName = handlerUserNickName;
}
public Long getRelKnowledgeCategoryId() {
return relKnowledgeCategoryId;
}
public void setRelKnowledgeCategoryId(Long relKnowledgeCategoryId) {
this.relKnowledgeCategoryId = relKnowledgeCategoryId;
}
public String getRemindCycle() {
return remindCycle;
}
public void setRemindCycle(String remindCycle) {
this.remindCycle = remindCycle;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public Long getDeptId() {
return deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public List<WorkOrderCategory> getChildren() {
return children;
}
public void setChildren(List<WorkOrderCategory> children) {
this.children = children;
}
}

View File

@ -52,7 +52,7 @@ public class SysRoleServiceImpl implements ISysRoleService
* @return 角色数据集合信息
*/
@Override
@DataScope(deptAlias = "d")
//@DataScope(deptAlias = "d")
public List<SysRole> selectRoleList(SysRole role)
{
return roleMapper.selectRoleList(role);

View File

@ -19,10 +19,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="fileScope" column="file_scope" />
</resultMap>
<sql id="selectRoleVo">
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.file_scope, r.menu_check_strictly, r.dept_check_strictly,
r.status, r.del_flag, r.create_time, r.remark
from sys_role r
left join sys_user_role ur on ur.role_id = r.role_id
@ -100,6 +101,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="roleKey != null and roleKey != ''">role_key,</if>
<if test="roleSort != null">role_sort,</if>
<if test="dataScope != null and dataScope != ''">data_scope,</if>
<if test="fileScope != null and fileScope != ''">file_scope,</if>
<if test="menuCheckStrictly != null">menu_check_strictly,</if>
<if test="deptCheckStrictly != null">dept_check_strictly,</if>
<if test="status != null and status != ''">status,</if>
@ -112,6 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="roleKey != null and roleKey != ''">#{roleKey},</if>
<if test="roleSort != null">#{roleSort},</if>
<if test="dataScope != null and dataScope != ''">#{dataScope},</if>
<if test="fileScope != null and fileScope != ''">#{fileScope},</if>
<if test="menuCheckStrictly != null">#{menuCheckStrictly},</if>
<if test="deptCheckStrictly != null">#{deptCheckStrictly},</if>
<if test="status != null and status != ''">#{status},</if>
@ -128,6 +131,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="roleKey != null and roleKey != ''">role_key = #{roleKey},</if>
<if test="roleSort != null">role_sort = #{roleSort},</if>
<if test="dataScope != null and dataScope != ''">data_scope = #{dataScope},</if>
<if test="fileScope != null and fileScope != ''">file_scope = #{fileScope},</if>
<if test="menuCheckStrictly != null">menu_check_strictly = #{menuCheckStrictly},</if>
<if test="deptCheckStrictly != null">dept_check_strictly = #{deptCheckStrictly},</if>
<if test="status != null and status != ''">status = #{status},</if>