Skip to content

Commit

Permalink
Merge pull request #127 from LuoRenMu/refactor-schema
Browse files Browse the repository at this point in the history
fix: 后端战斗流程协议与客户端战斗流程协议不匹配
  • Loading branch information
dragove authored Aug 19, 2023
2 parents 3b8c20e + 468be4c commit 3d62d53
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/main/java/plus/maa/backend/common/aop/JsonSchemaAop.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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(), "数据不符合规范,请前往前端作业编辑器进行操作");
}
}
Expand Down
21 changes: 13 additions & 8 deletions src/main/java/plus/maa/backend/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}


}
4 changes: 3 additions & 1 deletion src/main/resources/static/templates/maa-copilot-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,16 @@
"技能用法",
"打印",
"摆完挂机",
"移动镜头",
"Deploy",
"Skill",
"Retreat",
"SpeedUp",
"BulletTime",
"SkillUsage",
"Output",
"SkillDaemon"
"SkillDaemon",
"MoveCamera"
]
},
"kills": {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/static/templates/maa-rating-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"properties": {
"rating": {
"type": "string",
"description": "The rating must be Like, Dislike, None",
"enum": [
"Like",
"Dislike",
Expand Down

0 comments on commit 3d62d53

Please sign in to comment.