| | |
| | | package com.ruoyi.worker.controller; |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.utils.GaoDeMapUtil; |
| | | import com.ruoyi.order.api.feignClient.OrderClient; |
| | | import com.ruoyi.worker.utils.FileImageWatermarkUtils; |
| | | import com.ruoyi.worker.utils.TencentCosUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.imageio.ImageIO; |
| | | import javax.imageio.stream.ImageOutputStream; |
| | | import java.awt.*; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.*; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Date; |
| | | |
| | | |
| | | /** |
| | | * @author HJL |
| | |
| | | @RestController |
| | | @RequestMapping("/oss") |
| | | @Api(tags = "师傅端-文件上传") |
| | | @Slf4j |
| | | public class OssController { |
| | | |
| | | @Resource |
| | | private OrderClient orderClient; |
| | | @Resource |
| | | private TencentCosUtil tencentCosUtil; |
| | | |
| | | |
| | | @PostMapping("/upload") |
| | | @ApiOperation(value = "文件上传", tags = "师傅端-文件上传") |
| | |
| | | return R.ok(tencentCosUtil.upLoadFile(file)); |
| | | } |
| | | |
| | | @PostMapping(value = "/pic", produces = "application/json;charset=UTF-8") |
| | | @ApiOperation(value = "文件上传加水印", tags = "师傅端-文件上传") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "文件", name = "file", dataType = "MultipartFile", required = true) |
| | | }) |
| | | public R<String> pic(@RequestParam("file") MultipartFile file,@RequestParam String longitude,@RequestParam String address, |
| | | @RequestParam String latitude) { |
| | | // Result<String> address = GaoDeMapUtil.getAddress(longitude, latitude); |
| | | |
| | | |
| | | // 获取当前时间 |
| | | |
| | | LocalDateTime date = LocalDateTime.now(); |
| | | |
| | | // 设置日期格式 |
| | | |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | // 通过format调用转换的方法 |
| | | |
| | | String dateWatermark = formatter.format(date); |
| | | // System.err.println("==========="+LocalDateTime.now()); |
| | | log.error("==========="+LocalDateTime.now()); |
| | | |
| | | MultipartFile watermarkFile = FileImageWatermarkUtils.markWithContent(file,dateWatermark,address); |
| | | // System.err.println("==========="+LocalDateTime.now()); |
| | | log.error("==========="+LocalDateTime.now()); |
| | | |
| | | |
| | | String url = tencentCosUtil.upLoadFile(watermarkFile); |
| | | log.error("==========="+LocalDateTime.now()); |
| | | return R.ok(url); |
| | | |
| | | } |
| | | |
| | | |
| | | } |