Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[建议]API接口的输入输出参数都采用独立Model #4

Closed
dukecheng opened this issue Feb 13, 2017 · 5 comments
Closed

[建议]API接口的输入输出参数都采用独立Model #4

dukecheng opened this issue Feb 13, 2017 · 5 comments
Labels

Comments

@dukecheng
Copy link
Contributor

转自: #2
每个接口的输入输出参数都采用独立Model序列化和反序列化,便于维护
@pinzi

@dukecheng
Copy link
Contributor Author

个人意见,这个没有明确的定义,
正向的例子是: Search的API, 会有很多的条件,如果不采用模型,每次增加查询条件,Action方法参数都会发生变化, 这种情况采用独立的RequestModel会更好.
反向的例子: GetById/GetByNameAPI, 这种API的参数基本不可变,并且非常少,采用独立的Model只会导致类爆炸.

总结: 这个看情况定义,每个人可以自由裁定, 只是在适当的时候提出重构就好.

@Leowuqunqun
Copy link

@dukecheng 最好是都有, 解析的时候也可以解析到model ,把model里面的内容都展示出来,尤其要注意嵌套model这样的.... 虽然能解决,也麻烦

@dukecheng dukecheng changed the title 每个接口的输入输出参数都采用独立Model序列化和反序列化,便于维护 [建议]API接口的输入输出参数都采用独立Model Feb 13, 2017
@dukecheng
Copy link
Contributor Author

@Leowuqunqun 那对于GetUserById这样只需要一个UserId的参数的例子,也是要建一个GetUserByIdRequestModel么? 里面只有一个UserId参数 ?

@Leowuqunqun
Copy link

Leowuqunqun commented Feb 13, 2017

@dukecheng 没必要... 多余2个以上的都建议用model 基本类型可以解析到

@dukecheng
Copy link
Contributor Author

@Leowuqunqun 是这个意思,两个(不包含两个)以上要使用model

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants