Commit 9c3609e8 by 284718418@qq.com

1.云盘-我空间业务代码

parent a27e7f3e
......@@ -143,4 +143,20 @@ public class DiskCatalogue extends Model<DiskCatalogue> {
@TableField(exist = false)
private List<DiskCatalogue> breadcrumb;
/**
* 用户类型:0.超级管理员,1.管理员,2.普通用户
*/
@ApiModelProperty(value = "用户类型:0.超级管理员,1.管理员,2.普通用户")
@Transient
@TableField(exist = false)
private Integer userRole;
/**
* 用户权限:r查看,w编辑,x删除,d下载:例如rwxd
*/
@Transient
@TableField(exist = false)
@ApiModelProperty(value = "用户权限:r查看,w编辑,x删除,d下载:例如rwxd")
private String userPower;
}
package cn.timer.api.bean.disk;
import cn.timer.api.config.annotation.UserBean;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
......@@ -84,4 +85,22 @@ public class DiskCloudDiskUser extends Model<DiskCloudDiskUser> {
*/
@ApiModelProperty(value = "逻辑删除标记0.未删除 1.删除")
private Integer deleteFlag;
public String getUserPower() {
return userPower;
}
public void setUserPower(String userPower) {
switch (this.userRole){
case 0:
this.userPower="rwxd";
break;
case 1:
this.userPower="rwd";
break;
case 2:
this.userPower="rd";
break;
}
}
}
......@@ -2,11 +2,16 @@ package cn.timer.api.controller.disk;
import cn.timer.api.bean.disk.DiskCatalogue;
import cn.timer.api.bean.disk.DiskCatalogueFiles;
import cn.timer.api.bean.disk.DiskCloudDiskUser;
import cn.timer.api.bean.disk.DiskFiles;
import cn.timer.api.bean.kqgl.UserAttendanceRel;
import cn.timer.api.bean.qyzx.QyzxEmpLogin;
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.config.enuminterface.JxglEnumInterface;
import cn.timer.api.config.exception.CustomException;
import cn.timer.api.controller.disk.sevice.DiskCatalogueService;
import cn.timer.api.controller.disk.sevice.DiskCloudDiskUserService;
import cn.timer.api.controller.disk.sevice.DiskFilesService;
import cn.timer.api.dto.disk.DiskCatalogueDto;
import cn.timer.api.dto.disk.DiskCatalogueParam;
......@@ -19,6 +24,7 @@ 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.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -46,6 +52,9 @@ public class DiskCatalogueController {
@Autowired
private DiskFilesService diskFilesService;
@Autowired
private DiskCloudDiskUserService diskCloudDiskUserService;
/**
* 云盘-新建文件夹
*
......@@ -59,8 +68,18 @@ public class DiskCatalogueController {
try{
DiskCatalogue diskCatalogue = new DiskCatalogue();
DiskCatalogue catalogue = DiskCatalogue.builder().id(diskCatalogueDto.getParentId()).build().selectById();
Integer empNum = userBean.getEmpNum();
Integer orgCode = userBean.getOrgCode();
// 云盘修改 权限判断
if(JxglEnumInterface.DiskCatalogueType.DISK_YUN.getType().equals(diskCatalogueDto.getType()) &&
!StringUtils.isEmpty(diskCatalogueDto.getId()) && diskCatalogueDto.getId() > 0){
diskCatalogueDto.setUserId(userBean.getEmpNum());
if(!diskCloudDiskUserService.getDiskUserRole(diskCatalogueDto,DiskCatalogue.builder().id(diskCatalogueDto.getId()).build().selectById())){
return ResultUtil.error("无权限,操作失败!");
}
}
BeanUtils.copyProperties(diskCatalogueDto, diskCatalogue);
String parentIds = "";
if (!StringUtils.isEmpty(catalogue)) {
......@@ -69,11 +88,47 @@ public class DiskCatalogueController {
}else {
diskCatalogue.setParentIds(parentIds);
}
diskCatalogue.setCreateUserId(empNum);
diskCatalogue.setOrgId(orgCode);
diskCatalogue.setCreateUserId(userBean.getEmpNum());
diskCatalogue.setOrgId(userBean.getOrgCode());
diskCatalogue.setUserName(userBean.getUserInfo().getName());
diskCatalogue.setUpdateUserId(empNum);
diskCatalogue.setUpdateUserId(userBean.getEmpNum());
Boolean count = diskCatalogue.insertOrUpdate();
// 云盘修改
if(!StringUtils.isEmpty(diskCatalogueDto.getId()) && diskCatalogueDto.getId() > 0
&& JxglEnumInterface.DiskCatalogueType.DISK_YUN.getType().equals(diskCatalogueDto.getType())){
// 删除之前的成员 全部重新添加
DiskCloudDiskUser.builder().build().delete(new QueryWrapper<DiskCloudDiskUser>()
.lambda().eq(DiskCloudDiskUser::getOrgId, userBean.getOrgCode())
.eq(DiskCloudDiskUser::getCatalogueId, diskCatalogue.getId()));
if(!CollectionUtils.isEmpty(diskCatalogueDto.getDiskCloudDiskUsers())){
for (DiskCloudDiskUser entity : diskCatalogueDto.getDiskCloudDiskUsers()) {
QyzxEmpLogin login = QyzxEmpLogin.builder().build().selectOne(new QueryWrapper<QyzxEmpLogin>().select("username","head_url").eq("id", entity.getUserId()));
entity.setCatalogueId(diskCatalogue.getId());
entity.setUserPower(entity.getUserPower());
entity.setOrgId(userBean.getOrgCode());
entity.setUserName(login.getUsername());
entity.setUserHeadUrl(StringUtils.isEmpty(login.getHeadUrl())?"":login.getHeadUrl());
entity.insert();
}
}
}
// 云盘新增
if((StringUtils.isEmpty(diskCatalogueDto.getId()) || diskCatalogueDto.getId() <= 0)
&& JxglEnumInterface.DiskCatalogueType.DISK_YUN.getType().equals(diskCatalogueDto.getType())
&& !CollectionUtils.isEmpty(diskCatalogueDto.getDiskCloudDiskUsers())){
for (DiskCloudDiskUser entity : diskCatalogueDto.getDiskCloudDiskUsers()) {
QyzxEmpLogin login = QyzxEmpLogin.builder().build().selectOne(new QueryWrapper<QyzxEmpLogin>().select("username","head_url").eq("id", entity.getUserId()));
entity.setCatalogueId(diskCatalogue.getId());
entity.setUserPower(entity.getUserPower());
entity.setOrgId(userBean.getOrgCode());
entity.setUserName(login.getUsername());
entity.setUserHeadUrl(StringUtils.isEmpty(login.getHeadUrl())?"":login.getHeadUrl());
entity.insert();
}
}
if (count) {
return ResultUtil.data(diskCatalogue, "新建文件夹成功!");
} else {
......@@ -97,9 +152,7 @@ public class DiskCatalogueController {
@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);
List<DiskCatalogue> list = diskCatalogueService.getDiskCatalogueList(userBean.getOrgCode(), userBean.getEmpNum(), type);
return ResultUtil.data(list);
}
......@@ -115,17 +168,26 @@ public class DiskCatalogueController {
@ApiOperationSupport(order = 2)
public Result<Object> myfile(@CurrentUser UserBean userBean, DiskCatalogueParam diskCatalogueParam) {
try {
Integer empNum = userBean.getEmpNum();
Integer orgCode = userBean.getOrgCode();
diskCatalogueParam.setUserId(empNum);
diskCatalogueParam.setUserId(userBean.getEmpNum());
// 获取文件夹
List<DiskCatalogue> diskCatalogueList = DiskCatalogue.builder().build().selectList(new QueryWrapper<DiskCatalogue>()
.lambda().eq(DiskCatalogue::getOrgId, orgCode)
.eq(DiskCatalogue::getCreateUserId, empNum)
.lambda().eq(DiskCatalogue::getOrgId, userBean.getOrgCode())
.eq(DiskCatalogue::getCreateUserId, userBean.getEmpNum())
.eq(DiskCatalogue::getParentId, diskCatalogueParam.getParentId())
.eq(DiskCatalogue::getType, diskCatalogueParam.getType())
.eq(DiskCatalogue::getDeleteFlag, 0)
);
if(StringUtils.isEmpty(diskCatalogueParam.getParentId()) || diskCatalogueParam.getParentId() == 0){
//空间 获取有权限的
List<DiskCatalogue> diskCatalogueList2 = DiskCatalogue.builder().build().selectList(new QueryWrapper<DiskCatalogue>()
.lambda().eq(DiskCatalogue::getOrgId, userBean.getOrgCode())
.eq(DiskCatalogue::getCreateUserId, userBean.getEmpNum())
.eq(DiskCatalogue::getParentId, diskCatalogueParam.getParentId())
.eq(DiskCatalogue::getType, diskCatalogueParam.getType())
.eq(DiskCatalogue::getDeleteFlag, 0)
);
}
// 获取文件夹下所有文件
List<DiskFiles> filesList = diskFilesService.getDiskFiles(diskCatalogueParam);
// 获取面包屑
List<DiskCatalogue> breadcrumbDataList = null;
......@@ -143,12 +205,12 @@ public class DiskCatalogueController {
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::getOrgId, userBean.getOrgCode())
.eq(DiskCatalogue::getCreateUserId, userBean.getEmpNum())
.eq(DiskCatalogue::getDeleteFlag, 0)
);
}
Map<String,Object> map = new HashMap<>(2);
Map<String,Object> map = new HashMap<>(3);
map.put("diskCatalogueData",diskCatalogueList);
map.put("diskFileData",filesList);
map.put("breadcrumbData",breadcrumbDataList);
......@@ -158,4 +220,18 @@ public class DiskCatalogueController {
throw new CustomException("获取我的文件夹列表异常");
}
}
/**
* 获取当前云空间成员
*/
@GetMapping(value="/user/{id}")
@ApiOperation(value = "获取当前云空间成员", httpMethod = "GET", notes = "获取当前云空间成员")
public Result<Object> getAttUserGroupList(@CurrentUser UserBean userBean, @PathVariable("id") Integer id) {
List<DiskCloudDiskUser> userattgor = DiskCloudDiskUser.builder().build().selectList(new QueryWrapper<DiskCloudDiskUser>()
.lambda().eq(DiskCloudDiskUser::getCatalogueId,id)
.eq(DiskCloudDiskUser::getOrgId,userBean.getOrgCode())
.eq(DiskCloudDiskUser::getDeleteFlag,0)
);
return ResultUtil.data(userattgor);
}
}
......@@ -23,9 +23,7 @@ public interface DiskCatalogueService {
/**
* 我的文件夹
* @param orgId
* @param userId
* @param type
* @param diskCatalogueParam
* @return
*/
List<DiskCatalogue> getDiskCatalogue(DiskCatalogueParam diskCatalogueParam);
......
package cn.timer.api.controller.disk.sevice;
import cn.timer.api.bean.disk.DiskCatalogue;
import cn.timer.api.bean.disk.DiskCloudDiskUser;
import cn.timer.api.bean.disk.DiskFiles;
import cn.timer.api.dto.disk.DiskCatalogueDto;
import cn.timer.api.dto.disk.DiskCatalogueParam;
import java.util.List;
/**
* @author wuqingjun
* @email 284718418@qq.com
* @date 2022/1/4
*/
public interface DiskCloudDiskUserService {
/**
* 判断用户是否拥有该权限
* @param diskCatalogueDto
* @return
*/
boolean getDiskUserRole(DiskCatalogueDto diskCatalogueDto, DiskCatalogue catalogue);
}
package cn.timer.api.controller.disk.sevice;
import cn.timer.api.bean.disk.DiskCatalogue;
import cn.timer.api.bean.disk.DiskCloudDiskUser;
import cn.timer.api.config.enuminterface.JxglEnumInterface;
import cn.timer.api.dao.disk.DiskCloudDiskUserMapper;
import cn.timer.api.dto.disk.DiskCatalogueDto;
import cn.timer.api.utils.ResultUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
/**
* @author wuqingjun
* @email 284718418@qq.com
* @date 2021/12/29
*/
@Service
public class DiskCloudDiskUserServiceImpl implements DiskCloudDiskUserService {
@Resource
private DiskCloudDiskUserMapper diskCloudDiskUserMapper;
@Override
public boolean getDiskUserRole(DiskCatalogueDto diskCatalogueDto, DiskCatalogue catalogue) {
if(StringUtils.isEmpty(catalogue) || StringUtils.isEmpty(diskCatalogueDto)){
return false;
}
if(catalogue.getCreateUserId().equals(diskCatalogueDto.getUserId())){
return true;
}
DiskCloudDiskUser dcdUser = DiskCloudDiskUser.builder().build().selectOne(new QueryWrapper<DiskCloudDiskUser>()
.lambda().eq(DiskCloudDiskUser::getUserId,diskCatalogueDto.getUserId()));
if(StringUtils.isEmpty(dcdUser)){
return false;
}
return false;
}
}
package cn.timer.api.dto.disk;
import cn.timer.api.bean.disk.DiskCloudDiskUser;
import cn.timer.api.config.exception.ValidationMsg;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
......@@ -10,6 +11,7 @@ import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
/**
* @author wuqingjun
......@@ -63,4 +65,12 @@ public class DiskCatalogueDto implements Serializable{
*/
@ApiModelProperty(value = "备注信息")
private String remark;
/**
* 用户ID
*/
@ApiModelProperty(value = "用户ID")
private Integer userId;
@ApiModelProperty(value = "云空间成员")
List<DiskCloudDiskUser> diskCloudDiskUsers;
}
......@@ -26,6 +26,9 @@
LEFT JOIN disk_catalogue_files cf ON f.id=cf.files_id AND cf.id > 0
WHERE f.delete_flag=0 AND cf.delete_flag = 0
AND f.create_user_id = #{param.userId} AND cf.catalogue_id=#{param.parentId}
<if test="param.searchName != null and param.searchName != ''">
AND f.title like CONCAT('%',#{param.searchName},'%')
</if>
ORDER BY f.create_time DESC
</select>
......
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