宿舍管理学生打卡模块,对学务和辅导员角色查看学生打卡记录做了数据筛选

This commit is contained in:
MDSMO
2025-08-20 09:03:13 +08:00
parent 14933e6dac
commit d9b4f4a731
3 changed files with 91 additions and 4 deletions

View File

@@ -116,7 +116,13 @@ public class DmsStuDaily{
@TableField(exist = false)
private String teacherName;
@TableField(exist = false)
private String teacherNo;
@TableField(exist = false)
private String idCard;
@TableField(exist = false)
private String roleType;
}

View File

@@ -93,9 +93,16 @@
<if test="majorId != null "> and b.major_id = #{majorId}</if>
<if test="classId != null "> and b.class_id = #{classId}</if>
<if test="gradeId != null "> and b.grade_id = #{gradeId}</if>
<if test="stuName != null and stuName != ''"> and b.stu_name like concat('%',#{stuName},'%')</if>
<if test="teacherName != null and teacherName != ''"> and b.teacher_name like concat('%',#{teacherName},'%')</if>
<if test="idCard != null and idCard != ''"> and AES_DECRYPT(UNHEX(b.id_card),'zhxg') = #{idCard}</if>
<if test="stuName != null and stuName != ''">
and b.stu_name like concat('%',#{stuName},'%')</if>
<if test="teacherName != null and teacherName != ''">
and b.teacher_name like concat('%',#{teacherName},'%')</if>
<if test="teacherNo != null and teacherNo != ''">
and b.t_no = #{teacherNo}</if>
<if test="deptName != null and deptName != ''">
and b.dept_name = #{deptName}</if>
<if test="idCard != null and idCard != ''">
and AES_DECRYPT(UNHEX(b.id_card),'zhxg') = #{idCard}</if>
</where>
order by a.id desc
</select>

View File

@@ -2,6 +2,7 @@ package com.srs.web.controller.dormitory;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@@ -21,6 +22,9 @@ import com.srs.common.utils.poi.ExcelUtil;
import com.srs.common.enums.BusinessType;
import com.srs.common.annotation.Log;
import com.srs.common.core.page.TableDataInfo;
import com.srs.common.utils.SecurityUtils;
import com.srs.common.core.domain.entity.SysUser;
import com.srs.system.service.ISysUserService;
/**
* 学生宿舍打卡Controller
@@ -35,6 +39,9 @@ public class DmsStuDailyController extends BaseController {
@Autowired
private IDmsStuDailyService dmsStuDailyService;
@Autowired
private ISysUserService userService;
@GetMapping("/countDeptCard")
public AjaxResult countDeptCard(){
List<Map<String, Object>> list = dmsStuDailyService.countDeptCard();
@@ -75,11 +82,78 @@ public class DmsStuDailyController extends BaseController {
@ApiOperation("查询学生宿舍打卡列表")
public TableDataInfo listView(DmsStuDaily param)
{
// 获取当前用户信息
String username = getUsername();
SysUser currentUser = userService.selectUserByUserName(username);
// 根据用户角色设置数据过滤条件
if (currentUser != null) {
// 获取用户角色组
String roleGroup = userService.selectUserRoleGroup(username);
// 检查是否同时拥有学务干事和辅导员角色
boolean isDeptRole = roleGroup.contains("学务干事") || roleGroup.contains("学务办初审");
boolean isTeacherRole = roleGroup.contains("辅导员");
// 根据前端传递的roleType参数进行过滤
if (isDeptRole && isTeacherRole) {
// 同时拥有两个角色根据roleType参数决定查看哪种数据
if ("teacher".equals(param.getRoleType())) {
// 查看个人班级数据
param.setTeacherNo(username);
} else {
// 默认查看学院数据
if (currentUser.getDept() != null) {
param.setDeptName(currentUser.getDept().getDeptName());
}
}
} else if (isDeptRole) {
// 只有学务干事角色,查看学院数据
if (currentUser.getDept() != null) {
param.setDeptName(currentUser.getDept().getDeptName());
}
} else if (isTeacherRole) {
// 只有辅导员角色,查看个人班级数据
param.setTeacherNo(username);
}
// 超级管理员可以查看所有数据,不设置过滤条件
}
startPage();
List<DmsStuDaily> list = dmsStuDailyService.listView(param);
return getDataTable(list);
}
/**
* 主要用于前端不同角色的切换返回不同的数据
*/
@GetMapping("/checkRoles")
@ApiOperation("检查用户角色信息")
public AjaxResult checkUserRoles() {
String username = getUsername();
String roleGroup = userService.selectUserRoleGroup(username);
SysUser currentUser = userService.selectUserByUserName(username);
boolean isDeptRole = roleGroup.contains("学务干事");
boolean isTeacherRole = roleGroup.contains("辅导员");
boolean hasMultipleRoles = isDeptRole && isTeacherRole;
Map<String, Object> roleInfo = new HashMap<>();
roleInfo.put("hasMultipleRoles", hasMultipleRoles);
roleInfo.put("defaultRole", "dept"); // 默认显示学院数据
roleInfo.put("isAdmin", SecurityUtils.isAdmin(SecurityUtils.getUserId()));
roleInfo.put("isXuewu", roleGroup.contains("学务干事"));
roleInfo.put("isFudaoyuan", roleGroup.contains("辅导员"));
// 添加用户部门信息
if (currentUser != null && currentUser.getDept() != null) {
roleInfo.put("userDeptName", currentUser.getDept().getDeptName());
}
return AjaxResult.success(roleInfo);
}
@ApiOperation("学生打卡")
@PostMapping("/doCard")