From e9de5771a31803c108132605df6247e1ffc975d2 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期五, 22 八月 2025 14:17:53 +0800
Subject: [PATCH] 修改bug
---
user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java | 83 +++++++++++++++++++----------------------
1 files changed, 38 insertions(+), 45 deletions(-)
diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java
index 75d126b..1d57649 100644
--- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java
+++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java
@@ -1,21 +1,18 @@
package com.supersavedriving.user.modular.api;
+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.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
-import com.heredata.hos.model.bucket.Bucket;
-import com.sun.xml.internal.bind.v2.TODO;
-import com.supersavedriving.user.core.common.annotion.ServiceLog;
import com.supersavedriving.user.core.util.ToolUtil;
import com.supersavedriving.user.modular.system.model.*;
import com.supersavedriving.user.modular.system.service.*;
import com.supersavedriving.user.modular.system.util.*;
import com.supersavedriving.user.modular.system.util.GaoDe.MapUtil;
import com.supersavedriving.user.modular.system.util.GaoDe.model.District;
-import com.supersavedriving.user.modular.system.util.MallBook.model.InterfaceResponse;
-import com.supersavedriving.user.modular.system.util.MallBook.util.RSASignature;
-import com.supersavedriving.user.modular.system.util.huawei.OBSUtil;
-import com.supersavedriving.user.modular.system.util.qianyuntong.NCOSSUtil;
import com.supersavedriving.user.modular.system.util.qianyuntong.QianYunTongConfig;
import com.supersavedriving.user.modular.system.util.qianyuntong.SMSUtil;
import com.supersavedriving.user.modular.system.util.qianyuntong.model.SendSmsRequest;
@@ -26,14 +23,13 @@
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import java.io.File;
import java.io.InputStream;
-import java.io.PrintWriter;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -78,9 +74,12 @@
private TCheckCarActivityService checkCarActivityService;
@Autowired
private ITBranchOfficeAreaService branchOfficeAreaService;
-
- @Resource
- private QianYunTongConfig qianYunTongConfig;
+
+ @Value("${qyt.admin_url}")
+ private String adminUrl;
+
+ @Value("${filePath}")
+ private String filePath;
@@ -251,21 +250,30 @@
BeanUtils.copyProperties(appUser, userInfoWarpper);
District geocode = MapUtil.geocode(lon, lat);
- TBranchOfficeArea branchOfficeArea = branchOfficeAreaService.selectOne(new EntityWrapper<TBranchOfficeArea>().eq("areaCode", geocode.getDistrictCode())
- .last("LIMIT 1"));
- if(null == branchOfficeArea){
+ if(null != geocode){
+ TBranchOfficeArea branchOfficeArea = branchOfficeAreaService.selectOne(new EntityWrapper<TBranchOfficeArea>().eq("areaCode", geocode.getDistrictCode())
+ .last("LIMIT 1"));
+ if(null == branchOfficeArea){
+ SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 7));
+ if(null != systemConfig){
+ JSONObject jsonObject = JSON.parseObject(systemConfig.getContent());
+ userInfoWarpper.setServiceCell(jsonObject.getString("num1"));
+ }
+ }else{
+ SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 8).eq("companyId", branchOfficeArea.getBranchOfficeId()));
+ if(null != systemConfig){
+ JSONObject jsonObject = JSON.parseObject(systemConfig.getContent());
+ userInfoWarpper.setServiceCell(jsonObject.getString("num2"));
+ }
+ }
+ }else{
SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 7));
if(null != systemConfig){
JSONObject jsonObject = JSON.parseObject(systemConfig.getContent());
userInfoWarpper.setServiceCell(jsonObject.getString("num1"));
}
- }else{
- SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 8).eq("companyId", branchOfficeArea.getBranchOfficeId()));
- if(null != systemConfig){
- JSONObject jsonObject = JSON.parseObject(systemConfig.getContent());
- userInfoWarpper.setServiceCell(jsonObject.getString("num2"));
- }
}
+
return ResponseWarpper.success(userInfoWarpper);
}catch (Exception e){
e.printStackTrace();
@@ -286,30 +294,15 @@
InputStream inputStream = file.getInputStream();
String name = file.getOriginalFilename();
name = UUIDUtil.getRandomCode() + name.substring(name.lastIndexOf("."));
-// String s = OBSUtil.putObjectToBucket(inputStream, name);
-// String s = OssUploadUtil.ossUpload(file);
- String bucketName = qianYunTongConfig.getBucketName();
- Bucket grjyTest = NCOSSUtil.getBucketInfo(bucketName);
- if (null == grjyTest) {
- //创建桶
- Boolean bucket = NCOSSUtil.createBucket(bucketName);
- if (!bucket) {
- throw new RuntimeException("创建存储桶失败");
- }
- //设置桶策略
- String policyText = "{\"Version\":\"2025-06-23\",\"Statement\":[{\"Sid\":\"Stmt20250623\",\"Action\":[\"GetObject\"],\"Effect\":\"Allow\",\"Resource\":\"" + bucketName + "/*\",\"Principal\":\"*\"}]}";
- Boolean bucketPolicy = NCOSSUtil.setBucketPolicy(bucketName, policyText);
- if (!bucketPolicy) {
- throw new RuntimeException("设置桶策略失败");
- }
+ File file1 = FileUtil.writeFromStream(inputStream, new File(filePath + name));
+ HttpRequest post = HttpUtil.createPost(adminUrl + "/upload/image");
+ HttpRequest form = post.form("file", file1);
+ HttpResponse execute = form.execute();
+ int status = execute.getStatus();
+ if(200 != status){
+ throw new RuntimeException("上传图片异常");
}
- //上传对象
- String key = "imgs/daijia/user/" + name;
- String object = NCOSSUtil.putObject(bucketName, key, inputStream);
- if (null == object) {
- throw new RuntimeException("上传图片失败");
- }
- return ResponseWarpper.success("https://traffic.qytzt.cn/v1/AUTH_" + qianYunTongConfig.getAccount() + "/" + bucketName + "/" + key);
+ return ResponseWarpper.success(execute.body());
}catch (Exception e){
e.printStackTrace();
return new ResponseWarpper(500, e.getMessage());
--
Gitblit v1.7.1