Commit 42eff639 by 翁国栋

禅道bug-

1357、所有文件中单个文件的删除功能异常,无法对单个文件进行删除操作
parent cfea190a
...@@ -391,7 +391,7 @@ public class DiskCatalogueController { ...@@ -391,7 +391,7 @@ public class DiskCatalogueController {
@GetMapping(value = "/getFileById") @GetMapping(value = "/getFileById")
@ApiOperation(value = "查看用户文件夹列表", httpMethod = "GET", notes = "文件夹或共享空间:type=0共享空间,1文件夹") @ApiOperation(value = "查看用户文件夹列表", httpMethod = "GET", notes = "文件夹或共享空间:type=0共享空间,1文件夹")
@ApiOperationSupport(order = 2) @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()); diskCatalogueParam.setOrgId(userBean.getOrgCode());
YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getEmpNum,diskCatalogueParam.getUserId())); YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getEmpNum,diskCatalogueParam.getUserId()));
// 获取文件夹 // 获取文件夹
...@@ -445,11 +445,12 @@ public class DiskCatalogueController { ...@@ -445,11 +445,12 @@ public class DiskCatalogueController {
return ResultUtil.data(map); return ResultUtil.data(map);
} }
@GetMapping(value = "/deleteAlLFile") @GetMapping(value = "/deleteAlLFile")
@ApiOperation(value = "删除用户下的所有文件夹", httpMethod = "GET", notes = "文件夹或共享空间:type=0共享空间,1文件夹") @ApiOperation(value = "删除用户下的所有文件夹", httpMethod = "GET", notes = "文件夹或共享空间:type=0共享空间,1文件夹")
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
@Log(title = "删除用户下的所有文件夹", businessType = BusinessType.OTHER) @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() List<DiskCatalogue> diskCatalogueList = DiskCatalogue.builder().build().selectList(new QueryWrapper<DiskCatalogue>().lambda()
.eq(DiskCatalogue::getCreateUserId,diskCatalogueParam.getUserId()) .eq(DiskCatalogue::getCreateUserId,diskCatalogueParam.getUserId())
.eq(DiskCatalogue::getParentId,0) .eq(DiskCatalogue::getParentId,0)
...@@ -457,57 +458,92 @@ public class DiskCatalogueController { ...@@ -457,57 +458,92 @@ public class DiskCatalogueController {
if (diskCatalogueList.size()<=0){ if (diskCatalogueList.size()<=0){
return ResultUtil.error("该用户下没有文件"); return ResultUtil.error("该用户下没有文件");
} }
/*查找ids第一个*/
diskCatalogueList.forEach(d->{ 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.setDeleteFlag(1);
d.updateById(); d.updateById();
}); });
return ResultUtil.success(); 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; ...@@ -2,6 +2,7 @@ package cn.timer.api.controller.disk.sevice;
import cn.timer.api.bean.disk.DiskCatalogue; import cn.timer.api.bean.disk.DiskCatalogue;
import cn.timer.api.dto.disk.DiskCatalogueParam; import cn.timer.api.dto.disk.DiskCatalogueParam;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -28,6 +29,13 @@ public interface DiskCatalogueService { ...@@ -28,6 +29,13 @@ public interface DiskCatalogueService {
*/ */
List<DiskCatalogue> getDiskCatalogue(DiskCatalogueParam diskCatalogueParam); 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; ...@@ -2,10 +2,12 @@ package cn.timer.api.controller.disk.sevice;
import cn.timer.api.bean.disk.DiskCatalogue; import cn.timer.api.bean.disk.DiskCatalogue;
import cn.timer.api.bean.disk.DiskCatalogueFiles; 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.bean.disk.DiskFiles;
import cn.timer.api.dao.disk.DiskCatalogueMapper; import cn.timer.api.dao.disk.DiskCatalogueMapper;
import cn.timer.api.dto.disk.DiskCatalogueParam; import cn.timer.api.dto.disk.DiskCatalogueParam;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -101,6 +103,11 @@ public class DiskCatalogueServiceImpl implements DiskCatalogueService { ...@@ -101,6 +103,11 @@ public class DiskCatalogueServiceImpl implements DiskCatalogueService {
return true; return true;
} }
@Override
public List<DiskCatalogue> getSubCatalogueList(String ids,Integer userId){
return diskCatalogueMapper.getSubCatalogueList(ids,userId);
}
/** /**
* 递归获取树形结构 * 递归获取树形结构
* *
......
...@@ -28,4 +28,12 @@ public interface DiskFilesService { ...@@ -28,4 +28,12 @@ public interface DiskFilesService {
* @return * @return
*/ */
DiskFileCatalogueDto getFileCount(Integer userId); DiskFileCatalogueDto getFileCount(Integer userId);
/**
* 删除文件
* @param list
* @return
*/
Integer deleteDiskFile(List<Integer> list);
} }
...@@ -40,4 +40,9 @@ public class DiskFilesServiceImpl implements DiskFilesService { ...@@ -40,4 +40,9 @@ public class DiskFilesServiceImpl implements DiskFilesService {
dto.setShowSize("1G"); dto.setShowSize("1G");
return dto; return dto;
} }
@Override
public Integer deleteDiskFile(List<Integer> list) {
return diskFilesMapper.deleteDiskFile(list);
}
} }
...@@ -4,6 +4,8 @@ package cn.timer.api.dao.disk; ...@@ -4,6 +4,8 @@ package cn.timer.api.dao.disk;
import cn.timer.api.bean.disk.DiskCatalogue; import cn.timer.api.bean.disk.DiskCatalogue;
import cn.timer.api.dto.disk.DiskCatalogueParam; import cn.timer.api.dto.disk.DiskCatalogueParam;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; 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.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -21,4 +23,5 @@ public interface DiskCatalogueMapper extends BaseMapper<DiskCatalogue> { ...@@ -21,4 +23,5 @@ public interface DiskCatalogueMapper extends BaseMapper<DiskCatalogue> {
List<Integer> selectIdListById(@Param("id") Integer id); List<Integer> selectIdListById(@Param("id") Integer id);
List<DiskCatalogue> getSubCatalogueList(@Param("ids") String ids,@Param("userId") Integer userId);
} }
...@@ -35,4 +35,11 @@ public interface DiskFilesMapper extends BaseMapper<DiskFiles> { ...@@ -35,4 +35,11 @@ public interface DiskFilesMapper extends BaseMapper<DiskFiles> {
*/ */
DiskFileCatalogueDto selectFileCount(@Param("userId")Integer userId); DiskFileCatalogueDto selectFileCount(@Param("userId")Integer userId);
/**
* 删除文件
* @param list
* @return
*/
Integer deleteDiskFile(@Param("list") List<Integer> list);
} }
...@@ -27,4 +27,9 @@ ...@@ -27,4 +27,9 @@
SELECT id FROM disk_catalogue WHERE delete_flag = 0 AND find_in_set(#{id},parent_ids) OR id = #{id} SELECT id FROM disk_catalogue WHERE delete_flag = 0 AND find_in_set(#{id},parent_ids) OR id = #{id}
</select> </select>
<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> </mapper>
...@@ -20,7 +20,9 @@ ...@@ -20,7 +20,9 @@
SELECT c.*,cdu.id as cloud_disk_user_id,cdu.user_role,cdu.user_power FROM `disk_catalogue` c 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 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 WHERE c.delete_flag=0 AND cdu.delete_flag = 0
<if test="param.userId!=null">
AND cdu.user_id = #{param.userId} AND cdu.user_id = #{param.userId}
</if>
AND cdu.org_id = #{param.orgId} AND cdu.org_id = #{param.orgId}
AND c.parent_id = #{param.parentId} AND c.parent_id = #{param.parentId}
<if test="param.id != null and param.id != ''"> <if test="param.id != null and param.id != ''">
......
...@@ -36,4 +36,12 @@ ...@@ -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 COALESCE(sum(file_size),0) as countSize FROM `disk_files` where create_user_id = #{userId} AND delete_flag=0
</select> </select>
<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> </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