123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- package com.qmth.exam.reserve.controller.admin;
- import com.qmth.boot.api.annotation.Aac;
- import com.qmth.boot.api.constant.ApiConstant;
- import com.qmth.boot.core.collection.PageResult;
- import com.qmth.boot.core.exception.StatusException;
- import com.qmth.exam.reserve.bean.Constants;
- import com.qmth.exam.reserve.bean.login.LoginUser;
- import com.qmth.exam.reserve.bean.student.StudentReq;
- import com.qmth.exam.reserve.bean.student.StudentVO;
- import com.qmth.exam.reserve.controller.BaseController;
- import com.qmth.exam.reserve.enums.Role;
- import com.qmth.exam.reserve.service.StudentService;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.multipart.MultipartFile;
- import java.io.IOException;
- import java.util.Objects;
- @RestController
- @Api(tags = "【管理端】考生相关接口")
- @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/admin/student")
- @Aac(strict = false, auth = true)
- public class StudentAdminController extends BaseController {
- @Autowired
- private StudentService studentService;
- @ApiOperation(value = "考生管理分页")
- @PostMapping(value = "/page")
- public PageResult<StudentVO> page(@RequestBody StudentReq req) {
- LoginUser loginUser = this.curLoginUser();
- if(loginUser.getRole().equals(Role.TEACHING)) {
- req.setTeachingId(loginUser.getCategoryId());
- }
- return studentService.pageStudent(req);
- }
- @ApiOperation(value = "删除考生")
- @PostMapping(value = "/delete")
- public void delete(@ApiParam("考生ID") @RequestParam Long id) {
- LoginUser loginUser = this.curLoginUser();
- studentService.delete(id, loginUser.getId());
- }
- @ApiOperation(value = "修改考生可预约次数")
- @PostMapping(value = "/modify/apply/number")
- public void modifyApplyNumber(@ApiParam("考生ID") @RequestParam Long id, @ApiParam("可预约次数") @RequestParam Integer applyNumber) {
- LoginUser loginUser = this.curLoginUser();
- if (!loginUser.getRole().equals(Role.ADMIN)) {
- throw new StatusException("没有权限");
- }
- studentService.modifyApplyNumber(id, loginUser.getId(), applyNumber);
- }
- @ApiOperation(value = "上传考生的照片")
- @PostMapping(value = "upload/student/photo")
- public String uploadStudentPhoto(MultipartFile file) throws IOException {
- if (!Objects.requireNonNull(file.getOriginalFilename()).endsWith(".zip")) {
- throw new StatusException("请上传zip文件");
- }
- LoginUser loginUser = this.curLoginUser();
- studentService.uploadStudentPhoto(loginUser.getId(), file);
- return Constants.ASYNC_TIPS;
- }
- }
|