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

关于Model的使用问题 #83

Closed
bigfish3000 opened this issue Mar 21, 2019 · 2 comments
Closed

关于Model的使用问题 #83

bigfish3000 opened this issue Mar 21, 2019 · 2 comments

Comments

@bigfish3000
Copy link
Contributor

目前的 model 是自动生成的, 生成之后,如果有代码变动的情况下

  1. 下一次添加新表,需要新的生成
  2. 某个表加了很多字段,需要重新生成

为了不破坏原有的结构

  1. 生成的model不动, 另写一个类,继承这个model
  2. 另外写一套 数据操作模型, model 仅做为基本操作

目前我这边是写的新的一几个东西, 不知道,这些,做者是怎么考量的。

@an-tao
Copy link
Member

an-tao commented Mar 21, 2019

@bigfish3000 一个Model对象只代表一行数据,你可以通过接口获得或者修改它的内容(本地的),model源文件不应被修改,相关数据库操作由Mapper对象或者DbClient对象完成,至于业务相关的逻辑,应该由专门的业务类实现,继承不是个好主意,毕竟耦合比较深,我认为组合更好,用model对象构造你的业务类对象并被后者持有。
你说的数据操作模型,我不太清楚指什么,如果是业务无关的通用接口,可以整合到model或者Mapper里的,你可以提Issue,由Drogon来实现。

@bigfish3000
Copy link
Contributor Author

不错,不错,我继续研究。。。文档,文档。。。

@an-tao an-tao closed this as completed Mar 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants