Commit 42eff639 by 翁国栋

禅道bug-

1357、所有文件中单个文件的删除功能异常,无法对单个文件进行删除操作
parent cfea190a
......@@ -391,7 +391,7 @@ public class DiskCatalogueController {
@GetMapping(value = "/getFileById")
@ApiOperation(value = "查看用户文件夹列表", httpMethod = "GET", notes = "文件夹或共享空间:type=0共享空间,1文件夹")
@ApiOperationSupport(order = 2)
public Result<Object> getFileOfId(@CurrentUser UserBean userBean, DiskCatalogueParam diskCatalogueParam) {
public Result<Object> getFileById(@CurrentUser UserBean userBean, DiskCatalogueParam diskCatalogueParam) {
diskCatalogueParam.setOrgId(userBean.getOrgCode());
YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getEmpNum,diskCatalogueParam.getUserId()));
// 获取文件夹
......@@ -445,11 +445,12 @@ public class DiskCatalogueController {
return ResultUtil.data(map);
}
@GetMapping(value = "/deleteAlLFile")
@ApiOperation(value = "删除用户下的所有文件夹", httpMethod = "GET", notes = "文件夹或共享空间:type=0共享空间,1文件夹")
@ApiOperationSupport(order = 2)
@Log(title = "删除用户下的所有文件夹", businessType = BusinessType.OTHER)
private Result<Object> deleteAlLFile(@CurrentUser UserBean userBean, DiskCatalogueParam diskCatalogueParam){
public Result<Object> deleteAlLFile(@CurrentUser UserBean userBean, DiskCatalogueParam diskCatalogueParam){
List<DiskCatalogue> diskCatalogueList = DiskCatalogue.builder().build().selectList(new QueryWrapper<DiskCatalogue>().lambda()
.eq(DiskCatalogue::getCreateUserId,diskCatalogueParam.getUserId())
.eq(DiskCatalogue::getParentId,0)
......@@ -457,57 +458,92 @@ public class DiskCatalogueController {
if (diskCatalogueList.size()<=0){
return ResultUtil.error("该用户下没有文件");
}
/*查找ids第一个*/
diskCatalogueList.forEach(d->{
getSubCatalogueList(d.getId());
List<DiskCatalogue> subList =diskCatalogueService.getSubCatalogueList(d.getId().toString(),diskCatalogueParam.getUserId());//所有的子文件夹
if(subList!=null) {
subList.forEach(s -> {
List<DiskCatalogueFiles> diskCatalogueFilesList = DiskCatalogueFiles.builder().build().selectList(new QueryWrapper<DiskCatalogueFiles>().lambda()
.eq(DiskCatalogueFiles::getCatalogueId, s.getId())
.eq(DiskCatalogueFiles::getDeleteFlag, 0));
if (diskCatalogueFilesList.size() > 0) {
diskFilesService.deleteDiskFile(diskCatalogueFilesList.stream().map(DiskCatalogueFiles::getFilesId).collect(Collectors.toList()));
}
});
}
d.setDeleteFlag(1);
d.updateById();
});
return ResultUtil.success();
}
private void getSubCatalogueList(Integer id){
List<DiskCatalogue> subFileList =DiskCatalogue.builder().build().selectList(new QueryWrapper<DiskCatalogue>().lambda()
.like(DiskCatalogue::getParentId,id)
.eq(DiskCatalogue::getDeleteFlag,0));
subFileList.forEach(s->{
if(subFileList.size()>0){
getSubCatalogueList(s.getId());
}
List<DiskCatalogueFiles> diskCatalogueFilesList = DiskCatalogueFiles.builder().build().selectList(new QueryWrapper<DiskCatalogueFiles>().lambda()
.eq(DiskCatalogueFiles::getCatalogueId,s.getId())
.eq(DiskCatalogueFiles::getDeleteFlag,0));
diskCatalogueFilesList.forEach(f->{
DiskFiles.builder().deleteFlag(1).build().update(new QueryWrapper<DiskFiles>().lambda().eq(DiskFiles::getId,f.getFilesId()));
f.setDeleteFlag(1);
f.updateById();
});
s.setDeleteFlag(1);
s.updateById();
});
}
// private void getSubCatalogueList2(Integer id){
// List<DiskCatalogue> subFileList =DiskCatalogue.builder().build().selectList(new QueryWrapper<DiskCatalogue>().lambda()
// .like(DiskCatalogue::getParentId,id)
// .eq(DiskCatalogue::getDeleteFlag,0));
// subFileList.forEach(s->{
// if(subFileList.size()>0){
// getSubCatalogueList(s.getId());
// }
// List<DiskCatalogueFiles> diskCatalogueFilesList = DiskCatalogueFiles.builder().build().selectList(new QueryWrapper<DiskCatalogueFiles>().lambda()
// .eq(DiskCatalogueFiles::getCatalogueId,s.getId())
// .eq(DiskCatalogueFiles::getDeleteFlag,0));
// if(diskCatalogueFilesList!=null) {
// if(diskCatalogueFilesList.size()>0) {
// diskFilesService.deleteDiskFile(diskCatalogueFilesList.stream().map(DiskCatalogueFiles::getFilesId).collect(Collectors.toList()));
// }
// }
//// diskCatalogueFilesList.forEach(f->{
//// DiskFiles.builder().deleteFlag(1).build().update(new QueryWrapper<DiskFiles>().lambda().eq(DiskFiles::getId,f.getFilesId()));
//// });
// s.setDeleteFlag(1);
// s.updateById();
// });
// }
}
......@@ -2,6 +2,7 @@ package cn.timer.api.controller.disk.sevice;
import cn.timer.api.bean.disk.DiskCatalogue;
import cn.timer.api.dto.disk.DiskCatalogueParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -28,6 +29,13 @@ public interface DiskCatalogueService {
*/
List<DiskCatalogue> getDiskCatalogue(DiskCatalogueParam diskCatalogueParam);
/**
* 获取所有子文件夹
* @param ids
* @return
*/
List<DiskCatalogue> getSubCatalogueList(String ids,Integer userId);
/**
......
......@@ -2,10 +2,12 @@ package cn.timer.api.controller.disk.sevice;
import cn.timer.api.bean.disk.DiskCatalogue;
import cn.timer.api.bean.disk.DiskCatalogueFiles;
import cn.timer.api.bean.disk.DiskFileImage;
import cn.timer.api.bean.disk.DiskFiles;
import cn.timer.api.dao.disk.DiskCatalogueMapper;
import cn.timer.api.dto.disk.DiskCatalogueParam;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
......@@ -101,6 +103,11 @@ public class DiskCatalogueServiceImpl implements DiskCatalogueService {
return true;
}
@Override
public List<DiskCatalogue> getSubCatalogueList(String ids,Integer userId){
return diskCatalogueMapper.getSubCatalogueList(ids,userId);
}
/**
* 递归获取树形结构
*
......
......@@ -28,4 +28,12 @@ public interface DiskFilesService {
* @return
*/
DiskFileCatalogueDto getFileCount(Integer userId);
/**
* 删除文件
* @param list
* @return
*/
Integer deleteDiskFile(List<Integer> list);
}
......@@ -40,4 +40,9 @@ public class DiskFilesServiceImpl implements DiskFilesService {
dto.setShowSize("1G");
return dto;
}
@Override
public Integer deleteDiskFile(List<Integer> list) {
return diskFilesMapper.deleteDiskFile(list);
}
}
......@@ -4,6 +4,8 @@ package cn.timer.api.dao.disk;
import cn.timer.api.bean.disk.DiskCatalogue;
import cn.timer.api.dto.disk.DiskCatalogueParam;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
......@@ -11,7 +13,7 @@ import java.util.List;
/**
* 云盘-资源目录表
*
*
* @author wuqingjun
* @email 284718418@qq.com
* @date 2021-12-27 10:05:49
......@@ -20,5 +22,6 @@ import java.util.List;
public interface DiskCatalogueMapper extends BaseMapper<DiskCatalogue> {
List<Integer> selectIdListById(@Param("id") Integer id);
List<DiskCatalogue> getSubCatalogueList(@Param("ids") String ids,@Param("userId") Integer userId);
}
......@@ -12,7 +12,7 @@ import java.util.List;
/**
* 云盘-资源上传文件表
*
*
* @author wuqingjun
* @email 284718418@qq.com
* @date 2021-12-27 10:05:49
......@@ -34,5 +34,12 @@ public interface DiskFilesMapper extends BaseMapper<DiskFiles> {
* @return
*/
DiskFileCatalogueDto selectFileCount(@Param("userId")Integer userId);
/**
* 删除文件
* @param list
* @return
*/
Integer deleteDiskFile(@Param("list") List<Integer> list);
}
......@@ -27,4 +27,9 @@
SELECT id FROM disk_catalogue WHERE delete_flag = 0 AND find_in_set(#{id},parent_ids) OR id = #{id}
</select>
</mapper>
\ No newline at end of file
<select id="getSubCatalogueList" resultMap="BaseResultMap">
select d.* from disk_catalogue d
where d.delete_flag = 0 and d.parent_ids like CONCAT(#{ids},'%') and d.create_user_id = #{userId}
</select>
</mapper>
......@@ -20,7 +20,9 @@
SELECT c.*,cdu.id as cloud_disk_user_id,cdu.user_role,cdu.user_power FROM `disk_catalogue` c
LEFT JOIN disk_cloud_disk_user cdu ON c.id=cdu.catalogue_id AND c.id > 0
WHERE c.delete_flag=0 AND cdu.delete_flag = 0
<if test="param.userId!=null">
AND cdu.user_id = #{param.userId}
</if>
AND cdu.org_id = #{param.orgId}
AND c.parent_id = #{param.parentId}
<if test="param.id != null and param.id != ''">
......@@ -28,4 +30,4 @@
</if>
</select>
</mapper>
\ No newline at end of file
</mapper>
......@@ -36,4 +36,12 @@
SELECT COALESCE(sum(file_size),0) as countSize FROM `disk_files` where create_user_id = #{userId} AND delete_flag=0
</select>
</mapper>
\ No newline at end of file
<update id="deleteDiskFile" parameterType="java.util.List">
update disk_catalogue_files set delete_flag = 1
where id in
<foreach item="item" index="index" collection="list" open="("
separator="," close=")">#{item}</foreach>
</update>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment