From c95d04de9c717a491135aa76c9107c88dc9c7e6c Mon Sep 17 00:00:00 2001
From: heheng <475597332@qq.com>
Date: 星期三, 03 十二月 2025 16:53:34 +0800
Subject: [PATCH] 修改权限
---
multi-system/src/main/java/com/gkhy/exam/system/service/impl/AnnualMaintenanceServiceServiceImpl.java | 74 ++++++++++++++++++++-----------------
1 files changed, 40 insertions(+), 34 deletions(-)
diff --git a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/AnnualMaintenanceServiceServiceImpl.java b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/AnnualMaintenanceServiceServiceImpl.java
index a4348c7..218668b 100644
--- a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/AnnualMaintenanceServiceServiceImpl.java
+++ b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/AnnualMaintenanceServiceServiceImpl.java
@@ -7,6 +7,7 @@
import com.gkhy.exam.common.api.CommonPage;
import com.gkhy.exam.common.api.CommonResult;
import com.gkhy.exam.common.constant.UserConstant;
+import com.gkhy.exam.common.exception.ApiException;
import com.gkhy.exam.common.utils.PageUtils;
import com.gkhy.exam.common.utils.SecurityUtils;
import com.gkhy.exam.system.domain.*;
@@ -54,6 +55,7 @@
}
@Override
+ @Transactional
public CommonResult saveAnnualMaintenanceService(AnnualMaintenanceService annualMaintenanceService) {
List<AnnualMaintenanceServiceContent> annualMaintenanceServiceContentList = annualMaintenanceService.getAnnualMaintenanceServiceContentList();
List<AnnualMaintenanceServiceUser> annualMaintenanceServiceUserList = annualMaintenanceService.getAnnualMaintenanceServiceUserList();
@@ -89,7 +91,7 @@
});
int insert = annualMaintenanceServiceContentMapper.batchInsert(annualMaintenanceServiceContentList);
if (insert <= 0) {
- throw new RuntimeException("保存保养内容失败");
+ throw new ApiException("保存保养内容失败");
}
} else {
annualMaintenanceServiceContentList.forEach(content -> {
@@ -98,7 +100,7 @@
});
int update = annualMaintenanceServiceContentMapper.batchUpdate(annualMaintenanceServiceContentList);
if (update <= 0) {
- throw new RuntimeException("保存保养内容失败");
+ throw new ApiException("保存保养内容失败");
}
}
}
@@ -111,34 +113,40 @@
.in(AnnualMaintenanceServiceUser::getId, delServiceUserIds)
);
if (update1 <= 0) {
- throw new RuntimeException("保存失败");
+ throw new ApiException("保存失败");
}
}
List<AnnualMaintenanceServiceUser> addUser = annualMaintenanceServiceUserList.stream()
.filter(user -> null == user.getId())
.collect(Collectors.toList());
- addUser.forEach(user -> {
- user.setCreateBy(SecurityUtils.getUsername());
- user.setCreateTime(LocalDateTime.now());
- user.setAnnualMaintenanceServiceId(serviceId);
- });
- int i = annualMaintenanceServiceUserMapper.batchInsert(addUser);
- if (i <= 0) {
- throw new RuntimeException("保存失败");
+ if (ObjectUtil.isNotEmpty(addUser)){
+ addUser.forEach(user -> {
+ user.setCreateBy(SecurityUtils.getUsername());
+ user.setCreateTime(LocalDateTime.now());
+ user.setAnnualMaintenanceServiceId(serviceId);
+ });
+ int i = annualMaintenanceServiceUserMapper.batchInsert(addUser);
+ if (i <= 0) {
+ throw new ApiException("保存失败");
+ }
}
+
List<AnnualMaintenanceServiceUser> updateUser = annualMaintenanceServiceUserList.stream()
.filter(user -> null != user.getId())
.collect(Collectors.toList());
- updateUser.forEach(user -> {
- user.setUpdateBy(SecurityUtils.getUsername());
- user.setUpdateTime(LocalDateTime.now());
- });
- int update = annualMaintenanceServiceUserMapper.batchUpdate(updateUser);
- if (update <= 0) {
- throw new RuntimeException("保存失败");
+ if (ObjectUtil.isNotEmpty(updateUser)){
+ updateUser.forEach(user -> {
+ user.setUpdateBy(SecurityUtils.getUsername());
+ user.setUpdateTime(LocalDateTime.now());
+ });
+ int update = annualMaintenanceServiceUserMapper.batchUpdate(updateUser);
+ if (update <= 0) {
+ throw new ApiException("保存失败");
+ }
}
+
}
private void checkUser(List<AnnualMaintenanceServiceUser> annualMaintenanceServiceUserList) {
@@ -147,52 +155,52 @@
.filter(user -> 1 == user.getUserType())
.collect(Collectors.toList());
if (ObjectUtil.isEmpty(filteredUsers)) {
- throw new RuntimeException("请填写一级保养操作人员");
+ throw new ApiException("请填写一级保养操作人员");
}
Set<Long> userIdSet = filteredUsers.stream()
.map(AnnualMaintenanceServiceUser::getUserId)
.collect(Collectors.toSet());
if (userIdSet.size() != filteredUsers.size()) {
- throw new RuntimeException("一级保养操作人员重复");
+ throw new ApiException("一级保养操作人员重复");
}
List<AnnualMaintenanceServiceUser> filteredUsers2 = annualMaintenanceServiceUserList.stream()
.filter(user -> 2 == user.getUserType())
.collect(Collectors.toList());
if (ObjectUtil.isEmpty(filteredUsers2)) {
- throw new RuntimeException("请填写一级保养检查人员");
+ throw new ApiException("请填写一级保养检查人员");
}
Set<Long> userIdSet2 = filteredUsers2.stream()
.map(AnnualMaintenanceServiceUser::getUserId)
.collect(Collectors.toSet());
if (userIdSet2.size() != filteredUsers2.size()) {
- throw new RuntimeException("一级保养检查人员重复");
+ throw new ApiException("一级保养检查人员重复");
}
List<AnnualMaintenanceServiceUser> filteredUsers3 = annualMaintenanceServiceUserList.stream()
.filter(user -> 3 == user.getUserType())
.collect(Collectors.toList());
if (ObjectUtil.isEmpty(filteredUsers3)) {
- throw new RuntimeException("请填写二级保养操作人员");
+ throw new ApiException("请填写二级保养操作人员");
}
- Set<Long> userIdSet3 = filteredUsers.stream()
+ Set<Long> userIdSet3 = filteredUsers3.stream()
.map(AnnualMaintenanceServiceUser::getUserId)
.collect(Collectors.toSet());
if (userIdSet3.size() != filteredUsers3.size()) {
- throw new RuntimeException("二级保养操作人员重复");
+ throw new ApiException("二级保养操作人员重复");
}
List<AnnualMaintenanceServiceUser> filteredUsers4 = annualMaintenanceServiceUserList.stream()
.filter(user -> 4 == user.getUserType())
.collect(Collectors.toList());
if (ObjectUtil.isEmpty(filteredUsers4)) {
- throw new RuntimeException("请填写二级保养检查人员");
+ throw new ApiException("请填写二级保养检查人员");
}
- Set<Long> userIdSet4 = filteredUsers2.stream()
+ Set<Long> userIdSet4 = filteredUsers4.stream()
.map(AnnualMaintenanceServiceUser::getUserId)
.collect(Collectors.toSet());
if (userIdSet4.size() != filteredUsers4.size()) {
- throw new RuntimeException("二级保养检查人员重复");
+ throw new ApiException("二级保养检查人员重复");
}
}
@@ -227,18 +235,16 @@
.set(AnnualMaintenanceServiceUser::getDelFlag, UserConstant.DEPT_DISABLE)
.set(AnnualMaintenanceServiceUser::getUpdateTime, LocalDateTime.now())
.set(AnnualMaintenanceServiceUser::getUpdateBy, SecurityUtils.getUsername()));
- if (update1 <= 0) {
- throw new RuntimeException("删除失败");
- }
+// if (update1 <= 0) {
+// throw new ApiException("删除失败");
+// }
int update2 = annualMaintenanceServiceContentMapper.update(new AnnualMaintenanceServiceContent(),
new LambdaUpdateWrapper<AnnualMaintenanceServiceContent>().eq(AnnualMaintenanceServiceContent::getAnnualMaintenanceServiceId, id)
.set(AnnualMaintenanceServiceContent::getDelFlag, UserConstant.DEPT_DISABLE)
.set(AnnualMaintenanceServiceContent::getUpdateTime, LocalDateTime.now())
.set(AnnualMaintenanceServiceContent::getUpdateBy, SecurityUtils.getUsername())
);
- if (update2 <= 0) {
- throw new RuntimeException("删除失败");
- }
+
return CommonResult.success();
}
return CommonResult.failed();
--
Gitblit v1.9.2