| | |
| | | package com.yuanchu.mom.controller; |
| | | |
| | | |
| | | import cn.hutool.core.lang.UUID; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.annotation.ValueAuth; |
| | | import com.yuanchu.mom.pojo.Device; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | return Result.success(deviceService.search(status, deviceName, specificationModel, largeCategory)); |
| | | } |
| | | |
| | | //图片上传 |
| | | @ApiOperation(value = "图片上传") |
| | | @RequestMapping(value = "/uploadFile", method = RequestMethod.POST) |
| | | public Result uploadFile(MultipartFile file, HttpServletRequest request) throws IOException { |
| | | //获取文件名称 |
| | | HashMap<String, String> list = new HashMap<>(); |
| | | String filename = file.getOriginalFilename(); |
| | | String s = filename.substring(filename.lastIndexOf("."), filename.length()); |
| | | |
| | | System.out.println(filename); |
| | | //获取真实路径 |
| | | String realPath = request.getServletContext().getRealPath("/Users/gaoaoy/webapp/images"); |
| | | //创建文件 |
| | | File file1 = new File(realPath); |
| | | if (!file1.exists()) { |
| | | file1.mkdirs(); |
| | | } |
| | | file.transferTo(new File(file1 + "/" + filename)); |
| | | String ss= filename; |
| | | UUID uuid = UUID.randomUUID(); |
| | | ss = uuid.toString() + s; |
| | | String ful = "/Users/gaoaoy/webapp/images" + ss; |
| | | System.out.println(file1); |
| | | |
| | | list.put("url", ful); |
| | | list.put("name", filename); |
| | | return Result.success(list); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取设备负责人") |
| | | @GetMapping("/selectDevicePrincipal") |
| | | @ValueAuth |
| | | public Result selectDevicePrincipal() { |
| | | return Result.success(deviceService.selectDevicePrincipal()); |
| | | } |
| | | } |
| | | |