Grails で友人 - 友情関係をどのようにモデル化しますか? これまで、私の User クラスには多くのフォロワーがいました
class User {
//Searchable plugin
static searchable = true
String userId
String password
boolean enabled = true
// For Spring Security plugin's user registration.
String email
String userRealName
boolean emailShow
Date dateCreated
Profile profile
static hasMany = [
posts : Post,
tags : Tag,
following : User,
authorities : Role,
notifications: Notification,
locations: Location,
incomingLocations:IncomingLocation,
]
static belongsTo = Role
static constraints = {
userId(blank: false, size:3..20, unique: true)
password(blank: false)
dateCreated()
profile(nullable: true)
userRealName(nullable: true, blank: true)
email(nullable: true, blank: true)
}
static mapping = {
profile lazy:false
}
}
しかし、私は次を変更したいと思います:友情のようなもののためのユーザー:友情と次のように友情クラスを作成します:
class Friendship {
static belongsTo= [user:User]
User friend2
boolean areFriends
}
これは理想的な実装ですか?
握手(保留中の友情を受け入れる/拒否する)をどのように実装しますか?