| | |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | | import com.yuanchu.mom.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | |
| | | * 设备(DeviceController)表控制层 |
| | | */ |
| | | @Api(tags = "设备") |
| | | @AllArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/deviceScope") |
| | | public class DeviceController { |
| | | |
| | | |
| | | @Resource |
| | | private DeviceService deviceService; |
| | | |
| | | @Value("${file.path}") |
| | | private String filePath; |
| | | |
| | | @ApiOperation(value = "查询设备详情列表") |
| | | @PostMapping("/selectDeviceParameter") |
| | |
| | | } |
| | | |
| | | //图片上传 |
| | | @ApiOperation(value = "图片上传") |
| | | @ApiOperation(value = "设备图片上传") |
| | | @PostMapping("/uploadFile") |
| | | public Result uploadFile(MultipartFile file) { |
| | | |
| | | System.out.println(file.getOriginalFilename()); |
| | | String urlString = null; |
| | | String pathName = null; |
| | | String urlString; |
| | | String pathName; |
| | | String filename = file.getOriginalFilename(); |
| | | try { |
| | | String path = "/Users/gaoaoy/webapp/images"; |
| | | String path = filePath; |
| | | 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); |
| | |
| | | public Result selectDevicePrincipal() { |
| | | return Result.success(deviceService.selectDevicePrincipal()); |
| | | } |
| | | |
| | | @ApiOperation(value = "通过设备分类获取设备列表") |
| | | @PostMapping("/selectDeviceByCategory") |
| | | @ValueAuth |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "category", value = "设备分类", dataTypeClass = String.class), |
| | | }) |
| | | public Result selectDeviceByCategory(String category) { |
| | | return Result.success(deviceService.selectDeviceByCategory(category)); |
| | | } |
| | | } |
| | | |