|
|
|
|
@ -962,6 +962,15 @@ public class UserController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//查询
|
|
|
|
|
ResultEntity<PageInfo<Userinfo>> selectStudent(String schoolId,
|
|
|
|
|
String schoolClassId,
|
|
|
|
|
String name,
|
|
|
|
|
String userName,
|
|
|
|
|
Integer index,
|
|
|
|
|
Integer size) {
|
|
|
|
|
return selectStudent(schoolId, schoolClassId, name, userName, index, size, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/selectStudent")
|
|
|
|
|
@ApiOperation("学生管理-查询学生账号信息")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ -970,7 +979,13 @@ public class UserController {
|
|
|
|
|
@ApiParam("学生姓名") @RequestParam(required = false) String name,
|
|
|
|
|
@ApiParam("学生学号") @RequestParam(required = false) String userName,
|
|
|
|
|
@RequestParam Integer index,
|
|
|
|
|
@RequestParam Integer size) {
|
|
|
|
|
@RequestParam Integer size,
|
|
|
|
|
@RequestParam(required = false) String operatorId) {
|
|
|
|
|
Userinfo operator = StringUtils.isBlank(operatorId) ? null : userinfoMapper.selectByPrimaryKey(operatorId);
|
|
|
|
|
boolean teacherRosterScope = isSchoolTeacher(operator) && isTeacherRosterMode(operator.getSchoolId());
|
|
|
|
|
if (teacherRosterScope) {
|
|
|
|
|
schoolId = operator.getSchoolId();
|
|
|
|
|
}
|
|
|
|
|
PageHelper.startPage(index, size);
|
|
|
|
|
UserinfoExample userInfoExample = new UserinfoExample();
|
|
|
|
|
UserinfoExample.Criteria criteria = userInfoExample.createCriteria();
|
|
|
|
|
@ -986,6 +1001,13 @@ public class UserController {
|
|
|
|
|
if (StringUtils.isNotBlank(userName)) {
|
|
|
|
|
criteria.andUsernameEqualTo(userName);
|
|
|
|
|
}
|
|
|
|
|
if (teacherRosterScope) {
|
|
|
|
|
List<String> ownedStudentIds = resolveOwnedRosterStudentIds(operator, schoolClassId);
|
|
|
|
|
if (ownedStudentIds == null) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "只能查看自己教学班内的学生");
|
|
|
|
|
}
|
|
|
|
|
criteria.andUserIdIn(ownedStudentIds.isEmpty() ? Collections.singletonList("__empty__") : ownedStudentIds);
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(schoolClassId)) {
|
|
|
|
|
schoolClass = schoolClassMapper.selectByPrimaryKey(schoolClassId);
|
|
|
|
|
if (schoolClass != null && "TEACHING".equals(schoolClass.getClassType()) && teachingClassStudentMapper != null) {
|
|
|
|
|
@ -1031,6 +1053,35 @@ public class UserController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//编辑
|
|
|
|
|
private List<String> resolveOwnedRosterStudentIds(Userinfo operator, String teachingClassId) {
|
|
|
|
|
if (!isSchoolTeacher(operator) || teachingClassStudentMapper == null) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
List<SchoolClass> teachingClasses;
|
|
|
|
|
if (StringUtils.isNotBlank(teachingClassId)) {
|
|
|
|
|
SchoolClass teachingClass = schoolClassMapper.selectByPrimaryKey(teachingClassId);
|
|
|
|
|
if (!isOwnedTeachingClass(teachingClass, operator.getUserId())) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
teachingClasses = Collections.singletonList(teachingClass);
|
|
|
|
|
} else {
|
|
|
|
|
SchoolClassExample example = new SchoolClassExample();
|
|
|
|
|
example.createCriteria().andSchoolIdEqualTo(operator.getSchoolId())
|
|
|
|
|
.andCreatedByEqualTo(operator.getUserId()).andClassTypeEqualTo("TEACHING");
|
|
|
|
|
teachingClasses = schoolClassMapper.selectByExample(example);
|
|
|
|
|
}
|
|
|
|
|
Set<String> studentIds = new LinkedHashSet<>();
|
|
|
|
|
for (SchoolClass teachingClass : teachingClasses == null ? Collections.<SchoolClass>emptyList() : teachingClasses) {
|
|
|
|
|
List<TeachingClassStudent> members = teachingClassStudentMapper.selectByTeachingClassId(teachingClass.getSchoolClassId());
|
|
|
|
|
for (TeachingClassStudent member : members == null ? Collections.<TeachingClassStudent>emptyList() : members) {
|
|
|
|
|
if (member != null && StringUtils.isNotBlank(member.getStudentUserId())) {
|
|
|
|
|
studentIds.add(member.getStudentUserId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return new ArrayList<>(studentIds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/updateStudent")
|
|
|
|
|
@ApiOperation("学生管理-编辑学生账号信息")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ -1506,10 +1557,26 @@ public class UserController {
|
|
|
|
|
@ApiOperation("学生管理-导出")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
public void exportStudentUserInfo(HttpServletResponse response,
|
|
|
|
|
@RequestParam String schoolId) {
|
|
|
|
|
@RequestParam String schoolId,
|
|
|
|
|
@RequestParam(required = false) String operatorId,
|
|
|
|
|
@RequestParam(required = false) String schoolClassId) {
|
|
|
|
|
Userinfo operator = StringUtils.isBlank(operatorId) ? null : userinfoMapper.selectByPrimaryKey(operatorId);
|
|
|
|
|
boolean teacherRosterScope = isSchoolTeacher(operator) && isTeacherRosterMode(operator.getSchoolId());
|
|
|
|
|
if (teacherRosterScope) {
|
|
|
|
|
schoolId = operator.getSchoolId();
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(schoolId)) {
|
|
|
|
|
UserinfoExample userInfoExample = new UserinfoExample();
|
|
|
|
|
userInfoExample.createCriteria().andSchoolIdEqualTo(schoolId).andRoleEqualTo(4);
|
|
|
|
|
if (teacherRosterScope) {
|
|
|
|
|
List<String> ownedStudentIds = resolveOwnedRosterStudentIds(operator, schoolClassId);
|
|
|
|
|
if (ownedStudentIds == null) {
|
|
|
|
|
response.setStatus(HttpStatus.BAD_REQUEST.value());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
userInfoExample.getOredCriteria().get(0)
|
|
|
|
|
.andUserIdIn(ownedStudentIds.isEmpty() ? Collections.singletonList("__empty__") : ownedStudentIds);
|
|
|
|
|
}
|
|
|
|
|
List<Userinfo> list = userinfoMapper.selectByExample(userInfoExample);
|
|
|
|
|
//导出的表名
|
|
|
|
|
String title = "学生账号汇总";
|
|
|
|
|
|