0
您将如何建模Grails中的朋友关系?到现在为止我的User类有许多追随者如何建模朋友 - Grails中的友谊关系
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
}
这是一个理想的实现?
您将如何实施握手(接受/拒绝待定的友谊)?