Commit cf8a390b by 284718418@qq.com

Merge branch 'develop' into feature_20220222_huayi

# Conflicts:
#	src/main/resources/application-pro.yml
parents 663f5dde f0d60fa1
...@@ -78,11 +78,16 @@ public class DiskFiles extends Model<DiskFiles> { ...@@ -78,11 +78,16 @@ public class DiskFiles extends Model<DiskFiles> {
@ApiModelProperty(value = "上传文件时的IP") @ApiModelProperty(value = "上传文件时的IP")
private String uploadIp; private String uploadIp;
/** /**
* 逻辑删除标记0.未删除 1.删除 * 逻辑删除标记0.未删除 1.删除
*/ */
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
private Integer deleteFlag; private Integer deleteFlag;
/** /**
* 当前企业id
*/
@ApiModelProperty(value = "当前企业id")
private Integer orgId;
/**
* 创建者 * 创建者
*/ */
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
......
...@@ -4,6 +4,7 @@ import cn.timer.api.bean.disk.DiskCatalogue; ...@@ -4,6 +4,7 @@ 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.DiskFiles; import cn.timer.api.bean.disk.DiskFiles;
import cn.timer.api.bean.disk.DiskFilesLog; import cn.timer.api.bean.disk.DiskFilesLog;
import cn.timer.api.bean.qyzx.QyzxEmpLogin;
import cn.timer.api.config.annotation.CurrentUser; import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean; import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.config.enuminterface.JxglEnumInterface; import cn.timer.api.config.enuminterface.JxglEnumInterface;
...@@ -75,23 +76,45 @@ public class DiskFilesController { ...@@ -75,23 +76,45 @@ public class DiskFilesController {
@PostMapping("/upload") @PostMapping("/upload")
@ApiOperation(value = "上传普通文件", httpMethod = "POST", notes = "接口发布说明") @ApiOperation(value = "上传普通文件", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> upload(@CurrentUser UserBean userBean, @RequestParam(required = true) MultipartFile[] file, public Result<Object> upload(@CurrentUser UserBean userBean, @RequestParam(required = true) MultipartFile[] file,
@ApiParam("文件文件夹或共享空间ID") @RequestParam(required = true) Integer catalogueId,HttpServletRequest request) { @ApiParam("文件文件夹或共享空间ID") @RequestParam(required = false) Integer catalogueId,HttpServletRequest request) {
if(catalogueId<=0){ if(catalogueId<=0){
return ResultUtil.error("上传失败,请选择文件夹"); DiskCatalogue diskCatalogue = DiskCatalogue.builder().build().selectOne(new QueryWrapper<DiskCatalogue>().select("id")
.eq("org_id", userBean.getOrgCode())
.eq("delete_flag",0)
.eq("create_user_id",userBean.getEmpNum()).orderByAsc("create_time")
);
if(StringUtils.isEmpty(diskCatalogue)){
diskCatalogue = new DiskCatalogue();
diskCatalogue.setCreateUserId(userBean.getEmpNum());
diskCatalogue.setOrgId(userBean.getOrgCode());
diskCatalogue.setParentIds("");
diskCatalogue.setName("我的文件夹");
diskCatalogue.setUserName(userBean.getUserInfo().getName());
diskCatalogue.setType(JxglEnumInterface.DiskCatalogueType.DISK_FILE.getType());
diskCatalogue.insert();
}
catalogueId = diskCatalogue.getId();
//return ResultUtil.error("上传失败,请选择文件夹");
} }
if (file == null || file.length == 0) { if (file == null || file.length == 0) {
return ResultUtil.error("上传失败,请选择上传文件"); return ResultUtil.error("上传失败,请选择上传文件");
} }
DiskFiles diskFiles = new DiskFiles(); DiskFiles diskFiles = new DiskFiles();
diskFiles.setOrgId(userBean.getOrgCode());
diskFiles.setCreateUserId(userBean.getEmpNum());
diskFiles.setUploadIp(UserIp.getIpAddr(request));
diskFiles.setUserName(userBean.getQyzxEmpLogin().getUsername());
DiskCatalogueFiles diskCatalogueFiles = new DiskCatalogueFiles(); DiskCatalogueFiles diskCatalogueFiles = new DiskCatalogueFiles();
DiskFilesLog diskFilesLog = new DiskFilesLog(); DiskFilesLog diskFilesLog = new DiskFilesLog();
diskFilesLog.setUserId(userBean.getEmpNum());
diskFilesLog.setUserName(userBean.getQyzxEmpLogin().getUsername());
List<FileInfoDto> imageUrls; List<FileInfoDto> imageUrls;
try { try {
//上传文件到服务器 //上传文件到服务器
imageUrls = ftpService.uploadFile(targetPath, file, reservedName); imageUrls = ftpService.uploadFile(targetPath, file, reservedName);
for (FileInfoDto dto : imageUrls) { for (FileInfoDto dto : imageUrls) {
//新增资源上传文件 //新增资源上传文件
diskFiles.setCreateUserId(userBean.getEmpNum());
diskFiles.setFileType(dto.getFileSuffix()); diskFiles.setFileType(dto.getFileSuffix());
//"/home/disk/123456.jpg" //"/home/disk/123456.jpg"
diskFiles.setDiskPath(root + targetPath + "/" + dto.getFileName()); diskFiles.setDiskPath(root + targetPath + "/" + dto.getFileName());
...@@ -100,8 +123,6 @@ public class DiskFilesController { ...@@ -100,8 +123,6 @@ public class DiskFilesController {
diskFiles.setFileSize(dto.getFileSize()); diskFiles.setFileSize(dto.getFileSize());
// 显示大小:10KB,5M,2G // 显示大小:10KB,5M,2G
diskFiles.setShowSize(FileUtils.getSize(dto.getFileSize())); diskFiles.setShowSize(FileUtils.getSize(dto.getFileSize()));
diskFiles.setUserName(userBean.getQyzxEmpLogin().getUsername());
diskFiles.setUploadIp(UserIp.getIpAddr(request));
diskFiles.insert(); diskFiles.insert();
//新增中间关系 //新增中间关系
...@@ -115,8 +136,6 @@ public class DiskFilesController { ...@@ -115,8 +136,6 @@ public class DiskFilesController {
diskFilesLog.setFileSize(dto.getFileSize() + "B"); diskFilesLog.setFileSize(dto.getFileSize() + "B");
diskFilesLog.setTitle(dto.getResourceFileName()); diskFilesLog.setTitle(dto.getResourceFileName());
diskFilesLog.setType(JxglEnumInterface.DiskFilesLogType.CREATE_LOG.getType()); diskFilesLog.setType(JxglEnumInterface.DiskFilesLogType.CREATE_LOG.getType());
diskFilesLog.setUserId(userBean.getEmpNum());
diskFilesLog.setUserName(userBean.getQyzxEmpLogin().getUsername());
diskFilesLog.insert(); diskFilesLog.insert();
} }
...@@ -212,11 +231,11 @@ public class DiskFilesController { ...@@ -212,11 +231,11 @@ public class DiskFilesController {
* @param userBean * @param userBean
* @return * @return
*/ */
@GetMapping(value = "/mycatalogue") @GetMapping(value = "/mycatalogue/{type}")
@ApiOperation(value = "我的文件空间大小", httpMethod = "GET", notes = "我的文件空间大小") @ApiOperation(value = "我的文件空间大小", httpMethod = "GET", notes = "我的文件空间大小")
public Result<Object> myCatalogue(@CurrentUser UserBean userBean) { public Result<Object> myCatalogue(@PathVariable("type")Integer type,@CurrentUser UserBean userBean) {
try { try {
DiskFileCatalogueDto diskFileCatalogueDto = diskFilesService.getFileCount(userBean.getEmpNum()); DiskFileCatalogueDto diskFileCatalogueDto = diskFilesService.getFileCount(userBean,type);
return ResultUtil.data(diskFileCatalogueDto); return ResultUtil.data(diskFileCatalogueDto);
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
......
...@@ -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.bean.disk.DiskFiles; import cn.timer.api.bean.disk.DiskFiles;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.dto.disk.DiskCatalogueParam; import cn.timer.api.dto.disk.DiskCatalogueParam;
import cn.timer.api.dto.disk.DiskFileCatalogueDto; import cn.timer.api.dto.disk.DiskFileCatalogueDto;
...@@ -24,10 +25,10 @@ public interface DiskFilesService { ...@@ -24,10 +25,10 @@ public interface DiskFilesService {
/** /**
* 获取用户文件空间大小 * 获取用户文件空间大小
* @param userId * @param userBean
* @return * @return
*/ */
DiskFileCatalogueDto getFileCount(Integer userId); DiskFileCatalogueDto getFileCount(UserBean userBean,Integer type);
/** /**
* 删除文件 * 删除文件
......
package cn.timer.api.controller.disk.sevice; package cn.timer.api.controller.disk.sevice;
import cn.timer.api.bean.disk.DiskFiles; import cn.timer.api.bean.disk.DiskFiles;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.dao.disk.DiskFilesMapper; import cn.timer.api.dao.disk.DiskFilesMapper;
import cn.timer.api.dto.disk.DiskCatalogueParam; import cn.timer.api.dto.disk.DiskCatalogueParam;
import cn.timer.api.dto.disk.DiskFileCatalogueDto; import cn.timer.api.dto.disk.DiskFileCatalogueDto;
...@@ -29,8 +30,8 @@ public class DiskFilesServiceImpl implements DiskFilesService { ...@@ -29,8 +30,8 @@ public class DiskFilesServiceImpl implements DiskFilesService {
} }
@Override @Override
public DiskFileCatalogueDto getFileCount(Integer userId) { public DiskFileCatalogueDto getFileCount(UserBean userBean,Integer type) {
DiskFileCatalogueDto dto = diskFilesMapper.selectFileCount(userId); DiskFileCatalogueDto dto = diskFilesMapper.selectFileCount(userBean,type);
if(StringUtils.isEmpty(dto)){ if(StringUtils.isEmpty(dto)){
dto = new DiskFileCatalogueDto(); dto = new DiskFileCatalogueDto();
} }
......
...@@ -2,6 +2,7 @@ package cn.timer.api.dao.disk; ...@@ -2,6 +2,7 @@ package cn.timer.api.dao.disk;
import cn.timer.api.bean.disk.DiskFiles; import cn.timer.api.bean.disk.DiskFiles;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.dto.disk.DiskCatalogueParam; import cn.timer.api.dto.disk.DiskCatalogueParam;
import cn.timer.api.dto.disk.DiskFileCatalogueDto; import cn.timer.api.dto.disk.DiskFileCatalogueDto;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
...@@ -30,10 +31,10 @@ public interface DiskFilesMapper extends BaseMapper<DiskFiles> { ...@@ -30,10 +31,10 @@ public interface DiskFilesMapper extends BaseMapper<DiskFiles> {
/** /**
* 获取用户文件空间大小 * 获取用户文件空间大小
* @param userId * @param userBean
* @return * @return
*/ */
DiskFileCatalogueDto selectFileCount(@Param("userId")Integer userId); DiskFileCatalogueDto selectFileCount(@Param("param") UserBean userBean,@Param("type")Integer type);
/** /**
* 删除文件 * 删除文件
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
<result property="showSize" column="show_size"/> <result property="showSize" column="show_size"/>
<result property="fileType" column="file_type"/> <result property="fileType" column="file_type"/>
<result property="uploadIp" column="upload_ip"/> <result property="uploadIp" column="upload_ip"/>
<result property="orgId" column="org_id"/>
<result property="deleteFlag" column="delete_flag"/> <result property="deleteFlag" column="delete_flag"/>
<result property="createUserId" column="create_user_id"/> <result property="createUserId" column="create_user_id"/>
<result property="userName" column="user_name"/> <result property="userName" column="user_name"/>
...@@ -33,7 +34,14 @@ ...@@ -33,7 +34,14 @@
</select> </select>
<select id="selectFileCount" resultType="cn.timer.api.dto.disk.DiskFileCatalogueDto"> <select id="selectFileCount" resultType="cn.timer.api.dto.disk.DiskFileCatalogueDto">
SELECT COALESCE(sum(file_size),0) as countSize FROM `disk_files` where create_user_id = #{userId} AND delete_flag=0 SELECT COALESCE(sum(df.file_size),0) as countSize FROM `disk_files` df
LEFT JOIN disk_catalogue_files dcf ON df.id = dcf.files_id
LEFT JOIN disk_catalogue dc ON dc.id = dcf.catalogue_id
WHERE df.delete_flag=0
<if test="type == 1">
AND df.create_user_id = #{param.empNum}
</if>
AND df.org_id=#{param.orgCode} AND dcf.delete_flag=0 AND dc.delete_flag=0 AND dc.type = #{type}
</select> </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