From eb4b52e8185465a98d92566259a8bcdf6ed0801e Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Sat, 19 Feb 2022 16:59:41 +0800
Subject: [PATCH] 注册判断

---
 src/main/java/org/springblade/modules/zc/controller/ZcController.java |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/springblade/modules/zc/controller/ZcController.java b/src/main/java/org/springblade/modules/zc/controller/ZcController.java
index edfc1c1..6038c8a 100644
--- a/src/main/java/org/springblade/modules/zc/controller/ZcController.java
+++ b/src/main/java/org/springblade/modules/zc/controller/ZcController.java
@@ -29,6 +29,7 @@
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.DigestUtil;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.StringUtil;
 import org.springblade.modules.FTP.FtpUtil;
 import org.springblade.modules.system.service.IDeptService;
 import org.springblade.modules.system.service.IUserService;
@@ -211,8 +212,11 @@
 		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 		String times = df.format(new Date());
 		zc.setZctime(times);
+		Integer userCount = iUserService.selectCount(zc.getUsername());
+		if (userCount > 0) {
+			throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前用户 [{}] 已存在!", zc.getUsername()));
+		}
 		zcService.inster(zc);
-
 		String s = "insert into act_zc(id,username,password,sname,sex,phone,zctime,deptid,parent_id,jurisdiction,cardid)" +
 			"values(" + "'" + zc.getId() + "'" +
 			"," + "'" + zc.getUsername() + "'" +
@@ -225,11 +229,22 @@
 			"," + "'" + zc.getParentId() + "'" +
 			"," + "'" + zc.getJurisdiction() + "'" +
 			"," + "'" + zc.getCardid() + "'" + ")";
-
-		System.out.println(s);
 		FtpUtil.sqlFileUpload(s);
-
 		return R.success("新增成功");
 	}
 
+	/**
+	 * 用户验证
+	 * @param username
+	 * @return
+	 */
+	@GetMapping("/inspect")
+	public R inspect(String username) {
+		Integer userCount = iUserService.selectCount(username);
+		if (userCount > 0) {
+			throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前用户{}已存在!", username));
+		}
+		return R.success("当前用户已存在!");
+	}
+
 }

--
Gitblit v1.9.3