From 063e13c7dfbe8352bd566c63023e319e47459d56 Mon Sep 17 00:00:00 2001 From: lidongdong <1459917685@qq.com> Date: 星期四, 09 三月 2023 17:14:17 +0800 Subject: [PATCH] 修改获取安全知识培训跳转url --- springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/CommonApi.java | 48 +++++++++++++++++++++++++++++++++++++----------- 1 files changed, 37 insertions(+), 11 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/CommonApi.java b/springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/CommonApi.java index 97945b0..36be447 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/CommonApi.java +++ b/springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/CommonApi.java @@ -1,22 +1,18 @@ package com.panzhihua.applets.api; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; - import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; - -import com.jcraft.jsch.SftpException; import com.panzhihua.applets.config.MinioUtil; import com.panzhihua.applets.umf.UmfPayUtil; import com.panzhihua.common.controller.BaseController; -import com.panzhihua.common.utlis.DateUtils; -import com.panzhihua.common.utlis.MimeTypeUtils; +import com.panzhihua.common.model.vos.community.Base64File; +import com.panzhihua.common.utlis.*; import net.coobird.thumbnailator.Thumbnails; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.RandomUtils; @@ -26,7 +22,6 @@ import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; - import com.alibaba.fastjson.JSON; import com.panzhihua.applets.config.WxMaConfiguration; import com.panzhihua.common.constants.Constants; @@ -36,9 +31,6 @@ import com.panzhihua.common.model.vos.community.WeatherVO; import com.panzhihua.common.model.vos.user.UserPhoneVO; import com.panzhihua.common.service.community.CommunityService; -import com.panzhihua.common.utlis.HttpUtils; -import com.panzhihua.common.utlis.SFTPUtil; - import cn.binarywang.wx.miniapp.api.WxMaSecCheckService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -170,6 +162,23 @@ } } + @ApiOperation(value = "文件流上传接口") + @PostMapping(value = "/uploadImagesInputStream") + public R uploadImagesInputStream(@RequestBody Base64File file, HttpServletRequest request) { + if(StringUtils.isEmpty(file.getFile())){ + return R.fail("文件不能为Null"); + } + try { + String name = UUID.randomUUID().toString().replaceAll("-", "") + ".jpg"; + InputStream is = minioUtil.base64StrToInputStream(file.getFile().replace("data:image/png;base64,","").replace("data:image/jpg;base64,","").replace("data:image/jpeg;base64,","")); + String imageUrl = minioUtil.uploadInputStream(is, name); + return R.ok(imageUrl); + } catch (Exception e) { + log.error("上传照片失败【{}】", e.getMessage()); + return R.fail(); + } + } + @ApiOperation(value = "新上传照片压缩接口") @PostMapping(value = "/uploadimagescompress", consumes = "multipart/*", headers = "content-type=multipart/form-date") public R uploadImagesComPress(@RequestParam MultipartFile file, HttpServletRequest request) { @@ -178,10 +187,12 @@ String extension = FilenameUtils.getExtension(file.getOriginalFilename()); String uuid=UUID.randomUUID().toString().replaceAll("-", ""); String name = uuid + "."+ extension; - minioUtil.upload(file, name); + String fileName = minioUtil.uploadRetFileName(file, name); Thumbnails.of(file.getInputStream()).scale(0.5).outputQuality(0.71).outputFormat("jpg").toFile(uuid+"_compress"); File file1=new File(uuid+"_compress.jpg"); String imageUrl = minioUtil.uploadFile(file1, uuid+"_compress.jpg"); + //上传完压缩图后把原图清理,防止文件服务器资源爆满 + minioUtil.removeMinio(fileName); return R.ok(imageUrl); } catch (Exception e) { log.error("上传照片失败【{}】", e.getMessage()); @@ -213,10 +224,25 @@ String result = HttpUtils.sendGet(url, param); return R.ok(JSON.parseObject(result)); } + + @ApiOperation(value = "获取安全知识培训跳转url") + @GetMapping(value = "getSafety") + public R getSafety() + { + return R.ok(""); + } + + @ApiOperation("uu洗车下单接口") @GetMapping("/uuPay") public R uuPay(@RequestParam("orderid") String orderid,@RequestParam("openid")String openid,@RequestParam("amount")String amount){ Map map=umfPayUtil.pay(orderid, DateUtils.getCurrentDateString(),openid,amount); return R.ok(map); } + @ApiOperation("无水洗车下单接口") + @GetMapping("/wsPay") + public R wsPay(@RequestParam("orderid") String orderid,@RequestParam("openid")String openid,@RequestParam("amount")String amount){ + Map map=umfPayUtil.pay2(orderid, DateUtils.getCurrentDateString(),openid,amount); + return R.ok(map); + } } -- Gitblit v1.7.1