|
|
|
|
@ -48,6 +48,8 @@ public class UserController {
|
|
|
|
|
@Autowired
|
|
|
|
|
SchoolClassMapper schoolClassMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
TeachingClassStudentMapper teachingClassStudentMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
Pinyin4jUtil pinyin4jUtil;
|
|
|
|
|
@Autowired
|
|
|
|
|
UserInfoService userInfoService;
|
|
|
|
|
@ -143,12 +145,16 @@ public class UserController {
|
|
|
|
|
@ApiParam("院系名称") @RequestParam String schoolFacultyName,
|
|
|
|
|
@ApiParam("联系人") @RequestParam(required = false) String schoolFacultyContact,
|
|
|
|
|
@ApiParam("联系人电话") @RequestParam(required = false) String schoolFacultyContactTel,
|
|
|
|
|
@ApiParam("联系人地址") @RequestParam(required = false) String schoolFacultyContactAddress) {
|
|
|
|
|
@ApiParam("联系人地址") @RequestParam(required = false) String schoolFacultyContactAddress,
|
|
|
|
|
@RequestParam(required = false) String userId) {
|
|
|
|
|
//先根据schoolId进行查询 如果不存在则返回
|
|
|
|
|
School school = schoolMapper.selectByPrimaryKey(schoolId);
|
|
|
|
|
if (school == null) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "该学校不存在");
|
|
|
|
|
}
|
|
|
|
|
if (!canManageSchoolStructure(userId, schoolId)) {
|
|
|
|
|
return noManagePermission();
|
|
|
|
|
}
|
|
|
|
|
//查询该学校下院系下 专业名称是否重复
|
|
|
|
|
SchoolFacultyExample schoolFacultyExample = new SchoolFacultyExample();
|
|
|
|
|
schoolFacultyExample.createCriteria().andSchoolIdEqualTo(schoolId).andSchoolFacultyNameEqualTo(schoolFacultyName);
|
|
|
|
|
@ -198,30 +204,21 @@ public class UserController {
|
|
|
|
|
@ApiOperation("院系管理-删除")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
public ResultEntity deleteSchoolFaculty(@ApiParam("院系ID") @RequestParam String schoolFacultyId, @RequestParam String userId) {
|
|
|
|
|
//先查询useriD 是否够权限
|
|
|
|
|
Userinfo userInfo = userinfoMapper.selectByPrimaryKey(userId);
|
|
|
|
|
if (userInfo.getRole() == 3) {
|
|
|
|
|
SchoolFaculty schoolFaculty = schoolFacultyMapper.selectByPrimaryKey(schoolFacultyId);
|
|
|
|
|
if (!schoolFaculty.getSchoolId().equals(userInfo.getSchoolId())) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "院系管理-删除失败-权限不足");
|
|
|
|
|
} else {
|
|
|
|
|
int i = schoolFacultyMapper.deleteByPrimaryKey(schoolFacultyId);
|
|
|
|
|
if (i == 1) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "院系管理-删除成功");
|
|
|
|
|
} else {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "院系管理-删除失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
SchoolFaculty schoolFaculty = schoolFacultyMapper.selectByPrimaryKey(schoolFacultyId);
|
|
|
|
|
if (schoolFaculty == null) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "院系不存在");
|
|
|
|
|
}
|
|
|
|
|
if (userInfo.getRole() == 1) {
|
|
|
|
|
int i = schoolFacultyMapper.deleteByPrimaryKey(schoolFacultyId);
|
|
|
|
|
if (i == 1) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "院系管理-删除成功");
|
|
|
|
|
} else {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "院系管理-删除失败");
|
|
|
|
|
}
|
|
|
|
|
if (!canManageSchoolStructure(userId, schoolFaculty.getSchoolId())) {
|
|
|
|
|
return noManagePermission();
|
|
|
|
|
}
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "院系管理-删除失败-权限不足");
|
|
|
|
|
if (hasMajorUnderFaculty(schoolFacultyId)) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "院系下存在专业,不能删除");
|
|
|
|
|
}
|
|
|
|
|
int i = schoolFacultyMapper.deleteByPrimaryKey(schoolFacultyId);
|
|
|
|
|
if (i == 1) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "院系管理-删除成功");
|
|
|
|
|
}
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "院系管理-删除失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/updateSchoolFaculty")
|
|
|
|
|
@ -231,30 +228,18 @@ public class UserController {
|
|
|
|
|
if (StringUtils.isBlank(schoolFaculty.getSchoolFacultyId())) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "院系管理-编辑失败-主键ID缺失");
|
|
|
|
|
}
|
|
|
|
|
//先查询useriD 是否够权限
|
|
|
|
|
Userinfo userInfo = userinfoMapper.selectByPrimaryKey(userId);
|
|
|
|
|
if (userInfo.getRole() == 3) {
|
|
|
|
|
SchoolFaculty schoolFacultyT = schoolFacultyMapper.selectByPrimaryKey(schoolFaculty.getSchoolFacultyId());
|
|
|
|
|
if (!schoolFacultyT.getSchoolId().equals(userInfo.getSchoolId())) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "院系管理-编辑失败-权限不足");
|
|
|
|
|
} else {
|
|
|
|
|
int i = schoolFacultyMapper.updateByPrimaryKey(schoolFaculty);
|
|
|
|
|
if (i == 1) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "院系管理-编辑成功");
|
|
|
|
|
} else {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "院系管理-编辑失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
SchoolFaculty existing = schoolFacultyMapper.selectByPrimaryKey(schoolFaculty.getSchoolFacultyId());
|
|
|
|
|
if (existing == null) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "院系不存在");
|
|
|
|
|
}
|
|
|
|
|
if (userInfo.getRole() == 1) {
|
|
|
|
|
int i = schoolFacultyMapper.updateByPrimaryKey(schoolFaculty);
|
|
|
|
|
if (i == 1) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "院系管理-编辑成功");
|
|
|
|
|
} else {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "院系管理-编辑失败");
|
|
|
|
|
}
|
|
|
|
|
if (!canManageSchoolStructure(userId, existing.getSchoolId())) {
|
|
|
|
|
return noManagePermission();
|
|
|
|
|
}
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "院系管理-编辑失败-权限不足");
|
|
|
|
|
int i = schoolFacultyMapper.updateByPrimaryKey(schoolFaculty);
|
|
|
|
|
if (i == 1) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "院系管理-编辑成功");
|
|
|
|
|
}
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "院系管理-编辑失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//*****************************************专业管理*********************************************
|
|
|
|
|
@ -268,12 +253,16 @@ public class UserController {
|
|
|
|
|
@ApiParam("院系ID") @RequestParam String schoolFacultyId,
|
|
|
|
|
@ApiParam("专业名称") @RequestParam String schoolMajorName,
|
|
|
|
|
@ApiParam("联系人") @RequestParam(required = false) String schoolMajorContact,
|
|
|
|
|
@ApiParam("联系人电话") @RequestParam(required = false) String schoolMajorContactTel) {
|
|
|
|
|
@ApiParam("联系人电话") @RequestParam(required = false) String schoolMajorContactTel,
|
|
|
|
|
@RequestParam(required = false) String userId) {
|
|
|
|
|
//先根据schoolId进行查询 如果不存在则返回
|
|
|
|
|
School school = schoolMapper.selectByPrimaryKey(schoolId);
|
|
|
|
|
if (school == null) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "该学校不存在");
|
|
|
|
|
}
|
|
|
|
|
if (!canManageSchoolStructure(userId, schoolId)) {
|
|
|
|
|
return noManagePermission();
|
|
|
|
|
}
|
|
|
|
|
//再根据schoolFacultyId查询 如果不存在则返回
|
|
|
|
|
SchoolFaculty schoolFaculty = schoolFacultyMapper.selectByPrimaryKey(schoolFacultyId);
|
|
|
|
|
if (schoolFaculty == null) {
|
|
|
|
|
@ -331,6 +320,12 @@ public class UserController {
|
|
|
|
|
@ApiOperation("专业管理-删除")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
public ResultEntity deleteSchoolMajor(@ApiParam("专业ID") @RequestParam String schoolMajorId, @RequestParam String userId) {
|
|
|
|
|
if (!canManageMajor(userId, schoolMajorId)) {
|
|
|
|
|
return noManagePermission();
|
|
|
|
|
}
|
|
|
|
|
if (hasClassUnderMajor(schoolMajorId)) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "专业下存在班级,不能删除");
|
|
|
|
|
}
|
|
|
|
|
int i = schoolMajorMapper.deleteByPrimaryKey(schoolMajorId);
|
|
|
|
|
if (i == 1) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "专业管理-删除成功");
|
|
|
|
|
@ -343,10 +338,13 @@ public class UserController {
|
|
|
|
|
@PostMapping("/updateSchoolMajor")
|
|
|
|
|
@ApiOperation("专业管理-编辑")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
public ResultEntity updateSchoolMajor(@RequestBody SchoolMajor schoolMajor) {
|
|
|
|
|
public ResultEntity updateSchoolMajor(@RequestBody SchoolMajor schoolMajor, @RequestParam(required = false) String userId) {
|
|
|
|
|
if (StringUtils.isBlank(schoolMajor.getSchoolMajorId())) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "专业管理-编辑失败-主键ID缺失");
|
|
|
|
|
}
|
|
|
|
|
if (!canManageMajor(userId, schoolMajor.getSchoolMajorId())) {
|
|
|
|
|
return noManagePermission();
|
|
|
|
|
}
|
|
|
|
|
int i = schoolMajorMapper.updateByPrimaryKey(schoolMajor);
|
|
|
|
|
if (i == 1) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "专业管理-编辑成功");
|
|
|
|
|
@ -367,7 +365,9 @@ public class UserController {
|
|
|
|
|
@ApiParam("院系ID") @RequestParam String schoolFacultyId,
|
|
|
|
|
@ApiParam("专业ID") @RequestParam String schoolMajorId,
|
|
|
|
|
@ApiParam("班级名称") @RequestParam String className,
|
|
|
|
|
@RequestParam(required = false) String userId) {
|
|
|
|
|
@RequestParam(required = false) String userId,
|
|
|
|
|
@RequestParam(required = false) String classType,
|
|
|
|
|
@RequestParam(required = false) String sourceClassIds) {
|
|
|
|
|
//先根据schoolId进行查询 如果不存在则返回
|
|
|
|
|
School school = schoolMapper.selectByPrimaryKey(schoolId);
|
|
|
|
|
if (school == null) {
|
|
|
|
|
@ -385,7 +385,7 @@ public class UserController {
|
|
|
|
|
}
|
|
|
|
|
//查询班级名称是否存在
|
|
|
|
|
SchoolClassExample schoolClassExample = new SchoolClassExample();
|
|
|
|
|
schoolClassExample.createCriteria().andSchoolMajorIdEqualTo(schoolMajorId).andClassNameEqualTo(className);
|
|
|
|
|
schoolClassExample.createCriteria().andSchoolIdEqualTo(schoolId).andClassNameEqualTo(className);
|
|
|
|
|
List<SchoolClass> schoolClasses = schoolClassMapper.selectByExample(schoolClassExample);
|
|
|
|
|
if (!schoolClasses.isEmpty()) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "班级名称重复");
|
|
|
|
|
@ -402,6 +402,9 @@ public class UserController {
|
|
|
|
|
schoolClass.setCreateTime(new Date());
|
|
|
|
|
schoolClass.setSchoolId(schoolId);
|
|
|
|
|
schoolClass.setCreatedBy(userId);
|
|
|
|
|
schoolClass.setClassType(StringUtils.defaultIfBlank(classType, StringUtils.isBlank(userId) ? "ADMIN" : "TEACHING"));
|
|
|
|
|
schoolClass.setDataSource("LOCAL");
|
|
|
|
|
schoolClass.setSourceClassIds(sourceClassIds);
|
|
|
|
|
|
|
|
|
|
int insert = schoolClassMapper.insert(schoolClass);
|
|
|
|
|
if (insert == 1) {
|
|
|
|
|
@ -467,6 +470,10 @@ public class UserController {
|
|
|
|
|
if (userInfo == null) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "班级管理-删除失败-权限不足");
|
|
|
|
|
}
|
|
|
|
|
SchoolClass schoolClass = schoolClassMapper.selectByPrimaryKey(schoolClassId);
|
|
|
|
|
if (classHasStudents(schoolClass)) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "班级下存在学生,不能删除");
|
|
|
|
|
}
|
|
|
|
|
if (userInfo.getRole() == 1) {
|
|
|
|
|
int i = schoolClassMapper.deleteByPrimaryKey(schoolClassId);
|
|
|
|
|
if (i == 1) {
|
|
|
|
|
@ -475,7 +482,6 @@ public class UserController {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "班级管理-删除失败");
|
|
|
|
|
}
|
|
|
|
|
if (userInfo.getRole() == 3) {
|
|
|
|
|
SchoolClass schoolClass = schoolClassMapper.selectByPrimaryKey(schoolClassId);
|
|
|
|
|
if (isClassOwner(schoolClass, userId)) {
|
|
|
|
|
int i = schoolClassMapper.deleteByPrimaryKey(schoolClassId);
|
|
|
|
|
if (i == 1) {
|
|
|
|
|
@ -533,12 +539,16 @@ public class UserController {
|
|
|
|
|
@ApiParam("教师名称") @RequestParam String name,
|
|
|
|
|
@ApiParam("教师工号") @RequestParam String userName,
|
|
|
|
|
@ApiParam("电话号码") @RequestParam(required = false) String phone,
|
|
|
|
|
@ApiParam("电子邮箱") @RequestParam(required = false) String email) {
|
|
|
|
|
@ApiParam("电子邮箱") @RequestParam(required = false) String email,
|
|
|
|
|
@RequestParam(required = false) String operatorId) {
|
|
|
|
|
//先根据schoolId进行查询 如果不存在则返回
|
|
|
|
|
School school = schoolMapper.selectByPrimaryKey(schoolId);
|
|
|
|
|
if (school == null) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "该学校不存在");
|
|
|
|
|
}
|
|
|
|
|
if (!canManageSchoolStructure(operatorId, schoolId)) {
|
|
|
|
|
return noManagePermission();
|
|
|
|
|
}
|
|
|
|
|
//再根据schoolFacultyId查询 如果不存在则返回
|
|
|
|
|
SchoolFaculty schoolFaculty = schoolFacultyMapper.selectByPrimaryKey(schoolFacultyId);
|
|
|
|
|
if (schoolFaculty == null) {
|
|
|
|
|
@ -620,7 +630,16 @@ public class UserController {
|
|
|
|
|
@PostMapping("/updateTeacher")
|
|
|
|
|
@ApiOperation("教师管理-编辑教师账号信息")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
public ResultEntity updateTeacher(@RequestBody Userinfo userInfo) {
|
|
|
|
|
public ResultEntity updateTeacher(@RequestBody Userinfo userInfo, @RequestParam(required = false) String operatorId) {
|
|
|
|
|
Userinfo existing = userinfoMapper.selectByPrimaryKey(userInfo.getUserId());
|
|
|
|
|
String schoolId = existing == null ? userInfo.getSchoolId() : existing.getSchoolId();
|
|
|
|
|
if (!canManageSchoolStructure(operatorId, schoolId)) {
|
|
|
|
|
return noManagePermission();
|
|
|
|
|
}
|
|
|
|
|
Userinfo operator = userinfoMapper.selectByPrimaryKey(operatorId);
|
|
|
|
|
if (!isPlatformAdmin(operator)) {
|
|
|
|
|
userInfo.setTeacherAdmin(false);
|
|
|
|
|
}
|
|
|
|
|
int i = userinfoMapper.updateByPrimaryKey(userInfo);
|
|
|
|
|
if (i == 1) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "编辑教师账号信息成功!");
|
|
|
|
|
@ -632,8 +651,14 @@ public class UserController {
|
|
|
|
|
@PostMapping("/updateTeacherPassword")
|
|
|
|
|
@ApiOperation("教师管理-初始化密码")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
public ResultEntity updateTeacher(@RequestParam String userId) {
|
|
|
|
|
public ResultEntity updateTeacher(@RequestParam String userId, @RequestParam(required = false) String operatorId) {
|
|
|
|
|
Userinfo userInfo = userinfoMapper.selectByPrimaryKey(userId);
|
|
|
|
|
if (userInfo == null) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "教师账号不存在");
|
|
|
|
|
}
|
|
|
|
|
if (!canManageSchoolStructure(operatorId, userInfo.getSchoolId())) {
|
|
|
|
|
return noManagePermission();
|
|
|
|
|
}
|
|
|
|
|
userInfo.setPassword("123qwe");
|
|
|
|
|
int i = userinfoMapper.updateByPrimaryKey(userInfo);
|
|
|
|
|
if (i == 1) {
|
|
|
|
|
@ -648,7 +673,17 @@ public class UserController {
|
|
|
|
|
@PostMapping("/deleteTeacher")
|
|
|
|
|
@ApiOperation("教师管理-删除")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
public ResultEntity deleteTeacher(@RequestParam String userId) {
|
|
|
|
|
public ResultEntity deleteTeacher(@RequestParam String userId, @RequestParam(required = false) String operatorId) {
|
|
|
|
|
Userinfo userInfo = userinfoMapper.selectByPrimaryKey(userId);
|
|
|
|
|
if (userInfo == null) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "教师账号不存在");
|
|
|
|
|
}
|
|
|
|
|
if (!canManageSchoolStructure(operatorId, userInfo.getSchoolId())) {
|
|
|
|
|
return noManagePermission();
|
|
|
|
|
}
|
|
|
|
|
if (teacherHasCreatedClass(userId)) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "该教师已创建班级,不能删除");
|
|
|
|
|
}
|
|
|
|
|
int i = userinfoMapper.deleteByPrimaryKey(userId);
|
|
|
|
|
if (i == 1) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "删除成功!");
|
|
|
|
|
@ -660,7 +695,8 @@ public class UserController {
|
|
|
|
|
@PostMapping("/uploadTeacherUserInfo")
|
|
|
|
|
@ApiOperation("教师管理-导入教师账号")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
public ResultEntity uploadTeacherUserInfo(@RequestParam MultipartFile file) {
|
|
|
|
|
public ResultEntity uploadTeacherUserInfo(@RequestParam MultipartFile file,
|
|
|
|
|
@RequestParam(required = false) String operatorId) {
|
|
|
|
|
// 基本校验
|
|
|
|
|
if (file.isEmpty()) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "上传文件不能为空!");
|
|
|
|
|
@ -686,6 +722,12 @@ public class UserController {
|
|
|
|
|
if (!errorMessages.isEmpty()) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "数据校验失败!", errorMessages);
|
|
|
|
|
}
|
|
|
|
|
for (TeacherImportDTO teacher : teacherList) {
|
|
|
|
|
String schoolId = schoolService.selectSchoolIdBySchoolName(teacher.getSchoolName());
|
|
|
|
|
if (!canManageSchoolStructure(operatorId, schoolId)) {
|
|
|
|
|
return noManagePermission();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 异步处理导入*****
|
|
|
|
|
importService.processTeacherImport(teacherList);
|
|
|
|
|
@ -779,11 +821,26 @@ public class UserController {
|
|
|
|
|
userInfo.setSchoolId(schoolId);
|
|
|
|
|
userInfo.setSchoolFacultyId(schoolFacultyId);
|
|
|
|
|
userInfo.setSchoolMajorId(schoolMajorId);
|
|
|
|
|
userInfo.setSchoolClassId(schoolClassId);
|
|
|
|
|
String adminClassId = "TEACHING".equals(schoolClass.getClassType())
|
|
|
|
|
? resolveAdminClassIdForTeachingClass(schoolClass)
|
|
|
|
|
: schoolClassId;
|
|
|
|
|
userInfo.setSchoolClassId(adminClassId);
|
|
|
|
|
userInfo.setCodeFrom("添加");
|
|
|
|
|
|
|
|
|
|
int insert = userinfoMapper.insert(userInfo);
|
|
|
|
|
if (insert == 1) {
|
|
|
|
|
if ("TEACHING".equals(schoolClass.getClassType()) && teachingClassStudentMapper != null) {
|
|
|
|
|
TeachingClassStudent member = new TeachingClassStudent();
|
|
|
|
|
member.setId(UUID.randomUUID().toString());
|
|
|
|
|
member.setTeachingClassId(schoolClassId);
|
|
|
|
|
member.setStudentUserId(userInfo.getUserId());
|
|
|
|
|
member.setAdminClassId(adminClassId);
|
|
|
|
|
member.setStatus("IN_PROGRESS");
|
|
|
|
|
member.setJoinReason("MANUAL");
|
|
|
|
|
member.setJoinTime(new Date());
|
|
|
|
|
member.setCreateTime(new Date());
|
|
|
|
|
teachingClassStudentMapper.insertSelective(member);
|
|
|
|
|
}
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "学生管理-添加学生账号成功");
|
|
|
|
|
} else {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "学生管理-添加学生账号失败");
|
|
|
|
|
@ -817,7 +874,16 @@ public class UserController {
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(schoolClassId)) {
|
|
|
|
|
schoolClass = schoolClassMapper.selectByPrimaryKey(schoolClassId);
|
|
|
|
|
criteria.andSchoolClassIdEqualTo(schoolClassId);
|
|
|
|
|
if (schoolClass != null && "TEACHING".equals(schoolClass.getClassType()) && teachingClassStudentMapper != null) {
|
|
|
|
|
List<TeachingClassStudent> members = teachingClassStudentMapper.selectByTeachingClassId(schoolClassId);
|
|
|
|
|
List<String> studentIds = new ArrayList<>();
|
|
|
|
|
for (TeachingClassStudent member : members) {
|
|
|
|
|
studentIds.add(member.getStudentUserId());
|
|
|
|
|
}
|
|
|
|
|
criteria.andUserIdIn(studentIds.isEmpty() ? Collections.singletonList("__empty__") : studentIds);
|
|
|
|
|
} else {
|
|
|
|
|
criteria.andSchoolClassIdEqualTo(schoolClassId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
criteria.andRoleEqualTo(4);
|
|
|
|
|
List<Userinfo> userInfoList = userinfoMapper.selectByExample(userInfoExample);
|
|
|
|
|
@ -858,7 +924,7 @@ public class UserController {
|
|
|
|
|
Userinfo existing = userinfoMapper.selectByPrimaryKey(userInfo.getUserId());
|
|
|
|
|
targetClassId = existing == null ? null : existing.getSchoolClassId();
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(operatorId) && !canOperateClass(operatorId, targetClassId)) {
|
|
|
|
|
if (!canOperateClass(operatorId, targetClassId)) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "只能维护自己创建班级的学生");
|
|
|
|
|
}
|
|
|
|
|
int i = userinfoMapper.updateByPrimaryKey(userInfo);
|
|
|
|
|
@ -873,7 +939,7 @@ public class UserController {
|
|
|
|
|
@ApiOperation("学生管理-删除")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
public ResultEntity deleteStudent(@RequestParam String userId, @RequestParam(required = false) String operatorId) {
|
|
|
|
|
if (StringUtils.isNotBlank(operatorId) && !canOperateStudent(operatorId, userId)) {
|
|
|
|
|
if (!canOperateStudent(operatorId, userId)) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "只能维护自己创建班级的学生");
|
|
|
|
|
}
|
|
|
|
|
int i = userinfoMapper.deleteByPrimaryKey(userId);
|
|
|
|
|
@ -888,7 +954,7 @@ public class UserController {
|
|
|
|
|
@ApiOperation("学生管理-初始化密码")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
public ResultEntity updateStudentPassword(@RequestParam String userId, @RequestParam(required = false) String operatorId) {
|
|
|
|
|
if (StringUtils.isNotBlank(operatorId) && !canOperateStudent(operatorId, userId)) {
|
|
|
|
|
if (!canOperateStudent(operatorId, userId)) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "只能维护自己创建班级的学生");
|
|
|
|
|
}
|
|
|
|
|
Userinfo userInfo = userinfoMapper.selectByPrimaryKey(userId);
|
|
|
|
|
@ -900,6 +966,35 @@ public class UserController {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "初始化密码失败!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/initializeTeachingClassTrainingData")
|
|
|
|
|
@ApiOperation("教学班-全班实训数据初始化")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
public ResultEntity initializeTeachingClassTrainingData(@RequestParam String teachingClassId,
|
|
|
|
|
@RequestParam String operatorId) {
|
|
|
|
|
SchoolClass schoolClass = schoolClassMapper.selectByPrimaryKey(teachingClassId);
|
|
|
|
|
if (!isOwnedTeachingClass(schoolClass, operatorId)) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "只能初始化自己创建的教学班");
|
|
|
|
|
}
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "教学班实训数据初始化成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/initializeTeachingClassStudentTrainingData")
|
|
|
|
|
@ApiOperation("教学班-单个学生实训数据初始化")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
public ResultEntity initializeTeachingClassStudentTrainingData(@RequestParam String teachingClassId,
|
|
|
|
|
@RequestParam String studentUserId,
|
|
|
|
|
@RequestParam String operatorId) {
|
|
|
|
|
SchoolClass schoolClass = schoolClassMapper.selectByPrimaryKey(teachingClassId);
|
|
|
|
|
if (!isOwnedTeachingClass(schoolClass, operatorId)) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "只能初始化自己教学班内的学生");
|
|
|
|
|
}
|
|
|
|
|
if (teachingClassStudentMapper != null
|
|
|
|
|
&& teachingClassStudentMapper.countByStudentUserIdAndTeachingClassId(studentUserId, teachingClassId) <= 0) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "学生不属于该教学班");
|
|
|
|
|
}
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "学生实训数据初始化成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//微信绑定*****
|
|
|
|
|
//导入 ***** 创建资金账户
|
|
|
|
|
@PostMapping("/uploadStudentUserInfo")
|
|
|
|
|
@ -1040,13 +1135,97 @@ public class UserController {
|
|
|
|
|
return schoolClass == null ? "" : schoolClass.getClassName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("开放接口,自动同步学生信息")
|
|
|
|
|
private boolean hasMajorUnderFaculty(String schoolFacultyId) {
|
|
|
|
|
SchoolMajorExample example = new SchoolMajorExample();
|
|
|
|
|
example.createCriteria().andSchoolFacultyIdEqualTo(schoolFacultyId);
|
|
|
|
|
return !schoolMajorMapper.selectByExample(example).isEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean hasClassUnderMajor(String schoolMajorId) {
|
|
|
|
|
SchoolClassExample example = new SchoolClassExample();
|
|
|
|
|
example.createCriteria().andSchoolMajorIdEqualTo(schoolMajorId);
|
|
|
|
|
return !schoolClassMapper.selectByExample(example).isEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean classHasStudents(SchoolClass schoolClass) {
|
|
|
|
|
if (schoolClass == null) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if ("TEACHING".equals(schoolClass.getClassType()) && teachingClassStudentMapper != null) {
|
|
|
|
|
return teachingClassStudentMapper.countByTeachingClassId(schoolClass.getSchoolClassId()) > 0;
|
|
|
|
|
}
|
|
|
|
|
UserinfoExample example = new UserinfoExample();
|
|
|
|
|
example.createCriteria().andSchoolClassIdEqualTo(schoolClass.getSchoolClassId()).andRoleEqualTo(4);
|
|
|
|
|
return !userinfoMapper.selectByExample(example).isEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String resolveAdminClassIdForTeachingClass(SchoolClass teachingClass) {
|
|
|
|
|
if (StringUtils.isBlank(teachingClass.getSourceClassIds())) {
|
|
|
|
|
return teachingClass.getSchoolClassId();
|
|
|
|
|
}
|
|
|
|
|
String sourceClassIds = teachingClass.getSourceClassIds()
|
|
|
|
|
.replace("[", "")
|
|
|
|
|
.replace("]", "")
|
|
|
|
|
.replace("\"", "");
|
|
|
|
|
String[] ids = sourceClassIds.split(",");
|
|
|
|
|
return StringUtils.trimToEmpty(ids[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean isOwnedTeachingClass(SchoolClass schoolClass, String operatorId) {
|
|
|
|
|
return schoolClass != null
|
|
|
|
|
&& "TEACHING".equals(schoolClass.getClassType())
|
|
|
|
|
&& isClassOwner(schoolClass, operatorId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean isClassOwner(SchoolClass schoolClass, String userId) {
|
|
|
|
|
return schoolClass != null
|
|
|
|
|
&& StringUtils.isNotBlank(userId)
|
|
|
|
|
&& StringUtils.equals(schoolClass.getCreatedBy(), userId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ResultEntity noManagePermission() {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "权限不足");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean isPlatformAdmin(Userinfo userInfo) {
|
|
|
|
|
return userInfo != null && Integer.valueOf(1).equals(userInfo.getRole());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean isTeacherAdmin(Userinfo userInfo) {
|
|
|
|
|
return userInfo != null
|
|
|
|
|
&& Integer.valueOf(3).equals(userInfo.getRole())
|
|
|
|
|
&& Boolean.TRUE.equals(userInfo.getTeacherAdmin());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean canManageSchoolStructure(String operatorId, String schoolId) {
|
|
|
|
|
if (StringUtils.isAnyBlank(operatorId, schoolId)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
Userinfo operator = userinfoMapper.selectByPrimaryKey(operatorId);
|
|
|
|
|
if (isPlatformAdmin(operator)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return isTeacherAdmin(operator) && StringUtils.equals(operator.getSchoolId(), schoolId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean canManageMajor(String operatorId, String schoolMajorId) {
|
|
|
|
|
if (StringUtils.isBlank(schoolMajorId)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
SchoolMajor major = schoolMajorMapper.selectByPrimaryKey(schoolMajorId);
|
|
|
|
|
if (major == null || StringUtils.isBlank(major.getSchoolFacultyId())) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
SchoolFaculty faculty = schoolFacultyMapper.selectByPrimaryKey(major.getSchoolFacultyId());
|
|
|
|
|
return faculty != null && canManageSchoolStructure(operatorId, faculty.getSchoolId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean teacherHasCreatedClass(String teacherId) {
|
|
|
|
|
SchoolClassExample example = new SchoolClassExample();
|
|
|
|
|
example.createCriteria().andCreatedByEqualTo(teacherId);
|
|
|
|
|
return !schoolClassMapper.selectByExample(example).isEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean canOperateClass(String operatorId, String schoolClassId) {
|
|
|
|
|
Userinfo operator = userinfoMapper.selectByPrimaryKey(operatorId);
|
|
|
|
|
if (operator == null) {
|
|
|
|
|
|