38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
|
package entity
|
||
|
|
||
|
import (
|
||
|
"time"
|
||
|
|
||
|
"go.mongodb.org/mongo-driver/v2/bson"
|
||
|
)
|
||
|
|
||
|
// UserRole 用戶角色關聯實體
|
||
|
type UserRole struct {
|
||
|
ID bson.ObjectID `bson:"_id,omitempty" json:"id"`
|
||
|
Brand string `bson:"brand" json:"brand"`
|
||
|
UID string `bson:"uid" json:"uid"`
|
||
|
RoleUID string `bson:"role_uid" json:"role_uid"`
|
||
|
Status int `bson:"status" json:"status"`
|
||
|
CreateTime time.Time `bson:"create_time" json:"create_time"`
|
||
|
UpdateTime time.Time `bson:"update_time" json:"update_time"`
|
||
|
}
|
||
|
|
||
|
// CollectionName 返回集合名稱
|
||
|
func (ur *UserRole) CollectionName() string {
|
||
|
return "user_roles"
|
||
|
}
|
||
|
|
||
|
//// Validate 驗證用戶角色關聯數據
|
||
|
//func (ur *UserRole) Validate() error {
|
||
|
// if ur.Brand == "" {
|
||
|
// return mongo.WriteError{Code: 400, Message: "brand is required"}
|
||
|
// }
|
||
|
// if ur.UID == "" {
|
||
|
// return mongo.WriteError{Code: 400, Message: "uid is required"}
|
||
|
// }
|
||
|
// if ur.RoleUID == "" {
|
||
|
// return mongo.WriteError{Code: 400, Message: "role_uid is required"}
|
||
|
// }
|
||
|
// return nil
|
||
|
//}
|