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 | 74 ++++++++++++++++++++++++------------
1 files changed, 49 insertions(+), 25 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 6167971..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;
@@ -45,7 +46,7 @@
import java.util.List;
/**
- * 控制器
+ * 控制器
*
* @author BladeX
* @since 2020-09-08
@@ -99,38 +100,43 @@
IPage<ZcVO> page = zcService.selectZcPage(Condition.getPage(query), zc);
for (int j = 0; j < page.getRecords().size(); j++) {
- if (page.getRecords().get(j).getDeptid() != null && !page.getRecords().get(j).getDeptid().equals("")){
+ if (page.getRecords().get(j).getDeptid() != null && !page.getRecords().get(j).getDeptid().equals("")) {
String[] split = page.getRecords().get(j).getDeptid().split(",");
List<String> list = Arrays.asList(split);
StringBuffer deptNameBuiffer = new StringBuffer();
//数据匹配封装
- for (String deptId:list) {
- for (DeptVo deptVo:deptVos) {
- if (deptId.equals(deptVo.getId().toString())){
+ for (String deptId : list) {
+ for (DeptVo deptVo : deptVos) {
+ if (deptId.equals(deptVo.getId().toString())) {
deptNameBuiffer.append(deptVo.getDeptName()).append(",");
}
}
}
//封装部门名称数据
- page.getRecords().get(j).setDeptName(deptNameBuiffer.substring(0,deptNameBuiffer.length()-1));
+ if (deptNameBuiffer.length() > 0) {
+ page.getRecords().get(j).setDeptName(deptNameBuiffer.substring(0, deptNameBuiffer.length() - 1));
+ }
+
}
}
for (int j = 0; j < page.getRecords().size(); j++) {
- if (page.getRecords().get(j).getJurisdiction() != null && !page.getRecords().get(j).getJurisdiction().equals("")){
+ if (page.getRecords().get(j).getJurisdiction() != null && !page.getRecords().get(j).getJurisdiction().equals("")) {
String[] split = page.getRecords().get(j).getJurisdiction().split(",");
List<String> list = Arrays.asList(split);
StringBuffer deptNameBuiffer = new StringBuffer();
//数据匹配封装
- for (String deptId:list) {
- for (DeptVo deptVo:xqVos) {
- if (deptId.equals(deptVo.getId().toString())){
+ for (String deptId : list) {
+ for (DeptVo deptVo : xqVos) {
+ if (deptId.equals(deptVo.getId().toString())) {
deptNameBuiffer.append(deptVo.getDeptName()).append(",");
}
}
}
//封装部门名称数据
- page.getRecords().get(j).setXQName(deptNameBuiffer.substring(0,deptNameBuiffer.length()-1));
+ if (deptNameBuiffer.length() > 0) {
+ page.getRecords().get(j).setXQName(deptNameBuiffer.substring(0, deptNameBuiffer.length() - 1));
+ }
}
}
@@ -165,7 +171,7 @@
@ApiOperation(value = "新增或修改", notes = "传入zc")
public R submit(@Valid @RequestBody Zc zc) {
String type = zc.getType();
- if (type.equals("1")){
+ if (type.equals("1")) {
User user = new User();
user.setAccount(zc.getUsername());
user.setPassword(DigestUtil.encrypt(zc.getPassword()));
@@ -180,20 +186,7 @@
user.setCardid(zc.getCardid());
iUserService.saveOrUpdate(user);
- String s = "insert into blade_user(id,tenant_id,account,password,name,real_name,avatar,email,phone,sex,role_id,dept_id,cardid," +
- "jurisdiction,examination_type,status,is_deleted) " +
- "values(" + "'" + user.getId() + "'" + "," + "'" + user.getTenantId() + "'" + "," + "'" + user.getAccount() + "'" + "," +
- "'" + user.getPassword() + "'" + "," + "'" + user.getName() + "'" + "," + "'" + user.getRealName() + "'" + "," + "'" + user.getAvatar() + "'" + "," +
- "'" + user.getEmail() + "'" + "," + "'" + user.getPhone() + "'" + "," + "'" + user.getSex() + "'" + "," + "'" + user.getRoleId() + "'" +
- "," + "'" + user.getDeptId() + "'" +
- "," + "'" + user.getCardid() + "'" +
- "," + "'" + user.getJurisdiction() + "'" +
- "," + "'" + user.getExamination_type() + "'" +
- "," + "'" + user.getStatus() + "'" +
- "," + "'" + user.getIsDeleted() + "'" + ")";
- System.out.println(s);
- FtpUtil.sqlFileUpload(s);
}
return R.status(zcService.saveOrUpdate(zc));
}
@@ -219,8 +212,39 @@
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() + "'" +
+ "," + "'" + zc.getPassword() + "'" +
+ "," + "'" + zc.getSname() + "'" +
+ "," + "'" + zc.getSex() + "'" +
+ "," + "'" + zc.getPhone() + "'" +
+ "," + "'" + zc.getZctime() + "'" +
+ "," + "'" + zc.getDeptid() + "'" +
+ "," + "'" + zc.getParentId() + "'" +
+ "," + "'" + zc.getJurisdiction() + "'" +
+ "," + "'" + zc.getCardid() + "'" + ")";
+ 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