Commit a9fb2bb0 by 284718418@qq.com

修改BUG 空间大小总计

parent 38dae9b4
......@@ -83,6 +83,11 @@ public class DiskFiles extends Model<DiskFiles> {
@ApiModelProperty(value = "")
private Integer deleteFlag;
/**
* 当前企业id
*/
@ApiModelProperty(value = "当前企业id")
private Integer orgId;
/**
* 创建者
*/
@ApiModelProperty(value = "")
......
......@@ -101,15 +101,20 @@ public class DiskFilesController {
return ResultUtil.error("上传失败,请选择上传文件");
}
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();
DiskFilesLog diskFilesLog = new DiskFilesLog();
diskFilesLog.setUserId(userBean.getEmpNum());
diskFilesLog.setUserName(userBean.getQyzxEmpLogin().getUsername());
List<FileInfoDto> imageUrls;
try {
//上传文件到服务器
imageUrls = ftpService.uploadFile(targetPath, file, reservedName);
for (FileInfoDto dto : imageUrls) {
//新增资源上传文件
diskFiles.setCreateUserId(userBean.getEmpNum());
diskFiles.setFileType(dto.getFileSuffix());
//"/home/disk/123456.jpg"
diskFiles.setDiskPath(root + targetPath + "/" + dto.getFileName());
......@@ -118,8 +123,6 @@ public class DiskFilesController {
diskFiles.setFileSize(dto.getFileSize());
// 显示大小:10KB,5M,2G
diskFiles.setShowSize(FileUtils.getSize(dto.getFileSize()));
diskFiles.setUserName(userBean.getQyzxEmpLogin().getUsername());
diskFiles.setUploadIp(UserIp.getIpAddr(request));
diskFiles.insert();
//新增中间关系
......@@ -133,8 +136,6 @@ public class DiskFilesController {
diskFilesLog.setFileSize(dto.getFileSize() + "B");
diskFilesLog.setTitle(dto.getResourceFileName());
diskFilesLog.setType(JxglEnumInterface.DiskFilesLogType.CREATE_LOG.getType());
diskFilesLog.setUserId(userBean.getEmpNum());
diskFilesLog.setUserName(userBean.getQyzxEmpLogin().getUsername());
diskFilesLog.insert();
}
......@@ -234,7 +235,7 @@ public class DiskFilesController {
@ApiOperation(value = "我的文件空间大小", httpMethod = "GET", notes = "我的文件空间大小")
public Result<Object> myCatalogue(@CurrentUser UserBean userBean) {
try {
DiskFileCatalogueDto diskFileCatalogueDto = diskFilesService.getFileCount(userBean.getEmpNum());
DiskFileCatalogueDto diskFileCatalogueDto = diskFilesService.getFileCount(userBean);
return ResultUtil.data(diskFileCatalogueDto);
}catch (Exception e){
e.printStackTrace();
......
......@@ -2,6 +2,7 @@ package cn.timer.api.controller.disk.sevice;
import cn.timer.api.bean.disk.DiskCatalogue;
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.DiskFileCatalogueDto;
......@@ -24,10 +25,10 @@ public interface DiskFilesService {
/**
* 获取用户文件空间大小
* @param userId
* @param userBean
* @return
*/
DiskFileCatalogueDto getFileCount(Integer userId);
DiskFileCatalogueDto getFileCount(UserBean userBean);
/**
* 删除文件
......
package cn.timer.api.controller.disk.sevice;
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.dto.disk.DiskCatalogueParam;
import cn.timer.api.dto.disk.DiskFileCatalogueDto;
......@@ -29,8 +30,8 @@ public class DiskFilesServiceImpl implements DiskFilesService {
}
@Override
public DiskFileCatalogueDto getFileCount(Integer userId) {
DiskFileCatalogueDto dto = diskFilesMapper.selectFileCount(userId);
public DiskFileCatalogueDto getFileCount(UserBean userBean) {
DiskFileCatalogueDto dto = diskFilesMapper.selectFileCount(userBean);
if(StringUtils.isEmpty(dto)){
dto = new DiskFileCatalogueDto();
}
......
......@@ -2,6 +2,7 @@ package cn.timer.api.dao.disk;
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.DiskFileCatalogueDto;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
......@@ -30,10 +31,10 @@ public interface DiskFilesMapper extends BaseMapper<DiskFiles> {
/**
* 获取用户文件空间大小
* @param userId
* @param userBean
* @return
*/
DiskFileCatalogueDto selectFileCount(@Param("userId")Integer userId);
DiskFileCatalogueDto selectFileCount(@Param("param") UserBean userBean);
/**
* 删除文件
......
......@@ -13,6 +13,7 @@
<result property="showSize" column="show_size"/>
<result property="fileType" column="file_type"/>
<result property="uploadIp" column="upload_ip"/>
<result property="orgId" column="org_id"/>
<result property="deleteFlag" column="delete_flag"/>
<result property="createUserId" column="create_user_id"/>
<result property="userName" column="user_name"/>
......@@ -33,7 +34,10 @@
</select>
<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>
......
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