| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.Instant; |
| | | import java.util.Date; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | |
| | | log.info("获取token:{}",string); |
| | | JSONObject jsonObject = JSONObject.parseObject(string); |
| | | JSONObject tokenJson = jsonObject.getJSONObject("token"); |
| | | Date expiresAt = tokenJson.getDate("expires_at"); |
| | | redisService.setCacheObject("PRIVATE_NUMBER:",token,expiresAt.getTime()-System.currentTimeMillis(), TimeUnit.MILLISECONDS); |
| | | // 2025-10-23T07:27:59.224000Z |
| | | String expiresAt = tokenJson.getString("expires_at"); |
| | | // 将字符串解析为Instant |
| | | Instant instant = Instant.parse(expiresAt); |
| | | // 转换为Date |
| | | Date date = Date.from(instant); |
| | | // String replace = expiresAt.substring(0, expiresAt.lastIndexOf(".")).replace("T", " "); |
| | | // Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(replace); |
| | | redisService.setCacheObject("PRIVATE_NUMBER:",token,date.getTime()-System.currentTimeMillis(), TimeUnit.MILLISECONDS); |
| | | } catch (IOException e) { |
| | | throw new ServiceException(e.getMessage()); |
| | | } |
| | |
| | | multipartFile.getBytes() |
| | | ); |
| | | builder.addFormDataPart("files", multipartFile.getOriginalFilename(), fileBody); |
| | | System.err.println("文件名称+"+multipartFile.getOriginalFilename()); |
| | | } |
| | | } |
| | | } catch (IOException e) { |
| | |
| | | JSONObject jsonObject = JSONObject.parseObject(string); |
| | | String result = jsonObject.getString("result"); |
| | | if("Upload Successful.".equals(result)){ |
| | | System.err.println("返回的文件名称+"+file.getOriginalFilename()); |
| | | return R.ok(file.getOriginalFilename(),""); |
| | | }else { |
| | | String failReason = jsonObject.getString("failReason"); |