From 517a0052bca76fe92ce1610db60e81d35bc42f2b Mon Sep 17 00:00:00 2001 From: zlwu <704541015@qq.com> Date: Fri, 25 Jul 2025 14:51:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=AD=A6=E7=94=9F=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=9D=83=E9=99=90=E8=AE=BE=E7=BD=AE=E7=9A=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../XgStudentManagerController.java | 132 +++++++++ .../XgStudentManagerSourceController.java | 117 ++++++++ .../dromara/xg/domain/XgStudentManager.java | 77 ++++++ .../xg/domain/XgStudentManagerSource.java | 67 +++++ .../xg/domain/bo/XgStudentManagerBo.java | 77 ++++++ .../domain/bo/XgStudentManagerSourceBo.java | 67 +++++ .../xg/domain/vo/ClassTeacherInfoVo.java | 15 + .../domain/vo/XgStudentManagerSourceVo.java | 80 ++++++ .../xg/domain/vo/XgStudentManagerVo.java | 111 ++++++++ .../xg/mapper/XgStudentManagerMapper.java | 25 ++ .../mapper/XgStudentManagerSourceMapper.java | 15 + .../xg/service/IXgStudentManagerService.java | 86 ++++++ .../IXgStudentManagerSourceService.java | 76 +++++ .../impl/XgDormManagerServiceImpl.java | 2 +- .../impl/XgStudentManagerServiceImpl.java | 186 +++++++++++++ .../XgStudentManagerSourceServiceImpl.java | 167 +++++++++++ .../XgStudentManagerMapper.xml | 36 +++ .../XgStudentManagerSourceMapper.xml | 7 + .../code-adjust-record-2025-07-24-wuzilong.md | 17 ++ docs/开发文档/API/API文档总览.md | 27 ++ docs/开发文档/API/宿舍管理员信息API.md | 259 ++++++++++++++++++ .../xgStudentManager/studentManager/index.ts | 95 +++++++ .../xgStudentManager/studentManager/types.ts | 156 +++++++++++ .../studentManagerSource/index.ts | 63 +++++ .../studentManagerSource/types.ts | 126 +++++++++ .../authmsg/components/AdminDialog.vue | 200 ++++++++++++-- .../authmsg/components/ScopeDialog.vue | 216 +++++++++++---- web/src/views/studentMsg/authmsg/index.vue | 165 +++++------ 28 files changed, 2506 insertions(+), 161 deletions(-) create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/controller/XgStudentManagerController.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/controller/XgStudentManagerSourceController.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/XgStudentManager.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/XgStudentManagerSource.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/bo/XgStudentManagerBo.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/bo/XgStudentManagerSourceBo.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/ClassTeacherInfoVo.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/XgStudentManagerSourceVo.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/XgStudentManagerVo.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/mapper/XgStudentManagerMapper.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/mapper/XgStudentManagerSourceMapper.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/IXgStudentManagerService.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/IXgStudentManagerSourceService.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/impl/XgStudentManagerServiceImpl.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/impl/XgStudentManagerSourceServiceImpl.java create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/resources/mapper/xgStudentManager/XgStudentManagerMapper.xml create mode 100644 backend/ruoyi-modules/ruoyi-xg/src/main/resources/mapper/xgStudentManagerSource/XgStudentManagerSourceMapper.xml create mode 100644 docs/变更管理/code-adjust-record-2025-07-24-wuzilong.md create mode 100644 docs/开发文档/API/宿舍管理员信息API.md create mode 100644 web/src/api/xgStudentManager/studentManager/index.ts create mode 100644 web/src/api/xgStudentManager/studentManager/types.ts create mode 100644 web/src/api/xgStudentManagerSource/studentManagerSource/index.ts create mode 100644 web/src/api/xgStudentManagerSource/studentManagerSource/types.ts diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/controller/XgStudentManagerController.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/controller/XgStudentManagerController.java new file mode 100644 index 00000000..8cdcb9c2 --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/controller/XgStudentManagerController.java @@ -0,0 +1,132 @@ +package org.dromara.xg.controller; + +import java.util.List; + +import lombok.RequiredArgsConstructor; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.constraints.*; +import cn.dev33.satoken.annotation.SaCheckPermission; +import org.springframework.web.bind.annotation.*; +import org.springframework.validation.annotation.Validated; +import org.dromara.common.idempotent.annotation.RepeatSubmit; +import org.dromara.common.log.annotation.Log; +import org.dromara.common.web.core.BaseController; +import org.dromara.common.mybatis.core.page.PageQuery; +import org.dromara.common.core.domain.R; +import org.dromara.common.core.validate.AddGroup; +import org.dromara.common.core.validate.EditGroup; +import org.dromara.common.log.enums.BusinessType; +import org.dromara.common.excel.utils.ExcelUtil; +import org.dromara.xg.domain.vo.XgStudentManagerVo; +import org.dromara.xg.domain.bo.XgStudentManagerBo; +import org.dromara.xg.service.IXgStudentManagerService; +import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.xg.domain.vo.ClassTeacherInfoVo; + +/** + * 宿舍管理员信息 + * + * @author zlwu + * @date 2025-07-24 + */ +@Validated +@RequiredArgsConstructor +@RestController +@RequestMapping("/xgStudentManager/studentManager") +public class XgStudentManagerController extends BaseController { + + private final IXgStudentManagerService xgStudentManagerService; + + /** + * 查询宿舍管理员信息列表 + */ + @SaCheckPermission("xgStudentManager:studentManager:list") + @GetMapping("/list") + public TableDataInfo list(XgStudentManagerBo bo, PageQuery pageQuery) { + return xgStudentManagerService.queryPageList(bo, pageQuery); + } + + /** + * 导出宿舍管理员信息列表 + */ + @SaCheckPermission("xgStudentManager:studentManager:export") + @Log(title = "宿舍管理员信息", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(XgStudentManagerBo bo, HttpServletResponse response) { + List list = xgStudentManagerService.queryList(bo); + ExcelUtil.exportExcel(list, "宿舍管理员信息", XgStudentManagerVo.class, response); + } + + /** + * 获取宿舍管理员信息详细信息 + * + * @param id 主键 + */ + @SaCheckPermission("xgStudentManager:studentManager:query") + @GetMapping("/{id}") + public R getInfo(@NotNull(message = "主键不能为空") @PathVariable Long id) { + return R.ok(xgStudentManagerService.queryById(id)); + } + + /** + * 新增宿舍管理员信息 + */ + @SaCheckPermission("xgStudentManager:studentManager:add") + @Log(title = "宿舍管理员信息", businessType = BusinessType.INSERT) + @RepeatSubmit() + @PostMapping() + public R add(@Validated(AddGroup.class) @RequestBody XgStudentManagerBo bo) { + return toAjax(xgStudentManagerService.insertByBo(bo)); + } + + /** + * 修改宿舍管理员信息 + */ + @SaCheckPermission("xgStudentManager:studentManager:edit") + @Log(title = "宿舍管理员信息", businessType = BusinessType.UPDATE) + @RepeatSubmit() + @PutMapping() + public R edit(@Validated(EditGroup.class) @RequestBody XgStudentManagerBo bo) { + return toAjax(xgStudentManagerService.updateByBo(bo)); + } + + /** + * 删除宿舍管理员信息 + * + * @param ids 主键串 + */ + @SaCheckPermission("xgStudentManager:studentManager:remove") + @Log(title = "宿舍管理员信息", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public R remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ids) { + return toAjax(xgStudentManagerService.deleteWithValidByIds(List.of(ids), true)); + } + + /** + * 获取可用的教职工信息列表 + * + * @param managerType 管理员类型(1 全校管理员 2 自定义管理员 3 班主任) + */ + // @SaCheckPermission("xgStudentManager:studentManager:list") + @GetMapping("/listAvailableTeachers") + public R> listAvailableTeachers(@RequestParam("managerType") String managerType) { + List teachers = xgStudentManagerService.queryAvailableTeachers(managerType); + return R.ok(teachers); + } + + /** + * 获取当前正在教学的班主任信息 + * + * @param phone 手机号码(可选,模糊查询) + * @param name 姓名(可选,模糊查询) + * @return 班主任信息列表 + */ + @SaCheckPermission("xgStudentManager:studentManager:list") + @GetMapping("/listActiveClassTeachers") + public R> listActiveClassTeachers( + @RequestParam(value = "phone", required = false) String phone, + @RequestParam(value = "name", required = false) String name) { + List teachers = xgStudentManagerService.queryActiveClassTeachers(phone, name); + return R.ok(teachers); + } +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/controller/XgStudentManagerSourceController.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/controller/XgStudentManagerSourceController.java new file mode 100644 index 00000000..ddc7c810 --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/controller/XgStudentManagerSourceController.java @@ -0,0 +1,117 @@ +package org.dromara.xg.controller; + +import java.util.List; + +import lombok.RequiredArgsConstructor; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.constraints.*; +import cn.dev33.satoken.annotation.SaCheckPermission; +import org.springframework.web.bind.annotation.*; +import org.springframework.validation.annotation.Validated; +import org.dromara.common.idempotent.annotation.RepeatSubmit; +import org.dromara.common.log.annotation.Log; +import org.dromara.common.web.core.BaseController; +import org.dromara.common.mybatis.core.page.PageQuery; +import org.dromara.common.core.domain.R; +import org.dromara.common.core.validate.AddGroup; +import org.dromara.common.core.validate.EditGroup; +import org.dromara.common.log.enums.BusinessType; +import org.dromara.common.excel.utils.ExcelUtil; +import org.dromara.xg.domain.vo.XgStudentManagerSourceVo; +import org.dromara.xg.domain.bo.XgStudentManagerSourceBo; +import org.dromara.xg.service.IXgStudentManagerSourceService; +import org.dromara.common.mybatis.core.page.TableDataInfo; + +/** + * 学生管理员授权关系 + * + * @author zlwu + * @date 2025-07-24 + */ +@Validated +@RequiredArgsConstructor +@RestController +@RequestMapping("/xgStudentManagerSource/studentManagerSource") +public class XgStudentManagerSourceController extends BaseController { + + private final IXgStudentManagerSourceService xgStudentManagerSourceService; + + /** + * 查询学生管理员授权关系列表 + */ + @SaCheckPermission("xgStudentManagerSource:studentManagerSource:list") + @GetMapping("/list") + public TableDataInfo list(XgStudentManagerSourceBo bo, PageQuery pageQuery) { + return xgStudentManagerSourceService.queryPageList(bo, pageQuery); + } + + /** + * 导出学生管理员授权关系列表 + */ + @SaCheckPermission("xgStudentManagerSource:studentManagerSource:export") + @Log(title = "学生管理员授权关系", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(XgStudentManagerSourceBo bo, HttpServletResponse response) { + List list = xgStudentManagerSourceService.queryList(bo); + ExcelUtil.exportExcel(list, "学生管理员授权关系", XgStudentManagerSourceVo.class, response); + } + + /** + * 获取学生管理员授权关系详细信息 + * + * @param id 主键 + */ + @SaCheckPermission("xgStudentManagerSource:studentManagerSource:query") + @GetMapping("/{id}") + public R getInfo(@NotNull(message = "主键不能为空") @PathVariable Long id) { + return R.ok(xgStudentManagerSourceService.queryById(id)); + } + + /** + * 新增学生管理员授权关系 + */ + @SaCheckPermission("xgStudentManagerSource:studentManagerSource:add") + @Log(title = "学生管理员授权关系", businessType = BusinessType.INSERT) + @RepeatSubmit() + @PostMapping() + public R add(@Validated(AddGroup.class) @RequestBody XgStudentManagerSourceBo bo) { + return toAjax(xgStudentManagerSourceService.insertByBo(bo)); + } + + /** + * 修改学生管理员授权关系 + */ + @SaCheckPermission("xgStudentManagerSource:studentManagerSource:edit") + @Log(title = "学生管理员授权关系", businessType = BusinessType.UPDATE) + @RepeatSubmit() + @PutMapping() + public R edit(@Validated(EditGroup.class) @RequestBody XgStudentManagerSourceBo bo) { + return toAjax(xgStudentManagerSourceService.updateByBo(bo)); + } + + /** + * 删除学生管理员授权关系 + * + * @param ids 主键串 + */ + @SaCheckPermission("xgStudentManagerSource:studentManagerSource:remove") + @Log(title = "学生管理员授权关系", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public R remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ids) { + return toAjax(xgStudentManagerSourceService.deleteWithValidByIds(List.of(ids), true)); + } + + /** + * 自定义学生管理员授予部门权限 + * + * @param managerId 管理员ID + * @param authSourceIds 资源ID列表 + */ + @SaCheckPermission("xgStudentManagerSource:studentManagerSource:grantDeptAuth") + @Log(title = "学生管理员授权关系", businessType = BusinessType.UPDATE) + @PostMapping("/grantDeptAuth") + public R grantDeptAuth(@RequestParam Long managerId, @RequestBody List authSourceIds) { + xgStudentManagerSourceService.grantDeptAuth(managerId, authSourceIds); + return R.ok(); + } +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/XgStudentManager.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/XgStudentManager.java new file mode 100644 index 00000000..7ae2920c --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/XgStudentManager.java @@ -0,0 +1,77 @@ +package org.dromara.xg.domain; + +import org.dromara.common.tenant.core.TenantEntity; +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serial; + +/** + * 宿舍管理员信息对象 xg_student_manager + * + * @author zlwu + * @date 2025-07-24 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("xg_student_manager") +public class XgStudentManager extends TenantEntity { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 主键ID + */ + @TableId(value = "id") + private Long id; + + /** + * 管理员姓名 + */ + private String managerName; + + /** + * 管理员类型(1 全校管理员 2 自定义管理员 3 班主任) + */ + private String managerType; + + /** + * 管理级别(1-3,1为最高) + */ + private Long managerLevel; + + /** + * 关联用户ID + */ + private Long userId; + + /** + * 联系电话 + */ + private String phone; + + /** + * 性别(0男 1女 2未知) + */ + private String gender; + + /** + * 状态(0正常 1停用) + */ + private String status; + + /** + * 删除标志(0代表存在 1代表删除) + */ + @TableLogic(value = "0", delval = "1") + private String deleted; + + /** + * 备注 + */ + private String remark; + + +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/XgStudentManagerSource.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/XgStudentManagerSource.java new file mode 100644 index 00000000..a98dfac1 --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/XgStudentManagerSource.java @@ -0,0 +1,67 @@ +package org.dromara.xg.domain; + +import org.dromara.common.tenant.core.TenantEntity; +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serial; + +/** + * 学生管理员授权关系对象 xg_student_manager_source + * + * @author zlwu + * @date 2025-07-24 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("xg_student_manager_source") +public class XgStudentManagerSource extends TenantEntity { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 主键ID + */ + @TableId(value = "id") + private Long id; + + /** + * 管理员ID + */ + private Long managerId; + + /** + * 权限类型(1查看 2编辑 3完全管理) + */ + private String permissionType; + + /** + * 授权类型(1全校级 2自定义 3班主任) + */ + private String authType; + + /** + * 授权来源ID(对应班级id) + */ + private Long authSource; + + /** + * 状态(0有效 1已撤销) + */ + private String status; + + /** + * 删除标志(0代表存在 1代表删除) + */ + @TableLogic(value = "0", delval = "1") + private String deleted; + + /** + * 备注 + */ + private String remark; + + +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/bo/XgStudentManagerBo.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/bo/XgStudentManagerBo.java new file mode 100644 index 00000000..d6157e13 --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/bo/XgStudentManagerBo.java @@ -0,0 +1,77 @@ +package org.dromara.xg.domain.bo; + +import org.dromara.xg.domain.XgStudentManager; +import org.dromara.common.mybatis.core.domain.BaseEntity; +import org.dromara.common.core.validate.AddGroup; +import org.dromara.common.core.validate.EditGroup; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; +import lombok.EqualsAndHashCode; +import jakarta.validation.constraints.*; + +/** + * 宿舍管理员信息业务对象 xg_student_manager + * + * @author zlwu + * @date 2025-07-24 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@AutoMapper(target = XgStudentManager.class, reverseConvertGenerate = false) +public class XgStudentManagerBo extends BaseEntity { + + /** + * 主键ID + */ + @NotNull(message = "主键ID不能为空", groups = { EditGroup.class }) + private Long id; + + /** + * 管理员姓名 + */ + @NotBlank(message = "管理员姓名不能为空", groups = { AddGroup.class, EditGroup.class }) + private String managerName; + + /** + * 管理员类型(1 全校管理员 2 自定义管理员 3 班主任) + */ + @NotBlank(message = "管理员类型(1 全校管理员 2 自定义管理员 3 班主任)不能为空", groups = { AddGroup.class, EditGroup.class }) + private String managerType; + + /** + * 管理级别(1-3,1为最高) + */ + private Long managerLevel; + + /** + * 关联用户ID + */ + private Long userId; + + /** + * 联系电话 + */ + private String phone; + + /** + * 性别(0男 1女 2未知) + */ + private String gender; + + /** + * 状态(0正常 1停用) + */ + private String status; + + /** + * 删除标志(0代表存在 1代表删除) + */ + private String deleted; + + /** + * 备注 + */ + private String remark; + + +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/bo/XgStudentManagerSourceBo.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/bo/XgStudentManagerSourceBo.java new file mode 100644 index 00000000..9495b77f --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/bo/XgStudentManagerSourceBo.java @@ -0,0 +1,67 @@ +package org.dromara.xg.domain.bo; + +import org.dromara.xg.domain.XgStudentManagerSource; +import org.dromara.common.mybatis.core.domain.BaseEntity; +import org.dromara.common.core.validate.AddGroup; +import org.dromara.common.core.validate.EditGroup; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; +import lombok.EqualsAndHashCode; +import jakarta.validation.constraints.*; + +/** + * 学生管理员授权关系业务对象 xg_student_manager_source + * + * @author zlwu + * @date 2025-07-24 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@AutoMapper(target = XgStudentManagerSource.class, reverseConvertGenerate = false) +public class XgStudentManagerSourceBo extends BaseEntity { + + /** + * 主键ID + */ + @NotNull(message = "主键ID不能为空", groups = { EditGroup.class }) + private Long id; + + /** + * 管理员ID + */ + @NotNull(message = "管理员ID不能为空", groups = { AddGroup.class, EditGroup.class }) + private Long managerId; + + /** + * 权限类型(1查看 2编辑 3完全管理) + */ + private String permissionType; + + /** + * 授权类型(1全校级 2自定义 3班主任) + */ + @NotBlank(message = "授权类型(1全校级 2自定义 3班主任)不能为空", groups = { AddGroup.class, EditGroup.class }) + private String authType; + + /** + * 授权来源ID(对应班级id) + */ + private Long authSource; + + /** + * 状态(0有效 1已撤销) + */ + private String status; + + /** + * 删除标志(0代表存在 1代表删除) + */ + private String deleted; + + /** + * 备注 + */ + private String remark; + + +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/ClassTeacherInfoVo.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/ClassTeacherInfoVo.java new file mode 100644 index 00000000..6ec655aa --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/ClassTeacherInfoVo.java @@ -0,0 +1,15 @@ +package org.dromara.xg.domain.vo; + +import lombok.Data; +import java.io.Serializable; + +/** + * 班主任信息VO + */ +@Data +public class ClassTeacherInfoVo implements Serializable { + private String name; + private String phone; + private String sex; + private String className; +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/XgStudentManagerSourceVo.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/XgStudentManagerSourceVo.java new file mode 100644 index 00000000..f935a5db --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/XgStudentManagerSourceVo.java @@ -0,0 +1,80 @@ +package org.dromara.xg.domain.vo; + +import org.dromara.xg.domain.XgStudentManagerSource; +import cn.idev.excel.annotation.ExcelIgnoreUnannotated; +import cn.idev.excel.annotation.ExcelProperty; +import org.dromara.common.excel.annotation.ExcelDictFormat; +import org.dromara.common.excel.convert.ExcelDictConvert; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; + + + +/** + * 学生管理员授权关系视图对象 xg_student_manager_source + * + * @author zlwu + * @date 2025-07-24 + */ +@Data +@ExcelIgnoreUnannotated +@AutoMapper(target = XgStudentManagerSource.class) +public class XgStudentManagerSourceVo implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 主键ID + */ + @ExcelProperty(value = "主键ID") + private Long id; + + /** + * 管理员ID + */ + @ExcelProperty(value = "管理员ID") + private Long managerId; + + /** + * 权限类型(1查看 2编辑 3完全管理) + */ + @ExcelProperty(value = "权限类型(1查看 2编辑 3完全管理)") + private String permissionType; + + /** + * 授权类型(1全校级 2自定义 3班主任) + */ + @ExcelProperty(value = "授权类型(1全校级 2自定义 3班主任)") + private String authType; + + /** + * 授权来源ID(对应班级id) + */ + @ExcelProperty(value = "授权来源ID(对应班级id)") + private Long authSource; + + /** + * 状态(0有效 1已撤销) + */ + @ExcelProperty(value = "状态(0有效 1已撤销)") + private String status; + + /** + * 删除标志(0代表存在 1代表删除) + */ + @ExcelProperty(value = "删除标志(0代表存在 1代表删除)") + private String deleted; + + /** + * 备注 + */ + @ExcelProperty(value = "备注") + private String remark; + + +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/XgStudentManagerVo.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/XgStudentManagerVo.java new file mode 100644 index 00000000..7a588900 --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/XgStudentManagerVo.java @@ -0,0 +1,111 @@ +package org.dromara.xg.domain.vo; + +import org.dromara.xg.domain.XgStudentManager; +import cn.idev.excel.annotation.ExcelIgnoreUnannotated; +import cn.idev.excel.annotation.ExcelProperty; +import org.dromara.common.excel.annotation.ExcelDictFormat; +import org.dromara.common.excel.convert.ExcelDictConvert; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; + +/** + * 宿舍管理员信息视图对象 xg_student_manager + * + * @author zlwu + * @date 2025-07-24 + */ +@Data +@ExcelIgnoreUnannotated +@AutoMapper(target = XgStudentManager.class) +public class XgStudentManagerVo implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 主键ID + */ + @ExcelProperty(value = "主键ID") + private Long id; + + /** + * 管理员姓名 + */ + @ExcelProperty(value = "管理员姓名") + private String managerName; + + /** + * 管理员类型(1 全校管理员 2 自定义管理员 3 班主任) + */ + @ExcelProperty(value = "管理员类型(1 全校管理员 2 自定义管理员 3 班主任)") + private String managerType; + + /** + * 管理级别(1-3,1为最高) + */ + @ExcelProperty(value = "管理级别(1-3,1为最高)") + private Long managerLevel; + + /** + * 关联用户ID + */ + @ExcelProperty(value = "关联用户ID") + private Long userId; + + /** + * 联系电话 + */ + @ExcelProperty(value = "联系电话") + private String phone; + + /** + * 性别(0男 1女 2未知) + */ + @ExcelProperty(value = "性别(0男 1女 2未知)") + private String gender; + + /** + * 状态(0正常 1停用) + */ + @ExcelProperty(value = "状态(0正常 1停用)") + private String status; + + /** + * 删除标志(0代表存在 1代表删除) + */ + @ExcelProperty(value = "删除标志(0代表存在 1代表删除)") + private String deleted; + + /** + * 备注 + */ + @ExcelProperty(value = "备注") + private String remark; + + /** + * 创建者 + */ + private Long createBy; + + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + /** + * 更新者 + */ + private Long updateBy; + + /** + * 更新时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/mapper/XgStudentManagerMapper.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/mapper/XgStudentManagerMapper.java new file mode 100644 index 00000000..60cb2cc8 --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/mapper/XgStudentManagerMapper.java @@ -0,0 +1,25 @@ +package org.dromara.xg.mapper; + +import org.dromara.xg.domain.XgStudentManager; +import org.dromara.xg.domain.vo.XgStudentManagerVo; +import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 宿舍管理员信息Mapper接口 + * + * @author zlwu + * @date 2025-07-24 + */ +public interface XgStudentManagerMapper extends BaseMapperPlus { + + /** + * 查询可用的教职工信息 + * + * @param managerType 管理员类型 + * @return 可用的教职工信息列表 + */ + List selectAvailableTeachers(@Param("managerType") String managerType); +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/mapper/XgStudentManagerSourceMapper.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/mapper/XgStudentManagerSourceMapper.java new file mode 100644 index 00000000..2fd12e6d --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/mapper/XgStudentManagerSourceMapper.java @@ -0,0 +1,15 @@ +package org.dromara.xg.mapper; + +import org.dromara.xg.domain.XgStudentManagerSource; +import org.dromara.xg.domain.vo.XgStudentManagerSourceVo; +import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; + +/** + * 学生管理员授权关系Mapper接口 + * + * @author zlwu + * @date 2025-07-24 + */ +public interface XgStudentManagerSourceMapper extends BaseMapperPlus { + +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/IXgStudentManagerService.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/IXgStudentManagerService.java new file mode 100644 index 00000000..2cce1dbe --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/IXgStudentManagerService.java @@ -0,0 +1,86 @@ +package org.dromara.xg.service; + +import org.dromara.xg.domain.vo.XgStudentManagerVo; +import org.dromara.xg.domain.bo.XgStudentManagerBo; +import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.common.mybatis.core.page.PageQuery; +import org.dromara.xg.domain.vo.ClassTeacherInfoVo; + +import java.util.Collection; +import java.util.List; + +/** + * 宿舍管理员信息Service接口 + * + * @author zlwu + * @date 2025-07-24 + */ +public interface IXgStudentManagerService { + + /** + * 查询宿舍管理员信息 + * + * @param id 主键 + * @return 宿舍管理员信息 + */ + XgStudentManagerVo queryById(Long id); + + /** + * 分页查询宿舍管理员信息列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 宿舍管理员信息分页列表 + */ + TableDataInfo queryPageList(XgStudentManagerBo bo, PageQuery pageQuery); + + /** + * 查询符合条件的宿舍管理员信息列表 + * + * @param bo 查询条件 + * @return 宿舍管理员信息列表 + */ + List queryList(XgStudentManagerBo bo); + + /** + * 新增宿舍管理员信息 + * + * @param bo 宿舍管理员信息 + * @return 是否新增成功 + */ + Boolean insertByBo(XgStudentManagerBo bo); + + /** + * 修改宿舍管理员信息 + * + * @param bo 宿舍管理员信息 + * @return 是否修改成功 + */ + Boolean updateByBo(XgStudentManagerBo bo); + + /** + * 校验并批量删除宿舍管理员信息信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + Boolean deleteWithValidByIds(Collection ids, Boolean isValid); + + /** + * 获取可用的教职工信息列表 + * + * @param managerType 管理员类型(1 全校管理员 2 自定义管理员 3 班主任) + * @return 可用的教职工信息列表 + */ + List queryAvailableTeachers(String managerType); + + /** + * 获取当前正在教学的班主任信息 + * + * @param phone 手机号 + * @param name 姓名 + * @return 班主任信息列表 + */ + List queryActiveClassTeachers(String phone, String name); +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/IXgStudentManagerSourceService.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/IXgStudentManagerSourceService.java new file mode 100644 index 00000000..32d245c6 --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/IXgStudentManagerSourceService.java @@ -0,0 +1,76 @@ +package org.dromara.xg.service; + +import org.dromara.xg.domain.vo.XgStudentManagerSourceVo; +import org.dromara.xg.domain.bo.XgStudentManagerSourceBo; +import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.common.mybatis.core.page.PageQuery; + +import java.util.Collection; +import java.util.List; + +/** + * 学生管理员授权关系Service接口 + * + * @author zlwu + * @date 2025-07-24 + */ +public interface IXgStudentManagerSourceService { + + /** + * 查询学生管理员授权关系 + * + * @param id 主键 + * @return 学生管理员授权关系 + */ + XgStudentManagerSourceVo queryById(Long id); + + /** + * 分页查询学生管理员授权关系列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 学生管理员授权关系分页列表 + */ + TableDataInfo queryPageList(XgStudentManagerSourceBo bo, PageQuery pageQuery); + + /** + * 查询符合条件的学生管理员授权关系列表 + * + * @param bo 查询条件 + * @return 学生管理员授权关系列表 + */ + List queryList(XgStudentManagerSourceBo bo); + + /** + * 新增学生管理员授权关系 + * + * @param bo 学生管理员授权关系 + * @return 是否新增成功 + */ + Boolean insertByBo(XgStudentManagerSourceBo bo); + + /** + * 修改学生管理员授权关系 + * + * @param bo 学生管理员授权关系 + * @return 是否修改成功 + */ + Boolean updateByBo(XgStudentManagerSourceBo bo); + + /** + * 校验并批量删除学生管理员授权关系信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + Boolean deleteWithValidByIds(Collection ids, Boolean isValid); + + /** + * 自定义学生管理员授予部门权限 + * + * @param managerId 管理员ID + * @param authSourceIds 资源ID列表 + */ + void grantDeptAuth(Long managerId, List authSourceIds); +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/impl/XgDormManagerServiceImpl.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/impl/XgDormManagerServiceImpl.java index f897b784..d76255c5 100644 --- a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/impl/XgDormManagerServiceImpl.java +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/impl/XgDormManagerServiceImpl.java @@ -84,7 +84,7 @@ public class XgDormManagerServiceImpl implements IXgDormManagerService { public List> queryTeacherList(String name, String managerType) { StringBuilder sql = new StringBuilder(); sql.append( - "SELECT u.user_id as value, u.nick_name as label, u.user_name as username,u.phonenumber as phonenumber, u.sex as sex "); + "SELECT distinct u.user_id as value, u.nick_name as label, u.user_name as username,u.phonenumber as phonenumber, u.sex as sex "); sql.append("FROM sys_user u "); sql.append("INNER JOIN sys_user_role ur ON u.user_id = ur.user_id "); sql.append("INNER JOIN sys_role r ON ur.role_id = r.role_id "); diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/impl/XgStudentManagerServiceImpl.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/impl/XgStudentManagerServiceImpl.java new file mode 100644 index 00000000..30e6dd6b --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/impl/XgStudentManagerServiceImpl.java @@ -0,0 +1,186 @@ +package org.dromara.xg.service.impl; + +import org.dromara.common.core.utils.MapstructUtils; +import org.dromara.common.core.utils.StringUtils; +import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.common.mybatis.core.page.PageQuery; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.dromara.xg.domain.bo.XgStudentManagerBo; +import org.dromara.xg.domain.vo.XgStudentManagerVo; +import org.dromara.xg.domain.XgStudentManager; +import org.dromara.xg.mapper.XgStudentManagerMapper; +import org.dromara.xg.service.IXgStudentManagerService; +import org.dromara.xg.domain.vo.ClassTeacherInfoVo; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; +import java.util.Map; +import java.util.Collection; + +/** + * 宿舍管理员信息Service业务层处理 + * + * @author zlwu + * @date 2025-07-24 + */ +@Slf4j +@RequiredArgsConstructor +@Service +public class XgStudentManagerServiceImpl implements IXgStudentManagerService { + + private final XgStudentManagerMapper baseMapper; + + @Autowired + private JdbcTemplate jdbcTemplate; + + /** + * 查询宿舍管理员信息 + * + * @param id 主键 + * @return 宿舍管理员信息 + */ + @Override + public XgStudentManagerVo queryById(Long id) { + return baseMapper.selectVoById(id); + } + + /** + * 分页查询宿舍管理员信息列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 宿舍管理员信息分页列表 + */ + @Override + public TableDataInfo queryPageList(XgStudentManagerBo bo, PageQuery pageQuery) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + Page result = baseMapper.selectVoPage(pageQuery.build(), lqw); + return TableDataInfo.build(result); + } + + /** + * 查询符合条件的宿舍管理员信息列表 + * + * @param bo 查询条件 + * @return 宿舍管理员信息列表 + */ + @Override + public List queryList(XgStudentManagerBo bo) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + return baseMapper.selectVoList(lqw); + } + + private LambdaQueryWrapper buildQueryWrapper(XgStudentManagerBo bo) { + Map params = bo.getParams(); + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); + lqw.orderByAsc(XgStudentManager::getId); + lqw.like(StringUtils.isNotBlank(bo.getManagerName()), XgStudentManager::getManagerName, bo.getManagerName()); + lqw.eq(StringUtils.isNotBlank(bo.getManagerType()), XgStudentManager::getManagerType, bo.getManagerType()); + lqw.eq(bo.getManagerLevel() != null, XgStudentManager::getManagerLevel, bo.getManagerLevel()); + lqw.eq(bo.getUserId() != null, XgStudentManager::getUserId, bo.getUserId()); + lqw.like(StringUtils.isNotBlank(bo.getPhone()), XgStudentManager::getPhone, bo.getPhone()); + lqw.eq(StringUtils.isNotBlank(bo.getGender()), XgStudentManager::getGender, bo.getGender()); + lqw.eq(StringUtils.isNotBlank(bo.getStatus()), XgStudentManager::getStatus, bo.getStatus()); + lqw.eq(StringUtils.isNotBlank(bo.getDeleted()), XgStudentManager::getDeleted, bo.getDeleted()); + return lqw; + } + + /** + * 新增宿舍管理员信息 + * + * @param bo 宿舍管理员信息 + * @return 是否新增成功 + */ + @Override + public Boolean insertByBo(XgStudentManagerBo bo) { + XgStudentManager add = MapstructUtils.convert(bo, XgStudentManager.class); + validEntityBeforeSave(add); + boolean flag = baseMapper.insert(add) > 0; + if (flag) { + bo.setId(add.getId()); + } + return flag; + } + + /** + * 修改宿舍管理员信息 + * + * @param bo 宿舍管理员信息 + * @return 是否修改成功 + */ + @Override + public Boolean updateByBo(XgStudentManagerBo bo) { + XgStudentManager update = MapstructUtils.convert(bo, XgStudentManager.class); + validEntityBeforeSave(update); + return baseMapper.updateById(update) > 0; + } + + /** + * 保存前的数据校验 + */ + private void validEntityBeforeSave(XgStudentManager entity) { + // TODO 做一些数据校验,如唯一约束 + } + + /** + * 校验并批量删除宿舍管理员信息信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + @Override + public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { + if (isValid) { + // TODO 做一些业务上的校验,判断是否需要校验 + } + return baseMapper.deleteByIds(ids) > 0; + } + + /** + * 获取可用的教职工信息列表 + * + * @param managerType 管理员类型(1 全校管理员 2 自定义管理员 3 班主任) + * @return 可用的教职工信息列表 + */ + @Override + public List queryAvailableTeachers(String managerType) { + return baseMapper.selectAvailableTeachers(managerType); + } + + @Override + public List queryActiveClassTeachers(String phone, String name) { + StringBuilder sql = new StringBuilder( + "SELECT s.nick_name as name, s.phonenumber as phone, s.sex as sex, c.class_name as className " + + "FROM xg_class_msg c, sys_user s " + + "WHERE c.deleted = '0' " + + "AND c.class_status = '1' " + + "AND c.class_teacher_id IS NOT NULL " + + "AND c.class_teacher_id = s.user_id " + + "AND s.del_flag = '0' " + + "AND s.status = '0'"); + List params = new java.util.ArrayList<>(); + if (StringUtils.isNotBlank(name)) { + sql.append(" AND s.nick_name LIKE ?"); + params.add("%" + name + "%"); + } + if (StringUtils.isNotBlank(phone)) { + sql.append(" AND s.phonenumber LIKE ?"); + params.add("%" + phone + "%"); + } + return jdbcTemplate.query(sql.toString(), params.toArray(), (rs, rowNum) -> { + ClassTeacherInfoVo vo = new ClassTeacherInfoVo(); + vo.setName(rs.getString("name")); + vo.setPhone(rs.getString("phone")); + vo.setSex(rs.getString("sex")); + vo.setClassName(rs.getString("className")); + return vo; + }); + } +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/impl/XgStudentManagerSourceServiceImpl.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/impl/XgStudentManagerSourceServiceImpl.java new file mode 100644 index 00000000..f18fc922 --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/impl/XgStudentManagerSourceServiceImpl.java @@ -0,0 +1,167 @@ +package org.dromara.xg.service.impl; + +import org.dromara.common.core.utils.MapstructUtils; +import org.dromara.common.core.utils.StringUtils; +import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.common.mybatis.core.page.PageQuery; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.dromara.xg.domain.bo.XgStudentManagerSourceBo; +import org.dromara.xg.domain.vo.XgStudentManagerSourceVo; +import org.dromara.xg.domain.XgStudentManagerSource; +import org.dromara.xg.mapper.XgStudentManagerSourceMapper; +import org.dromara.xg.service.IXgStudentManagerSourceService; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Map; +import java.util.Collection; + +/** + * 学生管理员授权关系Service业务层处理 + * + * @author zlwu + * @date 2025-07-24 + */ +@Slf4j +@RequiredArgsConstructor +@Service +public class XgStudentManagerSourceServiceImpl implements IXgStudentManagerSourceService { + + private final XgStudentManagerSourceMapper baseMapper; + + @Autowired + private JdbcTemplate jdbcTemplate; + + /** + * 查询学生管理员授权关系 + * + * @param id 主键 + * @return 学生管理员授权关系 + */ + @Override + public XgStudentManagerSourceVo queryById(Long id) { + return baseMapper.selectVoById(id); + } + + /** + * 分页查询学生管理员授权关系列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 学生管理员授权关系分页列表 + */ + @Override + public TableDataInfo queryPageList(XgStudentManagerSourceBo bo, PageQuery pageQuery) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + Page result = baseMapper.selectVoPage(pageQuery.build(), lqw); + return TableDataInfo.build(result); + } + + /** + * 查询符合条件的学生管理员授权关系列表 + * + * @param bo 查询条件 + * @return 学生管理员授权关系列表 + */ + @Override + public List queryList(XgStudentManagerSourceBo bo) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + return baseMapper.selectVoList(lqw); + } + + private LambdaQueryWrapper buildQueryWrapper(XgStudentManagerSourceBo bo) { + Map params = bo.getParams(); + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); + lqw.orderByAsc(XgStudentManagerSource::getId); + lqw.eq(bo.getManagerId() != null, XgStudentManagerSource::getManagerId, bo.getManagerId()); + lqw.eq(StringUtils.isNotBlank(bo.getPermissionType()), XgStudentManagerSource::getPermissionType, + bo.getPermissionType()); + lqw.eq(StringUtils.isNotBlank(bo.getAuthType()), XgStudentManagerSource::getAuthType, bo.getAuthType()); + lqw.eq(bo.getAuthSource() != null, XgStudentManagerSource::getAuthSource, bo.getAuthSource()); + lqw.eq(StringUtils.isNotBlank(bo.getStatus()), XgStudentManagerSource::getStatus, bo.getStatus()); + lqw.eq(StringUtils.isNotBlank(bo.getDeleted()), XgStudentManagerSource::getDeleted, bo.getDeleted()); + return lqw; + } + + /** + * 新增学生管理员授权关系 + * + * @param bo 学生管理员授权关系 + * @return 是否新增成功 + */ + @Override + public Boolean insertByBo(XgStudentManagerSourceBo bo) { + XgStudentManagerSource add = MapstructUtils.convert(bo, XgStudentManagerSource.class); + validEntityBeforeSave(add); + boolean flag = baseMapper.insert(add) > 0; + if (flag) { + bo.setId(add.getId()); + } + return flag; + } + + /** + * 修改学生管理员授权关系 + * + * @param bo 学生管理员授权关系 + * @return 是否修改成功 + */ + @Override + public Boolean updateByBo(XgStudentManagerSourceBo bo) { + XgStudentManagerSource update = MapstructUtils.convert(bo, XgStudentManagerSource.class); + validEntityBeforeSave(update); + return baseMapper.updateById(update) > 0; + } + + /** + * 保存前的数据校验 + */ + private void validEntityBeforeSave(XgStudentManagerSource entity) { + // TODO 做一些数据校验,如唯一约束 + } + + /** + * 校验并批量删除学生管理员授权关系信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + @Override + public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { + if (isValid) { + // TODO 做一些业务上的校验,判断是否需要校验 + } + return baseMapper.deleteByIds(ids) > 0; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void grantDeptAuth(Long managerId, List authSourceIds) { + // 第一步:将该管理员的所有授权数据设为撤销和删除 + String updateSql = "UPDATE xg_student_manager_source SET status = '1', deleted = '1' WHERE manager_id = ? AND deleted = '0'"; + jdbcTemplate.update(updateSql, managerId); + // 第二步:批量插入新的授权数据 + if (authSourceIds != null && !authSourceIds.isEmpty()) { + List insertList = new java.util.ArrayList<>(); + for (Long authSourceId : authSourceIds) { + XgStudentManagerSource entity = new XgStudentManagerSource(); + entity.setManagerId(managerId); + entity.setPermissionType("3"); + entity.setAuthType("2"); + entity.setAuthSource(authSourceId); + entity.setStatus("0"); + entity.setDeleted("0"); + insertList.add(entity); + } + baseMapper.insertBatch(insertList); + } + } +} diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/resources/mapper/xgStudentManager/XgStudentManagerMapper.xml b/backend/ruoyi-modules/ruoyi-xg/src/main/resources/mapper/xgStudentManager/XgStudentManagerMapper.xml new file mode 100644 index 00000000..14f9f4c0 --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/resources/mapper/xgStudentManager/XgStudentManagerMapper.xml @@ -0,0 +1,36 @@ + + + + + + + diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/resources/mapper/xgStudentManagerSource/XgStudentManagerSourceMapper.xml b/backend/ruoyi-modules/ruoyi-xg/src/main/resources/mapper/xgStudentManagerSource/XgStudentManagerSourceMapper.xml new file mode 100644 index 00000000..e7239284 --- /dev/null +++ b/backend/ruoyi-modules/ruoyi-xg/src/main/resources/mapper/xgStudentManagerSource/XgStudentManagerSourceMapper.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/docs/变更管理/code-adjust-record-2025-07-24-wuzilong.md b/docs/变更管理/code-adjust-record-2025-07-24-wuzilong.md new file mode 100644 index 00000000..3a4d0674 --- /dev/null +++ b/docs/变更管理/code-adjust-record-2025-07-24-wuzilong.md @@ -0,0 +1,17 @@ +2025-07-24 20:00:00 新增 + +### 【后端】宿舍管理员信息模块 +- 新增API:获取当前正在教学的班主任信息 + - 路径:/xgStudentManager/studentManager/listActiveClassTeachers + - 入参:phone(手机号,模糊)、name(姓名,模糊) + - 出参:name、phone、sex、className + - 权限:xgStudentManager:studentManager:list +- 相关文件: + - XgStudentManagerController.java + - IXgStudentManagerService.java + - XgStudentManagerServiceImpl.java + - ClassTeacherInfoVo.java + - docs/开发文档/API/宿舍管理员信息API.md + - docs/开发文档/API/API文档总览.md +- 开发人:wuzilong +- 说明:严格遵循API文档与变更记录同步规范。 \ No newline at end of file diff --git a/docs/开发文档/API/API文档总览.md b/docs/开发文档/API/API文档总览.md index 0c7afbf3..eaded5ee 100644 --- a/docs/开发文档/API/API文档总览.md +++ b/docs/开发文档/API/API文档总览.md @@ -10,6 +10,8 @@ - [学生信息管理API](./学生信息管理API.md) - [班级信息管理API](./班级信息管理API.md) - [宿舍管理API](./宿舍管理API.md) +- [宿舍管理员信息API](./宿舍管理员信息API.md) +- [宿舍管理员授权API](./宿舍管理员授权API.md) ## 后勤管理模块API @@ -47,6 +49,29 @@ **详细文档**: [班级信息管理API.md](./班级信息管理API.md) +## 宿舍管理员信息API + +- [宿舍管理员信息API](./宿舍管理员信息API.md):包含宿舍管理员信息的增删改查接口 + - 支持不同类型宿舍管理员(全校管理员、自定义管理员、班主任)的管理 + - 提供获取可用教职工信息的接口,支持选择教职工作为宿舍管理员 + - **新增功能**: 在添加管理员时,通过下拉选择可用教师,支持模糊搜索,并自动填充选中教师的手机号码和性别信息 + +**核心功能**: +- 宿舍管理员信息分页查询(支持多条件搜索) +- 宿舍管理员信息新增、修改、删除 +- 宿舍管理员信息导出 +- 获取可用教职工信息列表(排除已经成为指定类型管理员的人员) +- 教师选择下拉搜索组件,支持模糊搜索和自动填充数据 + +**API基础路径**: `/xgStudentManager/studentManager` + +**最新更新**: +- 2025-07-25: 优化管理员添加界面,将姓名输入框改为可搜索的下拉选择框,选择后自动填充教师信息 +- 2025-07-24: 完成宿舍管理员信息管理模块的API接口设计 +- 2025-07-24: 添加获取可用的教职工信息列表接口,支持根据管理员类型筛选可用教职工 + +**详细文档**: [宿舍管理员信息API.md](./宿舍管理员信息API.md) + ## 企业信息管理API - [企业信息管理API](./企业信息管理API.md):包含企业信息、招聘岗位、招聘海报生成相关接口 @@ -67,3 +92,5 @@ - 2023-07-05: 添加企业规模、所属行业、岗位有效期类型等数据字典 **详细文档**: [企业信息管理API.md](./企业信息管理API.md) + +- [获取当前正在教学的班主任信息](/docs/开发文档/API/宿舍管理员信息API.md#获取当前正在教学的班主任信息) diff --git a/docs/开发文档/API/宿舍管理员信息API.md b/docs/开发文档/API/宿舍管理员信息API.md new file mode 100644 index 00000000..58f1fc8e --- /dev/null +++ b/docs/开发文档/API/宿舍管理员信息API.md @@ -0,0 +1,259 @@ +# 宿舍管理员信息API文档 + +## 1. API概述 +本文档提供宿舍管理员信息相关的API接口说明,包括管理员信息的查询、新增、修改、删除等功能,以及获取可用教师列表的接口。 + +## 2. 基本信息 +- **模块名称**:宿舍管理员信息管理 +- **接口前缀**:`/xgStudentManager/studentManager` +- **数据权限**:需要相应的权限才能访问接口 + +## 3. API列表 + +### 3.1 查询宿舍管理员信息列表 + +- **接口地址**:`/xgStudentManager/studentManager/list` +- **请求方式**:GET +- **权限标识**:`xgStudentManager:studentManager:list` +- **请求参数**: + +| 参数名 | 类型 | 是否必须 | 描述 | +|------------|--------|----------|-----------------------------------------------| +| managerName| string | 否 | 管理员姓名,支持模糊查询 | +| managerType| string | 否 | 管理员类型(1 全校管理员 2 自定义管理员 3 班主任) | +| managerLevel| number | 否 | 管理级别(1-3,1为最高) | +| phone | string | 否 | 联系电话 | +| gender | string | 否 | 性别(0男 1女 2未知) | +| status | string | 否 | 状态(0正常 1停用) | +| pageNum | number | 是 | 页码 | +| pageSize | number | 是 | 每页记录数 | + +- **返回示例**: +```json +{ + "total": 2, + "rows": [ + { + "id": 1, + "managerName": "张三", + "managerType": "1", + "managerLevel": 1, + "userId": 103, + "phone": "13800138001", + "gender": "0", + "status": "0", + "remark": "全校管理员", + "createTime": "2025-07-24 10:00:00", + "updateTime": "2025-07-24 10:00:00" + } + ], + "code": 200, + "msg": "查询成功" +} +``` + +### 3.2 获取宿舍管理员信息详细信息 + +- **接口地址**:`/xgStudentManager/studentManager/{id}` +- **请求方式**:GET +- **权限标识**:`xgStudentManager:studentManager:query` +- **请求参数**: + +| 参数名 | 类型 | 是否必须 | 描述 | +|-------|--------|----------|-------| +| id | number | 是 | 主键ID | + +- **返回示例**: +```json +{ + "data": { + "id": 1, + "managerName": "张三", + "managerType": "1", + "managerLevel": 1, + "userId": 103, + "phone": "13800138001", + "gender": "0", + "status": "0", + "remark": "全校管理员", + "createTime": "2025-07-24 10:00:00", + "updateTime": "2025-07-24 10:00:00" + }, + "code": 200, + "msg": "操作成功" +} +``` + +### 3.3 新增宿舍管理员信息 + +- **接口地址**:`/xgStudentManager/studentManager` +- **请求方式**:POST +- **权限标识**:`xgStudentManager:studentManager:add` +- **请求参数**: + +| 参数名 | 类型 | 是否必须 | 描述 | +|------------|--------|----------|-----------------------------------------------| +| managerName| string | 是 | 管理员姓名 | +| managerType| string | 是 | 管理员类型(1 全校管理员 2 自定义管理员 3 班主任) | +| managerLevel| number | 是 | 管理级别(1-3,1为最高) | +| userId | number | 是 | 关联用户ID | +| phone | string | 是 | 联系电话 | +| gender | string | 是 | 性别(0男 1女 2未知) | +| status | string | 否 | 状态(0正常 1停用),默认0 | +| remark | string | 否 | 备注 | + +- **返回示例**: +```json +{ + "code": 200, + "msg": "操作成功" +} +``` + +### 3.4 修改宿舍管理员信息 + +- **接口地址**:`/xgStudentManager/studentManager` +- **请求方式**:PUT +- **权限标识**:`xgStudentManager:studentManager:edit` +- **请求参数**: + +| 参数名 | 类型 | 是否必须 | 描述 | +|------------|--------|----------|-----------------------------------------------| +| id | number | 是 | 主键ID | +| managerName| string | 是 | 管理员姓名 | +| managerType| string | 是 | 管理员类型(1 全校管理员 2 自定义管理员 3 班主任) | +| managerLevel| number | 是 | 管理级别(1-3,1为最高) | +| userId | number | 是 | 关联用户ID | +| phone | string | 是 | 联系电话 | +| gender | string | 是 | 性别(0男 1女 2未知) | +| status | string | 否 | 状态(0正常 1停用) | +| remark | string | 否 | 备注 | + +- **返回示例**: +```json +{ + "code": 200, + "msg": "操作成功" +} +``` + +### 3.5 删除宿舍管理员信息 + +- **接口地址**:`/xgStudentManager/studentManager/{ids}` +- **请求方式**:DELETE +- **权限标识**:`xgStudentManager:studentManager:remove` +- **请求参数**: + +| 参数名 | 类型 | 是否必须 | 描述 | +|-------|--------|----------|-----------------------| +| ids | array | 是 | 主键ID数组,格式:[1,2] | + +- **返回示例**: +```json +{ + "code": 200, + "msg": "操作成功" +} +``` + +### 3.6 导出宿舍管理员信息 + +- **接口地址**:`/xgStudentManager/studentManager/export` +- **请求方式**:POST +- **权限标识**:`xgStudentManager:studentManager:export` +- **请求参数**:与查询列表接口参数相同 +- **返回内容**:Excel文件 + +### 3.7 获取可用教师列表 + +- **接口地址**:`/xgStudentManager/studentManager/listAvailableTeachers` +- **请求方式**:GET +- **权限标识**:`xgStudentManager:studentManager:list` +- **请求参数**: + +| 参数名 | 类型 | 是否必须 | 描述 | +|------------|--------|----------|-----------------------------------------------| +| managerType| string | 是 | 管理员类型(1 全校管理员 2 自定义管理员 3 班主任) | + +- **返回示例**: +```json +{ + "data": [ + { + "id": 101, + "managerName": "张三", + "phone": "13800138001", + "gender": "0" + }, + { + "id": 102, + "managerName": "李四", + "phone": "13800138002", + "gender": "1" + } + ], + "code": 200, + "msg": "操作成功" +} +``` + +## 获取当前正在教学的班主任信息 + +- **接口路径**:`/xgStudentManager/studentManager/listActiveClassTeachers` +- **请求方式**:GET +- **权限标识**:`xgStudentManager:studentManager:list` +- **入参**: + - `phone`(可选,string):手机号,模糊查询 + - `name`(可选,string):姓名,模糊查询 +- **出参**: + - `name`:姓名 + - `phone`:手机号 + - `sex`:性别 + - `className`:班级名称 +- **返回示例**: +```json +{ + "code": 200, + "msg": "操作成功", + "data": [ + { + "name": "张三", + "phone": "13800001111", + "sex": "0", + "className": "2025级1班" + } + ] +} +``` +- **说明**: + - 仅返回当前“正在教学”的班主任(班级状态为1,未删除,班主任ID有效,用户状态正常)。 + - 支持姓名和手机号的模糊查询,均为可选参数。 + +## 4. 数据结构说明 + +### 4.1 宿舍管理员对象 + +| 字段名 | 类型 | 描述 | +|------------|--------|-----------------------------------------------| +| id | number | 主键ID | +| managerName| string | 管理员姓名 | +| managerType| string | 管理员类型(1 全校管理员 2 自定义管理员 3 班主任) | +| managerLevel| number | 管理级别(1-3,1为最高) | +| userId | number | 关联用户ID | +| phone | string | 联系电话 | +| gender | string | 性别(0男 1女 2未知) | +| status | string | 状态(0正常 1停用) | +| deleted | string | 删除标志(0代表存在 1代表删除) | +| remark | string | 备注 | +| createBy | number | 创建者 | +| createTime | date | 创建时间 | +| updateBy | number | 更新者 | +| updateTime | date | 更新时间 | + +## 5. 错误码说明 + +| 错误码 | 描述 | 解决方案 | +|-------|----------------|-----------------------------| +| 500 | 系统内部错误 | 联系系统管理员 | +| 401 | 未授权 | 检查用户权限或重新登录 | +| 400 | 请求参数错误 | 检查请求参数是否符合要求 | \ No newline at end of file diff --git a/web/src/api/xgStudentManager/studentManager/index.ts b/web/src/api/xgStudentManager/studentManager/index.ts new file mode 100644 index 00000000..07e29bcc --- /dev/null +++ b/web/src/api/xgStudentManager/studentManager/index.ts @@ -0,0 +1,95 @@ +import request from '@/utils/request'; +import { AxiosPromise } from 'axios'; +import { StudentManagerVO, StudentManagerForm, StudentManagerQuery } from '@/api/xgStudentManager/studentManager/types'; + +// 临时定义一个接口来表示返回的教师数据 +export interface TeacherData { + id: string | number; + managerName: string; + phone: string; + gender: string; +} + +/** + * 获取可用的教职工信息列表 + * @param managerType 管理员类型(1 全校管理员 2 自定义管理员 3 班主任) + */ +export const listAvailableTeachers = (managerType: string): AxiosPromise => { + return request({ + url: '/xgStudentManager/studentManager/listAvailableTeachers', + method: 'get', + params: { managerType } + }); +}; + +/** + * 查询宿舍管理员信息列表 + * @param query + * @returns {*} + */ + +export const listStudentManager = (query?: StudentManagerQuery): AxiosPromise => { + return request({ + url: '/xgStudentManager/studentManager/list', + method: 'get', + params: query + }); +}; + +/** + * 查询宿舍管理员信息详细 + * @param id + */ +export const getStudentManager = (id: string | number): AxiosPromise => { + return request({ + url: '/xgStudentManager/studentManager/' + id, + method: 'get' + }); +}; + +/** + * 新增宿舍管理员信息 + * @param data + */ +export const addStudentManager = (data: StudentManagerForm) => { + return request({ + url: '/xgStudentManager/studentManager', + method: 'post', + data: data + }); +}; + +/** + * 修改宿舍管理员信息 + * @param data + */ +export const updateStudentManager = (data: StudentManagerForm) => { + return request({ + url: '/xgStudentManager/studentManager', + method: 'put', + data: data + }); +}; + +/** + * 删除宿舍管理员信息 + * @param id + */ +export const delStudentManager = (id: string | number | Array) => { + return request({ + url: '/xgStudentManager/studentManager/' + id, + method: 'delete' + }); +}; + +/** + * 获取当前正在教学的班主任信息 + * @param params 包含 phone 和 name 字段 + */ +export const listActiveClassTeachers = (params: { phone?: string; name?: string }) => { + return request({ + url: '/xgStudentManager/studentManager/listActiveClassTeachers', + method: 'get', + params + }); +}; diff --git a/web/src/api/xgStudentManager/studentManager/types.ts b/web/src/api/xgStudentManager/studentManager/types.ts new file mode 100644 index 00000000..6decf4ef --- /dev/null +++ b/web/src/api/xgStudentManager/studentManager/types.ts @@ -0,0 +1,156 @@ +export interface StudentManagerVO { + /** + * 主键ID + */ + id: string | number; + + /** + * 管理员姓名 + */ + managerName: string; + + /** + * 管理员类型(1 全校管理员 2 自定义管理员 3 班主任) + */ + managerType: string; + + /** + * 管理级别(1-3,1为最高) + */ + managerLevel: number; + + /** + * 关联用户ID + */ + userId: string | number; + + /** + * 联系电话 + */ + phone: string; + + /** + * 性别(0男 1女 2未知) + */ + gender: string; + + /** + * 状态(0正常 1停用) + */ + status: string; + + /** + * 删除标志(0代表存在 1代表删除) + */ + deleted: string; + + /** + * 备注 + */ + remark: string; + +} + +export interface StudentManagerForm extends BaseEntity { + /** + * 主键ID + */ + id?: string | number; + + /** + * 管理员姓名 + */ + managerName?: string; + + /** + * 管理员类型(1 全校管理员 2 自定义管理员 3 班主任) + */ + managerType?: string; + + /** + * 管理级别(1-3,1为最高) + */ + managerLevel?: number; + + /** + * 关联用户ID + */ + userId?: string | number; + + /** + * 联系电话 + */ + phone?: string; + + /** + * 性别(0男 1女 2未知) + */ + gender?: string; + + /** + * 状态(0正常 1停用) + */ + status?: string; + + /** + * 删除标志(0代表存在 1代表删除) + */ + deleted?: string; + + /** + * 备注 + */ + remark?: string; + +} + +export interface StudentManagerQuery extends PageQuery { + + /** + * 管理员姓名 + */ + managerName?: string; + + /** + * 管理员类型(1 全校管理员 2 自定义管理员 3 班主任) + */ + managerType?: string; + + /** + * 管理级别(1-3,1为最高) + */ + managerLevel?: number; + + /** + * 关联用户ID + */ + userId?: string | number; + + /** + * 联系电话 + */ + phone?: string; + + /** + * 性别(0男 1女 2未知) + */ + gender?: string; + + /** + * 状态(0正常 1停用) + */ + status?: string; + + /** + * 删除标志(0代表存在 1代表删除) + */ + deleted?: string; + + /** + * 日期范围参数 + */ + params?: any; +} + + + diff --git a/web/src/api/xgStudentManagerSource/studentManagerSource/index.ts b/web/src/api/xgStudentManagerSource/studentManagerSource/index.ts new file mode 100644 index 00000000..e5804338 --- /dev/null +++ b/web/src/api/xgStudentManagerSource/studentManagerSource/index.ts @@ -0,0 +1,63 @@ +import request from '@/utils/request'; +import { AxiosPromise } from 'axios'; +import { StudentManagerSourceVO, StudentManagerSourceForm, StudentManagerSourceQuery } from '@/api/xgStudentManagerSource/studentManagerSource/types'; + +/** + * 查询学生管理员授权关系列表 + * @param query + * @returns {*} + */ + +export const listStudentManagerSource = (query?: StudentManagerSourceQuery): AxiosPromise => { + return request({ + url: '/xgStudentManagerSource/studentManagerSource/list', + method: 'get', + params: query + }); +}; + +/** + * 查询学生管理员授权关系详细 + * @param id + */ +export const getStudentManagerSource = (id: string | number): AxiosPromise => { + return request({ + url: '/xgStudentManagerSource/studentManagerSource/' + id, + method: 'get' + }); +}; + +/** + * 新增学生管理员授权关系 + * @param data + */ +export const addStudentManagerSource = (data: StudentManagerSourceForm) => { + return request({ + url: '/xgStudentManagerSource/studentManagerSource', + method: 'post', + data: data + }); +}; + +/** + * 修改学生管理员授权关系 + * @param data + */ +export const updateStudentManagerSource = (data: StudentManagerSourceForm) => { + return request({ + url: '/xgStudentManagerSource/studentManagerSource', + method: 'put', + data: data + }); +}; + +/** + * 删除学生管理员授权关系 + * @param id + */ +export const delStudentManagerSource = (id: string | number | Array) => { + return request({ + url: '/xgStudentManagerSource/studentManagerSource/' + id, + method: 'delete' + }); +}; diff --git a/web/src/api/xgStudentManagerSource/studentManagerSource/types.ts b/web/src/api/xgStudentManagerSource/studentManagerSource/types.ts new file mode 100644 index 00000000..d9878323 --- /dev/null +++ b/web/src/api/xgStudentManagerSource/studentManagerSource/types.ts @@ -0,0 +1,126 @@ +export interface StudentManagerSourceVO { + /** + * 主键ID + */ + id: string | number; + + /** + * 管理员ID + */ + managerId: string | number; + + /** + * 权限类型(1查看 2编辑 3完全管理) + */ + permissionType: string; + + /** + * 授权类型(1全校级 2自定义 3班主任) + */ + authType: string; + + /** + * 授权来源ID(对应班级id) + */ + authSource: number; + + /** + * 状态(0有效 1已撤销) + */ + status: string; + + /** + * 删除标志(0代表存在 1代表删除) + */ + deleted: string; + + /** + * 备注 + */ + remark: string; + +} + +export interface StudentManagerSourceForm extends BaseEntity { + /** + * 主键ID + */ + id?: string | number; + + /** + * 管理员ID + */ + managerId?: string | number; + + /** + * 权限类型(1查看 2编辑 3完全管理) + */ + permissionType?: string; + + /** + * 授权类型(1全校级 2自定义 3班主任) + */ + authType?: string; + + /** + * 授权来源ID(对应班级id) + */ + authSource?: number; + + /** + * 状态(0有效 1已撤销) + */ + status?: string; + + /** + * 删除标志(0代表存在 1代表删除) + */ + deleted?: string; + + /** + * 备注 + */ + remark?: string; + +} + +export interface StudentManagerSourceQuery extends PageQuery { + + /** + * 管理员ID + */ + managerId?: string | number; + + /** + * 权限类型(1查看 2编辑 3完全管理) + */ + permissionType?: string; + + /** + * 授权类型(1全校级 2自定义 3班主任) + */ + authType?: string; + + /** + * 授权来源ID(对应班级id) + */ + authSource?: number; + + /** + * 状态(0有效 1已撤销) + */ + status?: string; + + /** + * 删除标志(0代表存在 1代表删除) + */ + deleted?: string; + + /** + * 日期范围参数 + */ + params?: any; +} + + + diff --git a/web/src/views/studentMsg/authmsg/components/AdminDialog.vue b/web/src/views/studentMsg/authmsg/components/AdminDialog.vue index 1b499ad6..0fcfb415 100644 --- a/web/src/views/studentMsg/authmsg/components/AdminDialog.vue +++ b/web/src/views/studentMsg/authmsg/components/AdminDialog.vue @@ -8,7 +8,21 @@ > - + + +
+ {{ item.managerName }} + ({{ item.phone }}) ({{ item.userId }}) +
+
+
@@ -33,8 +47,68 @@ @@ -162,4 +257,15 @@ defineExpose({ margin-right: 15px; margin-bottom: 10px; } +.loading-container { + display: flex; + align-items: center; + justify-content: center; + padding: 20px; + color: #909399; +} +.loading-container .el-icon { + margin-right: 8px; + font-size: 16px; +} diff --git a/web/src/views/studentMsg/authmsg/index.vue b/web/src/views/studentMsg/authmsg/index.vue index 5e4acf23..16be17d3 100644 --- a/web/src/views/studentMsg/authmsg/index.vue +++ b/web/src/views/studentMsg/authmsg/index.vue @@ -8,7 +8,7 @@ - + @@ -30,11 +30,11 @@ - + - + @@ -57,7 +57,7 @@ - + @@ -78,11 +78,11 @@ - + - + @@ -109,7 +109,7 @@ - + @@ -122,13 +122,13 @@ - - + - + @@ -167,19 +167,30 @@ import { ref, reactive, onMounted } from 'vue'; import AdminDialog from './components/AdminDialog.vue'; import ScopeDialog from './components/ScopeDialog.vue'; import { ElMessage, ElMessageBox } from 'element-plus'; +import { listStudentManager, delStudentManager, listActiveClassTeachers } from '@/api/xgStudentManager/studentManager'; +import type { StudentManagerQuery } from '@/api/xgStudentManager/studentManager/types'; // 暴露组件以修复导出问题 defineExpose({}); -// 导入改为使用模拟数据 -// import { getAdminList, deleteAdmin, assignScope, getScopeNames } from '@/api/studentMsg/authmsg'; - const activeTab = ref('school'); // 各tab独立检索表单 -const schoolSearchForm = reactive({ name: '', phone: '' }); -const customSearchForm = reactive({ name: '', phone: '' }); -const teacherSearchForm = reactive({ name: '', phone: '' }); +const schoolSearchForm = reactive({ + managerName: '', + phone: '', + managerType: '1', + pageNum: 1, + pageSize: 1000 +}); +const customSearchForm = reactive({ + managerName: '', + phone: '', + managerType: '2', + pageNum: 1, + pageSize: 1000 +}); +const teacherSearchForm = reactive({ managerName: '', phone: '' }); // 管理员数据 const schoolAdmins = ref([]); @@ -192,46 +203,39 @@ const currentAdmin = ref(null); const scopeDialogVisible = ref(false); const scopeType = ref(''); -// 模拟数据 -const mockData = { - school: [ - { id: 1, name: '张校长', phone: '13800138001', sex: 0, remark: '全校管理员' }, - { id: 2, name: '李主任', phone: '13800138002', sex: 1, remark: '教务处负责人' } - ], - custom: [ - { id: 3, name: '王组长', phone: '13800138003', sex: 0, scope: '高一年级', remark: '年级组长' }, - { id: 4, name: '赵主管', phone: '13800138004', sex: 1, scope: '高二年级', remark: '年级负责人' } - ], - teacher: [ - { id: 5, name: '刘老师', phone: '13800138005', sex: 0, scope: '高一(1)班', remark: '数学教师' }, - { id: 6, name: '陈老师', phone: '13800138006', sex: 1, scope: '高一(2)班', remark: '语文教师' } - ] -}; +// 班主任模拟数据 (预留,后续完善) +const mockTeacherData = [ + { id: 5, name: '刘老师', phone: '13800138005', sex: 0, scope: '高一(1)班', remark: '数学教师' }, + { id: 6, name: '陈老师', phone: '13800138006', sex: 1, scope: '高一(2)班', remark: '语文教师' } +]; // 获取管理员列表 async function fetchAdmins(type: string) { - // 实际项目中这里会调用API - // 此处使用模拟数据 try { - // 模拟API检索过滤 const searchForm = getSearchForm(type); - const filteredData = mockData[type].filter((item) => { - const nameMatch = !searchForm.name || item.name.includes(searchForm.name); - const phoneMatch = !searchForm.phone || item.phone.includes(searchForm.phone); - return nameMatch && phoneMatch; - }); - // 更新对应类型的管理员数据 - switch (type) { - case 'school': - schoolAdmins.value = filteredData; - break; - case 'custom': - customAdmins.value = filteredData; - break; - case 'teacher': - teacherAdmins.value = filteredData; - break; + if (type === 'school' || type === 'custom') { + // 调用API获取全校管理员或自定义管理员数据 + const managerType = type === 'school' ? '1' : '2'; + const res = await listStudentManager({ + ...searchForm, + managerType + }); + + // 更新对应类型的管理员数据 + if (type === 'school') { + schoolAdmins.value = res.rows || []; + } else { + customAdmins.value = res.rows || []; + } + } else if (type === 'teacher') { + // 通过API获取班主任数据 + const params = { + phone: searchForm.phone, + name: searchForm.managerName // teacherSearchForm 实际只有 managerName 字段 + }; + const res = await listActiveClassTeachers(params); + teacherAdmins.value = res.data || []; } } catch (error) { console.error('获取管理员列表失败:', error); @@ -274,17 +278,31 @@ function onEdit(type: string, admin: any) { async function onDelete(type: string, admin: any) { // 二次确认 - ElMessageBox.confirm(`确定要删除管理员【${admin.name}】吗?`, '提示', { + ElMessageBox.confirm(`确定要删除管理员【${admin.name || admin.managerName}】吗?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }) .then(async () => { try { - // 模拟删除成功 - mockData[type] = mockData[type].filter((item) => item.id !== admin.id); - ElMessage.success('删除成功'); - fetchAdmins(type); // 删除后刷新 + if (type === 'school' || type === 'custom') { + // 调用删除API + const res = await delStudentManager(admin.id); + if (res.code === 200) { + ElMessage.success('删除成功'); + fetchAdmins(type); + } else { + ElMessage.error(res.msg || '删除失败'); + } + } else { + // 班主任暂时使用模拟数据 + ElMessage.success('删除成功'); + mockTeacherData.splice( + mockTeacherData.findIndex((item) => item.id === admin.id), + 1 + ); + fetchAdmins(type); + } } catch (e) { ElMessage.error('删除失败'); } @@ -301,20 +319,7 @@ function onScope(type: string, admin: any) { } function onDialogSubmit(admin: any) { - // 模拟添加或编辑操作 - if (dialogMode.value === 'add') { - // 生成新ID - const newId = Math.max(...mockData[activeTab.value].map((item) => item.id), 0) + 1; - admin.id = newId; - mockData[activeTab.value].push(admin); - } else { - // 编辑 - const index = mockData[activeTab.value].findIndex((item) => item.id === admin.id); - if (index !== -1) { - mockData[activeTab.value][index] = admin; - } - } - + // 表单已在对话框组件内处理API调用 // 刷新列表数据 fetchAdmins(activeTab.value); dialogVisible.value = false; @@ -322,12 +327,7 @@ function onDialogSubmit(admin: any) { async function onScopeSubmit(scope: any) { try { - // 模拟分配范围 - const index = mockData[scopeType.value].findIndex((item) => item.id === currentAdmin.value.id); - if (index !== -1) { - mockData[scopeType.value][index].scope = scope.scopeName; - } - + // 范围分配已在对话框组件内处理API调用 // 成功后刷新数据并提示 ElMessage.success('管理范围分配成功'); fetchAdmins(scopeType.value); @@ -353,6 +353,7 @@ function getListByType(type: string) { // 过滤 function filteredAdmins(type: string) { + console.log(getListByType(type).value); return getListByType(type).value; } @@ -363,15 +364,15 @@ function handleSearch(type: string) { function handleReset(type: string) { switch (type) { case 'school': - schoolSearchForm.name = ''; + schoolSearchForm.managerName = ''; schoolSearchForm.phone = ''; break; case 'custom': - customSearchForm.name = ''; + customSearchForm.managerName = ''; customSearchForm.phone = ''; break; case 'teacher': - teacherSearchForm.name = ''; + teacherSearchForm.managerName = ''; teacherSearchForm.phone = ''; break; }