Commit a9fb2bb0 by 284718418@qq.com

修改BUG 空间大小总计

parent 38dae9b4
...@@ -83,6 +83,11 @@ public class DiskFiles extends Model<DiskFiles> { ...@@ -83,6 +83,11 @@ public class DiskFiles extends Model<DiskFiles> {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
private Integer deleteFlag; private Integer deleteFlag;
/** /**
* 当前企业id
*/
@ApiModelProperty(value = "当前企业id")
private Integer orgId;
/**
* 创建者 * 创建者
*/ */
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
......
...@@ -101,15 +101,20 @@ public class DiskFilesController { ...@@ -101,15 +101,20 @@ public class DiskFilesController {
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());
...@@ -118,8 +123,6 @@ public class DiskFilesController { ...@@ -118,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();
//新增中间关系 //新增中间关系
...@@ -133,8 +136,6 @@ public class DiskFilesController { ...@@ -133,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();
} }
...@@ -234,7 +235,7 @@ public class DiskFilesController { ...@@ -234,7 +235,7 @@ public class DiskFilesController {
@ApiOperation(value = "我的文件空间大小", httpMethod = "GET", notes = "我的文件空间大小") @ApiOperation(value = "我的文件空间大小", httpMethod = "GET", notes = "我的文件空间大小")
public Result<Object> myCatalogue(@CurrentUser UserBean userBean) { public Result<Object> myCatalogue(@CurrentUser UserBean userBean) {
try { try {
DiskFileCatalogueDto diskFileCatalogueDto = diskFilesService.getFileCount(userBean.getEmpNum()); DiskFileCatalogueDto diskFileCatalogueDto = diskFilesService.getFileCount(userBean);
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);
/** /**
* 删除文件 * 删除文件
......
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) {
DiskFileCatalogueDto dto = diskFilesMapper.selectFileCount(userId); DiskFileCatalogueDto dto = diskFilesMapper.selectFileCount(userBean);
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);
/** /**
* 删除文件 * 删除文件
......
...@@ -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,10 @@ ...@@ -33,7 +34,10 @@
</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.create_user_id = #{param.empNum} AND df.org_id=#{param.orgCode} AND df.delete_flag=0 AND dcf.delete_flag=0 AND dc.delete_flag=0 AND dc.type=0
</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