首页 > 解决方案 > 我在哪里可以在 grails 服务器角度客户端上添加代码

问题描述

我按照本指南修改了角度侧。我以前只使用过 grails,现在我遇到了问题。如何将函数添加到 post 方法?或者,我可以在服务器端的何处以及如何在注册新客户时添加自动发送电子邮件功能?

从我之前只使用 grails 的工作来看,这是使用控制器和修改save()方法制作的,但现在我找不到该方法或客户控制器的位置。

如果有人可以帮助我,我将不胜感激。另外,我不明白请求如何与角度一起工作。

标签: angularrestemailgrailsgroovy

解决方案


How can I add a function to the post method?

The post method is a function. In general they are referred to as methods in Groovy, but in this context those names mean the same thing. The language doesn't allow you to add a method to a method (or a function to a function, or any combo of those).

Or where and how in the server side can I add an automatically send email funtion when register a new customer?

That depends on a number of factors in your app but assuming your app is using GORM, you could have an asynchronous listener respond to PreInsertEvent (or similar) and in the listener initiate the sending of an email. If you are not using GORM, you could put the mail sending code in a Grails Service and call that service method from your controller action that supports registering a new customer.


推荐阅读