【新增、修改】1、新增 学生、教师关联关系;2、修改 用户表属性,权限属性
This commit is contained in:
@@ -125,6 +125,12 @@
|
||||
<groupId>org.dromara.hutool</groupId>
|
||||
<artifactId>hutool-extra</artifactId> <!-- 邮件 -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>pc.exam.gg</groupId>
|
||||
<artifactId>exam-module-exam-biz</artifactId>
|
||||
<version>2.4.2-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
@@ -35,9 +35,13 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static pc.exam.pp.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static pc.exam.pp.framework.common.pojo.CommonResult.error;
|
||||
import static pc.exam.pp.framework.common.pojo.CommonResult.success;
|
||||
import static pc.exam.pp.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
import static pc.exam.pp.module.system.enums.ErrorCodeConstants.STUDENT_USERNAME_LOGIN;
|
||||
import static pc.exam.pp.module.system.enums.ErrorCodeConstants.STUDENT_USERNAME_NOTLOGIN;
|
||||
|
||||
@Tag(name = "管理后台 - 认证")
|
||||
@RestController
|
||||
@@ -66,6 +70,15 @@ public class AuthController {
|
||||
@PermitAll
|
||||
@Operation(summary = "使用账号密码登录")
|
||||
public CommonResult<AuthLoginRespVO> login(@RequestBody @Valid AuthLoginReqVO reqVO) {
|
||||
// 判断账号类型
|
||||
AdminUserDO adminUserDO = userService.getUserByUsername(reqVO.getUsername());
|
||||
// 登陆非学生端,0,1
|
||||
if (Integer.parseInt(reqVO.getUserType()) <= 1) {
|
||||
if (Integer.parseInt(adminUserDO.getUserType()) == 2) return error(STUDENT_USERNAME_LOGIN);
|
||||
}
|
||||
if (Integer.parseInt(reqVO.getUserType()) == 2) {
|
||||
if (Integer.parseInt(adminUserDO.getUserType()) <= 1) return error(STUDENT_USERNAME_NOTLOGIN);
|
||||
}
|
||||
return success(authService.login(reqVO));
|
||||
}
|
||||
|
||||
|
@@ -41,6 +41,9 @@ public class AuthLoginReqVO extends CaptchaVerificationReqVO {
|
||||
@Schema(description = "授权码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private String socialCode;
|
||||
|
||||
@Schema(description = "用户类型")
|
||||
private String userType;
|
||||
|
||||
@Schema(description = "state", requiredMode = Schema.RequiredMode.REQUIRED, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62")
|
||||
private String socialState;
|
||||
|
||||
|
@@ -43,6 +43,13 @@ public class PermissionController {
|
||||
return success(permissionService.getRoleMenuListByRoleId(roleId));
|
||||
}
|
||||
|
||||
@Operation(summary = "获得教师拥有的专业编号")
|
||||
@Parameter(name = "teacherId", description = "专业编号", required = true)
|
||||
@GetMapping("/list-teacher-specialty")
|
||||
public CommonResult<Set<Long>> getTeaacherSpecoaltyList(Long teacherId) {
|
||||
return success(permissionService.getSpecialtyListByTeacherId(teacherId));
|
||||
}
|
||||
|
||||
@PostMapping("/assign-role-menu")
|
||||
@Operation(summary = "赋予角色菜单")
|
||||
@PreAuthorize("@ss.hasPermission('system:permission:assign-role-menu')")
|
||||
|
@@ -7,6 +7,8 @@ import pc.exam.pp.framework.common.pojo.CommonResult;
|
||||
import pc.exam.pp.framework.common.pojo.PageParam;
|
||||
import pc.exam.pp.framework.common.pojo.PageResult;
|
||||
import pc.exam.pp.framework.excel.core.util.ExcelUtils;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.classs.ClassDO;
|
||||
import pc.exam.pp.module.exam.service.classs.ClassService;
|
||||
import pc.exam.pp.module.system.controller.admin.user.vo.user.*;
|
||||
import pc.exam.pp.module.system.convert.user.UserConvert;
|
||||
import pc.exam.pp.module.system.dal.dataobject.dept.DeptDO;
|
||||
@@ -44,6 +46,8 @@ public class UserController {
|
||||
@Resource
|
||||
private AdminUserService userService;
|
||||
@Resource
|
||||
private ClassService classService;
|
||||
@Resource
|
||||
private DeptService deptService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@@ -54,6 +58,20 @@ public class UserController {
|
||||
return success(id);
|
||||
}
|
||||
|
||||
@PostMapping("/createStudent")
|
||||
@Operation(summary = "新增用户学生用户")
|
||||
public CommonResult<Long> createUserStudent(@Valid @RequestBody UserSaveReqVO reqVO) {
|
||||
Long id = userService.createUserStudent(reqVO);
|
||||
return success(id);
|
||||
}
|
||||
|
||||
@PostMapping("/createTeacher")
|
||||
@Operation(summary = "新增用户教师用户")
|
||||
public CommonResult<Long> createUserTeacher(@Valid @RequestBody UserSaveReqVO reqVO) {
|
||||
Long id = userService.createUserTeacher(reqVO);
|
||||
return success(id);
|
||||
}
|
||||
|
||||
@PutMapping("update")
|
||||
@Operation(summary = "修改用户")
|
||||
@PreAuthorize("@ss.hasPermission('system:user:update')")
|
||||
@@ -62,6 +80,21 @@ public class UserController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("updateStudent")
|
||||
@Operation(summary = "修改用户 学生")
|
||||
public CommonResult<Boolean> updateStudent(@Valid @RequestBody UserSaveReqVO reqVO) {
|
||||
userService.updateStudent(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("updateTeacher")
|
||||
@Operation(summary = "修改用户 教师")
|
||||
public CommonResult<Boolean> updateTeacher(@Valid @RequestBody UserSaveReqVO reqVO) {
|
||||
userService.updateTeacher(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除用户")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@@ -103,6 +136,22 @@ public class UserController {
|
||||
pageResult.getTotal()));
|
||||
}
|
||||
|
||||
@GetMapping("/studentpage")
|
||||
@Operation(summary = "获得学生分页列表")
|
||||
public CommonResult<PageResult<UserRespVO>> getStudentPage(@Valid UserPageReqVO pageReqVO) {
|
||||
// 获得用户分页列表
|
||||
PageResult<AdminUserDO> pageResult = userService.getStudentPage(pageReqVO);
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
return success(new PageResult<>(pageResult.getTotal()));
|
||||
}
|
||||
// 拼接数据 班级数据
|
||||
// 拼接数据
|
||||
Map<Long, ClassDO> classDOMap = classService.getClassMap(
|
||||
convertList(pageResult.getList(), AdminUserDO::getClassId));
|
||||
return success(new PageResult<>(UserConvert.INSTANCE.convertClassList(pageResult.getList(), classDOMap),
|
||||
pageResult.getTotal()));
|
||||
}
|
||||
|
||||
@GetMapping({"/list-all-simple", "/simple-list"})
|
||||
@Operation(summary = "获取用户精简信息列表", description = "只包含被开启的用户,主要用于前端的下拉选项")
|
||||
public CommonResult<List<UserSimpleRespVO>> getSimpleUserList() {
|
||||
@@ -124,8 +173,22 @@ public class UserController {
|
||||
}
|
||||
// 拼接数据
|
||||
DeptDO dept = deptService.getDept(user.getDeptId());
|
||||
// 学生-拼接班级数据
|
||||
if (user.getUserType().equals("2")) {
|
||||
ClassDO classDO = classService.getClass(user.getClassId());
|
||||
return success(UserConvert.INSTANCE.convertClass(user, dept, classDO));
|
||||
}
|
||||
return success(UserConvert.INSTANCE.convert(user, dept));
|
||||
}
|
||||
@GetMapping("/getByThId")
|
||||
@Operation(summary = "通过教师ID获取所有学生数据")
|
||||
public CommonResult<List<UserRespVO>> getUserById(@RequestParam("id") Long id) {
|
||||
List<UserRespVO> user = userService.getUserById(id);
|
||||
if (user == null) {
|
||||
return success(null);
|
||||
}
|
||||
return success(user);
|
||||
}
|
||||
|
||||
@GetMapping("/export")
|
||||
@Operation(summary = "导出用户")
|
||||
|
@@ -38,4 +38,10 @@ public class UserPageReqVO extends PageParam {
|
||||
@Schema(description = "角色编号", example = "1024")
|
||||
private Long roleId;
|
||||
|
||||
@Schema(description = "类型")
|
||||
private String userType;
|
||||
|
||||
@Schema(description = "班级")
|
||||
private String className;
|
||||
|
||||
}
|
||||
|
@@ -28,11 +28,16 @@ public class UserRespVO{
|
||||
@ExcelProperty("用户昵称")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "班级名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@ExcelProperty("班级名称")
|
||||
private String className;
|
||||
|
||||
@Schema(description = "备注", example = "我是一个用户")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "部门ID", example = "我是一个用户")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "部门名称", example = "IT 部")
|
||||
@ExcelProperty("部门名称")
|
||||
private String deptName;
|
||||
@@ -40,6 +45,9 @@ public class UserRespVO{
|
||||
@Schema(description = "岗位编号数组", example = "1")
|
||||
private Set<Long> postIds;
|
||||
|
||||
@Schema(description = "班级编号数组", example = "1")
|
||||
private Set<Long> classIds;
|
||||
|
||||
@Schema(description = "用户邮箱", example = "exam@iocoder.cn")
|
||||
@ExcelProperty("用户邮箱")
|
||||
private String email;
|
||||
|
@@ -41,10 +41,22 @@ public class UserSaveReqVO {
|
||||
@DiffLogField(name = "部门", function = DeptParseFunction.NAME)
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "班级编号", example = "我是一个用户")
|
||||
@DiffLogField(name = "班级", function = DeptParseFunction.NAME)
|
||||
private String className;
|
||||
|
||||
@Schema(description = "岗位编号数组", example = "1")
|
||||
@DiffLogField(name = "岗位", function = PostParseFunction.NAME)
|
||||
private Set<Long> postIds;
|
||||
|
||||
@Schema(description = "班级编号数组", example = "1")
|
||||
@DiffLogField(name = "班级", function = PostParseFunction.NAME)
|
||||
private Set<Long> classIds;
|
||||
|
||||
@Schema(description = "专业编号数组", example = "1")
|
||||
@DiffLogField(name = "专业", function = PostParseFunction.NAME)
|
||||
private Set<Long> specialtyIds;
|
||||
|
||||
@Schema(description = "用户邮箱", example = "exam@iocoder.cn")
|
||||
@Email(message = "邮箱格式不正确")
|
||||
@Size(max = 50, message = "邮箱长度不能超过 50 个字符")
|
||||
@@ -56,6 +68,9 @@ public class UserSaveReqVO {
|
||||
@DiffLogField(name = "手机号码")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "用户类型", example = "1")
|
||||
private String userType;
|
||||
|
||||
@Schema(description = "用户性别,参见 SexEnum 枚举类", example = "1")
|
||||
@DiffLogField(name = "用户性别", function = SexParseFunction.NAME)
|
||||
private Integer sex;
|
||||
|
@@ -3,6 +3,7 @@ package pc.exam.pp.module.system.convert.user;
|
||||
import pc.exam.pp.framework.common.util.collection.CollectionUtils;
|
||||
import pc.exam.pp.framework.common.util.collection.MapUtils;
|
||||
import pc.exam.pp.framework.common.util.object.BeanUtils;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.classs.ClassDO;
|
||||
import pc.exam.pp.module.system.controller.admin.dept.vo.dept.DeptSimpleRespVO;
|
||||
import pc.exam.pp.module.system.controller.admin.dept.vo.post.PostSimpleRespVO;
|
||||
import pc.exam.pp.module.system.controller.admin.permission.vo.role.RoleSimpleRespVO;
|
||||
@@ -29,6 +30,10 @@ public interface UserConvert {
|
||||
return CollectionUtils.convertList(list, user -> convert(user, deptMap.get(user.getDeptId())));
|
||||
}
|
||||
|
||||
default List<UserRespVO> convertClassList(List<AdminUserDO> list, Map<Long, ClassDO> classDOMap) {
|
||||
return CollectionUtils.convertList(list, user -> convertOneClass(user, classDOMap.get(user.getClassId())));
|
||||
}
|
||||
|
||||
default UserRespVO convert(AdminUserDO user, DeptDO dept) {
|
||||
UserRespVO userVO = BeanUtils.toBean(user, UserRespVO.class);
|
||||
if (dept != null) {
|
||||
@@ -36,6 +41,20 @@ public interface UserConvert {
|
||||
}
|
||||
return userVO;
|
||||
}
|
||||
default UserRespVO convertOneClass(AdminUserDO user, ClassDO classDO) {
|
||||
UserRespVO userVO = BeanUtils.toBean(user, UserRespVO.class);
|
||||
userVO.setClassName(classDO.getName());
|
||||
return userVO;
|
||||
}
|
||||
|
||||
default UserRespVO convertClass(AdminUserDO user, DeptDO dept, ClassDO classDO) {
|
||||
UserRespVO userVO = BeanUtils.toBean(user, UserRespVO.class);
|
||||
userVO.setClassName(classDO.getName());
|
||||
if (dept != null) {
|
||||
userVO.setDeptName(dept.getName());
|
||||
}
|
||||
return userVO;
|
||||
}
|
||||
|
||||
default List<UserSimpleRespVO> convertSimpleList(List<AdminUserDO> list, Map<Long, DeptDO> deptMap) {
|
||||
return CollectionUtils.convertList(list, user -> {
|
||||
|
@@ -55,11 +55,33 @@ public class AdminUserDO extends TenantBaseDO {
|
||||
* 部门 ID
|
||||
*/
|
||||
private Long deptId;
|
||||
/**
|
||||
* 班级 ID
|
||||
*/
|
||||
private Long classId;
|
||||
/**
|
||||
* 岗位编号数组
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private Set<Long> postIds;
|
||||
|
||||
/**
|
||||
* 班级编号数组
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private Set<Long> classIds;
|
||||
|
||||
/**
|
||||
* 专业编号数组
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private Set<Long> specialtyIds;
|
||||
|
||||
/**
|
||||
* 用户类型
|
||||
*/
|
||||
private String userType;
|
||||
|
||||
/**
|
||||
* 用户邮箱
|
||||
*/
|
||||
@@ -93,4 +115,6 @@ public class AdminUserDO extends TenantBaseDO {
|
||||
*/
|
||||
private LocalDateTime loginDate;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,40 @@
|
||||
package pc.exam.pp.module.system.dal.dataobject.user;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import pc.exam.pp.framework.mybatis.core.dataobject.BaseDO;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.classs.ClassDO;
|
||||
|
||||
/**
|
||||
* 教师班级关联
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@TableName("system_teacher_class")
|
||||
@KeySequence("system_teacher_class_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class TeacherClassDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 自增主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 用户 ID
|
||||
*
|
||||
* 关联 {@link AdminUserDO#getId()}
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 角色 ID
|
||||
*
|
||||
* 关联 {@link ClassDO#getId()}
|
||||
*/
|
||||
private Long classId;
|
||||
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
package pc.exam.pp.module.system.dal.dataobject.user;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import pc.exam.pp.framework.mybatis.core.dataobject.BaseDO;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.classs.ClassDO;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.specialty.ExamSpecialty;
|
||||
|
||||
/**
|
||||
* 教师专业关联
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@TableName("system_teacher_specialty")
|
||||
@KeySequence("system_teacher_specialty_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class TeacherSpecialtyDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 自增主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 用户 ID
|
||||
*
|
||||
* 关联 {@link AdminUserDO#getId()}
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 角色 ID
|
||||
*
|
||||
* 关联 {@link ExamSpecialty#getSpId()}
|
||||
*/
|
||||
private Long specialtyId;
|
||||
|
||||
}
|
@@ -1,9 +1,15 @@
|
||||
package pc.exam.pp.module.system.dal.mysql.user;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import pc.exam.pp.framework.common.pojo.PageResult;
|
||||
import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import pc.exam.pp.framework.mybatis.core.query.MPJLambdaWrapperX;
|
||||
import pc.exam.pp.module.exam.controller.admin.student.vo.StudentPageReqVO;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.student.StudentClassDO;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.student.StudentDO;
|
||||
import pc.exam.pp.module.system.controller.admin.user.vo.user.UserPageReqVO;
|
||||
import pc.exam.pp.module.system.controller.admin.user.vo.user.UserRespVO;
|
||||
import pc.exam.pp.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@@ -29,6 +35,20 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<AdminUserDO>()
|
||||
.likeIfPresent(AdminUserDO::getUsername, reqVO.getUsername())
|
||||
.likeIfPresent(AdminUserDO::getMobile, reqVO.getMobile())
|
||||
.eq(AdminUserDO::getUserType, reqVO.getUserType())
|
||||
.eqIfPresent(AdminUserDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(AdminUserDO::getCreateTime, reqVO.getCreateTime())
|
||||
.inIfPresent(AdminUserDO::getDeptId, deptIds)
|
||||
.inIfPresent(AdminUserDO::getId, userIds)
|
||||
.orderByDesc(AdminUserDO::getId));
|
||||
}
|
||||
|
||||
default PageResult<AdminUserDO> selectStuPage(UserPageReqVO reqVO, Collection<Long> deptIds, Collection<Long> userIds, Long classId) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<AdminUserDO>()
|
||||
.likeIfPresent(AdminUserDO::getUsername, reqVO.getUsername())
|
||||
.likeIfPresent(AdminUserDO::getMobile, reqVO.getMobile())
|
||||
.eq(AdminUserDO::getUserType, reqVO.getUserType())
|
||||
.eqIfPresent(AdminUserDO::getClassId, classId)
|
||||
.eqIfPresent(AdminUserDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(AdminUserDO::getCreateTime, reqVO.getCreateTime())
|
||||
.inIfPresent(AdminUserDO::getDeptId, deptIds)
|
||||
@@ -48,4 +68,6 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
|
||||
return selectList(AdminUserDO::getDeptId, deptIds);
|
||||
}
|
||||
|
||||
List<UserRespVO> selectUserByIdList(@Param("id") Long id);
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,24 @@
|
||||
package pc.exam.pp.module.system.dal.mysql.user;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import pc.exam.pp.module.system.dal.dataobject.dept.UserPostDO;
|
||||
import pc.exam.pp.module.system.dal.dataobject.user.TeacherClassDO;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface TeacherClassMapper extends BaseMapperX<TeacherClassDO> {
|
||||
|
||||
default List<TeacherClassDO> selectListByUserId(Long userId) {
|
||||
return selectList(TeacherClassDO::getUserId, userId);
|
||||
}
|
||||
|
||||
default void deleteByUserIdAndTeacherId(Long userId, Collection<Long> classIds) {
|
||||
delete(new LambdaQueryWrapperX<TeacherClassDO>()
|
||||
.eq(TeacherClassDO::getUserId, userId)
|
||||
.in(TeacherClassDO::getClassId, classIds));
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
package pc.exam.pp.module.system.dal.mysql.user;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import pc.exam.pp.module.system.dal.dataobject.permission.RoleMenuDO;
|
||||
import pc.exam.pp.module.system.dal.dataobject.user.TeacherClassDO;
|
||||
import pc.exam.pp.module.system.dal.dataobject.user.TeacherSpecialtyDO;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface TeacherSpecialtyMapper extends BaseMapperX<TeacherSpecialtyDO> {
|
||||
|
||||
default List<TeacherSpecialtyDO> selectListByTeacherId(Collection<Long> teacherIds) {
|
||||
return selectList(TeacherSpecialtyDO::getUserId, teacherIds);
|
||||
}
|
||||
|
||||
default List<TeacherSpecialtyDO> selectListByUserId(Long userId) {
|
||||
return selectList(TeacherSpecialtyDO::getUserId, userId);
|
||||
}
|
||||
|
||||
default void deleteByUserIdAndSpecialtyId(Long userId, Collection<Long> specialtyIds) {
|
||||
delete(new LambdaQueryWrapperX<TeacherSpecialtyDO>()
|
||||
.eq(TeacherSpecialtyDO::getUserId, userId)
|
||||
.in(TeacherSpecialtyDO::getSpecialtyId, specialtyIds));
|
||||
}
|
||||
}
|
@@ -67,6 +67,16 @@ public interface PermissionService {
|
||||
return getRoleMenuListByRoleId(singleton(roleId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得教师拥有的专业编号集合
|
||||
*
|
||||
* @param teacherId 教师ID
|
||||
* @return 专业编号集合
|
||||
*/
|
||||
default Set<Long> getSpecialtyListByTeacherId(Long teacherId) {
|
||||
return getSpecialtyListByTeacherId(singleton(teacherId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得角色们拥有的菜单编号集合
|
||||
*
|
||||
@@ -75,6 +85,14 @@ public interface PermissionService {
|
||||
*/
|
||||
Set<Long> getRoleMenuListByRoleId(Collection<Long> roleIds);
|
||||
|
||||
/**
|
||||
* 获得教师们拥有的专业编号集合
|
||||
*
|
||||
* @param teacherIds 专业编号数组
|
||||
* @return 专业编号集合
|
||||
*/
|
||||
Set<Long> getSpecialtyListByTeacherId(Collection<Long> teacherIds);
|
||||
|
||||
/**
|
||||
* 获得拥有指定菜单的角色编号数组,从缓存中获取
|
||||
*
|
||||
|
@@ -12,8 +12,10 @@ import pc.exam.pp.module.system.dal.dataobject.permission.MenuDO;
|
||||
import pc.exam.pp.module.system.dal.dataobject.permission.RoleDO;
|
||||
import pc.exam.pp.module.system.dal.dataobject.permission.RoleMenuDO;
|
||||
import pc.exam.pp.module.system.dal.dataobject.permission.UserRoleDO;
|
||||
import pc.exam.pp.module.system.dal.dataobject.user.TeacherSpecialtyDO;
|
||||
import pc.exam.pp.module.system.dal.mysql.permission.RoleMenuMapper;
|
||||
import pc.exam.pp.module.system.dal.mysql.permission.UserRoleMapper;
|
||||
import pc.exam.pp.module.system.dal.mysql.user.TeacherSpecialtyMapper;
|
||||
import pc.exam.pp.module.system.dal.redis.RedisKeyConstants;
|
||||
import pc.exam.pp.module.system.enums.permission.DataScopeEnum;
|
||||
import pc.exam.pp.module.system.service.dept.DeptService;
|
||||
@@ -48,6 +50,8 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
@Resource
|
||||
private RoleMenuMapper roleMenuMapper;
|
||||
@Resource
|
||||
private TeacherSpecialtyMapper teacherSpecialtyMapper;
|
||||
@Resource
|
||||
private UserRoleMapper userRoleMapper;
|
||||
|
||||
@Resource
|
||||
@@ -193,6 +197,21 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
// 如果是非管理员的情况下,获得拥有的菜单编号
|
||||
return convertSet(roleMenuMapper.selectListByRoleId(roleIds), RoleMenuDO::getMenuId);
|
||||
}
|
||||
@Override
|
||||
public Set<Long> getSpecialtyListByTeacherId(Collection<Long> teacherIds) {
|
||||
if (CollUtil.isEmpty(teacherIds)) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
// 如果是管理员的情况下,获取全部菜单编号
|
||||
// if (roleService.hasAnySuperAdmin(teacherIds)) {
|
||||
// return convertSet(menuService.getMenuList(), MenuDO::getId);
|
||||
// }
|
||||
// userService.getUserList(teacherIds);
|
||||
// 如果是非管理员的情况下,获得拥有的菜单编号
|
||||
return convertSet(teacherSpecialtyMapper.selectListByTeacherId(teacherIds), TeacherSpecialtyDO::getSpecialtyId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Cacheable(value = RedisKeyConstants.MENU_ROLE_ID_LIST, key = "#menuId")
|
||||
|
@@ -230,6 +230,7 @@ public class RoleServiceImpl implements RoleService {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void validateRoleList(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
|
@@ -6,10 +6,7 @@ import pc.exam.pp.framework.common.util.collection.CollectionUtils;
|
||||
import pc.exam.pp.module.system.controller.admin.auth.vo.AuthRegisterReqVO;
|
||||
import pc.exam.pp.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO;
|
||||
import pc.exam.pp.module.system.controller.admin.user.vo.profile.UserProfileUpdateReqVO;
|
||||
import pc.exam.pp.module.system.controller.admin.user.vo.user.UserImportExcelVO;
|
||||
import pc.exam.pp.module.system.controller.admin.user.vo.user.UserImportRespVO;
|
||||
import pc.exam.pp.module.system.controller.admin.user.vo.user.UserPageReqVO;
|
||||
import pc.exam.pp.module.system.controller.admin.user.vo.user.UserSaveReqVO;
|
||||
import pc.exam.pp.module.system.controller.admin.user.vo.user.*;
|
||||
import pc.exam.pp.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
@@ -33,6 +30,22 @@ public interface AdminUserService {
|
||||
* @return 用户编号
|
||||
*/
|
||||
Long createUser(@Valid UserSaveReqVO createReqVO);
|
||||
/**
|
||||
* 创建用户 学生
|
||||
*
|
||||
* @param createReqVO 用户信息 学生
|
||||
* @return 用户编号 学生
|
||||
*/
|
||||
Long createUserStudent(@Valid UserSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 创建用户 教师
|
||||
*
|
||||
* @param createReqVO 用户信息 学生
|
||||
* @return 用户编号 学生
|
||||
*/
|
||||
Long createUserTeacher(@Valid UserSaveReqVO createReqVO);
|
||||
|
||||
|
||||
/**
|
||||
* 注册用户
|
||||
@@ -49,6 +62,19 @@ public interface AdminUserService {
|
||||
*/
|
||||
void updateUser(@Valid UserSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 修改用户 学生
|
||||
*
|
||||
* @param updateReqVO 用户信息
|
||||
*/
|
||||
void updateStudent(@Valid UserSaveReqVO updateReqVO);
|
||||
/**
|
||||
* 修改用户 教师
|
||||
*
|
||||
* @param updateReqVO 教师信息
|
||||
*/
|
||||
void updateTeacher(@Valid UserSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 更新用户的最后登陆信息
|
||||
*
|
||||
@@ -128,6 +154,14 @@ public interface AdminUserService {
|
||||
*/
|
||||
PageResult<AdminUserDO> getUserPage(UserPageReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 获得学生分页列表
|
||||
*
|
||||
* @param reqVO 分页条件
|
||||
* @return 分页列表
|
||||
*/
|
||||
PageResult<AdminUserDO> getStudentPage(UserPageReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 通过用户 ID 查询用户
|
||||
*
|
||||
@@ -136,6 +170,13 @@ public interface AdminUserService {
|
||||
*/
|
||||
AdminUserDO getUser(Long id);
|
||||
|
||||
/**
|
||||
* 通过教师 ID 查询学生列表
|
||||
*
|
||||
* @param id 教师 ID
|
||||
* @return 学生列表
|
||||
*/
|
||||
List<UserRespVO> getUserById(Long id);
|
||||
/**
|
||||
* 获得指定部门的用户数组
|
||||
*
|
||||
|
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.bouncycastle.jcajce.provider.symmetric.TEA;
|
||||
import pc.exam.pp.framework.common.enums.CommonStatusEnum;
|
||||
import pc.exam.pp.framework.common.exception.ServiceException;
|
||||
import pc.exam.pp.framework.common.pojo.PageResult;
|
||||
@@ -11,20 +12,25 @@ import pc.exam.pp.framework.common.util.collection.CollectionUtils;
|
||||
import pc.exam.pp.framework.common.util.object.BeanUtils;
|
||||
import pc.exam.pp.framework.common.util.validation.ValidationUtils;
|
||||
import pc.exam.pp.framework.datapermission.core.util.DataPermissionUtils;
|
||||
import pc.exam.pp.module.exam.controller.admin.classs.vo.ClassSaveReqVO;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.classs.ClassDO;
|
||||
import pc.exam.pp.module.exam.dal.mysql.classs.ClassMapper;
|
||||
import pc.exam.pp.module.exam.service.classs.ClassService;
|
||||
import pc.exam.pp.module.infra.api.config.ConfigApi;
|
||||
import pc.exam.pp.module.infra.api.file.FileApi;
|
||||
import pc.exam.pp.module.system.controller.admin.auth.vo.AuthRegisterReqVO;
|
||||
import pc.exam.pp.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO;
|
||||
import pc.exam.pp.module.system.controller.admin.user.vo.profile.UserProfileUpdateReqVO;
|
||||
import pc.exam.pp.module.system.controller.admin.user.vo.user.UserImportExcelVO;
|
||||
import pc.exam.pp.module.system.controller.admin.user.vo.user.UserImportRespVO;
|
||||
import pc.exam.pp.module.system.controller.admin.user.vo.user.UserPageReqVO;
|
||||
import pc.exam.pp.module.system.controller.admin.user.vo.user.UserSaveReqVO;
|
||||
import pc.exam.pp.module.system.controller.admin.user.vo.user.*;
|
||||
import pc.exam.pp.module.system.dal.dataobject.dept.DeptDO;
|
||||
import pc.exam.pp.module.system.dal.dataobject.dept.UserPostDO;
|
||||
import pc.exam.pp.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import pc.exam.pp.module.system.dal.dataobject.user.TeacherClassDO;
|
||||
import pc.exam.pp.module.system.dal.dataobject.user.TeacherSpecialtyDO;
|
||||
import pc.exam.pp.module.system.dal.mysql.dept.UserPostMapper;
|
||||
import pc.exam.pp.module.system.dal.mysql.user.AdminUserMapper;
|
||||
import pc.exam.pp.module.system.dal.mysql.user.TeacherClassMapper;
|
||||
import pc.exam.pp.module.system.dal.mysql.user.TeacherSpecialtyMapper;
|
||||
import pc.exam.pp.module.system.service.dept.DeptService;
|
||||
import pc.exam.pp.module.system.service.dept.PostService;
|
||||
import pc.exam.pp.module.system.service.permission.PermissionService;
|
||||
@@ -64,6 +70,11 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
@Resource
|
||||
private AdminUserMapper userMapper;
|
||||
|
||||
@Resource
|
||||
private ClassMapper classMapper;
|
||||
@Resource
|
||||
private ClassService classService;
|
||||
|
||||
@Resource
|
||||
private DeptService deptService;
|
||||
@Resource
|
||||
@@ -78,6 +89,11 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
|
||||
@Resource
|
||||
private UserPostMapper userPostMapper;
|
||||
@Resource
|
||||
private TeacherClassMapper teacherClassMapper;
|
||||
|
||||
@Resource
|
||||
private TeacherSpecialtyMapper teacherSpecialtyMapper;
|
||||
|
||||
@Resource
|
||||
private FileApi fileApi;
|
||||
@@ -114,6 +130,92 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
LogRecordContext.putVariable("user", user);
|
||||
return user.getId();
|
||||
}
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@LogRecord(type = SYSTEM_USER_TYPE, subType = SYSTEM_USER_CREATE_SUB_TYPE, bizNo = "{{#user.id}}",
|
||||
success = SYSTEM_USER_CREATE_SUCCESS)
|
||||
public Long createUserStudent(UserSaveReqVO createReqVO) {
|
||||
// 1.1 校验账户配合
|
||||
tenantService.handleTenantInfo(tenant -> {
|
||||
long count = userMapper.selectCount();
|
||||
if (count >= tenant.getAccountCount()) {
|
||||
throw exception(USER_COUNT_MAX, tenant.getAccountCount());
|
||||
}
|
||||
});
|
||||
// 1.2 校验正确性
|
||||
validateUserForCreateOrUpdate(null, createReqVO.getUsername(),
|
||||
createReqVO.getMobile(), createReqVO.getEmail(), createReqVO.getDeptId(), createReqVO.getPostIds());
|
||||
|
||||
// 2.1 插入用户
|
||||
AdminUserDO user = BeanUtils.toBean(createReqVO, AdminUserDO.class);
|
||||
// 1.3 根据班级名称查询班级是否存在,如存在返回班级ID,如不存在创建并返回班级ID
|
||||
ClassDO classDO = classMapper.getClassNameOne(createReqVO.getClassName());
|
||||
if (classDO == null) {
|
||||
// 如果没有查询出来需要创建数据
|
||||
ClassSaveReqVO classSaveReqVO = new ClassSaveReqVO();
|
||||
classSaveReqVO.setName(createReqVO.getClassName());
|
||||
user.setClassId(classService.createClass(classSaveReqVO));
|
||||
} else {
|
||||
// 查询出数据后进行赋值
|
||||
user.setClassId(classDO.getId());
|
||||
}
|
||||
user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启
|
||||
user.setPassword(encodePassword(createReqVO.getPassword())); // 加密密码s
|
||||
userMapper.insert(user);
|
||||
// 2.2 插入关联岗位
|
||||
if (CollectionUtil.isNotEmpty(user.getPostIds())) {
|
||||
userPostMapper.insertBatch(convertList(user.getPostIds(),
|
||||
postId -> new UserPostDO().setUserId(user.getId()).setPostId(postId)));
|
||||
}
|
||||
// 3. 记录操作日志上下文
|
||||
LogRecordContext.putVariable("user", user);
|
||||
return user.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@LogRecord(type = SYSTEM_USER_TYPE, subType = SYSTEM_USER_CREATE_SUB_TYPE, bizNo = "{{#user.id}}",
|
||||
success = SYSTEM_USER_CREATE_SUCCESS)
|
||||
public Long createUserTeacher(UserSaveReqVO createReqVO) {
|
||||
// 1.1 校验账户配合
|
||||
tenantService.handleTenantInfo(tenant -> {
|
||||
long count = userMapper.selectCount();
|
||||
if (count >= tenant.getAccountCount()) {
|
||||
throw exception(USER_COUNT_MAX, tenant.getAccountCount());
|
||||
}
|
||||
});
|
||||
// 1.2 校验正确性
|
||||
validateUserForCreateOrUpdate(null, createReqVO.getUsername(),
|
||||
createReqVO.getMobile(), createReqVO.getEmail(), createReqVO.getDeptId(), createReqVO.getPostIds());
|
||||
|
||||
// 2.1 插入用户
|
||||
AdminUserDO user = BeanUtils.toBean(createReqVO, AdminUserDO.class);
|
||||
user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启
|
||||
user.setPassword(encodePassword(createReqVO.getPassword())); // 加密密码s
|
||||
userMapper.insert(user);
|
||||
// 2.2 插入关联岗位
|
||||
if (CollectionUtil.isNotEmpty(user.getPostIds())) {
|
||||
userPostMapper.insertBatch(convertList(user.getPostIds(),
|
||||
postId -> new UserPostDO().setUserId(user.getId()).setPostId(postId)));
|
||||
}
|
||||
|
||||
// 2.3 插入关联班级
|
||||
if (CollectionUtil.isNotEmpty(user.getClassIds())) {
|
||||
teacherClassMapper.insertBatch(convertList(user.getClassIds(),
|
||||
classId -> new TeacherClassDO().setUserId(user.getId()).setClassId(classId)));
|
||||
}
|
||||
|
||||
// 2.4 插入关联专业
|
||||
if (CollectionUtil.isNotEmpty(user.getSpecialtyIds())) {
|
||||
teacherSpecialtyMapper.insertBatch(convertList(user.getSpecialtyIds(),
|
||||
specialtyId -> new TeacherSpecialtyDO().setUserId(user.getId()).setSpecialtyId(specialtyId)));
|
||||
}
|
||||
|
||||
// 3. 记录操作日志上下文
|
||||
LogRecordContext.putVariable("user", user);
|
||||
return user.getId();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Long registerUser(AuthRegisterReqVO registerReqVO) {
|
||||
@@ -135,6 +237,64 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
return user.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@LogRecord(type = SYSTEM_USER_TYPE, subType = SYSTEM_USER_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}",
|
||||
success = SYSTEM_USER_UPDATE_SUCCESS)
|
||||
public void updateTeacher(UserSaveReqVO updateReqVO) {
|
||||
updateReqVO.setPassword(null); // 特殊:此处不更新密码
|
||||
// 1. 校验正确性
|
||||
AdminUserDO oldUser = validateUserForCreateOrUpdate(updateReqVO.getId(), updateReqVO.getUsername(),
|
||||
updateReqVO.getMobile(), updateReqVO.getEmail(), updateReqVO.getDeptId(), updateReqVO.getPostIds());
|
||||
|
||||
// 2.1 更新用户
|
||||
AdminUserDO updateObj = BeanUtils.toBean(updateReqVO, AdminUserDO.class);
|
||||
userMapper.updateById(updateObj);
|
||||
// 2.2 更新岗位
|
||||
updateUserPost(updateReqVO, updateObj);
|
||||
// 2.3 更新专业
|
||||
updateTeacherSpecialty(updateReqVO, updateObj);
|
||||
// 2.4 更新班级
|
||||
updateTeacherClass(updateReqVO, updateObj);
|
||||
|
||||
// 3. 记录操作日志上下文
|
||||
LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldUser, UserSaveReqVO.class));
|
||||
LogRecordContext.putVariable("teacher", oldUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@LogRecord(type = SYSTEM_USER_TYPE, subType = SYSTEM_USER_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}",
|
||||
success = SYSTEM_USER_UPDATE_SUCCESS)
|
||||
public void updateStudent(UserSaveReqVO updateReqVO) {
|
||||
updateReqVO.setPassword(null); // 特殊:此处不更新密码
|
||||
// 1. 校验正确性
|
||||
AdminUserDO oldUser = validateUserForCreateOrUpdate(updateReqVO.getId(), updateReqVO.getUsername(),
|
||||
updateReqVO.getMobile(), updateReqVO.getEmail(), updateReqVO.getDeptId(), updateReqVO.getPostIds());
|
||||
|
||||
// 1.3 根据班级名称查询班级是否存在,如存在返回班级ID,如不存在创建并返回班级ID
|
||||
AdminUserDO updateObj = BeanUtils.toBean(updateReqVO, AdminUserDO.class);
|
||||
ClassDO classDO = classMapper.getClassNameOne(updateReqVO.getClassName());
|
||||
if (classDO == null) {
|
||||
// 如果没有查询出来需要创建数据
|
||||
ClassSaveReqVO classSaveReqVO = new ClassSaveReqVO();
|
||||
classSaveReqVO.setName(updateReqVO.getClassName());
|
||||
updateObj.setClassId(classService.createClass(classSaveReqVO));
|
||||
} else {
|
||||
// 查询出数据后进行赋值
|
||||
updateObj.setClassId(classDO.getId());
|
||||
}
|
||||
// 2.1 更新用户
|
||||
userMapper.updateById(updateObj);
|
||||
// 2.2 更新岗位
|
||||
updateUserPost(updateReqVO, updateObj);
|
||||
// 3. 记录操作日志上下文
|
||||
LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldUser, UserSaveReqVO.class));
|
||||
LogRecordContext.putVariable("student", oldUser);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@LogRecord(type = SYSTEM_USER_TYPE, subType = SYSTEM_USER_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}",
|
||||
@@ -156,6 +316,42 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
LogRecordContext.putVariable("user", oldUser);
|
||||
}
|
||||
|
||||
private void updateTeacherClass(UserSaveReqVO reqVO, AdminUserDO updateObj) {
|
||||
Long userId = reqVO.getId();
|
||||
Set<Long> dbClassIds = convertSet(teacherClassMapper.selectListByUserId(userId), TeacherClassDO::getClassId);
|
||||
// 计算新增和删除的岗位编号
|
||||
Set<Long> classsIds = CollUtil.emptyIfNull(updateObj.getClassIds());
|
||||
Collection<Long> createClassIds = CollUtil.subtract(classsIds, dbClassIds);
|
||||
Collection<Long> deleteClassIds = CollUtil.subtract(dbClassIds, classsIds);
|
||||
|
||||
// 执行新增和删除。对于已经授权的班级,不用做任何处理
|
||||
if (!CollectionUtil.isEmpty(createClassIds)) {
|
||||
teacherClassMapper.insertBatch(convertList(createClassIds,
|
||||
classId -> new TeacherClassDO().setUserId(userId).setClassId(classId)));
|
||||
}
|
||||
if (!CollectionUtil.isEmpty(deleteClassIds)) {
|
||||
teacherClassMapper.deleteByUserIdAndTeacherId(userId, deleteClassIds);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTeacherSpecialty (UserSaveReqVO reqVO, AdminUserDO updateObj) {
|
||||
Long userId = reqVO.getId();
|
||||
Set<Long> dbSpecialtyIds = convertSet(teacherSpecialtyMapper.selectListByUserId(userId), TeacherSpecialtyDO::getSpecialtyId);
|
||||
// 计算新增和删除的岗位编号
|
||||
Set<Long> specialtyIds = CollUtil.emptyIfNull(updateObj.getSpecialtyIds());
|
||||
Collection<Long> createSpecialtyIds = CollUtil.subtract(specialtyIds, dbSpecialtyIds);
|
||||
Collection<Long> deleteSpecialtyIds = CollUtil.subtract(dbSpecialtyIds, specialtyIds);
|
||||
|
||||
// 执行新增和删除。对于已经授权的班级,不用做任何处理
|
||||
if (!CollectionUtil.isEmpty(createSpecialtyIds)) {
|
||||
teacherSpecialtyMapper.insertBatch(convertList(createSpecialtyIds,
|
||||
specialtyId -> new TeacherSpecialtyDO().setUserId(userId).setSpecialtyId(specialtyId)));
|
||||
}
|
||||
if (!CollectionUtil.isEmpty(deleteSpecialtyIds)) {
|
||||
teacherSpecialtyMapper.deleteByUserIdAndSpecialtyId(userId, deleteSpecialtyIds);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateUserPost(UserSaveReqVO reqVO, AdminUserDO updateObj) {
|
||||
Long userId = reqVO.getId();
|
||||
Set<Long> dbPostIds = convertSet(userPostMapper.selectListByUserId(userId), UserPostDO::getPostId);
|
||||
@@ -279,10 +475,27 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
return userMapper.selectPage(reqVO, getDeptCondition(reqVO.getDeptId()), userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<AdminUserDO> getStudentPage(UserPageReqVO reqVO) {
|
||||
Long classId = null;
|
||||
// 如果有角色编号,查询角色对应的用户编号
|
||||
Set<Long> userIds = reqVO.getRoleId() != null ?
|
||||
permissionService.getUserRoleIdListByRoleId(singleton(reqVO.getRoleId())) : null;
|
||||
|
||||
// 获取班级ID
|
||||
ClassDO classDO = classMapper.getClassNameOne(reqVO.getClassName());
|
||||
// 分页查询
|
||||
return userMapper.selectStuPage(reqVO, getDeptCondition(reqVO.getDeptId()), userIds, classDO != null ? classDO.getId() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdminUserDO getUser(Long id) {
|
||||
return userMapper.selectById(id);
|
||||
}
|
||||
@Override
|
||||
public List<UserRespVO> getUserById(Long id) {
|
||||
return userMapper.selectUserByIdList(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdminUserDO> getUserListByDeptIds(Collection<Long> deptIds) {
|
||||
|
@@ -0,0 +1,24 @@
|
||||
<?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="pc.exam.pp.module.system.dal.mysql.user.AdminUserMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
<select id="selectUserByIdList" resultType="pc.exam.pp.module.system.controller.admin.user.vo.user.UserRespVO">
|
||||
SELECT
|
||||
su.username,
|
||||
su.nickname,
|
||||
ec.`name` AS className,
|
||||
su.remark
|
||||
FROM
|
||||
system_users su
|
||||
LEFT JOIN system_teacher_class stc ON stc.class_id = su.class_id
|
||||
LEFT JOIN exam_class ec ON ec.id = su.class_id
|
||||
WHERE stc.user_id = #{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user