From 4228cb0f9ff33e4baa4be0ac904eb927f8d84a19 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期六, 11 十月 2025 14:28:27 +0800 Subject: [PATCH] 提交代码 --- user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java | 120 +++++++++++++++++++++++++++++++++++------------------------- 1 files changed, 70 insertions(+), 50 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..c172303 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,23 +1,22 @@ 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.UserUtil; +import com.supersavedriving.user.modular.system.util.qianyuntong.model.QYTUserInfo; import com.supersavedriving.user.modular.system.util.qianyuntong.model.SendSmsRequest; import com.supersavedriving.user.modular.system.util.weChat.WeChatUtil; import com.supersavedriving.user.modular.system.warpper.*; @@ -26,18 +25,15 @@ 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; -import java.util.Map; +import java.util.*; +import java.util.concurrent.TimeUnit; /** * 用户控制器 @@ -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; @@ -151,7 +150,29 @@ }) public ResponseWarpper queryCaptcha(String phone){ try { - AppUserUtil.queryCaptcha(phone); + Random random = new Random(); + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < 4; i++) { + sb.append((int) (random.nextDouble() * 10)); + } + String authCode = sb.toString(); + //中台没有用户数据,需要走注册接口,验证码校验走中台 + List<QYTUserInfo> infoByPhone = UserUtil.getUserInfoByPhone(phone); + if (null == infoByPhone || infoByPhone.isEmpty()) { + SMSUtil.sendVerifyCode(phone); + } else { + SendSmsRequest request = new SendSmsRequest(); + request.setDestAddress(phone); + request.setTemplateId("TPL202410290001"); + Map<String, String> templateParams = new HashMap<>(); + templateParams.put("code", authCode); + request.setTemplateParams(templateParams); + request.setCode("code"); + request.setSpId("T8d5hdfg"); + SMSUtil.sendSms(request); + //发送验证码短信 + redisUtil.setStrValue(phone, authCode, 5);//设置五分钟过期 + } return ResponseWarpper.success(); }catch (Exception e){ e.printStackTrace(); @@ -247,25 +268,39 @@ return ResponseWarpper.success(ResultUtil.tokenErr()); } AppUser appUser = appUserService.selectById(uid); + if(ToolUtil.isEmpty(appUser.getOnconUUID())){ + String onconUUIDByMobile = UserUtil.getOnconUUIDByMobile(appUser.getPhone()); + appUser.setOnconUUID(onconUUIDByMobile); + appUserService.updateById(appUser); + } UserInfoWarpper userInfoWarpper = new UserInfoWarpper(); 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 +321,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"); + post.form("file", file1); + HttpResponse execute = post.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