代码优化
This commit is contained in:
parent
0c228d18a8
commit
57b6138d8b
@ -8,18 +8,18 @@ import java.util.List;
|
|||||||
|
|
||||||
public interface IFileService extends IService<FileBean> {
|
public interface IFileService extends IService<FileBean> {
|
||||||
|
|
||||||
void insertFile(FileBean fileBean);
|
|
||||||
void batchInsertFile(List<FileBean> fileBeanList, Long userId);
|
void batchInsertFile(List<FileBean> fileBeanList, Long userId);
|
||||||
void updateFile(FileBean fileBean);
|
void updateFile(FileBean fileBean);
|
||||||
List<FileBean> selectFileByNameAndPath(FileBean fileBean);
|
List<FileBean> selectFileByNameAndPath(FileBean fileBean);
|
||||||
FileBean selectFileById(FileBean fileBean);
|
|
||||||
List<FileBean> selectFilePathTreeByUserId(FileBean fileBean);
|
List<FileBean> selectFilePathTreeByUserId(FileBean fileBean);
|
||||||
List<FileBean> selectFileList(FileBean fileBean);
|
List<FileBean> selectFileList(FileBean fileBean);
|
||||||
List<FileBean> selectFileListByIds(List<Integer> fileIdList);
|
|
||||||
|
|
||||||
List<FileBean> selectFileTreeListLikeFilePath(String filePath);
|
List<FileBean> selectFileTreeListLikeFilePath(String filePath);
|
||||||
void deleteFile(FileBean fileBean, UserBean sessionUserBean);
|
void deleteFile(FileBean fileBean, UserBean sessionUserBean);
|
||||||
void deleteFileByIds(List<Integer> fileIdList);
|
|
||||||
void updateFilepathByFilepath(String oldfilePath, String newfilePath, String fileName, String extendName);
|
void updateFilepathByFilepath(String oldfilePath, String newfilePath, String fileName, String extendName);
|
||||||
List<FileBean> selectFileByExtendName(List<String> fileNameList, long userId);
|
List<FileBean> selectFileByExtendName(List<String> fileNameList, long userId);
|
||||||
List<FileBean> selectFileNotInExtendNames(List<String> fileNameList, long userId);
|
List<FileBean> selectFileNotInExtendNames(List<String> fileNameList, long userId);
|
||||||
|
@ -22,10 +22,6 @@ public interface IFiletransferService {
|
|||||||
*/
|
*/
|
||||||
void uploadFile(HttpServletRequest request, FileBean fileBean, UserBean sessionUserBean);
|
void uploadFile(HttpServletRequest request, FileBean fileBean, UserBean sessionUserBean);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void deleteUserImageByIds(List<Integer> imageidList);
|
|
||||||
|
|
||||||
StorageBean selectStorageBean(StorageBean storageBean);
|
StorageBean selectStorageBean(StorageBean storageBean);
|
||||||
|
|
||||||
void insertStorageBean(StorageBean storageBean);
|
void insertStorageBean(StorageBean storageBean);
|
||||||
|
@ -62,7 +62,7 @@ public class FileController {
|
|||||||
|
|
||||||
fileBean.setUploadTime(DateUtil.getCurrentTime());
|
fileBean.setUploadTime(DateUtil.getCurrentTime());
|
||||||
|
|
||||||
fileService.insertFile(fileBean);
|
fileService.save(fileBean);
|
||||||
restResult.setSuccess(true);
|
restResult.setSuccess(true);
|
||||||
return restResult;
|
return restResult;
|
||||||
}
|
}
|
||||||
@ -124,6 +124,7 @@ public class FileController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fileBean.setFilePath(PathUtil.urlDecode(fileBean.getFilePath()));
|
fileBean.setFilePath(PathUtil.urlDecode(fileBean.getFilePath()));
|
||||||
|
|
||||||
List<FileBean> fileList = fileService.selectFileList(fileBean);
|
List<FileBean> fileList = fileService.selectFileList(fileBean);
|
||||||
|
|
||||||
restResult.setData(fileList);
|
restResult.setData(fileList);
|
||||||
|
@ -223,7 +223,7 @@ public class FiletransferController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RestResult<StorageBean> getStorage(@RequestHeader("token") String token) {
|
public RestResult<StorageBean> getStorage(@RequestHeader("token") String token) {
|
||||||
RestResult<StorageBean> restResult = new RestResult<StorageBean>();
|
RestResult<StorageBean> restResult = new RestResult<StorageBean>();
|
||||||
//UserBean sessionUserBean = (UserBean) SecurityUtils.getSubject().getPrincipal();
|
|
||||||
UserBean sessionUserBean = userService.getUserBeanByToken(token);
|
UserBean sessionUserBean = userService.getUserBeanByToken(token);
|
||||||
StorageBean storageBean = new StorageBean();
|
StorageBean storageBean = new StorageBean();
|
||||||
if (qiwenFileConfig.isShareMode()){
|
if (qiwenFileConfig.isShareMode()){
|
||||||
|
@ -19,66 +19,55 @@ import javax.persistence.*;
|
|||||||
@Entity
|
@Entity
|
||||||
@TableName("file")
|
@TableName("file")
|
||||||
public class FileBean {
|
public class FileBean {
|
||||||
/**
|
|
||||||
* 文件id
|
|
||||||
*/
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@TableId(type = IdType.AUTO)
|
@TableId(type = IdType.AUTO)
|
||||||
|
@Column(columnDefinition="bigint(20) comment '文件id'")
|
||||||
private Long fileId;
|
private Long fileId;
|
||||||
|
|
||||||
|
@Column(columnDefinition="bigint(20) comment '用户id'")
|
||||||
/**
|
|
||||||
* 用户id
|
|
||||||
*/
|
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(500) comment '文件url'")
|
||||||
* 文件URL
|
|
||||||
*/
|
|
||||||
private String fileUrl;
|
private String fileUrl;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(500) comment '文件路径'")
|
||||||
* 文件路径
|
|
||||||
*/
|
|
||||||
private String filePath;
|
private String filePath;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(25) comment '上传时间'")
|
||||||
* 上传时间
|
|
||||||
*/
|
|
||||||
private String uploadTime;
|
private String uploadTime;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(50) comment '时间戳名称'")
|
||||||
* 时间戳名称
|
|
||||||
*/
|
|
||||||
private String timeStampName;
|
private String timeStampName;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(10) comment '扩展名'")
|
||||||
* 扩展名
|
|
||||||
*/
|
|
||||||
private String extendName;
|
private String extendName;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(100) comment '文件名'")
|
||||||
* 文件名
|
|
||||||
*/
|
|
||||||
private String fileName;
|
private String fileName;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="bigint(10) comment '文件大小'")
|
||||||
* 文件大小
|
|
||||||
*/
|
|
||||||
private Long fileSize;
|
private Long fileSize;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="int(1) comment '是否是目录 0-否, 1-是'")
|
||||||
* 是否是目录
|
|
||||||
*/
|
|
||||||
private Integer isDir;
|
private Integer isDir;
|
||||||
|
|
||||||
|
@Column(columnDefinition="int(1) comment '是否是OSS云存储 0-否, 1-是'")
|
||||||
private Integer isOSS;
|
private Integer isOSS;
|
||||||
|
|
||||||
|
@Column(columnDefinition="int(11) comment '文件引用数量'")
|
||||||
private Integer pointCount;
|
private Integer pointCount;
|
||||||
|
|
||||||
|
@Column(columnDefinition="int(11) comment '文件删除标志 0/null-正常, 1-删除'")
|
||||||
private Integer deleteFlag;
|
private Integer deleteFlag;
|
||||||
|
|
||||||
|
@Column(columnDefinition="varchar(25) comment '删除时间'")
|
||||||
|
private String deleteTime;
|
||||||
|
|
||||||
|
@Column(columnDefinition="varchar(32) comment 'md5标识'")
|
||||||
|
private String identifier;
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String oldFilePath;
|
private String oldFilePath;
|
||||||
@ -115,6 +104,5 @@ public class FileBean {
|
|||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private long currentChunkSize;
|
private long currentChunkSize;
|
||||||
|
|
||||||
private String identifier;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,21 +13,16 @@ import javax.persistence.*;
|
|||||||
@Entity
|
@Entity
|
||||||
@TableName("storage")
|
@TableName("storage")
|
||||||
public class StorageBean {
|
public class StorageBean {
|
||||||
/**
|
|
||||||
* 存储id
|
|
||||||
*/
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(columnDefinition="bigint(20) comment '存储id'")
|
||||||
private Long storageId;
|
private Long storageId;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="bigint(20) comment '用户id'")
|
||||||
* 用户id
|
|
||||||
*/
|
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="bigint(20) comment '存储大小'")
|
||||||
* 存储大小
|
|
||||||
*/
|
|
||||||
private Long storageSize;
|
private Long storageSize;
|
||||||
|
|
||||||
public StorageBean() {
|
public StorageBean() {
|
||||||
|
@ -19,36 +19,28 @@ import java.util.List;
|
|||||||
@Entity
|
@Entity
|
||||||
@TableName("user")
|
@TableName("user")
|
||||||
public class UserBean {
|
public class UserBean {
|
||||||
/**
|
|
||||||
* 用户id
|
|
||||||
*/
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(columnDefinition="bigint(20) comment '用户id'")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(30) comment 'openId qq登录使用'")
|
||||||
* openId qq登录使用
|
|
||||||
*/
|
|
||||||
private String openId;
|
private String openId;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(30) comment '用户名'")
|
||||||
* 用户名称
|
|
||||||
*/
|
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(30) comment '真实名'")
|
||||||
* 真实名
|
|
||||||
*/
|
|
||||||
private String realname;
|
private String realname;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(35) comment '密码'")
|
||||||
* 密码
|
|
||||||
*/
|
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qq密码
|
* qq密码
|
||||||
*/
|
*/
|
||||||
|
@Column(columnDefinition="varchar(35) comment 'qq密码'")
|
||||||
private String qqPassword;
|
private String qqPassword;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,70 +49,45 @@ public class UserBean {
|
|||||||
@Transient
|
@Transient
|
||||||
private String passwordAgain;
|
private String passwordAgain;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(15) comment '手机号码'")
|
||||||
* 手机号码
|
|
||||||
*/
|
|
||||||
private String telephone;
|
private String telephone;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(100) comment '邮箱'")
|
||||||
* 邮箱
|
|
||||||
*/
|
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(3) comment '年龄'")
|
||||||
* 年龄
|
|
||||||
*/
|
|
||||||
private String sex;
|
private String sex;
|
||||||
|
|
||||||
/**
|
|
||||||
* 生日
|
@Column(columnDefinition="varchar(30) comment '生日'")
|
||||||
*/
|
|
||||||
private String birthday;
|
private String birthday;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(10) comment '省'")
|
||||||
* 省
|
|
||||||
*/
|
|
||||||
private String addrProvince;
|
private String addrProvince;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(10) comment '市'")
|
||||||
* 市
|
|
||||||
*/
|
|
||||||
private String addrCity;
|
private String addrCity;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(10) comment '区'")
|
||||||
* 区
|
|
||||||
*/
|
|
||||||
private String addrArea;
|
private String addrArea;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(50) comment '行业'")
|
||||||
* 行业
|
|
||||||
*/
|
|
||||||
private String industry;
|
private String industry;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(50) comment '职位'")
|
||||||
* 职位
|
|
||||||
*/
|
|
||||||
private String position;
|
private String position;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(5000) comment '介绍'")
|
||||||
* 介绍
|
|
||||||
*/
|
|
||||||
private String intro;
|
private String intro;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(20) comment '盐值'")
|
||||||
* 盐值
|
|
||||||
*/
|
|
||||||
private String salt;//加密密码的盐
|
private String salt;//加密密码的盐
|
||||||
//private byte state;//用户状态,0:创建未认证(比如没有激活,没有输入验证码等等)--等待验证的用户 , 1:正常状态,2:用户被锁定.
|
//private byte state;//用户状态,0:创建未认证(比如没有激活,没有输入验证码等等)--等待验证的用户 , 1:正常状态,2:用户被锁定.
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(100) comment '用户头像URL'")
|
||||||
* 用户头像URL
|
|
||||||
*/
|
|
||||||
private String imageUrl;
|
private String imageUrl;
|
||||||
|
|
||||||
/**
|
@Column(columnDefinition="varchar(30) comment '注册时间'")
|
||||||
* 注册时间
|
|
||||||
*/
|
|
||||||
private String registerTime;
|
private String registerTime;
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,19 +9,13 @@ import java.util.List;
|
|||||||
|
|
||||||
public interface FileMapper extends BaseMapper<FileBean> {
|
public interface FileMapper extends BaseMapper<FileBean> {
|
||||||
|
|
||||||
void insertFile(FileBean fileBean);
|
|
||||||
void batchInsertFile(List<FileBean> fileBeanList);
|
void batchInsertFile(List<FileBean> fileBeanList);
|
||||||
void updateFile(FileBean fileBean);
|
void updateFile(FileBean fileBean);
|
||||||
List<FileBean> selectFileByNameAndPath(FileBean fileBean);
|
|
||||||
FileBean selectFileById(FileBean fileBean);
|
|
||||||
List<FileBean> selectFilePathTreeByUserId(FileBean fileBean);
|
|
||||||
List<FileBean> selectFileList(FileBean fileBean);
|
List<FileBean> selectFileList(FileBean fileBean);
|
||||||
List<FileBean> selectFileTreeListLikeFilePath(FileBean fileBean);
|
|
||||||
void deleteFileById(FileBean fileBean);
|
|
||||||
void deleteFileByIds(List<Integer> fileIdList);
|
|
||||||
List<FileBean> selectFileListByIds(List<Integer> fileIdList);
|
|
||||||
void updateFilepathByFilepath(String oldfilePath, String newfilePath);
|
void updateFilepathByFilepath(String oldfilePath, String newfilePath);
|
||||||
void updateFilepathByPathAndName(String oldfilePath, String newfilePath, String fileName, String extendName);
|
void updateFilepathByPathAndName(String oldfilePath, String newfilePath, String fileName, String extendName);
|
||||||
List<FileBean> selectFileByExtendName(@Param("fileNameList") List<String> fileNameList,
|
|
||||||
@Param("userId") long userId);
|
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,9 @@ import com.qiwenshare.file.domain.StorageBean;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface FiletransferMapper {
|
public interface StorageMapper {
|
||||||
|
|
||||||
|
|
||||||
void deleteUserImageByIds(List<Integer> imageidList);
|
|
||||||
|
|
||||||
StorageBean selectStorageBean(StorageBean storageBean);
|
StorageBean selectStorageBean(StorageBean storageBean);
|
||||||
|
|
@ -33,14 +33,8 @@ public class FileService extends ServiceImpl<FileMapper, FileBean> implements IF
|
|||||||
@Resource
|
@Resource
|
||||||
QiwenFileConfig qiwenFileConfig;
|
QiwenFileConfig qiwenFileConfig;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void insertFile(FileBean fileBean) {
|
|
||||||
fileMapper.insertFile(fileBean);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void batchInsertFile(List<FileBean> fileBeanList, Long userId) {
|
public void batchInsertFile(List<FileBean> fileBeanList, Long userId) {
|
||||||
// UserBean sessionUserBean = (UserBean) SecurityUtils.getSubject().getPrincipal();
|
|
||||||
StorageBean storageBean = filetransferService.selectStorageBean(new StorageBean(userId));
|
StorageBean storageBean = filetransferService.selectStorageBean(new StorageBean(userId));
|
||||||
long fileSizeSum = 0;
|
long fileSizeSum = 0;
|
||||||
for (FileBean fileBean : fileBeanList) {
|
for (FileBean fileBean : fileBeanList) {
|
||||||
@ -65,17 +59,18 @@ public class FileService extends ServiceImpl<FileMapper, FileBean> implements IF
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FileBean> selectFileByNameAndPath(FileBean fileBean) {
|
public List<FileBean> selectFileByNameAndPath(FileBean fileBean) {
|
||||||
return fileMapper.selectFileByNameAndPath(fileBean);
|
LambdaQueryWrapper<FileBean> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
lambdaQueryWrapper.eq(FileBean::getFileName, fileBean.getFileName()).eq(FileBean::getFilePath, fileBean.getFilePath());
|
||||||
|
return fileMapper.selectList(lambdaQueryWrapper);
|
||||||
|
// return fileMapper.selectFileByNameAndPath(fileBean);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public FileBean selectFileById(FileBean fileBean) {
|
|
||||||
return fileMapper.selectFileById(fileBean);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FileBean> selectFilePathTreeByUserId(FileBean fileBean) {
|
public List<FileBean> selectFilePathTreeByUserId(FileBean fileBean) {
|
||||||
return fileMapper.selectFilePathTreeByUserId(fileBean);
|
LambdaQueryWrapper<FileBean> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
lambdaQueryWrapper.eq(FileBean::getUserId, fileBean.getUserId()).eq(FileBean::getIsDir, 1);
|
||||||
|
return fileMapper.selectList(lambdaQueryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -83,10 +78,6 @@ public class FileService extends ServiceImpl<FileMapper, FileBean> implements IF
|
|||||||
return fileMapper.selectFileList(fileBean);
|
return fileMapper.selectFileList(fileBean);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<FileBean> selectFileListByIds(List<Integer> fileIdList) {
|
|
||||||
return fileMapper.selectFileListByIds(fileIdList);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FileBean> selectFileTreeListLikeFilePath(String filePath) {
|
public List<FileBean> selectFileTreeListLikeFilePath(String filePath) {
|
||||||
@ -98,7 +89,10 @@ public class FileService extends ServiceImpl<FileMapper, FileBean> implements IF
|
|||||||
|
|
||||||
fileBean.setFilePath(filePath);
|
fileBean.setFilePath(filePath);
|
||||||
|
|
||||||
return fileMapper.selectFileTreeListLikeFilePath(fileBean);
|
LambdaQueryWrapper<FileBean> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
lambdaQueryWrapper.likeLeft(FileBean::getFilePath, filePath);
|
||||||
|
return fileMapper.selectList(lambdaQueryWrapper);
|
||||||
|
// return fileMapper.selectFileTreeListLikeFilePath(fileBean);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -114,7 +108,7 @@ public class FileService extends ServiceImpl<FileMapper, FileBean> implements IF
|
|||||||
for (int i = 0; i < fileList.size(); i++){
|
for (int i = 0; i < fileList.size(); i++){
|
||||||
FileBean file = fileList.get(i);
|
FileBean file = fileList.get(i);
|
||||||
//1.1、删除数据库文件
|
//1.1、删除数据库文件
|
||||||
fileMapper.deleteFileById(file);
|
fileMapper.deleteById(file.getFileId());
|
||||||
//1.2、如果是文件,需要记录文件大小
|
//1.2、如果是文件,需要记录文件大小
|
||||||
if (file.getIsDir() != 1){
|
if (file.getIsDir() != 1){
|
||||||
deleteSize += file.getFileSize();
|
deleteSize += file.getFileSize();
|
||||||
@ -133,9 +127,9 @@ public class FileService extends ServiceImpl<FileMapper, FileBean> implements IF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//2、根目录单独删除
|
//2、根目录单独删除
|
||||||
fileMapper.deleteFileById(fileBean);
|
fileMapper.deleteById(fileBean.getFileId());
|
||||||
}else{
|
}else{
|
||||||
fileMapper.deleteFileById(fileBean);
|
fileMapper.deleteById(fileBean.getFileId());
|
||||||
deleteSize = FileOperation.getFileSize(fileUrl);
|
deleteSize = FileOperation.getFileSize(fileUrl);
|
||||||
if (deleteSize == 0) {
|
if (deleteSize == 0) {
|
||||||
deleteSize = fileBean.getFileSize();
|
deleteSize = fileBean.getFileSize();
|
||||||
@ -163,11 +157,6 @@ public class FileService extends ServiceImpl<FileMapper, FileBean> implements IF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteFileByIds(List<Integer> fileIdList) {
|
|
||||||
fileMapper.deleteFileByIds(fileIdList);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateFilepathByFilepath(String oldfilePath, String newfilePath, String fileName, String extendName) {
|
public void updateFilepathByFilepath(String oldfilePath, String newfilePath, String fileName, String extendName) {
|
||||||
|
@ -15,10 +15,10 @@ import com.qiwenshare.file.api.IFiletransferService;
|
|||||||
import com.qiwenshare.common.domain.AliyunOSS;
|
import com.qiwenshare.common.domain.AliyunOSS;
|
||||||
import com.qiwenshare.file.config.QiwenFileConfig;
|
import com.qiwenshare.file.config.QiwenFileConfig;
|
||||||
import com.qiwenshare.file.mapper.FileMapper;
|
import com.qiwenshare.file.mapper.FileMapper;
|
||||||
import com.qiwenshare.file.mapper.FiletransferMapper;
|
|
||||||
import com.qiwenshare.file.domain.FileBean;
|
import com.qiwenshare.file.domain.FileBean;
|
||||||
import com.qiwenshare.file.domain.StorageBean;
|
import com.qiwenshare.file.domain.StorageBean;
|
||||||
import com.qiwenshare.file.domain.UserBean;
|
import com.qiwenshare.file.domain.UserBean;
|
||||||
|
import com.qiwenshare.file.mapper.StorageMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
||||||
@ -26,17 +26,13 @@ import org.springframework.stereotype.Service;
|
|||||||
public class FiletransferService implements IFiletransferService {
|
public class FiletransferService implements IFiletransferService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
FiletransferMapper filetransferMapper;
|
StorageMapper storageMapper;
|
||||||
@Resource
|
@Resource
|
||||||
FileMapper fileMapper;
|
FileMapper fileMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
QiwenFileConfig qiwenFileConfig;
|
QiwenFileConfig qiwenFileConfig;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteUserImageByIds(List<Integer> imageidList) {
|
|
||||||
filetransferMapper.deleteUserImageByIds(imageidList);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -92,21 +88,21 @@ public class FiletransferService implements IFiletransferService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StorageBean selectStorageBean(StorageBean storageBean) {
|
public StorageBean selectStorageBean(StorageBean storageBean) {
|
||||||
return filetransferMapper.selectStorageBean(storageBean);
|
return storageMapper.selectStorageBean(storageBean);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void insertStorageBean(StorageBean storageBean) {
|
public void insertStorageBean(StorageBean storageBean) {
|
||||||
filetransferMapper.insertStorageBean(storageBean);
|
storageMapper.insertStorageBean(storageBean);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateStorageBean(StorageBean storageBean) {
|
public void updateStorageBean(StorageBean storageBean) {
|
||||||
filetransferMapper.updateStorageBean(storageBean);
|
storageMapper.updateStorageBean(storageBean);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StorageBean selectStorageByUser(StorageBean storageBean) {
|
public StorageBean selectStorageByUser(StorageBean storageBean) {
|
||||||
return filetransferMapper.selectStorageByUser(storageBean);
|
return storageMapper.selectStorageByUser(storageBean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
package com.qiwenshare.file.service;
|
|
||||||
|
|
||||||
import javax.servlet.ServletRequestEvent;
|
|
||||||
import javax.servlet.ServletRequestListener;
|
|
||||||
import javax.servlet.annotation.WebListener;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
@WebListener
|
|
||||||
public class RequestListener implements ServletRequestListener {
|
|
||||||
|
|
||||||
public void requestInitialized(ServletRequestEvent sre) {
|
|
||||||
//将所有request请求都携带上httpSession
|
|
||||||
((HttpServletRequest) sre.getServletRequest()).getSession();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public RequestListener() {
|
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
|
||||||
|
|
||||||
public void requestDestroyed(ServletRequestEvent arg0) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
}
|
|
||||||
}
|
|
0
file-web/src/main/resources/banner.txt
Normal file
0
file-web/src/main/resources/banner.txt
Normal file
@ -6,13 +6,6 @@
|
|||||||
|
|
||||||
<mapper namespace="com.qiwenshare.file.mapper.FileMapper">
|
<mapper namespace="com.qiwenshare.file.mapper.FileMapper">
|
||||||
|
|
||||||
<insert id="insertFile" parameterType="com.qiwenshare.file.domain.FileBean">
|
|
||||||
INSERT ignore INTO file (userId, fileName,timeStampName, fileUrl,
|
|
||||||
filePath, extendName, uploadTime, fileSize, isDir)
|
|
||||||
VALUES (#{userId}, #{fileName},#{timeStampName},
|
|
||||||
#{fileUrl}, #{filePath}, #{extendName}, #{uploadTime},
|
|
||||||
#{fileSize}, #{isDir});
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<insert id="batchInsertFile" parameterType="java.util.List">
|
<insert id="batchInsertFile" parameterType="java.util.List">
|
||||||
INSERT ignore INTO file (userId, fileName,timeStampName, fileUrl,
|
INSERT ignore INTO file (userId, fileName,timeStampName, fileUrl,
|
||||||
@ -68,10 +61,6 @@
|
|||||||
</if>
|
</if>
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<select id="selectFileById" parameterType="com.qiwenshare.file.domain.FileBean" resultType="com.qiwenshare.file.domain.FileBean">
|
|
||||||
select * from file
|
|
||||||
where fileId = #{fileId}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectFileList" parameterType="com.qiwenshare.file.domain.FileBean" resultType="com.qiwenshare.file.domain.FileBean">
|
<select id="selectFileList" parameterType="com.qiwenshare.file.domain.FileBean" resultType="com.qiwenshare.file.domain.FileBean">
|
||||||
select * from file
|
select * from file
|
||||||
@ -79,56 +68,9 @@
|
|||||||
order by isDir desc, fileName
|
order by isDir desc, fileName
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectFileListByIds" resultType="com.qiwenshare.file.domain.FileBean" parameterType="int">
|
|
||||||
select * from file where fileId in
|
|
||||||
<foreach collection="list" open="(" separator="," close=")" item="fileId">
|
|
||||||
#{fileId}
|
|
||||||
</foreach>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectFileByExtendName" resultType="com.qiwenshare.file.domain.FileBean">
|
|
||||||
select * from file
|
|
||||||
where extendName in
|
|
||||||
<foreach collection="fileNameList" open="(" separator="," close=")" item="extendName">
|
|
||||||
#{extendName}
|
|
||||||
</foreach>
|
|
||||||
and userId = #{userId}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectFileTreeListLikeFilePath" parameterType="com.qiwenshare.file.domain.FileBean" resultType="com.qiwenshare.file.domain.FileBean">
|
|
||||||
select * from file
|
|
||||||
where filePath like N'${filePath}%'
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<delete id="deleteFileById" parameterType="com.qiwenshare.file.domain.FileBean">
|
|
||||||
DELETE FROM file WHERE fileId = #{fileId}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="deleteFileByIds" parameterType="int">
|
|
||||||
delete from file where fileId in
|
|
||||||
<foreach collection="list" open="(" separator="," close=")" item="fileId">
|
|
||||||
#{fileId}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<select id="selectFilePathTreeByUserId" parameterType="com.qiwenshare.file.domain.FileBean" resultType="com.qiwenshare.file.domain.FileBean">
|
|
||||||
SELECT * FROM file
|
|
||||||
WHERE isDir = 1 and userId=#{userId}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectFileByNameAndPath" parameterType="com.qiwenshare.file.domain.FileBean"
|
|
||||||
resultType="com.qiwenshare.file.domain.FileBean">
|
|
||||||
SELECT * FROM file
|
|
||||||
WHERE filename = #{fileName} AND filepath = #{filePath}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <select id="selectFileByExtendName" resultType="FileBean" parameterType="java.lang.String">-->
|
|
||||||
<!-- select * from file-->
|
|
||||||
<!-- where extendName in-->
|
|
||||||
<!-- <foreach collection="list" separator="," open="(" close=")" item="extendName">-->
|
|
||||||
<!-- #{extendName}-->
|
|
||||||
<!-- </foreach>-->
|
|
||||||
<!-- </select>-->
|
|
||||||
</mapper>
|
</mapper>
|
@ -4,7 +4,7 @@
|
|||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
<mapper namespace="com.qiwenshare.file.mapper.FiletransferMapper">
|
<mapper namespace="com.qiwenshare.file.mapper.StorageMapper">
|
||||||
|
|
||||||
|
|
||||||
<select id="selectStorageBean" resultType="com.qiwenshare.file.domain.StorageBean" parameterType="com.qiwenshare.file.domain.StorageBean">
|
<select id="selectStorageBean" resultType="com.qiwenshare.file.domain.StorageBean" parameterType="com.qiwenshare.file.domain.StorageBean">
|
Loading…
Reference in New Issue
Block a user