From 0a4fbcd9d997005bda2b5ac5dc9daa586342d7db Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Fri, 25 Feb 2022 14:43:11 +0800
Subject: [PATCH] 任务数量统计
---
src/main/java/org/springblade/modules/zc/controller/ZcController.java | 71 ++++++++++++++++++++++++-----------
1 files changed, 49 insertions(+), 22 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..6769a30 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;
@@ -170,24 +171,16 @@
@ApiOperation(value = "新增或修改", notes = "传入zc")
public R submit(@Valid @RequestBody Zc zc) {
String type = zc.getType();
+ String stype="1";
+ String account=zc.getUsername();
if (type.equals("1")) {
- User user = new User();
- user.setAccount(zc.getUsername());
- user.setPassword(DigestUtil.encrypt(zc.getPassword()));
- user.setRealName(zc.getSname());
- user.setSex(Integer.valueOf(zc.getSex()));
- user.setPhone(zc.getPhone());
- user.setDeptId(zc.getDeptid());
- user.setRoleId(zc.getParentId());
- user.setJurisdiction(zc.getJurisdiction());
- user.setExamination_type("0");
- user.setExamination_mx("正常");
- user.setCardid(zc.getCardid());
- iUserService.saveOrUpdate(user);
-
-
+ iUserService.updateAcc(stype,account);
+ zcService.saveOrUpdate(zc);
+ } else {
+ iUserService.delete(account);
+ zcService.deleteZc(account);
}
- return R.status(zcService.saveOrUpdate(zc));
+ return R.success("成功");
}
@@ -211,9 +204,28 @@
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)" +
+ //同时新增到用户表
+ User user = new User();
+ user.setAccount(zc.getUsername());
+ user.setPassword(DigestUtil.encrypt(zc.getPassword()));
+ user.setRealName(zc.getSname());
+ user.setSex(Integer.valueOf(zc.getSex()));
+ user.setPhone(zc.getPhone());
+ user.setDeptId(zc.getDeptid());
+ user.setRoleId(zc.getParentId());
+ user.setJurisdiction(zc.getJurisdiction());
+ user.setExamination_type("0");
+ user.setExamination_mx("正常");
+ user.setCardid(zc.getCardid());
+ user.setStype("0");
+ user.setAddress(zc.getAddress());
+ iUserService.saveOrUpdate(user);
+ String s = "insert into act_zc(id,username,password,sname,sex,phone,zctime,deptid,parent_id,jurisdiction,cardid,address)" +
"values(" + "'" + zc.getId() + "'" +
"," + "'" + zc.getUsername() + "'" +
"," + "'" + zc.getPassword() + "'" +
@@ -224,12 +236,27 @@
"," + "'" + zc.getDeptid() + "'" +
"," + "'" + zc.getParentId() + "'" +
"," + "'" + zc.getJurisdiction() + "'" +
- "," + "'" + zc.getCardid() + "'" + ")";
-
- System.out.println(s);
+ "," + "'" + zc.getCardid() + "'" +
+ "," + "'" + zc.getAddress() + "'"
+ + ")";
FtpUtil.sqlFileUpload(s);
-
return R.success("新增成功");
}
+ /**
+ * 用户验证
+ *
+ * @param username
+ * @return
+ */
+ @GetMapping("/inspect")
+ public R inspect(String username) {
+ Integer userCount = iUserService.selectCount(username);
+ Integer integer = zcService.selecyZcCount(username);
+ if (userCount > 0 || integer > 0) {
+ throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前用户{}已存在!", username));
+ }
+ return R.success("当前用户不存在!");
+ }
+
}
--
Gitblit v1.9.3