From 468be4c2cdaa4121e921169b23885b356e245e20 Mon Sep 17 00:00:00 2001 From: LoMu <61622984+LuoRenMu@users.noreply.github.com> Date: Sat, 19 Aug 2023 03:29:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=90=8E=E7=AB=AF=E6=88=98=E6=96=97?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E5=8D=8F=E8=AE=AE=E4=B8=8E=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E6=88=98=E6=96=97=E6=B5=81=E7=A8=8B=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E4=B8=8D=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../maa/backend/common/aop/JsonSchemaAop.java | 3 ++- .../plus/maa/backend/service/UserService.java | 21 ++++++++++++------- .../static/templates/maa-copilot-schema.json | 4 +++- .../static/templates/maa-rating-schema.json | 1 + 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/main/java/plus/maa/backend/common/aop/JsonSchemaAop.java b/src/main/java/plus/maa/backend/common/aop/JsonSchemaAop.java index 7832a3aa..60cbfcbb 100644 --- a/src/main/java/plus/maa/backend/common/aop/JsonSchemaAop.java +++ b/src/main/java/plus/maa/backend/common/aop/JsonSchemaAop.java @@ -55,7 +55,7 @@ public void pt() { public void before(JoinPoint joinPoint, JsonSchema jsonSchema) { String schema_json = null; String content = null; - //获取 CopilotCUDRequest形参的index + //判断是验证的是Copilot还是Rating for (Object arg : joinPoint.getArgs()) { if (arg instanceof CopilotCUDRequest) { content = ((CopilotCUDRequest) arg).getContent(); @@ -82,6 +82,7 @@ public void before(JoinPoint joinPoint, JsonSchema jsonSchema) { } catch (IOException e) { throw new RuntimeException(e); } catch (ValidationException e) { + log.warn("schema Location: {}", e.getViolatedSchema().getSchemaLocation()); throw new MaaResultException(HttpStatus.BAD_REQUEST.value(), "数据不符合规范,请前往前端作业编辑器进行操作"); } } diff --git a/src/main/java/plus/maa/backend/service/UserService.java b/src/main/java/plus/maa/backend/service/UserService.java index ab9fe1a1..111e8270 100644 --- a/src/main/java/plus/maa/backend/service/UserService.java +++ b/src/main/java/plus/maa/backend/service/UserService.java @@ -12,8 +12,8 @@ import plus.maa.backend.common.MaaStatusCode; import plus.maa.backend.common.utils.converter.MaaUserConverter; import plus.maa.backend.controller.request.user.*; -import plus.maa.backend.controller.response.user.MaaLoginRsp; import plus.maa.backend.controller.response.MaaResultException; +import plus.maa.backend.controller.response.user.MaaLoginRsp; import plus.maa.backend.controller.response.user.MaaUserInfo; import plus.maa.backend.repository.RedisCache; import plus.maa.backend.repository.UserRepository; @@ -104,6 +104,7 @@ public void modifyPassword(String userId, String rawPassword) { */ public MaaUserInfo register(RegisterDTO registerDTO) { String encode = passwordEncoder.encode(registerDTO.getPassword()); + MaaUser user = new MaaUser(); BeanUtils.copyProperties(registerDTO, user); user.setPassword(encode); @@ -236,15 +237,19 @@ public void activateAccount(EmailActivateReq activateDTO) { Assert.notNull(email, "链接已过期"); MaaUser user = userRepository.findByEmail(email); - if (Objects.equals(user.getStatus(), 1)) { + try { + if (Objects.equals(user.getStatus(), 1)) { + return; + } + // 激活账户 + user.setStatus(1); + userRepository.save(user); + + // 清除缓存 + } finally { redisCache.removeCache("UUID:" + uuid); - return; } - // 激活账户 - user.setStatus(1); - userRepository.save(user); - // 清除缓存 - redisCache.removeCache("UUID:" + uuid); } + } diff --git a/src/main/resources/static/templates/maa-copilot-schema.json b/src/main/resources/static/templates/maa-copilot-schema.json index 9e1292da..1caa2b6d 100644 --- a/src/main/resources/static/templates/maa-copilot-schema.json +++ b/src/main/resources/static/templates/maa-copilot-schema.json @@ -188,6 +188,7 @@ "技能用法", "打印", "摆完挂机", + "移动镜头", "Deploy", "Skill", "Retreat", @@ -195,7 +196,8 @@ "BulletTime", "SkillUsage", "Output", - "SkillDaemon" + "SkillDaemon", + "MoveCamera" ] }, "kills": { diff --git a/src/main/resources/static/templates/maa-rating-schema.json b/src/main/resources/static/templates/maa-rating-schema.json index b1f1bea7..cbdebfa6 100644 --- a/src/main/resources/static/templates/maa-rating-schema.json +++ b/src/main/resources/static/templates/maa-rating-schema.json @@ -4,6 +4,7 @@ "properties": { "rating": { "type": "string", + "description": "The rating must be Like, Dislike, None", "enum": [ "Like", "Dislike",