From 74b0af6814b96378201ea27d205e054bf01d0306 Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期二, 21 四月 2026 14:20:22 +0800
Subject: [PATCH] 代码生成
---
server/services/src/main/java/com/doumee/api/common/PublicCloudController.java | 33 +++++++++++++++++++++++++++------
1 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/server/services/src/main/java/com/doumee/api/common/PublicCloudController.java b/server/services/src/main/java/com/doumee/api/common/PublicCloudController.java
index c5608f0..06ecde2 100644
--- a/server/services/src/main/java/com/doumee/api/common/PublicCloudController.java
+++ b/server/services/src/main/java/com/doumee/api/common/PublicCloudController.java
@@ -11,7 +11,9 @@
import com.doumee.core.model.ApiResponse;
import com.doumee.core.utils.DateUtil;
import com.doumee.core.utils.FtpUtil;
+import com.doumee.core.utils.ImageWatermarkUtil;
import com.doumee.core.utils.aliyun.ALiYunUtil;
+import com.doumee.core.utils.geocode.MapUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@@ -47,14 +49,18 @@
@Autowired
private SystemDictDataBiz systemDictDataBiz;
- @ApiOperation(value = "涓婁紶OBS", notes = "涓婁紶OBS", httpMethod = "POST", position = 6)
+ @ApiOperation(value = "涓婁紶OSS", notes = "涓婁紶OSS锛屽彲浼犲叆缁忕含搴﹁嚜鍔ㄦ坊鍔犳椂闂�+鍦板潃姘村嵃", httpMethod = "POST", position = 6)
@ApiImplicitParams({
@ApiImplicitParam(name = "folder", value = "鏂囦欢澶�", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class),
- @ApiImplicitParam(name = "file", value = "鏂囦欢澶�", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class),
+ @ApiImplicitParam(name = "file", value = "鏂囦欢", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class),
+ @ApiImplicitParam(name = "latitude", value = "绾害锛堥潪蹇呭~锛屼紶鍏ユ椂娣诲姞姘村嵃锛�", paramType = "query", dataType = "Double"),
+ @ApiImplicitParam(name = "longitude", value = "缁忓害锛堥潪蹇呭~锛屼紶鍏ユ椂娣诲姞姘村嵃锛�", paramType = "query", dataType = "Double"),
})
@PostMapping(value = "/upload", headers = "content-type=multipart/form-data")
@ResponseBody
- public void upload(HttpServletRequest request, HttpServletResponse response, String folder,String flag) throws Exception {
+ public void upload(HttpServletRequest request, HttpServletResponse response, String folder, String flag,
+ @RequestParam(required = false) Double latitude,
+ @RequestParam(required = false) Double longitude) throws Exception {
Date d1 = new Date();
log.error("鎬诲緱涓婁紶鏂囦欢鎴愬姛=============寮�濮�========="+DateUtil.getPlusTime2(d1));
if(Objects.isNull(folder)){
@@ -75,6 +81,23 @@
System.out.println(file.getSize());
String originname = file.getOriginalFilename();
is = file.getInputStream();
+
+ // 缁忕含搴︽按鍗板鐞�
+ InputStream uploadStream = is;
+ if (latitude != null && longitude != null) {
+ try {
+ JSONObject geoResult = MapUtil.reverseGeocode(latitude, longitude);
+ String address = geoResult != null ? geoResult.getString("formatted_addresses") : "";
+ String timeText = DateUtil.getPlusTime2(new Date());
+ uploadStream = ImageWatermarkUtil.addWatermark(is, timeText, address, latitude, longitude);
+ log.info("鍥剧墖姘村嵃娣诲姞鎴愬姛: time={}, address={}", timeText, address);
+ } catch (Exception e) {
+ log.warn("姘村嵃澶勭悊澶辫触锛屼娇鐢ㄥ師鍥句笂浼�: {}", e.getMessage());
+ try { is.reset(); } catch (Exception ignored) {}
+ uploadStream = is;
+ }
+ }
+
String endType = ".jpg";
if(originname.indexOf(".")>0){
endType=originname.substring(originname.lastIndexOf("."),originname.length());
@@ -87,14 +110,12 @@
ALiYunUtil obs = new ALiYunUtil(systemDictDataBiz.queryByCode(Constants.OSS,Constants.ENDPOINT).getCode(),systemDictDataBiz.queryByCode(Constants.OSS,Constants.ACCESS_ID).getCode(),
systemDictDataBiz.queryByCode(Constants.OSS,Constants.ACCESS_KEY).getCode());
- r = obs.uploadOnlineObject(file.getInputStream(),systemDictDataBiz.queryByCode(Constants.OSS,Constants.BUCKETNAME).getCode(), fileName,null);
+ r = obs.uploadOnlineObject(uploadStream,systemDictDataBiz.queryByCode(Constants.OSS,Constants.BUCKETNAME).getCode(), fileName,null);
if(r){
context.put("success", true);
context.put("code", 200);
context.put("errno",0);
JSONObject fileJSON = new JSONObject();
-// fileJSON.put("prefixPath", prefixPath);
-// fileJSON.put("folder", folder);
fileJSON.put("url", prefixPath+fileName);
fileJSON.put("imgaddr", fName);
fileJSON.put("imgname", fileName);
--
Gitblit v1.9.3