|
|
|
@ -893,8 +893,8 @@ public class UserController {
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "无权维护学生名单");
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "无权维护学生名单");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SchoolClass teachingClass = schoolClassMapper.selectByPrimaryKey(teachingClassId);
|
|
|
|
SchoolClass teachingClass = schoolClassMapper.selectByPrimaryKey(teachingClassId);
|
|
|
|
if (!isOwnedTeachingClass(teachingClass, operatorId)) {
|
|
|
|
if (!canManageTeachingClass(operator, teachingClass)) {
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "只能选择自己创建的教学班");
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "只能选择可维护的教学班");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (StringUtils.isAnyBlank(StringUtils.trimToNull(name), StringUtils.trimToNull(userName))) {
|
|
|
|
if (StringUtils.isAnyBlank(StringUtils.trimToNull(name), StringUtils.trimToNull(userName))) {
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "学生姓名和学号不能为空");
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "学生姓名和学号不能为空");
|
|
|
|
@ -938,8 +938,8 @@ public class UserController {
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "无权维护该学生名单");
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "无权维护该学生名单");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SchoolClass teachingClass = schoolClassMapper.selectByPrimaryKey(teachingClassId);
|
|
|
|
SchoolClass teachingClass = schoolClassMapper.selectByPrimaryKey(teachingClassId);
|
|
|
|
if (!isOwnedTeachingClass(teachingClass, operatorId)) {
|
|
|
|
if (!canManageTeachingClass(operator, teachingClass)) {
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "只能选择自己创建的教学班");
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "只能选择可维护的教学班");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (StringUtils.isAnyBlank(StringUtils.trimToNull(name), StringUtils.trimToNull(userName))) {
|
|
|
|
if (StringUtils.isAnyBlank(StringUtils.trimToNull(name), StringUtils.trimToNull(userName))) {
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "学生姓名和学号不能为空");
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "学生姓名和学号不能为空");
|
|
|
|
@ -1002,11 +1002,11 @@ public class UserController {
|
|
|
|
criteria.andUsernameEqualTo(userName);
|
|
|
|
criteria.andUsernameEqualTo(userName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (teacherRosterScope) {
|
|
|
|
if (teacherRosterScope) {
|
|
|
|
List<String> ownedStudentIds = resolveOwnedRosterStudentIds(operator, schoolClassId);
|
|
|
|
List<String> managedStudentIds = resolveManagedRosterStudentIds(operator, schoolClassId);
|
|
|
|
if (ownedStudentIds == null) {
|
|
|
|
if (managedStudentIds == null) {
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "只能查看自己教学班内的学生");
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "无权查看该教学班内的学生");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
criteria.andUserIdIn(ownedStudentIds.isEmpty() ? Collections.singletonList("__empty__") : ownedStudentIds);
|
|
|
|
criteria.andUserIdIn(managedStudentIds.isEmpty() ? Collections.singletonList("__empty__") : managedStudentIds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (StringUtils.isNotBlank(schoolClassId)) {
|
|
|
|
if (StringUtils.isNotBlank(schoolClassId)) {
|
|
|
|
schoolClass = schoolClassMapper.selectByPrimaryKey(schoolClassId);
|
|
|
|
schoolClass = schoolClassMapper.selectByPrimaryKey(schoolClassId);
|
|
|
|
@ -1053,21 +1053,25 @@ public class UserController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//编辑
|
|
|
|
//编辑
|
|
|
|
private List<String> resolveOwnedRosterStudentIds(Userinfo operator, String teachingClassId) {
|
|
|
|
private List<String> resolveManagedRosterStudentIds(Userinfo operator, String teachingClassId) {
|
|
|
|
if (!isSchoolTeacher(operator) || teachingClassStudentMapper == null) {
|
|
|
|
if (!isSchoolTeacher(operator) || teachingClassStudentMapper == null) {
|
|
|
|
return Collections.emptyList();
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<SchoolClass> teachingClasses;
|
|
|
|
List<SchoolClass> teachingClasses;
|
|
|
|
if (StringUtils.isNotBlank(teachingClassId)) {
|
|
|
|
if (StringUtils.isNotBlank(teachingClassId)) {
|
|
|
|
SchoolClass teachingClass = schoolClassMapper.selectByPrimaryKey(teachingClassId);
|
|
|
|
SchoolClass teachingClass = schoolClassMapper.selectByPrimaryKey(teachingClassId);
|
|
|
|
if (!isOwnedTeachingClass(teachingClass, operator.getUserId())) {
|
|
|
|
if (!canManageTeachingClass(operator, teachingClass)) {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
teachingClasses = Collections.singletonList(teachingClass);
|
|
|
|
teachingClasses = Collections.singletonList(teachingClass);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
SchoolClassExample example = new SchoolClassExample();
|
|
|
|
SchoolClassExample example = new SchoolClassExample();
|
|
|
|
example.createCriteria().andSchoolIdEqualTo(operator.getSchoolId())
|
|
|
|
SchoolClassExample.Criteria criteria = example.createCriteria()
|
|
|
|
.andCreatedByEqualTo(operator.getUserId()).andClassTypeEqualTo("TEACHING");
|
|
|
|
.andSchoolIdEqualTo(operator.getSchoolId())
|
|
|
|
|
|
|
|
.andClassTypeEqualTo("TEACHING");
|
|
|
|
|
|
|
|
if (!isTeacherAdmin(operator)) {
|
|
|
|
|
|
|
|
criteria.andCreatedByEqualTo(operator.getUserId());
|
|
|
|
|
|
|
|
}
|
|
|
|
teachingClasses = schoolClassMapper.selectByExample(example);
|
|
|
|
teachingClasses = schoolClassMapper.selectByExample(example);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Set<String> studentIds = new LinkedHashSet<>();
|
|
|
|
Set<String> studentIds = new LinkedHashSet<>();
|
|
|
|
@ -1157,8 +1161,9 @@ public class UserController {
|
|
|
|
public ResultEntity initializeTeachingClassTrainingData(@RequestParam String teachingClassId,
|
|
|
|
public ResultEntity initializeTeachingClassTrainingData(@RequestParam String teachingClassId,
|
|
|
|
@RequestParam String operatorId) {
|
|
|
|
@RequestParam String operatorId) {
|
|
|
|
SchoolClass schoolClass = schoolClassMapper.selectByPrimaryKey(teachingClassId);
|
|
|
|
SchoolClass schoolClass = schoolClassMapper.selectByPrimaryKey(teachingClassId);
|
|
|
|
if (!isOwnedTeachingClass(schoolClass, operatorId)) {
|
|
|
|
Userinfo operator = userinfoMapper.selectByPrimaryKey(operatorId);
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "只能初始化自己创建的教学班");
|
|
|
|
if (!canManageTeachingClass(operator, schoolClass)) {
|
|
|
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "无权初始化该教学班");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<TeachingClassStudent> members = teachingClassStudentMapper.selectByTeachingClassId(teachingClassId);
|
|
|
|
List<TeachingClassStudent> members = teachingClassStudentMapper.selectByTeachingClassId(teachingClassId);
|
|
|
|
if (members == null) {
|
|
|
|
if (members == null) {
|
|
|
|
@ -1179,8 +1184,9 @@ public class UserController {
|
|
|
|
@RequestParam String studentUserId,
|
|
|
|
@RequestParam String studentUserId,
|
|
|
|
@RequestParam String operatorId) {
|
|
|
|
@RequestParam String operatorId) {
|
|
|
|
SchoolClass schoolClass = schoolClassMapper.selectByPrimaryKey(teachingClassId);
|
|
|
|
SchoolClass schoolClass = schoolClassMapper.selectByPrimaryKey(teachingClassId);
|
|
|
|
if (!isOwnedTeachingClass(schoolClass, operatorId)) {
|
|
|
|
Userinfo operator = userinfoMapper.selectByPrimaryKey(operatorId);
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "只能初始化自己教学班内的学生");
|
|
|
|
if (!canManageTeachingClass(operator, schoolClass)) {
|
|
|
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "无权初始化该教学班内的学生");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (teachingClassStudentMapper != null
|
|
|
|
if (teachingClassStudentMapper != null
|
|
|
|
&& teachingClassStudentMapper.countByStudentUserIdAndTeachingClassId(studentUserId, teachingClassId) <= 0) {
|
|
|
|
&& teachingClassStudentMapper.countByStudentUserIdAndTeachingClassId(studentUserId, teachingClassId) <= 0) {
|
|
|
|
@ -1569,13 +1575,13 @@ public class UserController {
|
|
|
|
UserinfoExample userInfoExample = new UserinfoExample();
|
|
|
|
UserinfoExample userInfoExample = new UserinfoExample();
|
|
|
|
userInfoExample.createCriteria().andSchoolIdEqualTo(schoolId).andRoleEqualTo(4);
|
|
|
|
userInfoExample.createCriteria().andSchoolIdEqualTo(schoolId).andRoleEqualTo(4);
|
|
|
|
if (teacherRosterScope) {
|
|
|
|
if (teacherRosterScope) {
|
|
|
|
List<String> ownedStudentIds = resolveOwnedRosterStudentIds(operator, schoolClassId);
|
|
|
|
List<String> managedStudentIds = resolveManagedRosterStudentIds(operator, schoolClassId);
|
|
|
|
if (ownedStudentIds == null) {
|
|
|
|
if (managedStudentIds == null) {
|
|
|
|
response.setStatus(HttpStatus.BAD_REQUEST.value());
|
|
|
|
response.setStatus(HttpStatus.BAD_REQUEST.value());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
userInfoExample.getOredCriteria().get(0)
|
|
|
|
userInfoExample.getOredCriteria().get(0)
|
|
|
|
.andUserIdIn(ownedStudentIds.isEmpty() ? Collections.singletonList("__empty__") : ownedStudentIds);
|
|
|
|
.andUserIdIn(managedStudentIds.isEmpty() ? Collections.singletonList("__empty__") : managedStudentIds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<Userinfo> list = userinfoMapper.selectByExample(userInfoExample);
|
|
|
|
List<Userinfo> list = userinfoMapper.selectByExample(userInfoExample);
|
|
|
|
//导出的表名
|
|
|
|
//导出的表名
|
|
|
|
@ -1726,6 +1732,14 @@ public class UserController {
|
|
|
|
&& isClassOwner(schoolClass, operatorId);
|
|
|
|
&& isClassOwner(schoolClass, operatorId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean canManageTeachingClass(Userinfo operator, SchoolClass teachingClass) {
|
|
|
|
|
|
|
|
return isSchoolTeacher(operator)
|
|
|
|
|
|
|
|
&& teachingClass != null
|
|
|
|
|
|
|
|
&& "TEACHING".equals(teachingClass.getClassType())
|
|
|
|
|
|
|
|
&& StringUtils.equals(operator.getSchoolId(), teachingClass.getSchoolId())
|
|
|
|
|
|
|
|
&& (isTeacherAdmin(operator) || isClassOwner(teachingClass, operator.getUserId()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isClassOwner(SchoolClass schoolClass, String userId) {
|
|
|
|
private boolean isClassOwner(SchoolClass schoolClass, String userId) {
|
|
|
|
return schoolClass != null
|
|
|
|
return schoolClass != null
|
|
|
|
&& StringUtils.isNotBlank(userId)
|
|
|
|
&& StringUtils.isNotBlank(userId)
|
|
|
|
@ -2345,6 +2359,9 @@ public class UserController {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SchoolClass schoolClass = schoolClassMapper.selectByPrimaryKey(schoolClassId);
|
|
|
|
SchoolClass schoolClass = schoolClassMapper.selectByPrimaryKey(schoolClassId);
|
|
|
|
|
|
|
|
if (canManageTeachingClass(operator, schoolClass)) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (canManageAdminClass(operator, schoolClass)) {
|
|
|
|
if (canManageAdminClass(operator, schoolClass)) {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|