From b6373daa40c3dc17ca107f3666fd252f3b6b0778 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期五, 03 一月 2025 18:34:52 +0800
Subject: [PATCH] 代码

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/MsgUtil.java |   36 +++++++++++++++++++++++++++++++++---
 1 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/MsgUtil.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/MsgUtil.java
index 5cb99ca..716af6c 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/MsgUtil.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/MsgUtil.java
@@ -2,22 +2,52 @@
 
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HttpUtil;
+import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.system.domain.TAppUser;
+import com.ruoyi.system.service.TAppUserService;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import java.util.HashMap;
+import java.util.Objects;
 import java.util.concurrent.ThreadLocalRandom;
 @RestController
 
 public class MsgUtil {
     @Resource
     private RedisCache redisCache;
-    @ApiOperation(value = "通用发送验证码",tags = "通用发送验证码")
+    @Resource
+    private TAppUserService appUserService;
+    @ApiOperation(value = "通用发送验证码,type:1=注册,2=登录,3=修改手机号,4=修改密码",tags = "通用发送验证码")
     @PostMapping("/common/send")
-    public  String send (String phone){
+    public R send (String phone,Integer type){
+        TAppUser one = appUserService.lambdaQuery().eq(TAppUser::getPhone, phone).one();
+        switch (type){
+            case 1:
+                if (one!=null){
+                    throw new ServiceException("当前手机号已注册");
+                }
+                break;
+            case 2:
+                if (Objects.isNull(one)){
+                    throw new ServiceException("当前手机号未注册");
+                }
+                break;
+            case 3:
+                if (one!=null){
+                    throw new ServiceException("当前手机号已存在");
+                }
+                break;
+            case 4:
+                if (Objects.isNull(one)){
+                    throw new ServiceException("当前手机号不存在");
+                }
+                break;
+        }
         String code = createCode();
         redisCache.setCacheObject(phone,code);
         HashMap<String, Object> paramMap = new HashMap<>();
@@ -33,7 +63,7 @@
         }
         result3 = StrUtil.trim(result3);
 
-    return result3;
+        return R.ok(result3);
     }
     public static String createCode(){
         return String.valueOf(ThreadLocalRandom.current().nextInt(100000, 999999));

--
Gitblit v1.7.1