Commit df0680a7 by 284718418@qq.com

1.云盘代码

parent 50fd5d6f
......@@ -129,4 +129,13 @@ public class DiskCatalogue extends Model<DiskCatalogue> {
@TableField(exist = false)
private List<DiskCatalogue> children;
/**
* 面包屑
*/
@ApiModelProperty(value = "面包屑")
@Transient
@TableField(exist = false)
private List<DiskCatalogue> breadcrumb;
}
......@@ -30,7 +30,7 @@ import java.util.Date;
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "disk_file_log")
@Table(name = "disk_files_log")
@ApiModel("文件浏览记录表")
public class DiskFilesLog extends Model<DiskFilesLog> {
private static final long serialVersionUID = 1L;
......
......@@ -3,11 +3,13 @@ package cn.timer.api.controller.disk;
import cn.timer.api.bean.disk.DiskCatalogue;
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.config.exception.CustomException;
import cn.timer.api.controller.disk.sevice.DiskCatalogueService;
import cn.timer.api.dto.disk.DiskCatalogueDto;
import cn.timer.api.dto.yggl.AddygdaDto;
import cn.timer.api.dto.disk.DiskCatalogueParam;
import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -19,7 +21,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.transaction.Transactional;
import java.util.List;
import java.util.*;
/**
......@@ -32,8 +34,8 @@ import java.util.List;
@Api(tags = "云盘")
@Transactional(rollbackOn = Exception.class)
@RestController
@RequestMapping(value = "/disk/catalogue", produces = { "application/json" })
public class DiskCatalogueController{
@RequestMapping(value = "/disk/catalogue", produces = {"application/json"})
public class DiskCatalogueController {
@Autowired
private DiskCatalogueService diskCatalogueService;
......@@ -48,17 +50,30 @@ public class DiskCatalogueController{
@ApiOperation(value = "1.新建文件夹或共享空间", httpMethod = "POST", notes = "新建文件夹或共享空间:type=0共享空间,1文件夹")
@ApiOperationSupport(order = 1)
public Result<Object> addcatalogue(@CurrentUser UserBean userBean, @Validated @RequestBody DiskCatalogueDto diskCatalogueDto) {
Integer empNum = userBean.getEmpNum();
Integer orgCode = userBean.getOrgCode();
DiskCatalogue diskCatalogue = new DiskCatalogue();
BeanUtils.copyProperties(diskCatalogueDto,diskCatalogue);
diskCatalogue.setCreateUserId(empNum);
diskCatalogue.setOrgId(orgCode);
Boolean count = diskCatalogue.insert();
if(count){
return ResultUtil.data(diskCatalogue, "新建文件夹成功!");
}else{
return ResultUtil.error("新建文件夹失败!");
try{
DiskCatalogue diskCatalogue = new DiskCatalogue();
DiskCatalogue catalogue = DiskCatalogue.builder().id(diskCatalogueDto.getParentId()).build().selectById();
Integer empNum = userBean.getEmpNum();
Integer orgCode = userBean.getOrgCode();
BeanUtils.copyProperties(diskCatalogueDto, diskCatalogue);
String parentIds = "";
if (!StringUtils.isEmpty(catalogue)) {
parentIds = catalogue.getParentIds();
diskCatalogue.setParentIds(catalogue.getParentId() > 0 ? parentIds + "," + catalogue.getId() : catalogue.getId().toString());
}else {
diskCatalogue.setParentIds(parentIds);
}
diskCatalogue.setCreateUserId(empNum);
diskCatalogue.setOrgId(orgCode);
Boolean count = diskCatalogue.insertOrUpdate();
if (count) {
return ResultUtil.data(diskCatalogue, "新建文件夹成功!");
} else {
return ResultUtil.error("新建文件夹失败!");
}
}catch (Exception e){
e.printStackTrace();
throw new CustomException("新建文件夹或共享空间异常");
}
}
......@@ -76,7 +91,60 @@ public class DiskCatalogueController{
@ApiParam("文件文件夹或共享空间ID") @RequestParam(required = true, defaultValue = "0") Integer type) {
Integer empNum = userBean.getEmpNum();
Integer orgCode = userBean.getOrgCode();
List<DiskCatalogue> list = diskCatalogueService.getDiskCatalogueList(orgCode,empNum,type);
List<DiskCatalogue> list = diskCatalogueService.getDiskCatalogueList(orgCode, empNum, type);
return ResultUtil.data(list);
}
/**
* 云盘-我的文件列表
*
* @param userBean
* @param diskCatalogueParam
* @return
*/
@GetMapping(value = "/myfile")
@ApiOperation(value = "我的文件夹列表", httpMethod = "GET", notes = "文件夹或共享空间:type=0共享空间,1文件夹")
@ApiOperationSupport(order = 2)
public Result<Object> myfile(@CurrentUser UserBean userBean, DiskCatalogueParam diskCatalogueParam) {
try {
Integer empNum = userBean.getEmpNum();
Integer orgCode = userBean.getOrgCode();
// 获取文件夹
List<DiskCatalogue> diskFileDataList = DiskCatalogue.builder().build().selectList(new QueryWrapper<DiskCatalogue>()
.lambda().eq(DiskCatalogue::getOrgId, orgCode)
.eq(DiskCatalogue::getCreateUserId, empNum)
.eq(DiskCatalogue::getParentId, diskCatalogueParam.getParentId())
.eq(DiskCatalogue::getType, diskCatalogueParam.getType())
.eq(DiskCatalogue::getDeleteFlag, 0)
);
// 获取面包屑
List<DiskCatalogue> breadcrumbDataList = null;
DiskCatalogue catalogue = DiskCatalogue.builder().id(diskCatalogueParam.getParentId()).build().selectById();
if(!StringUtils.isEmpty(catalogue)){
List<Integer> ids = new ArrayList<>();
if(!StringUtils.isEmpty(catalogue.getParentIds())){
String[] list = catalogue.getParentIds().split(",");
for (String str :list) {
ids.add(Integer.parseInt(str));
}
}
ids.add(catalogue.getId());
breadcrumbDataList = DiskCatalogue.builder().build().selectList(new QueryWrapper<DiskCatalogue>()
.lambda().in(DiskCatalogue::getId,ids)
.eq(DiskCatalogue::getOrgId, orgCode)
.eq(DiskCatalogue::getCreateUserId, empNum)
.eq(DiskCatalogue::getDeleteFlag, 0)
);
}
Map<String,Object> map = new HashMap<>(2);
map.put("diskFileData",diskFileDataList);
map.put("breadcrumbData",breadcrumbDataList);
return ResultUtil.data(map);
}catch (Exception e){
e.printStackTrace();
throw new CustomException("获取我的文件夹列表异常");
}
}
}
package cn.timer.api.controller.disk.sevice;
import cn.timer.api.bean.disk.DiskCatalogue;
import cn.timer.api.dto.disk.DiskCatalogueParam;
import java.util.List;
......@@ -19,4 +20,13 @@ public interface DiskCatalogueService {
* @return
*/
List<DiskCatalogue> getDiskCatalogueList(Integer orgId, Integer userId,Integer type);
/**
* 我的文件夹
* @param orgId
* @param userId
* @param type
* @return
*/
List<DiskCatalogue> getDiskCatalogue(DiskCatalogueParam diskCatalogueParam);
}
......@@ -3,10 +3,14 @@ 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.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.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -27,6 +31,9 @@ public class DiskCatalogueServiceImpl implements DiskCatalogueService {
//所有文件夹ID
private static Map<Integer, List<DiskCatalogueFiles>> map = new HashMap<Integer, List<DiskCatalogueFiles>>();
@Resource
private DiskCatalogueMapper diskCatalogueMapper;
@Override
public List<DiskCatalogue> getDiskCatalogueList(Integer orgId, Integer userId, Integer type) {
treeList = DiskCatalogue.builder().build().selectList(new QueryWrapper<DiskCatalogue>()
......@@ -57,6 +64,12 @@ public class DiskCatalogueServiceImpl implements DiskCatalogueService {
return getTree(list);
}
@Override
public List<DiskCatalogue> getDiskCatalogue(DiskCatalogueParam diskCatalogueParam) {
//diskCatalogueMapper.
return null;
}
/**
* 递归获取树形结构
*
......
......@@ -28,6 +28,12 @@ public class DiskCatalogueDto implements Serializable{
* 资源目录ID
*/
@ApiModelProperty(value = "资源目录ID")
private Integer id;
/**
* 资源目录ID
*/
@ApiModelProperty(value = "资源目录ID")
private Integer catalogueId;
/**
* 目录名称
......@@ -39,7 +45,7 @@ public class DiskCatalogueDto implements Serializable{
* 上级目录
*/
@NotNull(message = ValidationMsg.NOTNULL)
@ApiModelProperty(value = "上级目录")
@ApiModelProperty(value = "上级目录", example = "0")
private Integer parentId;
/**
* 所有上级目录
......
package cn.timer.api.dto.disk;
import cn.timer.api.config.exception.ValidationMsg;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @author wuqingjun
* @email 284718418@qq.com
* @date 2021/12/31
*/
@Data
public class DiskCatalogueParam implements Serializable {
private static final long serialVersionUID = -1230023773946170911L;
/**
* 资源目录ID
*/
@NotNull(message = ValidationMsg.NOTNULL)
@ApiModelProperty(value = "资源目录ID", example = "0")
private Integer id;
//@NotBlank(message = ValidationMsg.NOTBLANK)
@ApiModelProperty(value = "搜索条件")
private String searchName;
/**
* 上级目录
*/
@ApiModelProperty(value = "上级目录", example = "0")
private Integer parentId;
/**
* 0云盘,1文件夹
*/
@NotNull(message = ValidationMsg.NOTNULL)
@ApiModelProperty(value = "0云盘,1文件夹")
private Integer type;
}
......@@ -128,7 +128,7 @@ mybatis-plus:
mapper-locations: classpath:mapping/**/*Mapper.xml # dao到xml文件映射
type-aliases-package: cn.timer.api.bean # xml中#全局类名别名
configuration:
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # sql日志打印
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # sql日志打印
call-setters-on-nulls: true # Map做返回体时 字段值为null依然返回
cache-enabled: true
global-config:
......
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