Commit 5b9213f2 authored by Zheng Jie's avatar Zheng Jie
Browse files

代码优化

parent a74cf51c
......@@ -20,8 +20,10 @@ import me.zhengjie.annotation.Log;
import me.zhengjie.domain.LocalStorage;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.service.LocalStorageService;
import me.zhengjie.service.dto.LocalStorageDto;
import me.zhengjie.service.dto.LocalStorageQueryCriteria;
import me.zhengjie.utils.FileUtil;
import me.zhengjie.utils.PageResult;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
......@@ -48,7 +50,7 @@ public class LocalStorageController {
@GetMapping
@ApiOperation("查询文件")
@PreAuthorize("@el.check('storage:list')")
public ResponseEntity<Object> queryFile(LocalStorageQueryCriteria criteria, Pageable pageable){
public ResponseEntity<PageResult<LocalStorageDto>> queryFile(LocalStorageQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(localStorageService.queryAll(criteria,pageable),HttpStatus.OK);
}
......@@ -69,7 +71,7 @@ public class LocalStorageController {
@ApiOperation("上传图片")
@PostMapping("/pictures")
public ResponseEntity<Object> uploadPicture(@RequestParam MultipartFile file){
public ResponseEntity<LocalStorage> uploadPicture(@RequestParam MultipartFile file){
// 判断文件是否为图片
String suffix = FileUtil.getExtensionName(file.getOriginalFilename());
if(!FileUtil.IMAGE.equals(FileUtil.getFileType(suffix))){
......
......@@ -24,6 +24,7 @@ import me.zhengjie.domain.QiniuConfig;
import me.zhengjie.domain.QiniuContent;
import me.zhengjie.service.dto.QiniuQueryCriteria;
import me.zhengjie.service.QiNiuService;
import me.zhengjie.utils.PageResult;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
......@@ -50,7 +51,7 @@ public class QiniuController {
private final QiNiuService qiNiuService;
@GetMapping(value = "/config")
public ResponseEntity<Object> queryQiNiuConfig(){
public ResponseEntity<QiniuConfig> queryQiNiuConfig(){
return new ResponseEntity<>(qiNiuService.find(), HttpStatus.OK);
}
......@@ -71,7 +72,7 @@ public class QiniuController {
@ApiOperation("查询文件")
@GetMapping
public ResponseEntity<Object> queryQiNiu(QiniuQueryCriteria criteria, Pageable pageable){
public ResponseEntity<PageResult<QiniuContent>> queryQiNiu(QiniuQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(qiNiuService.queryAll(criteria,pageable),HttpStatus.OK);
}
......
......@@ -43,7 +43,6 @@ public interface EmailService {
* 发送邮件
* @param emailVo 邮件发送的内容
* @param emailConfig 邮件配置
* @throws Exception /
*/
void send(EmailVo emailVo, EmailConfig emailConfig);
}
......@@ -18,6 +18,7 @@ package me.zhengjie.service;
import me.zhengjie.domain.LocalStorage;
import me.zhengjie.service.dto.LocalStorageDto;
import me.zhengjie.service.dto.LocalStorageQueryCriteria;
import me.zhengjie.utils.PageResult;
import org.springframework.data.domain.Pageable;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
......@@ -36,7 +37,7 @@ public interface LocalStorageService {
* @param pageable 分页参数
* @return /
*/
Object queryAll(LocalStorageQueryCriteria criteria, Pageable pageable);
PageResult<LocalStorageDto> queryAll(LocalStorageQueryCriteria criteria, Pageable pageable);
/**
* 查询全部数据
......
......@@ -18,6 +18,7 @@ package me.zhengjie.service;
import me.zhengjie.domain.QiniuConfig;
import me.zhengjie.domain.QiniuContent;
import me.zhengjie.service.dto.QiniuQueryCriteria;
import me.zhengjie.utils.PageResult;
import org.springframework.data.domain.Pageable;
import org.springframework.web.multipart.MultipartFile;
......@@ -50,7 +51,7 @@ public interface QiNiuService {
* @param pageable 分页参数
* @return /
*/
Object queryAll(QiniuQueryCriteria criteria, Pageable pageable);
PageResult<QiniuContent> queryAll(QiniuQueryCriteria criteria, Pageable pageable);
/**
* 查询全部
......
......@@ -52,7 +52,7 @@ public class LocalStorageServiceImpl implements LocalStorageService {
private final FileProperties properties;
@Override
public Object queryAll(LocalStorageQueryCriteria criteria, Pageable pageable){
public PageResult<LocalStorageDto> queryAll(LocalStorageQueryCriteria criteria, Pageable pageable){
Page<LocalStorage> page = localStorageRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(localStorageMapper::toDto));
}
......
......@@ -29,14 +29,10 @@ import me.zhengjie.domain.QiniuConfig;
import me.zhengjie.domain.QiniuContent;
import me.zhengjie.repository.QiniuContentRepository;
import me.zhengjie.service.dto.QiniuQueryCriteria;
import me.zhengjie.utils.QiNiuUtil;
import me.zhengjie.utils.*;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.repository.QiNiuConfigRepository;
import me.zhengjie.service.QiNiuService;
import me.zhengjie.utils.FileUtil;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp;
import me.zhengjie.utils.ValidationUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CachePut;
......@@ -84,7 +80,7 @@ public class QiNiuServiceImpl implements QiNiuService {
}
@Override
public Object queryAll(QiniuQueryCriteria criteria, Pageable pageable){
public PageResult<QiniuContent> queryAll(QiniuQueryCriteria criteria, Pageable pageable){
return PageUtil.toPage(qiniuContentRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
}
......
Supports Markdown
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