1、文件树查询接口优化,增加是否为文件夹、是否公开字段返回;
2、修改文件是否公开接口实现; 3、修改文件访问范围接口实现
This commit is contained in:
parent
4694649c67
commit
4ca374ccb4
@ -526,25 +526,45 @@ public class FileController {
|
|||||||
return RestResult.success().data(vo);
|
return RestResult.success().data(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Operation(summary = "修改文件访问权限", description = "修改文件访问权限", tags = {"file"})
|
@ApiOperation(value = "5.4 修改文件是否公开")
|
||||||
@ApiOperation(value = "5.4 修改文件访问权限")
|
|
||||||
@ApiOperationSupport(order = 4)
|
@ApiOperationSupport(order = 4)
|
||||||
@RequestMapping(value = "/updateaccesspermission", method = RequestMethod.GET)
|
@RequestMapping(value = "/updateispublic", method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RestResult<String> updateAccessPermission(
|
public RestResult<String> updateIsPublic(
|
||||||
@Parameter(description = "用户文件Id", required = true) String userFileId,
|
@Parameter(description = "用户文件Id", required = true) String userFileId,
|
||||||
@Parameter(description = "访问权限 0禁止其他用户访问 1登录后可访问 2具备权限可访问", required = true) String accessPermission){
|
@Parameter(description = "是否公开 0否 1是", required = true) Integer isPublic){
|
||||||
try {
|
try {
|
||||||
UserFile userFile = new UserFile();
|
UserFile userFile = new UserFile();
|
||||||
userFile.setUserFileId(userFileId);
|
userFile.setUserFileId(userFileId);
|
||||||
userFile.setAccessPermission(accessPermission);
|
userFile.setIsPublic(isPublic);
|
||||||
userFile.setModifyUserId(SecurityUtils.getUserId());
|
userFile.setModifyUserId(SecurityUtils.getUserId());
|
||||||
userFile.setModifyTime(DateUtil.getCurrentTime());
|
userFile.setModifyTime(DateUtil.getCurrentTime());
|
||||||
userFileService.updateById(userFile);
|
userFileService.updateById(userFile);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new QiwenException(999999, "修改文件访问权限异常");
|
throw new QiwenException(999999, "修改文件是否公开异常");
|
||||||
}
|
}
|
||||||
return RestResult.success().message("修改文件访问权限成功");
|
return RestResult.success().message("修改文件是否公开成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
//@Operation(summary = "修改文件访问权限", description = "修改文件访问权限", tags = {"file"})
|
||||||
|
@ApiOperation(value = "5.5 修改文件访问范围")
|
||||||
|
@ApiOperationSupport(order = 5)
|
||||||
|
@RequestMapping(value = "/updateaccessscope", method = RequestMethod.GET)
|
||||||
|
@ResponseBody
|
||||||
|
public RestResult<String> updateAccessScope(
|
||||||
|
@Parameter(description = "用户文件Id", required = true) String userFileId,
|
||||||
|
@Parameter(description = "访问范围", required = true) String accessScope){
|
||||||
|
try {
|
||||||
|
UserFile userFile = new UserFile();
|
||||||
|
userFile.setUserFileId(userFileId);
|
||||||
|
userFile.setAccessScope(accessScope);
|
||||||
|
userFile.setModifyUserId(SecurityUtils.getUserId());
|
||||||
|
userFile.setModifyTime(DateUtil.getCurrentTime());
|
||||||
|
userFileService.updateById(userFile);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new QiwenException(999999, "修改文件访问范围异常");
|
||||||
|
}
|
||||||
|
return RestResult.success().message("修改文件访问范围成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,8 +66,11 @@ public class UserFile {
|
|||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Long fileSize;
|
private Long fileSize;
|
||||||
|
|
||||||
@Column(columnDefinition="char(1) comment '修改用户id'")
|
@Column(columnDefinition="int(0) comment '是否公开(0 否 1是)'")
|
||||||
private String accessPermission;
|
private Integer isPublic;
|
||||||
|
|
||||||
|
@Column(columnDefinition="varchar(25) comment '可见范围'")
|
||||||
|
private String accessScope;
|
||||||
|
|
||||||
@Column(columnDefinition="bigint(0) comment '下载次数'")
|
@Column(columnDefinition="bigint(0) comment '下载次数'")
|
||||||
private Long downloadCnt;
|
private Long downloadCnt;
|
||||||
|
|||||||
@ -32,7 +32,11 @@ public class UserFileDTO {
|
|||||||
|
|
||||||
private Long fileSize;
|
private Long fileSize;
|
||||||
|
|
||||||
private String accessPermission;
|
private Integer isPublic;
|
||||||
|
|
||||||
|
private String accessScope;
|
||||||
|
|
||||||
|
private Long downloadCnt;
|
||||||
|
|
||||||
private List<UserFileDTO> children = new ArrayList<UserFileDTO>();
|
private List<UserFileDTO> children = new ArrayList<UserFileDTO>();
|
||||||
|
|
||||||
@ -164,12 +168,28 @@ public class UserFileDTO {
|
|||||||
this.fileSize = fileSize;
|
this.fileSize = fileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAccessPermission() {
|
public Integer getIsPublic() {
|
||||||
return accessPermission;
|
return isPublic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAccessPermission(String accessPermission) {
|
public void setIsPublic(Integer isPublic) {
|
||||||
this.accessPermission = accessPermission;
|
this.isPublic = isPublic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccessScope() {
|
||||||
|
return accessScope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccessScope(String accessScope) {
|
||||||
|
this.accessScope = accessScope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getDownloadCnt() {
|
||||||
|
return downloadCnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDownloadCnt(Long downloadCnt) {
|
||||||
|
this.downloadCnt = downloadCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UserFileDTO> getChildren() {
|
public List<UserFileDTO> getChildren() {
|
||||||
@ -179,4 +199,5 @@ public class UserFileDTO {
|
|||||||
public void setChildren(List<UserFileDTO> children) {
|
public void setChildren(List<UserFileDTO> children) {
|
||||||
this.children = children;
|
this.children = children;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,5 +20,7 @@ public interface UserFileMapper extends BaseMapper<UserFile> {
|
|||||||
|
|
||||||
List<UserFileDTO> selectFileTreeByUserId(Long userId);
|
List<UserFileDTO> selectFileTreeByUserId(Long userId);
|
||||||
|
|
||||||
int incrementDownloadCount(@Param("userFileIdList") List<String> userFileIdList);
|
int incrementDownloadCount(@Param("userFileIds") List<String> userFileIds);
|
||||||
|
|
||||||
|
List<UserFile> selectByUserFileIds(@Param("userFileIds")List<String> userFileIds);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -278,7 +278,7 @@ public class UserFileServiceImpl extends ServiceImpl<UserFileMapper, UserFile> i
|
|||||||
rootNode.setChildren(new ArrayList<>());
|
rootNode.setChildren(new ArrayList<>());
|
||||||
|
|
||||||
for (UserFileDTO userFile : userFileList) {
|
for (UserFileDTO userFile : userFileList) {
|
||||||
QiwenFile qiwenFile = new QiwenFile(userFile.getFilePath(), userFile.getFileName(), false);
|
QiwenFile qiwenFile = new QiwenFile(userFile.getFilePath(), userFile.getFileName(), userFile.getIsDir() == 1);
|
||||||
String filePath = qiwenFile.getPath();
|
String filePath = qiwenFile.getPath();
|
||||||
|
|
||||||
Queue<String> queue = new LinkedList<>();
|
Queue<String> queue = new LinkedList<>();
|
||||||
@ -305,8 +305,8 @@ public class UserFileServiceImpl extends ServiceImpl<UserFileMapper, UserFile> i
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int incrementDownloadCount(List<String> userFileIdList) {
|
public int incrementDownloadCount(List<String> userFileIds) {
|
||||||
return userFileMapper.incrementDownloadCount(userFileIdList);
|
return userFileMapper.incrementDownloadCount(userFileIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -327,10 +327,12 @@ public class UserFileServiceImpl extends ServiceImpl<UserFileMapper, UserFile> i
|
|||||||
|
|
||||||
if (childNode == null) { // 没有该子节点 -> 插入
|
if (childNode == null) { // 没有该子节点 -> 插入
|
||||||
childNode = new FileTreeSelect();
|
childNode = new FileTreeSelect();
|
||||||
childNode.setLabel(nodeNameQueue.poll());
|
childNode.setLabel(nodeNameQueue.poll() + (userFile.getIsDir() == 0 ? "." + userFile.getExtendName() : ""));
|
||||||
|
childNode.setIsDir(userFile.getIsDir());
|
||||||
|
childNode.setIsPublic(userFile.getIsPublic());
|
||||||
childNode.setChildren(new ArrayList<>());
|
childNode.setChildren(new ArrayList<>());
|
||||||
|
|
||||||
// ⚠️ 所有节点都绑定 userFileId(目录/文件都在 UserFile 表里)
|
// 所有节点都绑定 userFileId(目录/文件都在 UserFile 表里)
|
||||||
childNode.setId(userFile.getUserFileId());
|
childNode.setId(userFile.getUserFileId());
|
||||||
|
|
||||||
childrenTreeNodes.add(childNode);
|
childrenTreeNodes.add(childNode);
|
||||||
|
|||||||
@ -20,6 +20,10 @@ public class FileTreeSelect implements Serializable
|
|||||||
/** 节点名称 */
|
/** 节点名称 */
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
|
private Integer isDir;
|
||||||
|
|
||||||
|
private Integer isPublic;
|
||||||
|
|
||||||
/** 子节点 */
|
/** 子节点 */
|
||||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||||
private List<FileTreeSelect> children;
|
private List<FileTreeSelect> children;
|
||||||
@ -49,6 +53,22 @@ public class FileTreeSelect implements Serializable
|
|||||||
this.label = label;
|
this.label = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getIsDir() {
|
||||||
|
return isDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsDir(Integer isDir) {
|
||||||
|
this.isDir = isDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIsPublic() {
|
||||||
|
return isPublic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsPublic(Integer isPublic) {
|
||||||
|
this.isPublic = isPublic;
|
||||||
|
}
|
||||||
|
|
||||||
public List<FileTreeSelect> getChildren()
|
public List<FileTreeSelect> getChildren()
|
||||||
{
|
{
|
||||||
return children;
|
return children;
|
||||||
|
|||||||
@ -23,7 +23,8 @@
|
|||||||
<result property="uploadTime" column="uploadTime"/>
|
<result property="uploadTime" column="uploadTime"/>
|
||||||
<result property="fileSize" column="fileSize"/>
|
<result property="fileSize" column="fileSize"/>
|
||||||
<result property="userId" column="userId"/>
|
<result property="userId" column="userId"/>
|
||||||
<result property="accessPermission" column="accessPermission"/>
|
<result property="isPublic" column="isPublic"/>
|
||||||
|
<result property="accessScope" column="accessScope"/>
|
||||||
<result property="downloadCnt" column="downloadCnt"/>
|
<result property="downloadCnt" column="downloadCnt"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
@ -44,7 +45,8 @@
|
|||||||
<result property="uploadTime" column="uploadTime"/>
|
<result property="uploadTime" column="uploadTime"/>
|
||||||
<result property="fileSize" column="fileSize"/>
|
<result property="fileSize" column="fileSize"/>
|
||||||
<result property="userId" column="userId"/>
|
<result property="userId" column="userId"/>
|
||||||
<result property="accessPermission" column="accessPermission"/>
|
<result property="isPublic" column="isPublic"/>
|
||||||
|
<result property="accessScope" column="accessScope"/>
|
||||||
<result property="downloadCnt" column="downloadCnt"/>
|
<result property="downloadCnt" column="downloadCnt"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
@ -104,16 +106,25 @@
|
|||||||
<select id="selectFileTreeByUserId" resultMap="UserFileDtoMap" parameterType="java.lang.Long">
|
<select id="selectFileTreeByUserId" resultMap="UserFileDtoMap" parameterType="java.lang.Long">
|
||||||
SELECT userfile.*, file.fileSize as fileSize FROM userfile
|
SELECT userfile.*, file.fileSize as fileSize FROM userfile
|
||||||
LEFT JOIN file ON file.fileId = userfile.fileId
|
LEFT JOIN file ON file.fileId = userfile.fileId
|
||||||
WHERE userfile.userId = #{userId}
|
WHERE userfile.userId = #{userId} and deleteFlag = 0
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="incrementDownloadCount">
|
<update id="incrementDownloadCount">
|
||||||
UPDATE userfile
|
UPDATE userfile
|
||||||
SET downloadCnt = downloadCnt + 1
|
SET downloadCnt = downloadCnt + 1
|
||||||
WHERE userFileId IN
|
WHERE userFileId IN
|
||||||
<foreach collection="userFileIdList" item="userFileId" open="(" separator="," close=")">
|
<foreach collection="userFileIds" item="userFileId" open="(" separator="," close=")">
|
||||||
#{userFileId}
|
#{userFileId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<select id="selectByUserFileIds" resultMap="UserFileMap">
|
||||||
|
SELECT userfile.*, file.fileSize as fileSize FROM userfile
|
||||||
|
LEFT JOIN file ON file.fileId = userfile.fileId
|
||||||
|
WHERE userfile.userFileId IN
|
||||||
|
<foreach collection="userFileIds" item="userFileId" open="(" separator="," close=")">
|
||||||
|
#{userFileId}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user