Browse Source

请假记录

Administrator 1 year ago
parent
commit
55cc9fea52

+ 1 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/RecordLeaveController.java

@@ -41,7 +41,6 @@ public class RecordLeaveController extends BaseController
     @GetMapping("/list")
     public TableDataInfo list(RecordLeave recordLeave)
     {
-        startPage();
         List<RecordLeave> list = recordLeaveService.selectRecordLeaveList(recordLeave);
         return getDataTable(list);
     }
@@ -85,7 +84,7 @@ public class RecordLeaveController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:leave:edit')")
     @Log(title = "请假记录信息", businessType = BusinessType.UPDATE)
-    @PutMapping
+    @PostMapping("/put")
     public AjaxResult edit(@RequestBody RecordLeave recordLeave)
     {
         return toAjax(recordLeaveService.updateRecordLeave(recordLeave));

+ 8 - 9
ruoyi-system/src/main/java/com/ruoyi/system/domain/RecordLeave.java

@@ -38,9 +38,9 @@ public class RecordLeave extends BaseEntity
     @Excel(name = "请假理由")
     private String reason;
 
-    /** 部门id */
-    @Excel(name = "部门id")
-    private Long classId;
+    /** 班级id */
+    @Excel(name = "班级id")
+    private String classId;
 
     /** 部门名称 */
     @Excel(name = "班级名称")
@@ -124,16 +124,15 @@ public class RecordLeave extends BaseEntity
     {
         return reason;
     }
-    public void setClassId(Long classId) 
-    {
-        this.classId = classId;
-    }
 
-    public Long getClassId() 
-    {
+    public String getClassId() {
         return classId;
     }
 
+    public void setClassId(String classId) {
+        this.classId = classId;
+    }
+
     public String getClassName() {
         return className;
     }

+ 61 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RecordLeaveServiceImpl.java

@@ -1,13 +1,26 @@
 package com.ruoyi.system.service.impl;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+
+import com.ruoyi.common.core.domain.entity.FormalParentsStudent;
+import com.ruoyi.common.core.domain.entity.FormalTeacherClass;
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.system.domain.score.ScoreData;
+import com.ruoyi.system.mapper.FormalParentsStudentMapper;
+import com.ruoyi.system.mapper.FormalTeacherClassMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.system.mapper.RecordLeaveMapper;
 import com.ruoyi.system.domain.RecordLeave;
 import com.ruoyi.system.service.IRecordLeaveService;
 
+import static com.ruoyi.common.utils.PageUtils.startPage;
+
 /**
  * 请假记录信息Service业务层处理
  * 
@@ -20,6 +33,12 @@ public class RecordLeaveServiceImpl implements IRecordLeaveService
     @Autowired
     private RecordLeaveMapper recordLeaveMapper;
 
+    @Autowired
+    private FormalTeacherClassMapper formalTeacherClassMapper;
+
+    @Autowired
+    private FormalParentsStudentMapper formalParentsStudentMapper;
+
     /**
      * 查询请假记录信息
      * 
@@ -41,7 +60,48 @@ public class RecordLeaveServiceImpl implements IRecordLeaveService
     @Override
     public List<RecordLeave> selectRecordLeaveList(RecordLeave recordLeave)
     {
-        return recordLeaveMapper.selectRecordLeaveList(recordLeave);
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        StringBuilder classId = new StringBuilder("0,");
+        Map<String, Object> params = recordLeave.getParams();
+        String role = "admin";
+        if (params != null && params.size() > 0) {
+            role = (String) params.get("role");
+        }
+        List<RecordLeave> recordLeaveList = new ArrayList<>();
+        if ("teacher".equals(role)) {
+            FormalTeacherClass formalTeacherClass = new FormalTeacherClass();
+            formalTeacherClass.setTeacherId(user.getUserId());
+            List<FormalTeacherClass> formalTeacherClasses = formalTeacherClassMapper.selectFormalTeacherClassList(formalTeacherClass);
+            if (formalTeacherClasses != null && formalTeacherClasses.size() > 0) {
+                for (FormalTeacherClass teacherClass : formalTeacherClasses) {
+                    classId.append(teacherClass.getClassId()).append(",");
+                }
+            }
+            if (StringUtils.isNotBlank(classId.toString())) {
+                classId = new StringBuilder(classId.substring(0, classId.length() - 1));
+            }
+            startPage();
+            recordLeave.setClassId(classId.toString());
+            recordLeaveList = recordLeaveMapper.selectRecordLeaveList(recordLeave);
+        } else if ("parents".equals(role)) {
+            FormalParentsStudent formalParentsStudent = new FormalParentsStudent();
+            formalParentsStudent.setParentsId(user.getUserId());
+            List<FormalParentsStudent> formalParentsStudents = formalParentsStudentMapper.selectFormalParentsStudentList(formalParentsStudent);
+            for (FormalParentsStudent parentsStudent : formalParentsStudents) {
+                classId.append(parentsStudent.getClassId()).append(",");
+            }
+            if (StringUtils.isNotBlank(classId.toString())) {
+                classId = new StringBuilder(classId.substring(0, classId.length() - 1));
+            }
+            startPage();
+            recordLeave.setClassId(classId.toString());
+            recordLeaveList = recordLeaveMapper.selectRecordLeaveList(recordLeave);
+        } else if ("admin".equals(role)) {
+            startPage();
+            recordLeaveList = recordLeaveMapper.selectRecordLeaveList(recordLeave);
+        }
+
+        return recordLeaveList;
     }
 
     /**

+ 1 - 1
ruoyi-system/src/main/resources/mapper/system/RecordLeaveMapper.xml

@@ -38,7 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="startTime != null "> and start_time = #{startTime}</if>
             <if test="endTime != null "> and end_time = #{endTime}</if>
             <if test="reason != null  and reason != ''"> and reason = #{reason}</if>
-            <if test="classId != null "> and class_id = #{classId}</if>
+            <if test="classId != null and classId!= ''"> and find_in_set(class_id,#{classId})</if>
             <if test="className != null  and className != ''"> and class_name like concat('%', #{className}, '%')</if>
             <if test="absenteeId != null  and absenteeId != ''"> and absentee_id = #{absenteeId}</if>
             <if test="absenteeName != null  and absenteeName != ''"> and absentee_name like concat('%', #{absenteeName}, '%')</if>