调整
This commit is contained in:
parent
1c901d71a0
commit
e3a0c8ef2b
@ -1,24 +1,30 @@
|
||||
package me.zhengjie.modules.front.rest;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.zhengjie.annotation.Log;
|
||||
import me.zhengjie.config.properties.FileProperties;
|
||||
import me.zhengjie.exception.BadRequestException;
|
||||
import me.zhengjie.modules.front.domain.dto.LoginVo;
|
||||
import me.zhengjie.modules.front.domain.dto.MyDeviceCriteria;
|
||||
import me.zhengjie.modules.security.service.dto.JwtUserDto;
|
||||
import me.zhengjie.modules.system.domain.BusDevice;
|
||||
import me.zhengjie.modules.system.domain.BusUser;
|
||||
import me.zhengjie.modules.system.domain.dto.BusDeviceQueryCriteria;
|
||||
import me.zhengjie.modules.system.service.BusDeviceService;
|
||||
import me.zhengjie.modules.system.service.BusUserService;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import me.zhengjie.utils.PageResult;
|
||||
import me.zhengjie.utils.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@ -29,6 +35,7 @@ public class BusUserController {
|
||||
|
||||
@Autowired private BusUserService busUserService;
|
||||
@Autowired private BusDeviceService busDeviceService;
|
||||
@Autowired private FileProperties fileProperties;
|
||||
|
||||
@Log("我的设备")
|
||||
@GetMapping(value = "myDevice")
|
||||
@ -67,6 +74,22 @@ public class BusUserController {
|
||||
return new ResponseEntity<>("修改成功", HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("上传图片")
|
||||
@ApiOperation("上传图片")
|
||||
@PostMapping(value = "/pictures")
|
||||
public ResponseEntity<String> uploadPicture(@RequestParam MultipartFile file) {
|
||||
// 判断文件是否为图片
|
||||
String suffix = FileUtil.getExtensionName(file.getOriginalFilename());
|
||||
if(!FileUtil.IMAGE.equals(FileUtil.getFileType(suffix))){
|
||||
throw new BadRequestException("只能上传图片");
|
||||
}
|
||||
String type = FileUtil.getFileType(suffix);
|
||||
File uploadFile = FileUtil.upload(file, fileProperties.getPath().getPath() + type + File.separator);
|
||||
if(ObjectUtil.isNull(uploadFile)){
|
||||
throw new BadRequestException("上传失败");
|
||||
}
|
||||
return new ResponseEntity<>(file.getName(), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user