Visitar URL original
建议:在输入引用赋值顺序错误时给出更明显的提示 · Issue #275 · APIJSON/APIJSON · GitHub
Skip to content

建议:在输入引用赋值顺序错误时给出更明显的提示 #275

Description

@jerrylususu

引用赋值需要请求中先出现原始值,然后才能被引用,如果顺序相反则引用无法成功。但是在使用 Request 表对输入进行校验时,引用赋值出现的位置(Request 表中)和用户实际使用的位置(POST 请求体)并不相同,在用户请求中因为顺序错误导致引用赋值失败时,给出的错误提示不够明显,导致排错十分困难。希望能给出更明显的提示。

问题场景:APIJSONBoot 示例项目中,有 User, Privacy 两表,其中用户注册时,请求会和 Request 表中对应项 (method=POST, tag=register)进行校验,校验规则简化如下,即 user.id 依赖于 privacy.id 。

简化后的依赖关系

{
  "User": {
    "UPDATE": {"id@": "Privacy/id"}
  },
  "Privacy": {}
}

在实际发起请求的时候,Requestbody 中需要 Privacy 在上,User 在下,如果顺序反过来,用户注册本身不会成功(数据库中无写入操作),但是请求显示正常完成(code=200)。

错误请求例(method=POST, addr=/post)

{
    "User": {
        "name": "test"
    },
    "Privacy": {
        "phone": "13323332338",
        "_password": "testpwd"
    },
    "verify": "9816",
    "tag": "register"
}

此情况下返回值(返回200,但 sql.execute 为0)

{
    "ok": true,
    "code": 200,
    "msg": "success",
    "sql:generate|cache|execute|maxExecute": "0|0|0|200",
    "depth:count|max": "1|5",
    "time:start|duration|end": "1627506120546|7|1627506120553"
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions