Commit f319827f by 284718418@qq.com

1.我的文件文件夹或共享空间列表接口

parent 39e17a53
package cn.timer.api.bean.disk;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
......@@ -10,11 +11,9 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.*;
import java.util.Date;
import java.util.List;
/**
......@@ -113,4 +112,21 @@ public class DiskCatalogue extends Model<DiskCatalogue> {
@ApiModelProperty(value = "更新时间")
private Date updateTime;
/**
* 文件集合
*/
@ApiModelProperty(value = "文件集合")
@Transient
@TableField(exist = false)
private List<DiskFiles> diskFilesList;
/**
* 文件子集
*/
@ApiModelProperty(value = "文件子集")
@Transient
@TableField(exist = false)
private List<DiskCatalogue> children;
}
......@@ -48,7 +48,7 @@ public class DiskFileImage extends Model<DiskFileImage> {
* 图标类型:txt,doc,html,pdf,jpg,png,gif,swf,
*/
@ApiModelProperty(value = "图标类型:txt,doc,html,pdf,jpg,png,gif,swf,")
private Integer type;
private String type;
/**
* 文件标题
*/
......
......@@ -254,7 +254,7 @@ public interface JxglEnumInterface {
*/
@Getter
enum DiskCatalogueType implements JxglEnumInterface {
NEED(0, "云盘"), NOT_NEED(1, "文件夹");
DISK_YUN(0, "云盘"), DISK_FILE(1, "文件夹");
private Integer type;
......
......@@ -3,6 +3,7 @@ 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.controller.disk.sevice.DiskCatalogueService;
import cn.timer.api.dto.disk.DiskCatalogueDto;
import cn.timer.api.dto.yggl.AddygdaDto;
import cn.timer.api.utils.Result;
......@@ -10,16 +11,15 @@ import cn.timer.api.utils.ResultUtil;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.transaction.Transactional;
import java.util.List;
/**
......@@ -34,6 +34,10 @@ import javax.transaction.Transactional;
@RestController
@RequestMapping(value = "/disk/catalogue", produces = { "application/json" })
public class DiskCatalogueController{
@Autowired
private DiskCatalogueService diskCatalogueService;
/**
* 云盘-新建文件夹
*
......@@ -43,7 +47,7 @@ public class DiskCatalogueController{
@PostMapping(value = "/add_catalogue")
@ApiOperation(value = "1.新建文件夹或共享空间", httpMethod = "POST", notes = "新建文件夹或共享空间:type=0共享空间,1文件夹")
@ApiOperationSupport(order = 1)
public Result<Object> addygda(@CurrentUser UserBean userBean, @Validated @RequestBody DiskCatalogueDto diskCatalogueDto) {
public Result<Object> addcatalogue(@CurrentUser UserBean userBean, @Validated @RequestBody DiskCatalogueDto diskCatalogueDto) {
Integer empNum = userBean.getEmpNum();
Integer orgCode = userBean.getOrgCode();
DiskCatalogue diskCatalogue = new DiskCatalogue();
......@@ -57,4 +61,22 @@ public class DiskCatalogueController{
return ResultUtil.error("新建文件夹失败!");
}
}
/**
* 云盘-我的文件文件夹或共享空间列表
*
* @param userBean
* @param type
* @return
*/
@GetMapping(value = "/myfile_list")
@ApiOperation(value = "2.我的文件文件夹或共享空间列表", httpMethod = "GET", notes = "文件夹或共享空间:type=0共享空间,1文件夹")
@ApiOperationSupport(order = 2)
public Result<Object> myfilelist(@CurrentUser UserBean userBean,
@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);
return ResultUtil.data(list);
}
}
......@@ -15,6 +15,7 @@ import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
......@@ -57,7 +58,8 @@ public class DiskFilesController {
@ApiOperation(value = "上传普通文件", httpMethod = "POST", notes = "接口发布说明")
@ResponseBody
@PostMapping("/upload")
public Result<Object> upload(@CurrentUser UserBean userBean, @RequestParam(required = true) MultipartFile[] file,@RequestParam(required = true) Integer catalogueId) {
public Result<Object> upload(@CurrentUser UserBean userBean, @RequestParam(required = true) MultipartFile[] file,
@ApiParam("文件文件夹或共享空间ID") @RequestParam(required = true) Integer catalogueId) {
if (file == null || file.length == 0) {
return ResultUtil.error("上传失败,请选择上传文件");
}
......
package cn.timer.api.controller.disk.sevice;
import cn.timer.api.bean.disk.DiskCatalogue;
import java.util.List;
/**
* @author wuqingjun
* @email 284718418@qq.com
* @date 2021/12/29
*/
public interface DiskCatalogueService {
/**
* 文件文件夹或共享空间列表
* @param orgId
* @param UserId
* @param type
* @return
*/
List<DiskCatalogue> getDiskCatalogueList(Integer orgId, Integer userId,Integer type);
}
package cn.timer.api.controller.disk.sevice;
import cn.timer.api.bean.disk.DiskCatalogue;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author wuqingjun
* @email 284718418@qq.com
* @date 2021/12/29
*/
@Service
public class DiskCatalogueServiceImpl implements DiskCatalogueService {
private static List<DiskCatalogue> treeList = new ArrayList<>();
@Override
public List<DiskCatalogue> getDiskCatalogueList(Integer orgId, Integer userId, Integer type) {
treeList = DiskCatalogue.builder().build().selectList(new QueryWrapper<DiskCatalogue>()
.lambda().eq(DiskCatalogue::getOrgId, orgId)
.eq(DiskCatalogue::getCreateUserId, userId)
.eq(DiskCatalogue::getType, type)
);
List<DiskCatalogue> list = treeList.stream().filter(s -> s.getParentId() == 0).collect(Collectors.toList());
return getTree(list);
}
/**
* 递归获取树形结构
*
* @param parentList 一级节点
* @return
*/
public static List<DiskCatalogue> getTree(List<DiskCatalogue> parentList) {
List<DiskCatalogue> list = new ArrayList<>();
if (parentList != null) {
for (int i = 0; i < parentList.size(); i++) {
list.add(recursiveTree(parentList.get(i).getId()));
}
}
return list;
}
/**
* 递归算法解析成树形结构
*
* @param cid
*/
public static DiskCatalogue recursiveTree(Integer cid) {
DiskCatalogue node = getMenuById(cid);
List<DiskCatalogue> childTreeNodes = getChildTreeById(cid);
for (DiskCatalogue child : childTreeNodes) {
DiskCatalogue n = recursiveTree(child.getId());
List<DiskCatalogue> list = new ArrayList<DiskCatalogue>();
list.add(n);
if (node.getChildren() == null) {
List<DiskCatalogue> li = new ArrayList<DiskCatalogue>();
node.setChildren(li);
}
node.getChildren().add(n);
}
return node;
}
/**
* 根据CID查询节点对象
*/
public static DiskCatalogue getMenuById(Integer cid) {
Map map = getTreeMap();
return (DiskCatalogue) map.get(cid);
}
/**
* 一次性取所有数据,为了减少对数据库查询操作
*
* @return
*/
public static Map getTreeMap() {
Map map = new HashMap<Integer, DiskCatalogue>();
if (null != treeList) {
for (DiskCatalogue d : treeList) {
map.put(d.getId(), d);
}
}
return map;
}
/**
* 根据父节点CID获取所有了节点
*/
public static List<DiskCatalogue> getChildTreeById(Integer cid) {
List<DiskCatalogue> list = new ArrayList<>();
if (null != treeList) {
for (DiskCatalogue d : treeList) {
if (null != cid) {
if (cid.equals(Integer.valueOf(d.getParentId()))) {
list.add(d);
}
}
}
}
return list;
}
}
......@@ -25,6 +25,11 @@ public class DiskCatalogueDto implements Serializable{
private static final long serialVersionUID = -1230023773946170911L;
/**
* 资源目录ID
*/
@ApiModelProperty(value = "资源目录ID")
private Integer catalogueId;
/**
* 目录名称
*/
@NotBlank(message = ValidationMsg.NOTBLANK)
......
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