From e2f37c5412d4cdcc5c3a35599c217388f80f79af Mon Sep 17 00:00:00 2001
From: weicd <weicd@yhzhg.cn>
Date: Mon, 09 Jan 2023 02:08:04 +0000
Subject: [PATCH] 各审批修改删除验证登录人,各审批添加修改时验证其他审批时间是否重复

---
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java
index 467a6d9..e6a9879 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java
@@ -107,12 +107,11 @@
         Attendance attendance = attendanceRepository.findById(resources.getId()).orElseGet(Attendance::new);
         ValidationUtil.isNull( attendance.getId(),"Attendance","id",resources.getId());
         attendance.copy(resources);
-
         //获取当前登入人信息
         User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
-        Job job = user.getJobs().iterator().next();
+        Role role = user.getRoles().iterator().next();
         //除超管、总经理只能修改自己信息
-        if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){
+        if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){
             if (!Long.valueOf(resources.getUserId()).equals(SecurityUtils.getCurrentUserId())){
                 throw new BadRequestException("只能修改自己的记录");
             }
@@ -205,7 +204,7 @@
         if (localDateTime.toLocalTime().isBefore(sysRostering.getWorkStartTime())) {
             return localDateTime.toLocalDate().atTime(sysRostering.getWorkStartTime());
         } else if (localDateTime.toLocalTime().isAfter(sysRostering.getLunchStartTime()) && localDateTime.toLocalTime().isBefore(sysRostering.getLunchEndTime())) {
-            return localDateTime.toLocalDate().atTime(sysRostering.getWorkEndTime());
+            return localDateTime.toLocalDate().atTime(sysRostering.getLunchEndTime());
         } else if (localDateTime.toLocalTime().isAfter(sysRostering.getWorkEndTime())) {
             return localDateTime.toLocalDate().atTime(sysRostering.getWorkEndTime());
         }
@@ -218,11 +217,11 @@
 
             //获取当前登入人信息
             User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
-            Job job = user.getJobs().iterator().next();
+            Role role = user.getRoles().iterator().next();
             //根据id查询记录
             Optional<Attendance> attendance = attendanceRepository.findById(id);
             //除超管、总经理只能删除自己信息
-            if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){
+            if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){
                 if (!Long.valueOf(attendance.get().getUserId()).equals(SecurityUtils.getCurrentUserId())){
                     throw new BadRequestException("只能删除自己的记录");
                 }
@@ -252,9 +251,9 @@
     public void getUserMakeUpCard(String userId) {
         //获取当前登入人信息
         User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
-        Job job = user.getJobs().iterator().next();
+        Role role = user.getRoles().iterator().next();
         //除超管、总经理只能补自己的卡
-        if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){
+        if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){
             if (!Long.valueOf(userId).equals(SecurityUtils.getCurrentUserId())){
                 throw new BadRequestException("只能补自己的卡");
             }

--
Gitblit v1.9.3