加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Grails:服务VS Groovy课程

发布时间:2020-12-14 16:37:19 所属栏目:大数据 来源:网络整理
导读:文件说: The Grails team discourages the embedding of core application logic inside controllers,as it does not promote re-use and a clean separation of concerns. 我在src / groovy文件夹中有一个API控制器和一些Groovy类。这些类只是实现了我的应
文件说:

The Grails team discourages the
embedding of core application logic
inside controllers,as it does not
promote re-use and a clean separation
of concerns.

我在src / groovy文件夹中有一个API控制器和一些Groovy类。这些类只是实现了我的应用程序逻辑,所以API控制器中的操作按照这样的方式工作:

//index page
def index = {
    render new IndexApi().index(params) as JSON
}

我很好奇 – 有没有理由将我的应用程序逻辑从普通的groovy类转移到服务中?

解决方法

如果你想要事务行为,你应该把你的逻辑在服务。否则,您将不得不自己关心它,这不符合使用Grails的精神。

我自己不是一个grails专家,我把’我的’不是事务’类放在服务层之外,就像构建器类,帮助者和其他不是事务性但是从服务层使用的逻辑。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读