package com.liangrui.hadoop_disk.service.impl;
import com.liangrui.hadoop_disk.bean.dto.FileAndFolderDto;
import com.liangrui.hadoop_disk.bean.dto.FolderDto;
import com.liangrui.hadoop_disk.bean.entity.Diskuser;
import com.liangrui.hadoop_disk.bean.entity.Fileindex;
import com.liangrui.hadoop_disk.bean.entity.Folder;
import com.liangrui.hadoop_disk.bean.entity.Upload;
import com.liangrui.hadoop_disk.mapper.DiskuserMapper;
import com.liangrui.hadoop_disk.mapper.FileindexMapper;
import com.liangrui.hadoop_disk.mapper.FolderMapper;
import com.liangrui.hadoop_disk.mapper.UploadMapper;
import com.liangrui.hadoop_disk.service.FileAndFolderService;
import com.liangrui.hadoop_disk.util.DateUtil;
import com.liangrui.hadoop_disk.util.RowkeyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
public class FileAndFolderServiceImpl implements FileAndFolderService {
@Autowired
private FolderMapper folderMapper;
@Autowired
private FileindexMapper fileindexMapper;
@Autowired
private UploadMapper uploadMapper;
@Autowired
private DiskuserMapper diskuserMapper;
@Override
public List<FileAndFolderDto> findAllFileAndFolder(String fatherFolderid) {
List<Folder> list=folderMapper.selectByFatherFolder(fatherFolderid);
List<Fileindex> list1=fileindexMapper.selectByFatherFolder(fatherFolderid);
List<FileAndFolderDto> list2 = new ArrayList<>();
for(Folder folder:list)
{
FileAndFolderDto fileAndFolderDto=new FileAndFolderDto();
fileAndFolderDto.setId(folder.getFolderid());
fileAndFolderDto.setName(folder.getName());
fileAndFolderDto.setSharetype(folder.getSharetype());
fileAndFolderDto.setUpdatetime(folder.getUpdatetime());
list2.add(fileAndFolderDto);
}
for(Fileindex fileindex:list1)
{
FileAndFolderDto fileAndFolderDto=new FileAndFolderDto();
fileAndFolderDto.setId(String.valueOf(fileindex.getFileid()));
fileAndFolderDto.setName(fileindex.getName());
fileAndFolderDto.setUpdatetime(fileindex.getUpdatetime());
fileAndFolderDto.setType(1);
fileAndFolderDto.setSize(fileindex.getSize());
fileAndFolderDto.setFiletype(fileindex.getFiletype());
fileAndFolderDto.setSharetype(fileindex.getSharetype());
list2.add(fileAndFolderDto);
}
return list2;
}
@Override
public List<FileAndFolderDto> findPublicAllFileAndFolder(String fatherFolderid) {
List<Folder> list = folderMapper.selectPublicByFatherFolder(fatherFolderid);
List<Fileindex> list1 = fileindexMapper.selectPublicByFatherFolder(fatherFolderid);
List<FileAndFolderDto> list2 = new ArrayList<>();
for (Folder folder : list) {
FileAndFolderDto fileAndFolderDto = new FileAndFolderDto();
fileAndFolderDto.setId(folder.getFolderid());
fileAndFolderDto.setName(folder.getName());
fileAndFolderDto.setSharetype(folder.getSharetype());
fileAndFolderDto.setUpdatetime(folder.getUpdatetime());
list2.add(fileAndFolderDto);
}
for (Fileindex fileindex : list1) {
FileAndFolderDto fileAndFolderDto = new FileAndFolderDto();
fileAndFolderDto.setId(String.valueOf(fileindex.getFileid()));
fileAndFolderDto.setName(fileindex.getName());
fileAndFolderDto.setUpdatetime(fileindex.getUpdatetime());
fileAndFolderDto.setType(1);
fileAndFolderDto.setSize(fileindex.getSize());
fileAndFolderDto.setFiletype(fileindex.getFiletype());
fileAndFolderDto.setSharetype(fileindex.getSharetype());
list2.add(fileAndFolderDto);
}
return list2;
}
@Override
public int addFolder(String filename, String fatherFolderid, int userid) {
Folder folder=new Folder();
RowkeyUtil rowkeyUtil=new RowkeyUtil();
folder.setFolderid(rowkeyUtil.getRowkey());
folder.setCreatetime(DateUtil.DateToString("yyyy-MM-dd HH:mm:ss", new Date()));
folder.setFatherfolderid(fatherFolderid);
folder.setUpdatetime(DateUtil.DateToString("yyyy-MM-dd HH:mm:ss", new Date()));
folder.setName(filename);
folder.setSharetype(0);
folder.setUserid(userid);
folder.setIsdelete(0);
return folderMapper.insert(folder);
}
@Override
public boolean isexist(String foldername, String fatherFolderid) {
Folder folder;
folder=folderMapper.selectByname(foldername,fatherFolderid);
return folder!=null;
}
@Override
public int delteFolder(String folderid) {
//删除其实是伪善除
return folderMapper.updateisdelete(1, folderid,DateUtil.DateToString("yyyy-MM-dd HH:mm:ss", new Date()));
}
@Override
public int updateFoler(String foldername, String folderid) {
Folder folder=new Folder();
folder.setFolderid(folderid);
folder.setUpdatetime(DateUtil.DateToString("yyyy-MM-dd HH:mm:ss", new Date()));
folder.setName(foldername);
return folderMapper.updateByPrimaryKey(folder);
}
@Override
public int changesharetype(int sharetype, int type, String fileid) {
if(type==0)
{
Folder folder=new Folder();
folder.setFolderid(fileid);
folder.setSharetype(sharetype);
return folderMapper.updateByPrimaryKey(folder);
}else{
Fileindex fileindex=new Fileindex();
fileindex.setFileid(Integer.valueOf(fileid));
fileindex.setFileid(Integer.valueOf(fileid));
fileindex.setSharetype(sharetype);
return fileindexMapper.updateByPrimaryKey(fileindex);
}
}
@Override
public boolean isexistfile(String filename, String fatherFolderid) {
Fileindex fileindex;
fileindex=fileindexMapper.selectByname(filename,fatherFolderid);
return fileindex!=null;
}
public int updateFileName(String filname, int fileid) {
Fileindex fileindex=new Fileindex();
fileindex.setFileid(Integer.valueOf(fileid));
fileindex.setUpdatetime(DateUtil.DateToString("yyyy-MM-dd HH:mm:ss", new Date()));
fileindex.setName(filname);
return fileindexMapper.updateByPrimaryKey(fileindex);
}
@Override
public int deleteFile(int fileid) {
Fileindex fileindex=new Fileindex();
fileindex.setFileid(Integer.valueOf(fileid));
fileindex.setIsdelete(1);
fileindex.setDeletetime(DateUtil.DateToString("yyyy-MM-dd HH:mm:ss", new Date()));
return fileindexMapper.updateByPrimaryKey(fileindex);
}
@Override
public List<FolderDto> getFolderTree(int userid) {
List<Folder> list=folderMapper.selectByUserid(userid);
List<FolderDto> list1=new ArrayList<>();
for(Folder f:list)
{
FolderDto folderDto=new FolderDto(f);
list1.add(folderDto);
}
return list1;
}
@Override
@Transactional(rollbackFor = {RuntimeException.class, Error.class})
public int copyFolder(String folderid, String aimFolderid, int userid) {
//先把自己给存了
Folder folderfirst=folderMapper.selectByPrimaryKey(folderid);
folderfirst.setFatherfolderid(aimFolderid);
addFolder(folderfirst.getName(),folderfirst.getFatherfolderid(),userid);
List<Folder> list=new ArrayList<>();
list.add(folderfirst);
while (list.size()>0)
{
List<Folder> folderList=new ArrayList<>();
//插入文件夹
for(Folder folder:list)
{
Fo
yava_free
- 粉丝: 5329
- 资源: 2089
最新资源
- 图形配置运动控制软件框架Demo 开发语言:C# 1.图形可放大缩小,任意位置摆放,工具增删改; 2.参数加载,另存为,保存; 3.仿真界面显示,程序可增删改; 4.目前适配SMC-604控制器
- Matlab通信边缘计算通信仿真 雷达跟踪算法matlab 跟踪滤波:卡尔曼滤波、扩展卡尔曼滤波、无迹卡尔曼滤波 matlab遗传算法粒子群路径规划算法改进
- 狼群算法求解柔性车间调度matlab版 有源码提供学习 可直接运行
- lunwen复现基于改进人工鱼群法的机器人,无人机,无人车,无人船的路径规划算法,MATLAB 在基本算法中加入了自适应视野和步长,加入了启发选择机制 该代码运行结果是那四个栅格地图的一个,只包含I
- 永磁同步电机直接公式法计算,它是将MTPA和弱磁结合起来应用,弱磁方法选择的是公式法(直接计算法) 包括直接法弱磁控制基本原理、实现方法及仿真 最最重要的提供从内环到外环电流环的仿真步骤,各个参数
- 三相逆变器之下垂控制?负载突变分析 图一控制阶跃信号为0.7 图二整体结构控制图 图三负载突变时,电流幅值发生变化曲线图 图四负载突变时,功率发生变化曲线图
- 灰狼算法优化支持向量机(GWO- VMD) 1、适合新手学习使用、保证运行哦 2、GWOSVM,gwosvm 适合新手学习,研究程序,代码很齐全 3、注释也很多,(matlab)程序哦 4、带入接带
- 光伏逆变器低电压穿越仿真模型,boost加NPC拓扑结构,基于MATLAB Simulink建模仿真 具备中点平衡SVPWM控制,正负序分离控制,pll,可进行低电压穿越仿真 仿真模型使用MATL
- 交错并联Boost PFC仿真电路模型 采用输出电压外环,电感电流内环的双闭环控制方式 交流侧输入电流畸变小,波形良好,如效果图所示 simulink仿真 matlab simulink仿真模型
- 永磁同步电机最大转矩电流比控制MTPA,id=0控制仿真及其对比,可帮助更好理解其区别 MTPA单位电流产生最大的输出扭矩,或者具有相同转矩情况下该电流幅值最小,该控制方法相对电流小=可以减小电机损
- comsol固态纳米孔稳态仿真
- STM32单片机指纹密码锁仿真 仿真程序 功能: 1.键盘解锁 2.指纹解锁 3.可修改密码 3.蜂鸣器 警报 4.LED灯 5.LCD显示屏 资料(源码 proteus仿真电路 演示视频)
- 西门子PID程序西门子PLC 1200和多台G120西门子变频器Modbud RTU通讯,带西门子触摸屏,带变频器参数 Modbus通讯报文详细讲解,PID自写FB块无密码可以直接应用到程序,PID带
- 光伏系统+boost电路+单相spwm逆变并网仿真 直流母线电压400V 输出交流电压220V 负载可调 THD小于5% 纹波小 simulink
- 基于yolov5的布匹缺陷检测(含源码和数据集)
- 永磁同步电机超前角弱磁控制,抵抗负载扰动,切弱磁的过程较为平滑,主要原理是通过电压反馈,得到偏转角度theta,并通过id=iscos(theta)的方式控制弱磁电流 该弱磁控制为一个多闭环系统,由
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈