提交学生管理权限设置的代码
This commit is contained in:
1 parent
0917c7f156
commit
517a0052bc
28 files changed
+2506
-161
No files matched your search
+132
@@ -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<XgStudentManagerVo> 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<XgStudentManagerVo> list = xgStudentManagerService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "宿舍管理员信息", XgStudentManagerVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取宿舍管理员信息详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("xgStudentManager:studentManager:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<XgStudentManagerVo> 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<Void> 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<Void> 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<Void> 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<List<XgStudentManagerVo>> listAvailableTeachers(@RequestParam("managerType") String managerType) {
|
||||
List<XgStudentManagerVo> teachers = xgStudentManagerService.queryAvailableTeachers(managerType);
|
||||
return R.ok(teachers);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前正在教学的班主任信息
|
||||
*
|
||||
* @param phone 手机号码(可选,模糊查询)
|
||||
* @param name 姓名(可选,模糊查询)
|
||||
* @return 班主任信息列表
|
||||
*/
|
||||
@SaCheckPermission("xgStudentManager:studentManager:list")
|
||||
@GetMapping("/listActiveClassTeachers")
|
||||
public R<List<ClassTeacherInfoVo>> listActiveClassTeachers(
|
||||
@RequestParam(value = "phone", required = false) String phone,
|
||||
@RequestParam(value = "name", required = false) String name) {
|
||||
List<ClassTeacherInfoVo> teachers = xgStudentManagerService.queryActiveClassTeachers(phone, name);
|
||||
return R.ok(teachers);
|
||||
}
|
||||
}
|
||||
+117
@@ -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<XgStudentManagerSourceVo> 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<XgStudentManagerSourceVo> list = xgStudentManagerSourceService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "学生管理员授权关系", XgStudentManagerSourceVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取学生管理员授权关系详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("xgStudentManagerSource:studentManagerSource:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<XgStudentManagerSourceVo> 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<Void> 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<Void> 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<Void> 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<Void> grantDeptAuth(@RequestParam Long managerId, @RequestBody List<Long> authSourceIds) {
|
||||
xgStudentManagerSourceService.grantDeptAuth(managerId, authSourceIds);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
+77
@@ -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;
|
||||
|
||||
|
||||
}
|
||||
+67
@@ -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;
|
||||
|
||||
|
||||
}
|
||||
+77
@@ -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;
|
||||
|
||||
|
||||
}
|
||||
+67
@@ -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;
|
||||
|
||||
|
||||
}
|
||||
+15
@@ -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;
|
||||
}
|
||||
+80
@@ -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;
|
||||
|
||||
|
||||
}
|
||||
+111
@@ -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;
|
||||
}
|
||||
+25
@@ -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<XgStudentManager, XgStudentManagerVo> {
|
||||
|
||||
/**
|
||||
* 查询可用的教职工信息
|
||||
*
|
||||
* @param managerType 管理员类型
|
||||
* @return 可用的教职工信息列表
|
||||
*/
|
||||
List<XgStudentManagerVo> selectAvailableTeachers(@Param("managerType") String managerType);
|
||||
}
|
||||
+15
@@ -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<XgStudentManagerSource, XgStudentManagerSourceVo> {
|
||||
|
||||
}
|
||||
+86
@@ -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<XgStudentManagerVo> queryPageList(XgStudentManagerBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的宿舍管理员信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 宿舍管理员信息列表
|
||||
*/
|
||||
List<XgStudentManagerVo> 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<Long> ids, Boolean isValid);
|
||||
|
||||
/**
|
||||
* 获取可用的教职工信息列表
|
||||
*
|
||||
* @param managerType 管理员类型(1 全校管理员 2 自定义管理员 3 班主任)
|
||||
* @return 可用的教职工信息列表
|
||||
*/
|
||||
List<XgStudentManagerVo> queryAvailableTeachers(String managerType);
|
||||
|
||||
/**
|
||||
* 获取当前正在教学的班主任信息
|
||||
*
|
||||
* @param phone 手机号
|
||||
* @param name 姓名
|
||||
* @return 班主任信息列表
|
||||
*/
|
||||
List<ClassTeacherInfoVo> queryActiveClassTeachers(String phone, String name);
|
||||
}
|
||||
+76
@@ -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<XgStudentManagerSourceVo> queryPageList(XgStudentManagerSourceBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的学生管理员授权关系列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 学生管理员授权关系列表
|
||||
*/
|
||||
List<XgStudentManagerSourceVo> 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<Long> ids, Boolean isValid);
|
||||
|
||||
/**
|
||||
* 自定义学生管理员授予部门权限
|
||||
*
|
||||
* @param managerId 管理员ID
|
||||
* @param authSourceIds 资源ID列表
|
||||
*/
|
||||
void grantDeptAuth(Long managerId, List<Long> authSourceIds);
|
||||
}
|
||||
+1
-1
@@ -84,7 +84,7 @@ public class XgDormManagerServiceImpl implements IXgDormManagerService {
|
||||
public List<Map<String, Object>> 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 ");
|
||||
|
||||
+186
@@ -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<XgStudentManagerVo> queryPageList(XgStudentManagerBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<XgStudentManager> lqw = buildQueryWrapper(bo);
|
||||
Page<XgStudentManagerVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的宿舍管理员信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 宿舍管理员信息列表
|
||||
*/
|
||||
@Override
|
||||
public List<XgStudentManagerVo> queryList(XgStudentManagerBo bo) {
|
||||
LambdaQueryWrapper<XgStudentManager> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<XgStudentManager> buildQueryWrapper(XgStudentManagerBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<XgStudentManager> 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<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
// TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取可用的教职工信息列表
|
||||
*
|
||||
* @param managerType 管理员类型(1 全校管理员 2 自定义管理员 3 班主任)
|
||||
* @return 可用的教职工信息列表
|
||||
*/
|
||||
@Override
|
||||
public List<XgStudentManagerVo> queryAvailableTeachers(String managerType) {
|
||||
return baseMapper.selectAvailableTeachers(managerType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ClassTeacherInfoVo> 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<Object> 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;
|
||||
});
|
||||
}
|
||||
}
|
||||
+167
@@ -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<XgStudentManagerSourceVo> queryPageList(XgStudentManagerSourceBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<XgStudentManagerSource> lqw = buildQueryWrapper(bo);
|
||||
Page<XgStudentManagerSourceVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的学生管理员授权关系列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 学生管理员授权关系列表
|
||||
*/
|
||||
@Override
|
||||
public List<XgStudentManagerSourceVo> queryList(XgStudentManagerSourceBo bo) {
|
||||
LambdaQueryWrapper<XgStudentManagerSource> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<XgStudentManagerSource> buildQueryWrapper(XgStudentManagerSourceBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<XgStudentManagerSource> 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<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
// TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void grantDeptAuth(Long managerId, List<Long> 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<XgStudentManagerSource> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.xg.mapper.XgStudentManagerMapper">
|
||||
|
||||
<!-- 查询可用的教职工信息 -->
|
||||
<select id="selectAvailableTeachers" resultType="org.dromara.xg.domain.vo.XgStudentManagerVo">
|
||||
SELECT
|
||||
u.user_id AS userId,
|
||||
u.nick_name AS managerName,
|
||||
u.phonenumber AS phone,
|
||||
u.sex AS gender,
|
||||
u.create_by AS createBy,
|
||||
u.create_time AS createTime,
|
||||
u.update_by AS updateBy,
|
||||
u.update_time AS updateTime
|
||||
FROM
|
||||
sys_user u
|
||||
WHERE
|
||||
u.account_type = '1'
|
||||
AND u.del_flag = '0'
|
||||
AND u.status = '0'
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM xg_student_manager m
|
||||
WHERE
|
||||
m.user_id = u.user_id
|
||||
AND m.status = '0'
|
||||
AND m.deleted = '0'
|
||||
AND m.manager_type = #{managerType}
|
||||
)
|
||||
ORDER BY
|
||||
u.user_id ASC
|
||||
</select>
|
||||
</mapper>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.xg.mapper.XgStudentManagerSourceMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -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文档与变更记录同步规范。
|
||||
@@ -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#获取当前正在教学的班主任信息)
|
||||
@@ -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 | 请求参数错误 | 检查请求参数是否符合要求 |
|
||||
@@ -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<TeacherData[]> => {
|
||||
return request({
|
||||
url: '/xgStudentManager/studentManager/listAvailableTeachers',
|
||||
method: 'get',
|
||||
params: { managerType }
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 查询宿舍管理员信息列表
|
||||
* @param query
|
||||
* @returns {*}
|
||||
*/
|
||||
|
||||
export const listStudentManager = (query?: StudentManagerQuery): AxiosPromise<StudentManagerVO[]> => {
|
||||
return request({
|
||||
url: '/xgStudentManager/studentManager/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 查询宿舍管理员信息详细
|
||||
* @param id
|
||||
*/
|
||||
export const getStudentManager = (id: string | number): AxiosPromise<StudentManagerVO> => {
|
||||
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<string | number>) => {
|
||||
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
|
||||
});
|
||||
};
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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<StudentManagerSourceVO[]> => {
|
||||
return request({
|
||||
url: '/xgStudentManagerSource/studentManagerSource/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 查询学生管理员授权关系详细
|
||||
* @param id
|
||||
*/
|
||||
export const getStudentManagerSource = (id: string | number): AxiosPromise<StudentManagerSourceVO> => {
|
||||
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<string | number>) => {
|
||||
return request({
|
||||
url: '/xgStudentManagerSource/studentManagerSource/' + id,
|
||||
method: 'delete'
|
||||
});
|
||||
};
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,21 @@
|
||||
>
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
|
||||
<el-form-item label="姓名" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入姓名" />
|
||||
<el-select
|
||||
v-model="form.name"
|
||||
filterable
|
||||
placeholder="请选择教师姓名"
|
||||
@change="handleTeacherChange"
|
||||
:disabled="mode === 'edit'"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option v-for="item in teacherOptions" :key="item.id" :label="item.managerName" :value="item.managerName">
|
||||
<div>
|
||||
<span> {{ item.managerName }} </span>
|
||||
<span style="color: #8492a6; font-size: 13px"> ({{ item.phone }}) ({{ item.userId }}) </span>
|
||||
</div>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号码" prop="phone">
|
||||
<el-input v-model="form.phone" placeholder="请输入手机号码" />
|
||||
@@ -33,8 +47,68 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, watchEffect, computed } from 'vue';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { ref, reactive, watchEffect, computed, onMounted } from 'vue';
|
||||
import { ElMessage, type FormInstance } from 'element-plus';
|
||||
import request from '@/utils/request';
|
||||
|
||||
/**
|
||||
* 教师信息数据结构
|
||||
*/
|
||||
interface TeacherData {
|
||||
/** 教师ID */
|
||||
userId: string | number;
|
||||
/** 管理员姓名 */
|
||||
managerName: string;
|
||||
/** 手机号码 */
|
||||
phone: string;
|
||||
/** 性别(0男 1女) */
|
||||
gender: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取可用的教职工信息列表
|
||||
* @param managerType 管理员类型(1 全校管理员 2 自定义管理员 3 班主任)
|
||||
*/
|
||||
const listAvailableTeachers = (managerType: string) => {
|
||||
return request({
|
||||
url: '/xgStudentManager/studentManager/listAvailableTeachers',
|
||||
method: 'get',
|
||||
params: { managerType }
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 新增宿舍管理员信息
|
||||
*/
|
||||
const addStudentManager = (data: any) => {
|
||||
return request({
|
||||
url: '/xgStudentManager/studentManager',
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 修改宿舍管理员信息
|
||||
*/
|
||||
const updateStudentManager = (data: any) => {
|
||||
return request({
|
||||
url: '/xgStudentManager/studentManager',
|
||||
method: 'put',
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
// 在setup函数中引入这种方式提示弹窗
|
||||
const message = (type: 'success' | 'error' | 'info', text: string) => {
|
||||
if (type === 'success') {
|
||||
ElMessage.success(text);
|
||||
} else if (type === 'error') {
|
||||
ElMessage.error(text);
|
||||
} else {
|
||||
ElMessage.info(text);
|
||||
}
|
||||
};
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
@@ -57,6 +131,9 @@ const props = defineProps({
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'submit']);
|
||||
|
||||
// 教师选项列表
|
||||
const teacherOptions = ref<TeacherData[]>([]);
|
||||
|
||||
// 计算属性:对话框可见性
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
@@ -64,9 +141,10 @@ const visible = computed({
|
||||
});
|
||||
|
||||
// 表单和校验
|
||||
const formRef = ref(null);
|
||||
const formRef = ref<FormInstance>();
|
||||
const form = reactive({
|
||||
id: null,
|
||||
userId: null,
|
||||
name: '',
|
||||
phone: '',
|
||||
sex: 0,
|
||||
@@ -74,27 +152,81 @@ const form = reactive({
|
||||
});
|
||||
|
||||
// 表单校验规则
|
||||
const rules = reactive({
|
||||
name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
|
||||
const rules = {
|
||||
name: [{ required: true, message: '请选择姓名', trigger: 'change' }],
|
||||
phone: [
|
||||
{ required: true, message: '请输入手机号码', trigger: 'blur' },
|
||||
{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码', trigger: 'blur' }
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
// 获取管理员类型对应的值
|
||||
const getManagerType = (type: string): string => {
|
||||
switch (type) {
|
||||
case 'school':
|
||||
return '1'; // 全校管理员
|
||||
case 'custom':
|
||||
return '2'; // 自定义管理员
|
||||
case 'teacher':
|
||||
return '3'; // 班主任
|
||||
default:
|
||||
return '1';
|
||||
}
|
||||
};
|
||||
|
||||
// 加载可用教师列表
|
||||
const loadTeachers = async () => {
|
||||
try {
|
||||
const managerType = getManagerType(props.type);
|
||||
const res = await listAvailableTeachers(managerType);
|
||||
if (res.data) {
|
||||
teacherOptions.value = res.data;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取可用教师列表失败', error);
|
||||
}
|
||||
};
|
||||
|
||||
// 选择教师后的处理
|
||||
const handleTeacherChange = (value: string) => {
|
||||
const selectedTeacher = teacherOptions.value.find((item) => item.managerName === value);
|
||||
if (selectedTeacher) {
|
||||
console.log(selectedTeacher.gender === '0');
|
||||
// 自动填充手机号码和性别
|
||||
form.phone = selectedTeacher.phone || '';
|
||||
form.sex = selectedTeacher.gender === '0' ? 0 : 1; // 0男 1女
|
||||
form.userId = selectedTeacher.userId;
|
||||
}
|
||||
};
|
||||
|
||||
// 监听传入的admin数据,更新表单
|
||||
watchEffect(() => {
|
||||
if (props.admin) {
|
||||
form.id = props.admin.id;
|
||||
form.name = props.admin.name;
|
||||
form.userId = props.admin.userId;
|
||||
form.name = props.admin.managerName;
|
||||
form.phone = props.admin.phone;
|
||||
form.sex = props.admin.sex;
|
||||
form.sex = props.admin.gender === '0' ? 0 : 1;
|
||||
form.remark = props.admin.remark;
|
||||
}
|
||||
});
|
||||
|
||||
// 监听对话框可见性变化,当打开时加载教师列表
|
||||
watchEffect(() => {
|
||||
if (visible.value && props.mode === 'add') {
|
||||
loadTeachers();
|
||||
}
|
||||
});
|
||||
|
||||
// 组件挂载时加载教师列表
|
||||
onMounted(() => {
|
||||
if (props.mode === 'add') {
|
||||
loadTeachers();
|
||||
}
|
||||
});
|
||||
|
||||
// 根据类型获取标签文本
|
||||
function getTypeLabel(type) {
|
||||
function getTypeLabel(type: string): string {
|
||||
switch (type) {
|
||||
case 'school':
|
||||
return '全校管理员';
|
||||
@@ -108,21 +240,43 @@ function getTypeLabel(type) {
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
function submitForm() {
|
||||
formRef.value?.validate((valid) => {
|
||||
async function submitForm() {
|
||||
formRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
// 这里模拟保存
|
||||
emit('submit', {
|
||||
id: form.id,
|
||||
name: form.name,
|
||||
phone: form.phone,
|
||||
sex: form.sex,
|
||||
remark: form.remark,
|
||||
scope: props.admin?.scope || ''
|
||||
});
|
||||
try {
|
||||
const formData = {
|
||||
id: form.id,
|
||||
managerName: form.name,
|
||||
userId: form.userId,
|
||||
phone: form.phone,
|
||||
gender: form.sex,
|
||||
remark: form.remark,
|
||||
status: '0',
|
||||
// scope: props.admin?.scope || '',
|
||||
managerType: getManagerType(props.type),
|
||||
managerLevel: getManagerType(props.type)
|
||||
};
|
||||
|
||||
ElMessage.success('保存成功');
|
||||
visible.value = false;
|
||||
let result;
|
||||
if (props.mode === 'add') {
|
||||
// 调用添加接口
|
||||
result = await addStudentManager(formData);
|
||||
} else {
|
||||
// 调用更新接口
|
||||
result = await updateStudentManager(formData);
|
||||
}
|
||||
|
||||
if (result.code === 200) {
|
||||
message('success', props.mode === 'add' ? '添加成功' : '更新成功');
|
||||
// 通知父组件处理成功
|
||||
emit('submit', formData);
|
||||
visible.value = false;
|
||||
} else {
|
||||
message('error', result.msg || '操作失败');
|
||||
}
|
||||
} catch (error: any) {
|
||||
message('error', '操作失败: ' + (error.message || '未知错误'));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,17 +2,35 @@
|
||||
<el-dialog :title="getScopeDialogTitle(type)" v-model="visible" width="600px" append-to-body destroy-on-close>
|
||||
<el-form :model="form" label-width="100px">
|
||||
<el-form-item :label="getScopeName(type)">
|
||||
<div v-if="type === 'custom'">
|
||||
<el-checkbox-group v-model="form.selectedScopes">
|
||||
<el-checkbox v-for="item in scopeOptions.custom" :key="item.id" :label="item.id">
|
||||
{{ item.name }}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
<div v-if="loading" class="loading-container">
|
||||
<el-icon class="is-loading"><Loading /></el-icon>
|
||||
<span>加载中...</span>
|
||||
</div>
|
||||
<div v-else-if="type === 'custom'">
|
||||
<el-tree
|
||||
:data="scopeOptions.custom"
|
||||
show-checkbox
|
||||
node-key="id"
|
||||
:default-checked-keys="form.selectedScopes"
|
||||
:props="{ label: 'label', children: 'children' }"
|
||||
@check="onTreeCheck"
|
||||
default-expand-all
|
||||
style="
|
||||
width: 100%;
|
||||
min-width: 100%;
|
||||
overflow-x: auto;
|
||||
overflow-y: auto;
|
||||
/* border: 1px solid #ebeef5; */
|
||||
border-radius: 4px;
|
||||
padding: 10px;
|
||||
box-sizing: border-box;
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<div v-else-if="type === 'teacher'">
|
||||
<el-checkbox-group v-model="form.selectedScopes">
|
||||
<el-checkbox v-for="item in scopeOptions.teacher" :key="item.id" :label="item.id">
|
||||
{{ item.name }}
|
||||
{{ item.label }}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</div>
|
||||
@@ -21,15 +39,18 @@
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button type="primary" @click="submitForm" :loading="loading">确 定</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed } from 'vue';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { ref, reactive, computed, watch, onMounted } from 'vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { Loading } from '@element-plus/icons-vue';
|
||||
import axios from 'axios';
|
||||
import request from '@/utils/request';
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
@@ -54,35 +75,107 @@ const visible = computed({
|
||||
set: (value) => emit('update:modelValue', value)
|
||||
});
|
||||
|
||||
// 范围选项(模拟数据)
|
||||
const scopeOptions = {
|
||||
custom: [
|
||||
{ id: 1, name: '高一年级' },
|
||||
{ id: 2, name: '高二年级' },
|
||||
{ id: 3, name: '高三年级' },
|
||||
{ id: 4, name: '初一年级' },
|
||||
{ id: 5, name: '初二年级' },
|
||||
{ id: 6, name: '初三年级' }
|
||||
],
|
||||
teacher: [
|
||||
{ id: 101, name: '高一(1)班' },
|
||||
{ id: 102, name: '高一(2)班' },
|
||||
{ id: 103, name: '高一(3)班' },
|
||||
{ id: 104, name: '高二(1)班' },
|
||||
{ id: 105, name: '高二(2)班' },
|
||||
{ id: 106, name: '高三(1)班' },
|
||||
{ id: 107, name: '高三(2)班' }
|
||||
]
|
||||
};
|
||||
// 范围选项(从API获取)
|
||||
const scopeOptions = reactive({
|
||||
custom: [] as any[],
|
||||
teacher: [] as any[]
|
||||
});
|
||||
|
||||
// 加载状态
|
||||
const loading = ref(false);
|
||||
|
||||
// 表单数据
|
||||
const form = reactive({
|
||||
selectedScopes: [] as number[]
|
||||
});
|
||||
|
||||
// 获取部门树数据
|
||||
async function fetchDeptTree() {
|
||||
try {
|
||||
loading.value = true;
|
||||
const response = await request({
|
||||
url: '/system/user/deptTree',
|
||||
method: 'get',
|
||||
params: {
|
||||
belongDeptId: 101
|
||||
}
|
||||
});
|
||||
if (response && response.code === 200) {
|
||||
// custom类型直接使用树形结构
|
||||
if (props.type === 'custom') {
|
||||
scopeOptions.custom = response.data || [];
|
||||
} else if (props.type === 'teacher') {
|
||||
// teacher类型仍可用扁平化
|
||||
scopeOptions.teacher = flattenTreeData(response.data || []);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取部门树数据失败:', error);
|
||||
ElMessage.error('获取范围选项失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 将树形数据扁平化
|
||||
function flattenTreeData(treeData: any[]): any[] {
|
||||
const result: any[] = [];
|
||||
|
||||
function traverse(nodes: any[]) {
|
||||
nodes.forEach((node) => {
|
||||
result.push({
|
||||
id: node.id,
|
||||
label: node.label
|
||||
});
|
||||
|
||||
if (node.children && node.children.length > 0) {
|
||||
traverse(node.children);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
traverse(treeData);
|
||||
return result;
|
||||
}
|
||||
|
||||
// 新增:获取历史范围数据
|
||||
async function fetchSelectedScopes(managerId: number | string) {
|
||||
if (!managerId) return;
|
||||
try {
|
||||
const res = await request({
|
||||
url: '/xgStudentManagerSource/studentManagerSource/list',
|
||||
method: 'get',
|
||||
params: { managerId }
|
||||
});
|
||||
if (res && res.code === 200) {
|
||||
// 提取rows中的authSource字段作为已选范围ID
|
||||
form.selectedScopes = (res.rows || []).map((item: any) => item.authSource);
|
||||
}
|
||||
} catch (e) {
|
||||
form.selectedScopes = [];
|
||||
}
|
||||
}
|
||||
|
||||
// 监听对话框显示状态,自动加载数据
|
||||
watch(visible, async (newVal) => {
|
||||
if (newVal) {
|
||||
const managerId = props.admin?.managerId || props.admin?.id;
|
||||
await fetchDeptTree();
|
||||
await fetchSelectedScopes(managerId);
|
||||
} else {
|
||||
// 对话框关闭时清空选择
|
||||
form.selectedScopes = [];
|
||||
}
|
||||
});
|
||||
|
||||
// el-tree勾选事件,确保能正确获取所有勾选节点的id
|
||||
function onTreeCheck(checkedNodes: any, info: { checkedKeys: any[]; halfCheckedKeys: any[] }) {
|
||||
form.selectedScopes = info.checkedKeys;
|
||||
}
|
||||
|
||||
// 获取范围对话框标题
|
||||
function getScopeDialogTitle(type: string) {
|
||||
const name = props.admin?.name || '';
|
||||
const name = props.admin?.managerName || '';
|
||||
switch (type) {
|
||||
case 'custom':
|
||||
return `为【${name}】分配管理范围`;
|
||||
@@ -106,32 +199,33 @@ function getScopeName(type: string) {
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
function submitForm() {
|
||||
async function submitForm() {
|
||||
// 组装要提交的数据
|
||||
const selectedIds = form.selectedScopes;
|
||||
let scopeName = '';
|
||||
|
||||
// 根据类型获取选中的名称
|
||||
if (type.value === 'custom') {
|
||||
scopeName = scopeOptions.custom
|
||||
.filter((item) => selectedIds.includes(item.id))
|
||||
.map((item) => item.name)
|
||||
.join(', ');
|
||||
} else if (type.value === 'teacher') {
|
||||
scopeName = scopeOptions.teacher
|
||||
.filter((item) => selectedIds.includes(item.id))
|
||||
.map((item) => item.name)
|
||||
.join(', ');
|
||||
console.log(selectedIds);
|
||||
const managerId = props.admin?.managerId || props.admin?.id; // 兼容不同字段
|
||||
if (!managerId) {
|
||||
ElMessage.error('管理员ID缺失,无法提交');
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
try {
|
||||
await request({
|
||||
url: '/xgStudentManagerSource/studentManagerSource/grantDeptAuth',
|
||||
method: 'post',
|
||||
params: { managerId },
|
||||
data: selectedIds
|
||||
});
|
||||
ElMessage.success('分配成功');
|
||||
visible.value = false;
|
||||
emit('submit', {
|
||||
sourceIds: selectedIds
|
||||
});
|
||||
} catch (error) {
|
||||
ElMessage.error('分配失败,请重试');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
// 提交
|
||||
emit('submit', {
|
||||
sourceIds: selectedIds,
|
||||
scopeName: scopeName
|
||||
});
|
||||
|
||||
ElMessage.success('分配成功');
|
||||
visible.value = false;
|
||||
}
|
||||
|
||||
// 取消
|
||||
@@ -145,7 +239,8 @@ const type = computed(() => props.type);
|
||||
// 暴露组件以修复导出问题
|
||||
defineExpose({
|
||||
submitForm,
|
||||
cancel
|
||||
cancel,
|
||||
fetchDeptTree
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
</style>
|
||||
@@ -8,7 +8,7 @@
|
||||
<el-card shadow="hover">
|
||||
<el-form :inline="true" :model="schoolSearchForm" class="search-form">
|
||||
<el-form-item label="姓名">
|
||||
<el-input v-model="schoolSearchForm.name" placeholder="请输入姓名" clearable @keyup.enter="handleSearch('school')" />
|
||||
<el-input v-model="schoolSearchForm.managerName" placeholder="请输入姓名" clearable @keyup.enter="handleSearch('school')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号码">
|
||||
<el-input v-model="schoolSearchForm.phone" placeholder="请输入手机号码" clearable @keyup.enter="handleSearch('school')" />
|
||||
@@ -30,11 +30,11 @@
|
||||
</el-row>
|
||||
</template>
|
||||
<el-table :data="filteredAdmins('school')" border>
|
||||
<el-table-column prop="name" label="姓名" align="center" />
|
||||
<el-table-column prop="managerName" label="姓名" align="center" />
|
||||
<el-table-column prop="phone" label="手机号码" align="center" />
|
||||
<el-table-column prop="sex" label="性别" align="center">
|
||||
<el-table-column prop="gender" label="性别" align="center">
|
||||
<template #default="scope">
|
||||
{{ scope.row.sex === 0 ? '男' : '女' }}
|
||||
{{ scope.row.gender == 0 ? '男' : '女' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" align="center" />
|
||||
@@ -57,7 +57,7 @@
|
||||
<el-card shadow="hover">
|
||||
<el-form :inline="true" :model="customSearchForm" class="search-form">
|
||||
<el-form-item label="姓名">
|
||||
<el-input v-model="customSearchForm.name" placeholder="请输入姓名" clearable @keyup.enter="handleSearch('custom')" />
|
||||
<el-input v-model="customSearchForm.managerName" placeholder="请输入姓名" clearable @keyup.enter="handleSearch('custom')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号码">
|
||||
<el-input v-model="customSearchForm.phone" placeholder="请输入手机号码" clearable @keyup.enter="handleSearch('custom')" />
|
||||
@@ -78,11 +78,11 @@
|
||||
</el-row>
|
||||
</template>
|
||||
<el-table :data="filteredAdmins('custom')" border>
|
||||
<el-table-column prop="name" label="姓名" align="center" />
|
||||
<el-table-column prop="managerName" label="姓名" align="center" />
|
||||
<el-table-column prop="phone" label="手机号码" align="center" />
|
||||
<el-table-column prop="sex" label="性别" align="center">
|
||||
<el-table-column prop="gender" label="性别" align="center">
|
||||
<template #default="scope">
|
||||
{{ scope.row.sex === 0 ? '男' : '女' }}
|
||||
{{ scope.row.gender == 0 ? '男' : '女' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="scope" label="管理范围" align="center" />
|
||||
@@ -109,7 +109,7 @@
|
||||
<el-card shadow="hover">
|
||||
<el-form :inline="true" :model="teacherSearchForm" class="search-form">
|
||||
<el-form-item label="姓名">
|
||||
<el-input v-model="teacherSearchForm.name" placeholder="请输入姓名" clearable @keyup.enter="handleSearch('teacher')" />
|
||||
<el-input v-model="teacherSearchForm.managerName" placeholder="请输入姓名" clearable @keyup.enter="handleSearch('teacher')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号码">
|
||||
<el-input v-model="teacherSearchForm.phone" placeholder="请输入手机号码" clearable @keyup.enter="handleSearch('teacher')" />
|
||||
@@ -122,13 +122,13 @@
|
||||
</el-card>
|
||||
</div>
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<!-- <template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="onAdd('teacher')">新增班主任</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
</template> -->
|
||||
<el-table :data="filteredAdmins('teacher')" border>
|
||||
<el-table-column prop="name" label="姓名" align="center" />
|
||||
<el-table-column prop="phone" label="手机号码" align="center" />
|
||||
@@ -137,9 +137,9 @@
|
||||
{{ scope.row.sex === 0 ? '男' : '女' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="scope" label="所管理班级" align="center" />
|
||||
<el-table-column prop="className" label="所管理班级" align="center" />
|
||||
<el-table-column prop="remark" label="备注" align="center" />
|
||||
<el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width">
|
||||
<!-- <el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="编辑" placement="top">
|
||||
<el-button link type="primary" plain icon="Edit" @click="onEdit('teacher', scope.row)" />
|
||||
@@ -151,7 +151,7 @@
|
||||
<el-button link type="danger" plain icon="Delete" @click="onDelete('teacher', scope.row)" />
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table-column> -->
|
||||
</el-table>
|
||||
</el-card>
|
||||
</el-tab-pane>
|
||||
@@ -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<StudentManagerQuery>({
|
||||
managerName: '',
|
||||
phone: '',
|
||||
managerType: '1',
|
||||
pageNum: 1,
|
||||
pageSize: 1000
|
||||
});
|
||||
const customSearchForm = reactive<StudentManagerQuery>({
|
||||
managerName: '',
|
||||
phone: '',
|
||||
managerType: '2',
|
||||
pageNum: 1,
|
||||
pageSize: 1000
|
||||
});
|
||||
const teacherSearchForm = reactive({ managerName: '', phone: '' });
|
||||
|
||||
// 管理员数据
|
||||
const schoolAdmins = ref([]);
|
||||
@@ -192,46 +203,39 @@ const currentAdmin = ref<any>(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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user