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 |   51 +++++++++++++++++++++++++++++++++------------------
 1 files changed, 33 insertions(+), 18 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 f4addb1..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
@@ -4,8 +4,6 @@
 import com.alibaba.fastjson.JSONObject;
 import com.doumee.api.BaseController;
 import com.doumee.biz.system.SystemDictDataBiz;
-import com.doumee.config.annotation.EncryptionReq;
-import com.doumee.config.annotation.EncryptionResp;
 import com.doumee.core.annotation.trace.Trace;
 import com.doumee.core.constants.Constants;
 import com.doumee.core.constants.ResponseStatus;
@@ -13,12 +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.azure.AzureBlobUtil;
-import com.doumee.core.utils.huaweiOBS.ObsUtil;
-import com.doumee.core.utils.qiyeweixin.QywxUtil;
-import com.doumee.core.utils.qiyeweixin.model.response.QywxUploadMediaResponse;
-import com.doumee.dao.system.model.SystemDictData;
-import com.doumee.service.common.EmailService;
+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;
@@ -54,20 +49,24 @@
     @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)){
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鐩爣鏂囦欢澶归敊璇�");
         }
-        String prefixPath = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RESOURCE_PATH).getCode();
+        String prefixPath = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode();
         InputStream is = null;
         response.setCharacterEncoding("UTF-8");
         response.setContentType("text/html;charset=UTF-8");
@@ -82,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());
@@ -90,17 +106,16 @@
                     String fName =  date+"/"+ UUID.randomUUID()+endType;
                     String fileName = folder+"/"+fName;
                     boolean r =false;
-                    ObsUtil obsUtil = new ObsUtil( systemDictDataBiz.queryByCode(Constants.HWY_OBS,Constants.HWY_OBS_ACCESSID).getCode(),
-                            systemDictDataBiz.queryByCode(Constants.HWY_OBS,Constants.HWY_OBS_ACCESSKEY).getCode(),
-                            systemDictDataBiz.queryByCode(Constants.HWY_OBS,Constants.HWY_OBS_ENDPOINT).getCode());
-                    r = obsUtil.uploadFile( systemDictDataBiz.queryByCode(Constants.HWY_OBS,Constants.HWY_OBS_BUCKET).getCode(),is,fileName);//涓婁紶
+
+                    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(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