复制项目

This commit is contained in:
kim.dev.6789
2026-01-14 22:35:45 +08:00
parent 305d526110
commit b7f8db7d08
297 changed files with 81784 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
// Copyright © 2023 OpenIM open source community. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package chat
import (
"context"
"time"
"github.com/openimsdk/tools/db/pagination"
)
// FavoriteType 收藏类型
const (
FavoriteTypeText = 1 // 文本
FavoriteTypeImage = 2 // 图片
FavoriteTypeLink = 3 // 链接
FavoriteTypeFile = 4 // 文件
FavoriteTypeVoice = 5 // 语音
FavoriteTypeVideo = 6 // 视频
FavoriteTypeLocation = 7 // 位置
)
type Favorite struct {
ID string `bson:"_id"` // 收藏IDMongoDB ObjectID
UserID string `bson:"user_id"` // 用户ID收藏者
Type int32 `bson:"type"` // 收藏类型1-文本2-图片3-链接4-文件5-语音6-视频7-位置
Title string `bson:"title"` // 标题(可选)
Content string `bson:"content"` // 内容根据类型不同可能是文本、图片URL、链接URL、文件路径等
Description string `bson:"description"` // 摘要/描述(可选)
Thumbnail string `bson:"thumbnail"` // 缩略图URL用于图片、视频、链接等
LinkURL string `bson:"link_url"` // 链接URL用于链接类型
FileSize int64 `bson:"file_size"` // 文件大小(字节,用于文件、语音、视频等)
Duration int32 `bson:"duration"` // 时长(秒,用于语音、视频等)
Location string `bson:"location"` // 位置信息JSON格式用于位置类型
Tags []string `bson:"tags"` // 标签列表
Remark string `bson:"remark"` // 备注(可选)
Status int32 `bson:"status"` // 状态0-已删除1-正常
CreateTime time.Time `bson:"create_time"` // 创建时间
UpdateTime time.Time `bson:"update_time"` // 更新时间
}
func (Favorite) TableName() string {
return "favorites"
}
type FavoriteInterface interface {
Create(ctx context.Context, favorites ...*Favorite) error
Take(ctx context.Context, favoriteID string) (*Favorite, error)
FindByUserID(ctx context.Context, userID string, pagination pagination.Pagination) (int64, []*Favorite, error)
FindByUserIDAndType(ctx context.Context, userID string, favoriteType int32, pagination pagination.Pagination) (int64, []*Favorite, error)
SearchByKeyword(ctx context.Context, userID string, keyword string, pagination pagination.Pagination) (int64, []*Favorite, error)
Update(ctx context.Context, favoriteID string, data map[string]any) error
Delete(ctx context.Context, favoriteIDs []string) error
DeleteByUserID(ctx context.Context, userID string) error
CountByUserID(ctx context.Context, userID string) (int64, error)
FindByTags(ctx context.Context, userID string, tags []string, pagination pagination.Pagination) (int64, []*Favorite, error)
}