Search in sources :

Example 1 with File

use of com.zyd.blog.business.entity.File in project OneBlog by zhangyd-c.

the class BizFileServiceImpl method findPageBreakByCondition.

@Override
public PageInfo<File> findPageBreakByCondition(FileConditionVO vo) {
    PageHelper.startPage(vo.getPageNumber(), vo.getPageSize());
    List<BizFile> list = shopFileMapper.findPageBreakByCondition(vo);
    List<File> boList = getFiles(list);
    if (boList == null)
        return null;
    PageInfo bean = new PageInfo<BizFile>(list);
    bean.setList(boList);
    return bean;
}
Also used : PageInfo(com.github.pagehelper.PageInfo) BizFile(com.zyd.blog.persistence.beans.BizFile) MultipartFile(org.springframework.web.multipart.MultipartFile) File(com.zyd.blog.business.entity.File) BizFile(com.zyd.blog.persistence.beans.BizFile)

Example 2 with File

use of com.zyd.blog.business.entity.File in project OneBlog by zhangyd-c.

the class BizFileServiceImpl method getByPrimaryKey.

@Override
public File getByPrimaryKey(Long primaryKey) {
    Assert.notNull(primaryKey, "Invalid parameter");
    BizFile entity = shopFileMapper.selectByPrimaryKey(primaryKey);
    return new File(entity);
}
Also used : BizFile(com.zyd.blog.persistence.beans.BizFile) MultipartFile(org.springframework.web.multipart.MultipartFile) File(com.zyd.blog.business.entity.File) BizFile(com.zyd.blog.persistence.beans.BizFile)

Example 3 with File

use of com.zyd.blog.business.entity.File in project OneBlog by zhangyd-c.

the class BizFileServiceImpl method selectFileByPathAndUploadType.

@Override
public File selectFileByPathAndUploadType(String filePath, String uploadType) {
    if (StringUtils.isEmpty(filePath)) {
        return null;
    }
    BizFile file = new BizFile();
    file.setFilePath(filePath);
    if (StringUtils.isEmpty(uploadType)) {
        file.setUploadType(uploadType);
    }
    List<BizFile> fileList = shopFileMapper.select(file);
    return CollectionUtils.isEmpty(fileList) ? null : new File(fileList.get(0));
}
Also used : BizFile(com.zyd.blog.persistence.beans.BizFile) MultipartFile(org.springframework.web.multipart.MultipartFile) File(com.zyd.blog.business.entity.File) BizFile(com.zyd.blog.persistence.beans.BizFile)

Example 4 with File

use of com.zyd.blog.business.entity.File in project OneBlog by zhangyd-c.

the class BizFileServiceImpl method remove.

@Override
@Transactional(rollbackFor = Exception.class)
public void remove(Long[] ids) {
    for (Long id : ids) {
        File oldFile = this.getByPrimaryKey(id);
        this.removeByPrimaryKey(id);
        try {
            FileUploader uploader = new GlobalFileUploader();
            uploader.delete(oldFile.getFilePath(), oldFile.getUploadType());
        } catch (Exception ignored) {
        }
    }
}
Also used : GlobalFileUploader(com.zyd.blog.plugin.file.GlobalFileUploader) FileUploader(com.zyd.blog.file.FileUploader) GlobalFileUploader(com.zyd.blog.plugin.file.GlobalFileUploader) BizFile(com.zyd.blog.persistence.beans.BizFile) MultipartFile(org.springframework.web.multipart.MultipartFile) File(com.zyd.blog.business.entity.File) GlobalFileException(com.zyd.blog.file.exception.GlobalFileException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with File

use of com.zyd.blog.business.entity.File in project OneBlog by zhangyd-c.

the class BaseFileUploader method saveFile.

VirtualFile saveFile(VirtualFile virtualFile, boolean save, String uploadType) {
    if (save) {
        BizFileService fileService = SpringContextHolder.getBean(BizFileService.class);
        try {
            SysConfigService configService = SpringContextHolder.getBean(SysConfigService.class);
            Map<String, Object> config = configService.getConfigs();
            String storageType = (String) config.get(ConfigKeyEnum.STORAGE_TYPE.getKey());
            BizFile fileInfo = BeanConvertUtil.doConvert(virtualFile, BizFile.class);
            User sessionUser = SessionUtil.getUser();
            fileInfo.setUserId(null == sessionUser ? null : sessionUser.getId());
            fileInfo.setUploadType(uploadType);
            fileInfo.setStorageType(storageType);
            fileService.insert(new File(fileInfo));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return virtualFile;
}
Also used : User(com.zyd.blog.business.entity.User) SysConfigService(com.zyd.blog.business.service.SysConfigService) BizFileService(com.zyd.blog.business.service.BizFileService) VirtualFile(com.zyd.blog.file.entity.VirtualFile) BizFile(com.zyd.blog.persistence.beans.BizFile) File(com.zyd.blog.business.entity.File) ZhydException(com.zyd.blog.framework.exception.ZhydException) GlobalFileException(com.zyd.blog.file.exception.GlobalFileException) BizFile(com.zyd.blog.persistence.beans.BizFile)

Aggregations

File (com.zyd.blog.business.entity.File)6 BizFile (com.zyd.blog.persistence.beans.BizFile)6 MultipartFile (org.springframework.web.multipart.MultipartFile)4 BizFileService (com.zyd.blog.business.service.BizFileService)2 VirtualFile (com.zyd.blog.file.entity.VirtualFile)2 GlobalFileException (com.zyd.blog.file.exception.GlobalFileException)2 PageInfo (com.github.pagehelper.PageInfo)1 User (com.zyd.blog.business.entity.User)1 SysConfigService (com.zyd.blog.business.service.SysConfigService)1 FileUploader (com.zyd.blog.file.FileUploader)1 ZhydException (com.zyd.blog.framework.exception.ZhydException)1 GlobalFileUploader (com.zyd.blog.plugin.file.GlobalFileUploader)1 Transactional (org.springframework.transaction.annotation.Transactional)1