|
|
|
|
@ -12,6 +12,7 @@ import com.sztzjy.linkCommerce.entity.dto.SchoolMajorDto;
|
|
|
|
|
import com.sztzjy.linkCommerce.entity.importDto.SchoolAdminStudentImportDTO;
|
|
|
|
|
import com.sztzjy.linkCommerce.mapper.*;
|
|
|
|
|
import com.sztzjy.linkCommerce.service.SchoolAdminService;
|
|
|
|
|
import com.sztzjy.linkCommerce.service.SchoolProductConfigService;
|
|
|
|
|
import com.sztzjy.linkCommerce.service.SchoolService;
|
|
|
|
|
import com.sztzjy.linkCommerce.service.UserInfoService;
|
|
|
|
|
import com.sztzjy.linkCommerce.util.ResultEntity;
|
|
|
|
|
@ -56,6 +57,8 @@ public class SchoolAdminController {
|
|
|
|
|
private UserinfoMapper userinfoMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private TaskAllocationMapper taskAllocationMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private SchoolProductConfigService schoolProductConfigService;
|
|
|
|
|
|
|
|
|
|
@GetMapping("/school")
|
|
|
|
|
@ApiOperation("学校管理员-当前学校详情")
|
|
|
|
|
@ -81,6 +84,7 @@ public class SchoolAdminController {
|
|
|
|
|
@RequestParam(required = false) String schoolFacultyName,
|
|
|
|
|
HttpServletRequest request) {
|
|
|
|
|
String schoolId = currentSchoolId(request);
|
|
|
|
|
requireAdministrativeOrganization(schoolId);
|
|
|
|
|
PageInfo<SchoolFacultyDto> pageInfo = schoolService.seleteSchoolFaculty(index, size, schoolId, schoolFacultyName);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "查询成功", pageInfo);
|
|
|
|
|
}
|
|
|
|
|
@ -89,6 +93,7 @@ public class SchoolAdminController {
|
|
|
|
|
@ApiOperation("学校管理员-新增院系")
|
|
|
|
|
public ResultEntity addFaculty(@RequestBody SchoolFaculty faculty, HttpServletRequest request) {
|
|
|
|
|
String schoolId = currentSchoolId(request);
|
|
|
|
|
requireAdministrativeOrganization(schoolId);
|
|
|
|
|
if (StringUtils.isBlank(faculty.getSchoolFacultyName())) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "院系名称不能为空");
|
|
|
|
|
}
|
|
|
|
|
@ -105,6 +110,7 @@ public class SchoolAdminController {
|
|
|
|
|
@RequestBody SchoolFaculty faculty,
|
|
|
|
|
HttpServletRequest request) {
|
|
|
|
|
String schoolId = currentSchoolId(request);
|
|
|
|
|
requireAdministrativeOrganization(schoolId);
|
|
|
|
|
SchoolFaculty existing = requireFaculty(id, schoolId);
|
|
|
|
|
faculty.setSchoolFacultyId(existing.getSchoolFacultyId());
|
|
|
|
|
faculty.setSchoolId(schoolId);
|
|
|
|
|
@ -116,6 +122,7 @@ public class SchoolAdminController {
|
|
|
|
|
@ApiOperation("学校管理员-删除院系")
|
|
|
|
|
public ResultEntity deleteFaculty(@PathVariable String id, HttpServletRequest request) {
|
|
|
|
|
String schoolId = currentSchoolId(request);
|
|
|
|
|
requireAdministrativeOrganization(schoolId);
|
|
|
|
|
requireFaculty(id, schoolId);
|
|
|
|
|
if (hasMajorInFaculty(id) || hasUserByFaculty(id)) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.ACCEPTED, "院系下存在专业或用户,不能删除");
|
|
|
|
|
@ -132,6 +139,7 @@ public class SchoolAdminController {
|
|
|
|
|
@RequestParam(required = false) String schoolFacultyId,
|
|
|
|
|
HttpServletRequest request) {
|
|
|
|
|
String schoolId = currentSchoolId(request);
|
|
|
|
|
requireAdministrativeOrganization(schoolId);
|
|
|
|
|
if (StringUtils.isNotBlank(schoolFacultyId)) {
|
|
|
|
|
requireFaculty(schoolFacultyId, schoolId);
|
|
|
|
|
}
|
|
|
|
|
@ -143,6 +151,7 @@ public class SchoolAdminController {
|
|
|
|
|
@ApiOperation("学校管理员-新增专业")
|
|
|
|
|
public ResultEntity addMajor(@RequestBody SchoolMajor major, HttpServletRequest request) {
|
|
|
|
|
String schoolId = currentSchoolId(request);
|
|
|
|
|
requireAdministrativeOrganization(schoolId);
|
|
|
|
|
if (StringUtils.isBlank(major.getSchoolMajorName())) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "专业名称不能为空");
|
|
|
|
|
}
|
|
|
|
|
@ -159,6 +168,7 @@ public class SchoolAdminController {
|
|
|
|
|
@RequestBody SchoolMajor major,
|
|
|
|
|
HttpServletRequest request) {
|
|
|
|
|
String schoolId = currentSchoolId(request);
|
|
|
|
|
requireAdministrativeOrganization(schoolId);
|
|
|
|
|
requireMajor(id, schoolId);
|
|
|
|
|
if (StringUtils.isNotBlank(major.getSchoolFacultyId())) {
|
|
|
|
|
requireFaculty(major.getSchoolFacultyId(), schoolId);
|
|
|
|
|
@ -172,6 +182,7 @@ public class SchoolAdminController {
|
|
|
|
|
@ApiOperation("学校管理员-删除专业")
|
|
|
|
|
public ResultEntity deleteMajor(@PathVariable String id, HttpServletRequest request) {
|
|
|
|
|
String schoolId = currentSchoolId(request);
|
|
|
|
|
requireAdministrativeOrganization(schoolId);
|
|
|
|
|
requireMajor(id, schoolId);
|
|
|
|
|
if (hasClassInMajor(id) || hasUserByMajor(id)) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.ACCEPTED, "专业下存在班级或用户,不能删除");
|
|
|
|
|
@ -189,6 +200,7 @@ public class SchoolAdminController {
|
|
|
|
|
@RequestParam(required = false) String schoolMajorId,
|
|
|
|
|
HttpServletRequest request) {
|
|
|
|
|
String schoolId = currentSchoolId(request);
|
|
|
|
|
requireAdministrativeOrganization(schoolId);
|
|
|
|
|
if (StringUtils.isNotBlank(schoolMajorId)) {
|
|
|
|
|
requireMajor(schoolMajorId, schoolId);
|
|
|
|
|
}
|
|
|
|
|
@ -200,6 +212,7 @@ public class SchoolAdminController {
|
|
|
|
|
@ApiOperation("学校管理员-新增班级")
|
|
|
|
|
public ResultEntity addClass(@RequestBody SchoolClass schoolClass, HttpServletRequest request) {
|
|
|
|
|
String schoolId = currentSchoolId(request);
|
|
|
|
|
requireAdministrativeOrganization(schoolId);
|
|
|
|
|
if (StringUtils.isBlank(schoolClass.getClassName())) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "班级名称不能为空");
|
|
|
|
|
}
|
|
|
|
|
@ -217,6 +230,7 @@ public class SchoolAdminController {
|
|
|
|
|
@RequestBody SchoolClass schoolClass,
|
|
|
|
|
HttpServletRequest request) {
|
|
|
|
|
String schoolId = currentSchoolId(request);
|
|
|
|
|
requireAdministrativeOrganization(schoolId);
|
|
|
|
|
requireClass(id, schoolId);
|
|
|
|
|
if (StringUtils.isNotBlank(schoolClass.getSchoolMajorId())) {
|
|
|
|
|
requireMajor(schoolClass.getSchoolMajorId(), schoolId);
|
|
|
|
|
@ -231,6 +245,7 @@ public class SchoolAdminController {
|
|
|
|
|
@ApiOperation("学校管理员-删除班级")
|
|
|
|
|
public ResultEntity deleteClass(@PathVariable String id, HttpServletRequest request) {
|
|
|
|
|
String schoolId = currentSchoolId(request);
|
|
|
|
|
requireAdministrativeOrganization(schoolId);
|
|
|
|
|
requireClass(id, schoolId);
|
|
|
|
|
if (hasStudentInClass(id) || hasTaskInClass(id, schoolId)) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.ACCEPTED, "班级下存在学生或任务,不能删除");
|
|
|
|
|
@ -302,6 +317,7 @@ public class SchoolAdminController {
|
|
|
|
|
@RequestParam(required = false) String schoolClassId,
|
|
|
|
|
HttpServletRequest request) {
|
|
|
|
|
String schoolId = currentSchoolId(request);
|
|
|
|
|
requireAdministrativeOrganization(schoolId);
|
|
|
|
|
if (StringUtils.isNotBlank(schoolClassId)) {
|
|
|
|
|
requireClass(schoolClassId, schoolId);
|
|
|
|
|
}
|
|
|
|
|
@ -313,6 +329,7 @@ public class SchoolAdminController {
|
|
|
|
|
@ApiOperation("学校管理员-新增学生")
|
|
|
|
|
public ResultEntity addStudent(@RequestBody Userinfo student, HttpServletRequest request) {
|
|
|
|
|
String schoolId = currentSchoolId(request);
|
|
|
|
|
requireAdministrativeOrganization(schoolId);
|
|
|
|
|
if (StringUtils.isBlank(student.getUsername()) || StringUtils.isBlank(student.getName())) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "学生姓名和学号不能为空");
|
|
|
|
|
}
|
|
|
|
|
@ -337,6 +354,7 @@ public class SchoolAdminController {
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public ResultEntity importStudents(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
|
|
|
|
|
String schoolId = currentSchoolId(request);
|
|
|
|
|
requireAdministrativeOrganization(schoolId);
|
|
|
|
|
ResultEntity fileError = validateImportFile(file);
|
|
|
|
|
if (fileError != null) {
|
|
|
|
|
return fileError;
|
|
|
|
|
@ -377,6 +395,7 @@ public class SchoolAdminController {
|
|
|
|
|
@RequestBody Userinfo student,
|
|
|
|
|
HttpServletRequest request) {
|
|
|
|
|
String schoolId = currentSchoolId(request);
|
|
|
|
|
requireAdministrativeOrganization(schoolId);
|
|
|
|
|
requireUser(id, schoolId, 4);
|
|
|
|
|
if (StringUtils.isNotBlank(student.getSchoolClassId())) {
|
|
|
|
|
requireClass(student.getSchoolClassId(), schoolId);
|
|
|
|
|
@ -391,6 +410,7 @@ public class SchoolAdminController {
|
|
|
|
|
@ApiOperation("学校管理员-删除学生")
|
|
|
|
|
public ResultEntity deleteStudent(@PathVariable String id, HttpServletRequest request) {
|
|
|
|
|
String schoolId = currentSchoolId(request);
|
|
|
|
|
requireAdministrativeOrganization(schoolId);
|
|
|
|
|
requireUser(id, schoolId, 4);
|
|
|
|
|
int count = userinfoMapper.deleteByPrimaryKey(id);
|
|
|
|
|
return writeResult(count, "删除成功", "删除失败");
|
|
|
|
|
@ -401,6 +421,10 @@ public class SchoolAdminController {
|
|
|
|
|
return schoolAdminService.requireSchoolAdmin(user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void requireAdministrativeOrganization(String schoolId) {
|
|
|
|
|
schoolProductConfigService.requireAdminClassEnabled(schoolId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ResultEntity writeResult(int count, String success, String fail) {
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, success);
|
|
|
|
|
|