|
@@ -1,23 +1,35 @@
|
|
|
package com.qmth.paper.library.api;
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.qmth.boot.api.annotation.Aac;
|
|
|
import com.qmth.boot.api.annotation.BOOL;
|
|
|
import com.qmth.boot.api.constant.ApiConstant;
|
|
|
+import com.qmth.paper.library.business.bean.params.ClientLoginParam;
|
|
|
import com.qmth.paper.library.business.service.ClientService;
|
|
|
+import com.qmth.paper.library.common.bean.result.LoginResult;
|
|
|
import com.qmth.paper.library.common.contant.SystemConstant;
|
|
|
+import com.qmth.paper.library.common.entity.BasicSchool;
|
|
|
+import com.qmth.paper.library.common.entity.SysUser;
|
|
|
+import com.qmth.paper.library.common.enums.AppSourceEnum;
|
|
|
+import com.qmth.paper.library.common.enums.ExceptionResultEnum;
|
|
|
+import com.qmth.paper.library.common.service.CommonCacheService;
|
|
|
+import com.qmth.paper.library.common.service.LibraryCommonService;
|
|
|
+import com.qmth.paper.library.common.service.SysUserService;
|
|
|
import com.qmth.paper.library.common.util.Result;
|
|
|
import com.qmth.paper.library.common.util.ResultUtil;
|
|
|
import io.swagger.annotations.*;
|
|
|
+import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.validation.Valid;
|
|
|
import javax.validation.constraints.Max;
|
|
|
import javax.validation.constraints.Min;
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -26,7 +38,7 @@ import javax.validation.constraints.Min;
|
|
|
*/
|
|
|
@Api(tags = "扫描端Controller")
|
|
|
@RestController
|
|
|
-@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/${prefix.url.client}/scan")
|
|
|
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/${prefix.url.client}")
|
|
|
@Validated
|
|
|
@Aac(strict = BOOL.FALSE, auth = BOOL.FALSE)
|
|
|
public class ClientController {
|
|
@@ -34,16 +46,80 @@ public class ClientController {
|
|
|
@Resource
|
|
|
private ClientService clientService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ SysUserService sysUserService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ CommonCacheService commonCacheService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ LibraryCommonService libraryCommonService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 登录
|
|
|
+ *
|
|
|
+ * @param login 登录参数
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "登录")
|
|
|
+ @PostMapping("/user/login")
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "用户信息", response = LoginResult.class)})
|
|
|
+ @Aac(auth = BOOL.FALSE)
|
|
|
+ public Result login(@ApiParam(value = "用户信息", required = true) @Valid @RequestBody ClientLoginParam login, BindingResult bindingResult) throws NoSuchAlgorithmException {
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ BasicSchool basicSchool = commonCacheService.schoolCache(login.getSchoolCode());
|
|
|
+ if (Objects.isNull(basicSchool)) {
|
|
|
+ throw ExceptionResultEnum.SCHOOL_NO_DATA.exception();
|
|
|
+ }
|
|
|
+
|
|
|
+ QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.lambda().eq(SysUser::getSchoolId, basicSchool.getId()).eq(SysUser::getLoginName, login.getLoginName());
|
|
|
+ SysUser sysUser = sysUserService.getOne(wrapper);
|
|
|
+ // 用户不存在
|
|
|
+ if (Objects.isNull(sysUser)) {
|
|
|
+ throw ExceptionResultEnum.USER_NO_DATA.exception();
|
|
|
+ }
|
|
|
+ // 校验密码
|
|
|
+ if (!Objects.equals(sysUser.getPassword(), login.getPassword())) {
|
|
|
+ throw ExceptionResultEnum.PASSWORD_ERROR.exception();
|
|
|
+ }
|
|
|
+ // 是否有客户端权限
|
|
|
+ clientService.checkPrivilege(sysUser.getId());
|
|
|
+
|
|
|
+ return ResultUtil.ok(libraryCommonService.login(login.getPassword(), sysUser, AppSourceEnum.PAPER_LIBRARY_CLIENT));
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "任务查询")
|
|
|
- @PostMapping("/page")
|
|
|
+ @PostMapping("/task/page")
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = Result.class)})
|
|
|
public Result page(@ApiParam(value = "档案") @RequestParam(required = false) Long paperArchivesId,
|
|
|
@ApiParam(value = "课程") @RequestParam(required = false) String courseName,
|
|
|
- @ApiParam(value = "班级") @RequestParam(required = false) String clazzName,
|
|
|
- @ApiParam(value = "是否扫描") @RequestParam(required = false) Boolean isScan,
|
|
|
+ @ApiParam(value = "班级") @RequestParam(required = false) String teachClazzName,
|
|
|
+ @ApiParam(value = "是否我认领的任务") @RequestParam(required = false) Boolean isMine,
|
|
|
@ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
|
|
|
@ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
|
|
|
- return ResultUtil.ok(clientService.pageScanTask(paperArchivesId, courseName, clazzName, isScan, pageNumber, pageSize));
|
|
|
+ return ResultUtil.ok(clientService.pageScanTask(paperArchivesId, courseName, teachClazzName, isMine, pageNumber, pageSize));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "绑定扫描员")
|
|
|
+ @PostMapping("/bind/user")
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "绑定成功", response = Result.class)})
|
|
|
+ public Result page(@ApiParam(value = "扫描任务ID") Long paperScanTaskId,
|
|
|
+ @ApiParam(value = "扫描员ID") @RequestParam(required = false) Long userId) {
|
|
|
+ return ResultUtil.ok(clientService.bindUser(paperScanTaskId, userId));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "上传图片")
|
|
|
+ @PostMapping("/picture/upload")
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "保存图片成功", response = Result.class)})
|
|
|
+ public Result pictureUpload(@ApiParam(value = "上传文件", required = true) @RequestParam Long paperScanTaskId,
|
|
|
+ @ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile frontFile,
|
|
|
+ @ApiParam(value = "上传文件类型", required = true) @RequestParam String frontMd5,
|
|
|
+ @ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile versoFile,
|
|
|
+ @ApiParam(value = "上传文件类型", required = true) @RequestParam String versoMd5) {
|
|
|
+ return ResultUtil.ok(clientService.pictureUpload(paperScanTaskId, frontFile, frontMd5, versoFile, versoMd5));
|
|
|
}
|
|
|
|
|
|
}
|