qmj преди 2 дни
родител
ревизия
0e02cfe0a9
променени са 1 файла, в които са добавени 14 реда и са изтрити 0 реда
  1. 14 0
      ruoyi-admin/src/main/java/com/ruoyi/app/stall/StallController.java

+ 14 - 0
ruoyi-admin/src/main/java/com/ruoyi/app/stall/StallController.java

@@ -5,6 +5,7 @@ import com.ruoyi.common.annotation.Anonymous;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.MessageUtils;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.system.domain.InfoUser;
 import com.ruoyi.system.domain.PosStore;
 import com.ruoyi.system.mapper.InfoUserMapper;
@@ -110,6 +111,9 @@ public class StallController extends BaseController {
         }
 
         // 校验必填字段
+        if (stallOwner.getUserName() == null || stallOwner.getUserName().isEmpty()) {
+            return error("用户名不能为空");
+        }
         if (stallOwner.getPhone() == null || stallOwner.getPhone().isEmpty()) {
             return error("手机号不能为空");
         }
@@ -117,6 +121,15 @@ public class StallController extends BaseController {
             return error("密码不能为空");
         }
 
+        // 检查用户名是否已存在
+        InfoUser existName = infoUserService.lambdaQuery()
+                .eq(InfoUser::getUserName, stallOwner.getUserName())
+                .eq(InfoUser::getDelFlag, "0")
+                .one();
+        if (existName != null) {
+            return error("用户名已存在");
+        }
+
         // 检查手机号是否已注册
         InfoUser existUser = infoUserService.lambdaQuery()
                 .eq(InfoUser::getPhone, stallOwner.getPhone())
@@ -131,6 +144,7 @@ public class StallController extends BaseController {
         stallOwner.setStatus("0");
         stallOwner.setDelFlag("0");
         stallOwner.setAuditStatus("1");
+        stallOwner.setPassword(SecurityUtils.encryptPassword(stallOwner.getPassword()));
 
         infoUserService.insertInfoUser(stallOwner);
         return success(MessageUtils.message("no.success"), stallOwner);