【发布时间】:2014-04-26 12:33:55
【问题描述】:
我有一个名为 Merchant 的类,它有两个相关字段(在域和数据库中都相关),如下所示:
/**
*This class keeps information about a merchant
*/
class Merchant{
...
//The email of the merchant which is also
//as the username property of the login field
String email
//The login credentials of the merchant
UserLogin login
...
}
Userlogin 类也是这样定义的
/**
*This class is used to hold the login credentials
* of a Customer, Admin or "Merchant"
*/
class UserLogin{
...
//The username used to Login
String username
//The password used to Login
String password
...
}
现在的问题是,在添加新商户的过程中,还会为商户生成一个登录,使用他的电子邮件作为用户名。
我正在使用动态脚手架,但只想添加代码来更新商家的 userLogin 的用户名字段。
现在,当一个商家的邮箱被更新时,登录的用户名没有更新,我通常在登录后使用用户名来获取相应的商家。
- 如何添加一个小代码 sn-p 在更改电子邮件时更新商家的登录凭据(用户名),或者我可以在商家的电子邮件和用户名之间创建数据库更新级联的任何方式他的登录名。(我可以在我覆盖的控制器操作中使用 super.update() 吗?)
【问题讨论】:
标签: grails grails-orm grails-controller