tanlie 1 тиждень тому
батько
коміт
fb34557162

+ 1 - 0
wishing-platform/platform-entity/platform-entity-wishing/src/main/java/cn/qinys/platform/entity/wishing/WishingUser.java

@@ -39,4 +39,5 @@ public class WishingUser extends BaseEntity implements Serializable {
 
     private Integer loginCount;
 
+    private Integer isAdmin;
 }

BIN
wishing-platform/platform-entity/platform-entity-wishing/target/classes/cn/qinys/platform/entity/wishing/WishingUser.class


BIN
wishing-platform/platform-entity/platform-entity-wishing/target/platform-entity-wishing-1.0.0-SNAPSHOT.jar


+ 23 - 0
wishing-platform/platform-service/platform-service-mobile/src/main/java/cn/qinys/platform/mobile/constants/WishtypeEnum.java

@@ -0,0 +1,23 @@
+package cn.qinys.platform.mobile.constants;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author lie tan
+ * @description
+ * @date 2026-06-14 10:01
+ **/
+
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+public enum WishtypeEnum {
+
+    MANUAL(1, "make by manual"),
+    AUTO(2, "support by ai"),;
+
+    private Integer value;
+    private String description;
+}

+ 2 - 0
wishing-platform/platform-service/platform-service-mobile/src/main/java/cn/qinys/platform/mobile/req/LoginReq.java

@@ -2,6 +2,7 @@ package cn.qinys.platform.mobile.req;
 
 import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Pattern;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -17,6 +18,7 @@ public class LoginReq implements Serializable {
      * 手机号 加密传输
      */
     @NotBlank(message = "电话号码不能为空")
+    @Pattern(regexp = "^(?:\\+?86)?1[3-9]\\d{9}$", message = "手机号格式不正确")
     private String mobile;
 
     /**

+ 2 - 0
wishing-platform/platform-service/platform-service-mobile/src/main/java/cn/qinys/platform/mobile/resp/LoginResp.java

@@ -20,4 +20,6 @@ public class LoginResp implements Serializable {
 
     private String avatar;
 
+    private Integer isAdmin;
+
 }

+ 42 - 1
wishing-platform/platform-service/platform-service-mobile/src/main/java/cn/qinys/platform/mobile/service/impl/LoginServiceImpl.java

@@ -23,6 +23,7 @@ import org.springframework.util.StringUtils;
 import java.time.LocalDateTime;
 import java.util.Map;
 import java.util.UUID;
+import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.atomic.AtomicReference;
 
 /**
@@ -60,7 +61,8 @@ public class LoginServiceImpl extends AbstractLoginService implements LoginServi
 
         WishingUser user = userMapper.selectByMobile(query.getMobile());
         if (user == null) {
-            throw new BizException("用户不存在");
+            //throw new BizException("用户不存在");
+            user = this.createWishingUser(query.getMobile());
         }
         user.setLastLoginAt(LocalDateTime.now());
         user.setLoginCount(user.getLoginCount() + 1);
@@ -82,6 +84,7 @@ public class LoginServiceImpl extends AbstractLoginService implements LoginServi
         resp.setMobile(user.getMobile());
         resp.setNickname(user.getNickname());
         resp.setAvatar(user.getAvatar());
+        resp.setIsAdmin(user.getIsAdmin());
         return resp;
     }
 
@@ -116,4 +119,42 @@ public class LoginServiceImpl extends AbstractLoginService implements LoginServi
         Integer userId = Integer.valueOf(CurrentUtils.getCurrentUserId());
         return wishMapper.selectWishSummary(userId);
     }
+
+
+    private WishingUser createWishingUser(String mobile) {
+        WishingUser user = new WishingUser();
+        user.setMobile(mobile);
+        user.setNickname(this.createRandUerName());
+        user.setLoginCount(0);
+        user.setAvatar("");
+        user.setIsAdmin(1);
+        userMapper.insert(user);
+        return user;
+    }
+
+    public String createRandUerName() {
+        // 常见单字姓氏列表(可根据需要扩充)
+        String[] surnames = new String[]{"李","王","张","刘","陈","杨","黄","赵","吴","周","徐","孙","胡","朱","高","林","何","郭","马","罗","梁","宋","郑","谢","唐"};
+
+        // 常见单字名字用字(男女通用,列表可扩充)
+        String[] nameChars = new String[]{
+                "伟","芳","娜","秀","英","敏","静","丽","强","磊",
+                "洋","勇","艳","杰","娟","涛","明","超","平","刚",
+                "桂","雪","飞","琳","玲","丹","萍","辉","建","华",
+                "晶","燕","晨","晨","鑫","彤","坤","怡","珊","瑶"
+        };
+
+        ThreadLocalRandom rnd = ThreadLocalRandom.current();
+        String surname = surnames[rnd.nextInt(surnames.length)];
+
+        // 给名长度 1 或 2
+        int givenLen = rnd.nextInt(1, 3); // 1 或 2
+        StringBuilder givenName = new StringBuilder();
+        for (int i = 0; i < givenLen; i++) {
+            givenName.append(nameChars[rnd.nextInt(nameChars.length)]);
+        }
+
+        return surname + givenName;
+    }
+
 }

+ 4 - 1
wishing-platform/platform-service/platform-service-mobile/src/main/java/cn/qinys/platform/mobile/service/impl/UserWishServiceImpl.java

@@ -3,6 +3,7 @@ package cn.qinys.platform.mobile.service.impl;
 import cn.qinys.platform.base.security.utils.CurrentUtils;
 import cn.qinys.platform.entity.wishing.UserWish;
 import cn.qinys.platform.entity.wishing.WishingTree;
+import cn.qinys.platform.mobile.constants.WishtypeEnum;
 import cn.qinys.platform.mobile.mapper.UserWishMapper;
 import cn.qinys.platform.mobile.mapper.WishingTreeMapper;
 import cn.qinys.platform.mobile.req.WishCreateReq;
@@ -78,7 +79,9 @@ public class UserWishServiceImpl extends AbstractUserWishService implements User
         wish.setType(req.getType());
         wishMapper.insert(wish);
         this.treeWishesCounter(req.getTreeId(), wish.getIsPublic());
-        imageService.appendWishImage(wish);
+        if (WishtypeEnum.AUTO.getValue().equals(req.getType())) {
+            imageService.appendWishImage(wish);
+        }
     }
 
     @Override