Controller -> Service -> Repository: Does service map Entity to ViewModel?

前端 未结 2 1412
误落风尘
误落风尘 2021-02-04 16:17

I haven MVC app, with \"M\" including Service and Repository layers.

However, I am a little confused as to where and how to do a couple of things.

  1. One Serv
2条回答
  •  隐瞒了意图╮
    2021-02-04 16:41

    ViewModel contains data, required for displaying model on view. If you'll use another view (e.g. mobile application, or desktop application, or even web service) you will require another data to be displayed on view. If you'll do mappings on service layer, then you will not be able to use it with another type of application. Thus controller is a place where you map domain data to display them on view (whatever type of view you have).

提交回复
热议问题