{"action":"created","issue":{"url":"https://api.github.com/repos/75team/thinkjs/issues/378","repository_url":"https://api.github.com/repos/75team/thinkjs","labels_url":"https://api.github.com/repos/75team/thinkjs/issues/378/labels{/name}","comments_url":"https://api.github.com/repos/75team/thinkjs/issues/378/comments","events_url":"https://api.github.com/repos/75team/thinkjs/issues/378/events","html_url":"https://github.com/75team/thinkjs/issues/378","id":162061571,"number":378,"title":"如何配置可以让参数可以有可无？","user":{"login":"FuDengrong","id":10692855,"avatar_url":"https://avatars.githubusercontent.com/u/10692855?v=3","gravatar_id":"","url":"https://api.github.com/users/FuDengrong","html_url":"https://github.com/FuDengrong","followers_url":"https://api.github.com/users/FuDengrong/followers","following_url":"https://api.github.com/users/FuDengrong/following{/other_user}","gists_url":"https://api.github.com/users/FuDengrong/gists{/gist_id}","starred_url":"https://api.github.com/users/FuDengrong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FuDengrong/subscriptions","organizations_url":"https://api.github.com/users/FuDengrong/orgs","repos_url":"https://api.github.com/users/FuDengrong/repos","events_url":"https://api.github.com/users/FuDengrong/events{/privacy}","received_events_url":"https://api.github.com/users/FuDengrong/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-06-24T02:06:01Z","updated_at":"2016-06-30T04:04:45Z","closed_at":null,"body":"## 配置传参\r\n\r\n### control层\r\n~~~javascript\r\nlet params = this.post();\r\nawait model.where(params).select()\r\n~~~\r\n### logic层\r\n~~~javascript\r\nthis.allowMethods = 'post';\r\nlet rules = {\r\n      name: 'required|string'\r\n}\r\n~~~\r\n\r\n如题所示，因前台某些参数可有可无，有的话就要在logic里面做参数校验；\r\n这时如果前台没有传参数,因为logic层做了参数校验的，在control层就变成了\r\n~~~javascript\r\nawait model.where({name: \"\"}).select()\r\n~~~\r\n这时在后台就找不到数据\r\n\r\n我想请问一下：如何做才能保证在有校验的情况下，如果没有传参数，where语句里面也是空的？谢谢！"},"comment":{"url":"https://api.github.com/repos/75team/thinkjs/issues/comments/229554397","html_url":"https://github.com/75team/thinkjs/issues/378#issuecomment-229554397","issue_url":"https://api.github.com/repos/75team/thinkjs/issues/378","id":229554397,"user":{"login":"FuDengrong","id":10692855,"avatar_url":"https://avatars.githubusercontent.com/u/10692855?v=3","gravatar_id":"","url":"https://api.github.com/users/FuDengrong","html_url":"https://github.com/FuDengrong","followers_url":"https://api.github.com/users/FuDengrong/followers","following_url":"https://api.github.com/users/FuDengrong/following{/other_user}","gists_url":"https://api.github.com/users/FuDengrong/gists{/gist_id}","starred_url":"https://api.github.com/users/FuDengrong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FuDengrong/subscriptions","organizations_url":"https://api.github.com/users/FuDengrong/orgs","repos_url":"https://api.github.com/users/FuDengrong/repos","events_url":"https://api.github.com/users/FuDengrong/events{/privacy}","received_events_url":"https://api.github.com/users/FuDengrong/received_events","type":"User","site_admin":false},"created_at":"2016-06-30T04:04:45Z","updated_at":"2016-06-30T04:04:45Z","body":"可是去掉之后还是会校验这个参数，并赋值为空字符串"}}
{"actor":{"display_login":"FuDengrong"}}