diff --git a/src/main/java/com/xdap/self_development/controller/DeleteController.java b/src/main/java/com/xdap/self_development/controller/DeleteController.java index 7864962..b691cbc 100644 --- a/src/main/java/com/xdap/self_development/controller/DeleteController.java +++ b/src/main/java/com/xdap/self_development/controller/DeleteController.java @@ -1,19 +1,22 @@ package com.xdap.self_development.controller; +import cn.hutool.core.codec.Base64; +import cn.hutool.json.JSONUtil; import com.definesys.mpaas.common.http.Response; -import com.xdap.api.moudle.user.vo.LoginUserVo; import com.xdap.runtime.service.RuntimeAppContextService; import com.xdap.runtime.service.RuntimeUserService; import com.xdap.self_development.config.BusinessDatabase; import com.xdap.self_development.feign.ApaasMyTokenFeign; import com.xdap.self_development.feign.dto.AppTokenDTO; +import com.xdap.self_development.feign.dto.FileUploadDTO; +import com.xdap.self_development.feign.dto.UserTokenDT0; import com.xdap.self_development.pojo.*; +import lombok.extern.slf4j.Slf4j; +import org.bson.types.ObjectId; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.util.HashMap; @@ -21,6 +24,7 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; +@Slf4j @RestController @RequestMapping("/custom/delete") public class DeleteController { @@ -33,18 +37,50 @@ public class DeleteController { @Autowired private ApaasMyTokenFeign apaasMyTokenFeign; - @GetMapping("/loginVo") - public Response loginVo(@RequestParam String userId) { + @PostMapping("/uploadFile") + public Response uploadFile(@RequestPart("file") MultipartFile file) { Map map = new HashMap<>(); AppTokenDTO token = apaasMyTokenFeign.getAppToken( "client_credentials", "2b5b3de8-e7fd-406a-a59a-d5568457b1f4", "94bddc6a-27a4-4204-885b-b075812ec535" ); - map.put("token", token); + map.put("appToken", token); + log.info("loginVo token:{}", token); + + UserTokenDT0 userToken = apaasMyTokenFeign.getUserToken( + token.getAccess_token(), + "100771325212057665536" + ); + map.put("userToken", userToken); + log.info("loginVo userToken:{}", userToken); + + String uploadId = new ObjectId().toHexString(); + FileUploadDTO fileUploadDTO = apaasMyTokenFeign.uploadFile( + "Bearer " + userToken.getAccess_token(), + "application/x-www-form-urlencoded", + file, + uploadId, + "223770822127386625", + "100771325212057665536" + ); + map.put("fileUploadDTO", fileUploadDTO); + log.info("loginVo fileUploadDTO:{}", fileUploadDTO); return Response.ok().data(map); } + @GetMapping("/downloadFile") + public Response downloadFile( + @RequestParam String url + ) { + Map map = new HashMap<>(); + map.put("xdaptenantid", "223770822127386625"); + cn.hutool.json.JSON json = JSONUtil.parse(map); + String token = Base64.encode(json.toString()); + String realUrl = url +"&download=download&token="+token; + return Response.ok().data(realUrl); + } + @GetMapping("getAll") public Response getAll() { List