diff --git a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/JumpController.java b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/JumpController.java index 8615000ee..ade476599 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/JumpController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/JumpController.java @@ -3,20 +3,27 @@ package com.jsowell.api.uniapp; import com.alibaba.fastjson2.JSONObject; import com.jsowell.common.annotation.Anonymous; import com.jsowell.common.core.controller.BaseController; +import com.jsowell.common.core.domain.AjaxResult; import com.jsowell.common.enums.ykc.ReturnCodeEnum; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.response.RestApiResponse; +import com.jsowell.common.util.file.AliyunOssUploadUtils; +import com.jsowell.common.util.file.FileUtils; import com.jsowell.pile.service.IOrderBasicInfoService; import com.jsowell.pile.vo.uniapp.PileConnectorVO; import com.jsowell.service.PileService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; + @Anonymous @RestController @RequestMapping("/app-xcx-h5") @@ -73,13 +80,26 @@ public class JumpController extends BaseController { } /** - * 更新接口 - * http://localhost:8080/app-xcx-h5/pile/updateOrderDetail + * 上传到阿里云oss + * http://localhost:8080/app-xcx-h5/uploadOSS + * @param file + * @return + * @throws Exception */ - @GetMapping("updateOrderDetail") - public RestApiResponse updateOrderDetail() { - orderBasicInfoService.updateElecAmount(); - return new RestApiResponse<>(); + @CrossOrigin + @PostMapping("/uploadOSS") + public AjaxResult uploadFileOSS(MultipartFile file) throws Exception { + try { + String url = AliyunOssUploadUtils.uploadFile(file); + AjaxResult ajax = AjaxResult.success(); + ajax.put("url", url); + ajax.put("fileName", FileUtils.getName(url)); + ajax.put("newFileName", FileUtils.getName(url)); + ajax.put("originalFilename", file.getOriginalFilename()); + return ajax; + }catch (Exception e){ + return AjaxResult.error(e.getMessage()); + } } }