|
@@ -11,6 +11,7 @@ import com.qmth.distributed.print.business.bean.result.EditResult;
|
|
|
import com.qmth.distributed.print.business.entity.ExamPrintPlan;
|
|
|
import com.qmth.distributed.print.business.entity.TBSyncTask;
|
|
|
import com.qmth.distributed.print.business.enums.DictionaryEnum;
|
|
|
+import com.qmth.distributed.print.business.enums.LoginTypeEnum;
|
|
|
import com.qmth.distributed.print.business.service.BasicVerifyCodeService;
|
|
|
import com.qmth.distributed.print.business.service.ExamPrintPlanService;
|
|
|
import com.qmth.distributed.print.business.service.PrintCommonService;
|
|
@@ -138,15 +139,72 @@ public class SysController {
|
|
|
}
|
|
|
}
|
|
|
QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
|
|
|
- wrapper.lambda().eq(SysUser::getLoginName, login.getLoginName());
|
|
|
- if (!login.getSchoolCode().equalsIgnoreCase(SystemConstant.ADMIN_CODE)) {
|
|
|
+ if (Objects.nonNull(basicSchool)) {
|
|
|
wrapper.lambda().eq(SysUser::getSchoolId, basicSchool.getId());
|
|
|
}
|
|
|
- List<SysUser> userList = sysUserService.list(wrapper);
|
|
|
- //用户不存在
|
|
|
- if (Objects.isNull(userList) || userList.size() == 0) {
|
|
|
- throw ExceptionResultEnum.USER_NO_DATA.exception();
|
|
|
+ // 账号密码登录
|
|
|
+ List<SysUser> userList = null;
|
|
|
+ if (LoginTypeEnum.ACCOUNT.name().equals(login.getType())) {
|
|
|
+ String loginName = login.getLoginName();
|
|
|
+ String password = login.getPassword();
|
|
|
+ // 非空校验
|
|
|
+ if (StringUtils.isBlank(loginName)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("用户名不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(password)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("密码不能为空");
|
|
|
+ }
|
|
|
+ wrapper.lambda().eq(SysUser::getLoginName, loginName);
|
|
|
+ userList = sysUserService.list(wrapper);
|
|
|
+
|
|
|
+ //用户不存在
|
|
|
+ if (userList == null || userList.isEmpty()) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("用户不存在");
|
|
|
+ }
|
|
|
+ if (userList.size() > 1) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("查出多个用户");
|
|
|
+ }
|
|
|
+
|
|
|
+ SysUser sysUser = userList.get(0);
|
|
|
+ if (!sysUser.getEnable()) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("用户被禁用");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!password.equals(userList.get(0).getPassword())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("密码错误");
|
|
|
+ }
|
|
|
+ } else if (LoginTypeEnum.PHONE.name().equals(login.getType())) {
|
|
|
+ String mobileNumber = login.getMobileNumber();
|
|
|
+ String code = login.getCode();
|
|
|
+ // 非空校验
|
|
|
+ if (StringUtils.isBlank(mobileNumber)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("手机号不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(code)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("验证码不能为空");
|
|
|
+ }
|
|
|
+ wrapper.lambda().eq(SysUser::getMobileNumber, mobileNumber);
|
|
|
+ userList = sysUserService.list(wrapper);
|
|
|
+
|
|
|
+ //用户不存在
|
|
|
+ if (userList == null || userList.isEmpty()) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("用户不存在");
|
|
|
+ }
|
|
|
+ if (userList.size() > 1) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("查出多个用户");
|
|
|
+ }
|
|
|
+ SysUser sysUser = userList.get(0);
|
|
|
+ // 校验验证码
|
|
|
+ sysUserService.checkSmsCode(sysUser.getId(), sysUser.getMobileNumber(), code);
|
|
|
+
|
|
|
+ // 如果不是共用验证码再过期
|
|
|
+ if (!dictionaryConfig.smsDomain().getSmsNormalCode().equals(login.getCode())) {
|
|
|
+ sysUserService.expiredVerifyCode(sysUser.getId(), sysUser.getMobileNumber());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("登录参数错误");
|
|
|
}
|
|
|
+
|
|
|
if (login.getSchoolCode().equalsIgnoreCase(SystemConstant.ADMIN_CODE)) {
|
|
|
userList.forEach(o -> {
|
|
|
AuthBean authBean = teachcloudCommonService.getUserAuth(o.getId());
|
|
@@ -157,21 +215,9 @@ public class SysController {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- if (userList.size() > 1) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("查询的用户有多条");
|
|
|
- }
|
|
|
SysUser sysUser = userList.get(0);
|
|
|
- if (Objects.nonNull(sysUser.getSchoolId()) && sysUser.getSchoolId().longValue() != basicSchool.getId().longValue()) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("用户学校不匹配");
|
|
|
- }
|
|
|
- // 校验验证码
|
|
|
- sysUserService.checkSmsCode(sysUser.getId(), sysUser.getMobileNumber(), login.getCode());
|
|
|
LoginResult loginResult = teachcloudCommonService.login(login.getPassword(), sysUser, AppSourceEnum.SYSTEM);
|
|
|
|
|
|
- // 如果不是共用验证码再过期
|
|
|
- if (!dictionaryConfig.smsDomain().getSmsNormalCode().equals(login.getCode())) {
|
|
|
- sysUserService.expiredVerifyCode(sysUser.getId(), sysUser.getMobileNumber());
|
|
|
- }
|
|
|
return ResultUtil.ok(loginResult);
|
|
|
}
|
|
|
|
|
@@ -199,8 +245,10 @@ public class SysController {
|
|
|
@RequestMapping(value = "/get_verify_code", method = RequestMethod.POST)
|
|
|
@Aac(auth = BOOL.FALSE)
|
|
|
public Result getVerifyCode(@RequestBody LoginParam loginParam) {
|
|
|
- String loginName = loginParam.getLoginName();
|
|
|
- String password = loginParam.getPassword();
|
|
|
+ String mobileNumber = loginParam.getMobileNumber();
|
|
|
+ if (StringUtils.isBlank(mobileNumber)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("手机号不能为空");
|
|
|
+ }
|
|
|
QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
|
|
|
if (StringUtils.isNotBlank(loginParam.getSchoolCode())) {
|
|
|
BasicSchool basicSchool = commonCacheService.schoolCache(loginParam.getSchoolCode());
|
|
@@ -208,29 +256,32 @@ public class SysController {
|
|
|
wrapper.lambda().eq(SysUser::getSchoolId, basicSchool.getId());
|
|
|
}
|
|
|
}
|
|
|
- wrapper.lambda().eq(SysUser::getLoginName, loginName);
|
|
|
- SysUser user = sysUserService.getOne(wrapper);
|
|
|
+ wrapper.lambda().eq(SysUser::getMobileNumber, mobileNumber);
|
|
|
+ List<SysUser> userList = sysUserService.list(wrapper);
|
|
|
+
|
|
|
//用户不存在
|
|
|
- if (Objects.isNull(user)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("用户不存在");
|
|
|
+ if (userList == null || userList.isEmpty()) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("手机号不存在");
|
|
|
}
|
|
|
- if (!password.equals(user.getPassword())) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("密码错误");
|
|
|
+ if (userList.size() > 1) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("查出多个用户");
|
|
|
}
|
|
|
- String mobileNumber = loginParam.getMobileNumber();
|
|
|
- if (!SystemConstant.strNotNull(mobileNumber)) {
|
|
|
- mobileNumber = user.getMobileNumber();
|
|
|
+ SysUser sysUser = userList.get(0);
|
|
|
+
|
|
|
+ if (!sysUser.getEnable()) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("手机号被禁用");
|
|
|
}
|
|
|
+
|
|
|
if (SystemConstant.strNotNull(mobileNumber)) {
|
|
|
- basicVerifyCodeService.sendVeirfyCode(mobileNumber, user.getId());
|
|
|
+ basicVerifyCodeService.sendVeirfyCode(mobileNumber, sysUser.getId());
|
|
|
}
|
|
|
- int pwdCount = user.getPwdCount();
|
|
|
- List<SysRole> sysRoleList = sysUserRoleService.listRoleByUserId(user.getId());
|
|
|
+ int pwdCount = sysUser.getPwdCount();
|
|
|
+ List<SysRole> sysRoleList = sysUserRoleService.listRoleByUserId(sysUser.getId());
|
|
|
if (sysRoleList.stream().map(SysRole::getType).collect(Collectors.toSet()).contains(RoleTypeEnum.ADMIN)) {
|
|
|
- mobileNumber = user.getLoginName() + "(特权用户)";
|
|
|
+ mobileNumber = sysUser.getLoginName() + "(特权用户)";
|
|
|
pwdCount = 1;
|
|
|
}
|
|
|
- UserLoginCheckResult userLoginCheckResult = new UserLoginCheckResult(user.getId(), mobileNumber, pwdCount);
|
|
|
+ UserLoginCheckResult userLoginCheckResult = new UserLoginCheckResult(sysUser.getId(), mobileNumber, pwdCount);
|
|
|
return ResultUtil.ok(userLoginCheckResult, "");
|
|
|
}
|
|
|
|
|
@@ -287,8 +338,8 @@ public class SysController {
|
|
|
@Transactional
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = EditResult.class)})
|
|
|
public Result fileExamPaperUpload(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file,
|
|
|
- @ApiParam(value = "上传文件类型", required = true) @RequestParam UploadFileEnum type) {
|
|
|
- Map<String,EditResult> resultMap = new HashMap<>();
|
|
|
+ @ApiParam(value = "上传文件类型", required = true) @RequestParam UploadFileEnum type) {
|
|
|
+ Map<String, EditResult> resultMap = new HashMap<>();
|
|
|
BasicAttachment basicOriginalAttachment = null;
|
|
|
BasicAttachment basicTranslateAttachment = null;
|
|
|
EditResult original = new EditResult();
|
|
@@ -298,7 +349,7 @@ public class SysController {
|
|
|
try {
|
|
|
pdfOriginalFile = FileUtil.multipartFileToFile(file);
|
|
|
PageSizeEnum pageSizeEnum = PdfUtil.getPdfFormat(pdfOriginalFile);
|
|
|
- switch (pageSizeEnum){
|
|
|
+ switch (pageSizeEnum) {
|
|
|
case A3:
|
|
|
basicOriginalAttachment = printCommonService.saveAttachment(file, ServletUtil.getRequestMd5(), type);
|
|
|
if (Objects.isNull(basicOriginalAttachment)) {
|
|
@@ -308,7 +359,7 @@ public class SysController {
|
|
|
original.setUrl(teachcloudCommonService.filePreview(basicOriginalAttachment.getPath()));
|
|
|
original.setPages(basicOriginalAttachment.getPages());
|
|
|
|
|
|
- BeanUtils.copyProperties(original,translate);
|
|
|
+ BeanUtils.copyProperties(original, translate);
|
|
|
break;
|
|
|
case A4:
|
|
|
basicOriginalAttachment = printCommonService.saveAttachment(file, ServletUtil.getRequestMd5(), type);
|
|
@@ -322,10 +373,10 @@ public class SysController {
|
|
|
String destUrl = SystemConstant.PDF_TEMP_FILES_DIR + File.separator + file.getOriginalFilename();
|
|
|
localTempFile = new File(destUrl);
|
|
|
OutputStream out = new FileOutputStream(localTempFile);
|
|
|
- PdfUtil.concatPDFs(new FileInputStream(pdfOriginalFile),out,false);
|
|
|
+ PdfUtil.concatPDFs(new FileInputStream(pdfOriginalFile), out, false);
|
|
|
// File转换成MutipartFile
|
|
|
FileInputStream inputStream = new FileInputStream(localTempFile);
|
|
|
- MultipartFile multipartFile = new MockMultipartFile(localTempFile.getName(),localTempFile.getName(), ContentType.APPLICATION_OCTET_STREAM.toString(), inputStream);
|
|
|
+ MultipartFile multipartFile = new MockMultipartFile(localTempFile.getName(), localTempFile.getName(), ContentType.APPLICATION_OCTET_STREAM.toString(), inputStream);
|
|
|
basicTranslateAttachment = printCommonService.saveAttachment(multipartFile, DigestUtils.md5Hex(multipartFile.getBytes()), type);
|
|
|
translate.setId(basicTranslateAttachment.getId());
|
|
|
translate.setUrl(teachcloudCommonService.filePreview(basicTranslateAttachment.getPath()));
|
|
@@ -334,8 +385,8 @@ public class SysController {
|
|
|
default:
|
|
|
throw ExceptionResultEnum.ERROR.exception("请上传A4或A3格式的试卷文件");
|
|
|
}
|
|
|
- resultMap.put("original",original);
|
|
|
- resultMap.put("translate",translate);
|
|
|
+ resultMap.put("original", original);
|
|
|
+ resultMap.put("translate", translate);
|
|
|
} catch (Exception e) {
|
|
|
log.error(SystemConstant.LOG_ERROR, e);
|
|
|
if (Objects.nonNull(basicOriginalAttachment)) {
|
|
@@ -350,10 +401,10 @@ public class SysController {
|
|
|
ResultUtil.error(e.getMessage());
|
|
|
}
|
|
|
} finally {
|
|
|
- if (Objects.nonNull(localTempFile)){
|
|
|
+ if (Objects.nonNull(localTempFile)) {
|
|
|
FileUtil.deleteFile(localTempFile);
|
|
|
}
|
|
|
- if (Objects.nonNull(pdfOriginalFile)){
|
|
|
+ if (Objects.nonNull(pdfOriginalFile)) {
|
|
|
FileUtil.deleteFile(pdfOriginalFile);
|
|
|
}
|
|
|
}
|