| | |
| | | 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 java.io.File; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | @RestController |
| | | @RequestMapping("/deviceScope") |
| | | public class DeviceController { |
| | | |
| | | |
| | | private DeviceService deviceService; |
| | | |
| | |
| | | return Result.success(deviceService.selectEquipmentOverview()); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取被授权人") |
| | | @GetMapping("/authorizedPerson") |
| | | @ValueAuth |
| | | public Result authorizedPerson() { |
| | | return Result.success(deviceService.authorizedPerson()); |
| | | } |
| | | |
| | | @ApiOperation(value = "搜索") |
| | | @GetMapping("/search") |
| | | @ValueAuth |
| | | public Result search(Integer status, String deviceName, String specificationModel, String largeCategory) { |
| | | return Result.success(deviceService.search(status, deviceName, specificationModel, largeCategory)); |
| | | } |
| | | |
| | | //图片上传 |
| | | @ApiOperation(value = "图片上传") |
| | | @PostMapping("/uploadFile") |
| | | public Result uploadFile(MultipartFile file) { |
| | | |
| | | System.out.println(file.getOriginalFilename()); |
| | | String urlString = null; |
| | | String pathName = null; |
| | | String filename = file.getOriginalFilename(); |
| | | try { |
| | | String path = "/Users/gaoaoy/webapp/images"; |
| | | File realpath = new File(path); |
| | | if (!realpath.exists()) { |
| | | realpath.mkdirs(); |
| | | } |
| | | pathName = UUID.randomUUID() + "_" + file.getOriginalFilename(); |
| | | urlString = realpath + "/" + pathName; |
| | | file.transferTo(new File(urlString)); |
| | | System.out.println(pathName); |
| | | HashMap<String, String> map = new HashMap<>(); |
| | | map.put("name", filename); |
| | | map.put("url", pathName); |
| | | return Result.success(map); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | System.err.println("图片上传错误"); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "获取设备负责人") |
| | | @GetMapping("/selectDevicePrincipal") |
| | | @ValueAuth |
| | | public Result selectDevicePrincipal() { |
| | | return Result.success(deviceService.selectDevicePrincipal()); |
| | | } |
| | | } |
| | | |