| | |
| | | package com.stylefeng.guns.modular.crossCity.controller; |
| | | |
| | | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.account.service.ITEnterpriseWithdrawalService; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.io.InputStream; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | | |
| | | @Api |
| | |
| | | |
| | | @Value("${spring.profiles.active}") |
| | | private String env; |
| | | |
| | | @Value("${filePath}") |
| | | private String filePath; |
| | | |
| | | @Value("${qyt.admin_url}") |
| | | private String adminUrl; |
| | | |
| | | |
| | | |
| | |
| | | return ResultUtil.error("生成小程序码失败"); |
| | | } |
| | | |
| | | // 5. 上传到OSS |
| | | String qrCodeUrl = OssUploadUtil.ossUploadByStream(driverId, inputStream); |
| | | if (ToolUtil.isEmpty(qrCodeUrl)) { |
| | | return ResultUtil.error("上传小程序码失败"); |
| | | // 5. 上传到服务器 |
| | | File file = FileUtil.writeFromStream(inputStream, new File(filePath + "/" + UUID.randomUUID().toString() + ".png")); |
| | | HttpRequest post = HttpUtil.createPost(adminUrl + "/upload/image"); |
| | | post.form("file", file); |
| | | HttpResponse execute = post.execute(); |
| | | int status = execute.getStatus(); |
| | | if(200 != status){ |
| | | throw new RuntimeException("上传图片异常"); |
| | | } |
| | | |
| | | // 6. 返回结果 |
| | | BaseWarpper baseWarpper = new BaseWarpper(); |
| | | baseWarpper.setContent(qrCodeUrl); |
| | | baseWarpper.setContent(execute.body()); |
| | | return ResultUtil.success(baseWarpper); |
| | | |
| | | } catch (Exception e) { |