Wie würden Sie einen Freund modellieren - Freundschaftsbeziehung in Grails? Bis jetzt meine User-Klasse hatte viele AnhängerWie man einen Freund - Freundschaftsbeziehung in Grails modelliert
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
}
}
Aber ich möchte folgendes ändern: User für so etwas wie Freundschaften: Freundschaft und erstellen Sie eine Freundschaft Klasse wie folgt:
class Friendship {
static belongsTo= [user:User]
User friend2
boolean areFriends
}
Ist dies eine ideale Implementierung?
Wie würden Sie den Handshake implementieren (eine ausstehende Freundschaft annehmen/ablehnen)?