mirror of
https://gitee.com/bookshelfplus/bookshelfplus
synced 2025-09-22 01:30:40 +08:00
后端获取文件列表 Api 完成
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package plus.bookshelf.Service.Impl;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import plus.bookshelf.Dao.DO.FileDO;
|
||||
import plus.bookshelf.Dao.Mapper.FileDOMapper;
|
||||
import plus.bookshelf.Service.Model.FileModel;
|
||||
import plus.bookshelf.Service.Service.FileService;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class FileServiceImpl implements FileService {
|
||||
|
||||
@Autowired
|
||||
FileDOMapper fileDOMapper;
|
||||
|
||||
/**
|
||||
* 列出所有文件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<FileModel> list() throws InvocationTargetException, IllegalAccessException {
|
||||
FileDO[] fileDOS = fileDOMapper.selectAll();
|
||||
|
||||
List<FileModel> fileModels = new ArrayList<>();
|
||||
for (FileDO fileDO : fileDOS) {
|
||||
FileModel fileModel = convertFromDataObject(fileDO);
|
||||
fileModels.add(fileModel);
|
||||
}
|
||||
|
||||
return fileModels;
|
||||
}
|
||||
|
||||
private FileModel convertFromDataObject(FileDO fileDO) throws InvocationTargetException, IllegalAccessException {
|
||||
FileModel fileModel = new FileModel();
|
||||
BeanUtils.copyProperties(fileDO, fileModel);
|
||||
return fileModel;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user