瀏覽代碼

考生导入-添加权限

haogh 1 年之前
父節點
當前提交
3aaebfe2f1

+ 7 - 6
src/main/java/com/qmth/exam/reserve/controller/admin/StudentImportTaskController.java

@@ -18,10 +18,12 @@ 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.PagerReq;
+import com.qmth.exam.reserve.bean.login.LoginUser;
 import com.qmth.exam.reserve.bean.studentimport.StudentImportTaskVO;
 import com.qmth.exam.reserve.controller.BaseController;
 import com.qmth.exam.reserve.entity.StudentImportTaskEntity;
 import com.qmth.exam.reserve.enums.ImportStatus;
+import com.qmth.exam.reserve.enums.Role;
 import com.qmth.exam.reserve.service.StudentImportTaskService;
 import com.qmth.exam.reserve.util.ResourceUtil;
 
@@ -49,21 +51,20 @@ public class StudentImportTaskController extends BaseController {
         exportFile("考生信息导入模板.xlsx", ResourceUtil.getStream("templates/studentImport.xlsx"));
     }
 
-    @Aac(strict = false, auth = false)
     @ApiOperation(value = "考生信息导入")
     @PostMapping(value = "/upload")
     public void upload(MultipartFile file) {
-        // LoginUser user = this.curLoginUser();
-        // if (!Role.ADMIN.equals(user.getRole())) {
-        // throw new StatusException("没有权限");
-        // }
+        LoginUser user = this.curLoginUser();
+        if (!Role.ADMIN.equals(user.getRole())) {
+            throw new StatusException("没有权限");
+        }
         LambdaQueryWrapper<StudentImportTaskEntity> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(StudentImportTaskEntity::getStatus, ImportStatus.RUNNING.toString());
         StudentImportTaskEntity exists = studentImportService.getOne(wrapper);
         if (exists != null)
             throw new StatusException("正在导入,请稍后再试");
         try {
-            studentImportService.importStudent(1l, file.getOriginalFilename(), file.getInputStream());
+            studentImportService.importStudent(user.getId(), file.getOriginalFilename(), file.getInputStream());
         } catch (IOException e) {
             throw new StatusException("文件读取出错", e);
         }