feat(contact): Contact 模型、DAO、常量与 DTO

- model/friendship.go: 好友关系模型(双向存储,4 种状态)
- model/friend_group.go: 好友分组模型
- constants/contact.go: 好友关系状态常量
- dto/contact_dto.go: 联系人请求/响应 DTO
- dao/friendship_dao.go: 好友关系 CRUD + 搜索 + 共同好友
- dao/friend_group_dao.go: 好友分组 CRUD + 移动好友

Made-with: Cursor
This commit is contained in:
bujinyuan
2026-03-02 17:03:13 +08:00
parent bfb4fb0ccb
commit d4ab5af34e
6 changed files with 594 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
package model
import "time"
// FriendGroup 好友分组模型,对应 contact_groups 表
type FriendGroup struct {
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"` // 分组唯一标识
UserID int64 `gorm:"not null;index:idx_contact_groups_user" json:"user_id"` // 所属用户 ID
Name string `gorm:"size:50;not null" json:"name"` // 分组名称
SortOrder int `gorm:"not null;default:0" json:"sort_order"` // 排序权重,越小越靠前
CreatedAt time.Time `gorm:"not null;autoCreateTime" json:"created_at"` // 创建时间
}
func (FriendGroup) TableName() string {
return "contact_groups"
}

View File

@@ -0,0 +1,21 @@
package model
import "time"
// Friendship 好友关系模型,对应 contact_friendships 表
// 双向存储A→B 和 B→A 各一条记录
type Friendship struct {
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"` // 记录唯一标识
UserID int64 `gorm:"not null;index:idx_friendships_user_status" json:"user_id"` // 发起方用户 ID
FriendID int64 `gorm:"not null;index:idx_friendships_friend_status" json:"friend_id"` // 好友用户 ID
Remark string `gorm:"size:50;default:''" json:"remark"` // 好友备注名
GroupID *int64 `gorm:"default:null" json:"group_id"` // 所属好友分组 ID
Status int `gorm:"not null;default:0;index:idx_friendships_user_status" json:"status"` // 状态0=待确认1=已接受2=已拒绝3=已拉黑
Message string `gorm:"size:200;default:''" json:"message"` // 好友申请附言
CreatedAt time.Time `gorm:"not null;autoCreateTime" json:"created_at"` // 创建时间
UpdatedAt time.Time `gorm:"not null;autoUpdateTime" json:"updated_at"` // 更新时间
}
func (Friendship) TableName() string {
return "contact_friendships"
}