service

package
v0.37.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2024 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAdminPermission

func CheckAdminPermission(ctx context.Context, userID int64, permissions ...types.Permission) bool

func CheckDeletedByURL

func CheckDeletedByURL(ctx context.Context, sourceURL string) bool

func Cleanup

func Cleanup(ctx context.Context) error

func CreateAdmin

func CreateAdmin(ctx context.Context, userID int64, permissions []types.Permission, grant int64, super bool) error

func CreateArtwork

func CreateArtwork(ctx context.Context, artwork *types.Artwork) (*types.Artwork, error)

func CreateCachedArtwork

func CreateCachedArtwork(ctx context.Context, artwork *types.Artwork, status types.ArtworkStatus) error

func CreateCallbackData

func CreateCallbackData(ctx context.Context, data string) (id string, err error)

func CreateFavorite

func CreateFavorite(ctx context.Context, userID, artworkID primitive.ObjectID) (*model.FavoriteModel, error)

func CreateLike

func CreateLike(ctx context.Context, userID, artworkID primitive.ObjectID) error

func CreateOrUpdateAdmin

func CreateOrUpdateAdmin(ctx context.Context, userID int64, permissions []types.Permission, grant int64, super bool) error

func CreateUnauthUser

func CreateUnauthUser(ctx context.Context, user *model.UnauthUserModel) (*model.UnauthUserModel, error)

func CreateUser

func CreateUser(ctx context.Context, user *model.UserModel) (*model.UserModel, error)

func DeleteAdmin

func DeleteAdmin(ctx context.Context, userID int64) error

func DeleteArtworkByID

func DeleteArtworkByID(ctx context.Context, id primitive.ObjectID) error

func DeleteArtworkByURL

func DeleteArtworkByURL(ctx context.Context, sourceURL string) error

func DeleteCachedArtworkPicture

func DeleteCachedArtworkPicture(ctx context.Context, cachedArtwork *model.CachedArtworksModel, pictureIndex int) error

func DeleteDeletedByURL

func DeleteDeletedByURL(ctx context.Context, sourceURL string) error

func DeleteEtcData

func DeleteEtcData(ctx context.Context, key string) (*mongo.DeleteResult, error)

func DeleteFavorite

func DeleteFavorite(ctx context.Context, userID, artworkID primitive.ObjectID) error

func DeletePictureByID

func DeletePictureByID(ctx context.Context, id primitive.ObjectID) error

删除单张图片, 如果删除后对应的 artwork 中没有图片, 则也删除 artwork

删除后对 artwork 的 pictures 的 index 进行重整

func DeletePictureByMessageID deprecated

func DeletePictureByMessageID(ctx context.Context, messageID int) error

通过消息删除 Picture

如果删除后 Artwork 中没有 Picture , 则也删除 Artwork

不会对存储进行操作

Deprecated: MessageID 现在不唯一且可能为 0

func DeleteUnauthUser

func DeleteUnauthUser(ctx context.Context, id primitive.ObjectID) error

func FixTwitterArtists

func FixTwitterArtists(ctx context.Context, bot *telego.Bot, message *telego.Message)

func GetAdminByUserID

func GetAdminByUserID(ctx context.Context, userID int64) (*model.AdminModel, error)

func GetAdminGroupIDs

func GetAdminGroupIDs(ctx context.Context) ([]int64, error)

func GetAdminUserIDs

func GetAdminUserIDs(ctx context.Context) ([]int64, error)

func GetArtistByID

func GetArtistByID(ctx context.Context, artistID primitive.ObjectID) (*types.Artist, error)

func GetArtistByUID

func GetArtistByUID(ctx context.Context, uid string, sourceType types.SourceType) (*types.Artist, error)

func GetArtworkByID

func GetArtworkByID(ctx context.Context, id primitive.ObjectID, opts ...*adapter.AdapterOption) (*types.Artwork, error)

func GetArtworkByMessageID deprecated

func GetArtworkByMessageID(ctx context.Context, messageID int, opts ...*adapter.AdapterOption) (*types.Artwork, error)

Deprecated: MessageID 现在可能为 0

func GetArtworkByURL

func GetArtworkByURL(ctx context.Context, sourceURL string, opts ...*adapter.AdapterOption) (*types.Artwork, error)

func GetArtworkCount

func GetArtworkCount(ctx context.Context, r18 types.R18Type) (int64, error)

func GetArtworkIDByPicture

func GetArtworkIDByPicture(ctx context.Context, picture *types.Picture) (primitive.ObjectID, error)

func GetArtworksByArtistID

func GetArtworksByArtistID(ctx context.Context, artistID primitive.ObjectID, r18 types.R18Type, page, pageSize int64, convertOpts ...*adapter.AdapterOption) ([]*types.Artwork, error)

func GetArtworksByTags

func GetArtworksByTags(ctx context.Context, tags [][]string, r18 types.R18Type, page, pageSize int64, convertOpts ...*adapter.AdapterOption) ([]*types.Artwork, error)

通过标签获取作品, 标签名使用全字匹配

tags: 二维数组, tags = [["tag1", "tag2"], ["tag3", "tag4"]] 表示 (tag1 || tag2) && (tag3 || tag4)

func GetCachedArtworkByURL

func GetCachedArtworkByURL(ctx context.Context, sourceURL string) (*model.CachedArtworksModel, error)

func GetCachedArtworkByURLWithCache

func GetCachedArtworkByURLWithCache(ctx context.Context, sourceURL string) (*model.CachedArtworksModel, error)

GetCachedArtworkByURLWithCache get cached artwork by sourceURL, if not exist, fetch from source and cache it

func GetCallbackDataByID

func GetCallbackDataByID(ctx context.Context, id string) (string, error)

func GetDatabaseStats

func GetDatabaseStats(ctx context.Context) (*stats, error)

func GetDeletedByURL

func GetDeletedByURL(ctx context.Context, sourceURL string) (*model.DeletedModel, error)

func GetEtcData

func GetEtcData(ctx context.Context, key string) any

func GetFavorite

func GetFavorite(ctx context.Context, userID, artworkID primitive.ObjectID) (*model.FavoriteModel, error)

func GetLatestArtworks

func GetLatestArtworks(ctx context.Context, r18 types.R18Type, page, pageSize int64, convertOpts ...*adapter.AdapterOption) ([]*types.Artwork, error)

func GetPictureByID

func GetPictureByID(ctx context.Context, id primitive.ObjectID) (*types.Picture, error)

func GetPictureByMessageID deprecated

func GetPictureByMessageID(ctx context.Context, messageID int) (*types.Picture, error)

Deprecated: MessageID 现在可能为 0

func GetPicturesByHashHammingDistance

func GetPicturesByHashHammingDistance(ctx context.Context, hash string, distance int) ([]*types.Picture, error)

func GetRandomArtworks

func GetRandomArtworks(ctx context.Context, r18 types.R18Type, limit int, convertOpts ...*adapter.AdapterOption) ([]*types.Artwork, error)

func GetRandomTagModels

func GetRandomTagModels(ctx context.Context, limit int) ([]*model.TagModel, error)

func GetRandomTags

func GetRandomTags(ctx context.Context, limit int) ([]string, error)

func GetUnauthUserByID

func GetUnauthUserByID(ctx context.Context, id primitive.ObjectID) (*model.UnauthUserModel, error)

func GetUnauthUserByUsername

func GetUnauthUserByUsername(ctx context.Context, username string) (*model.UnauthUserModel, error)

func GetUserByEmail

func GetUserByEmail(ctx context.Context, email string) (*model.UserModel, error)

func GetUserByID

func GetUserByID(ctx context.Context, id primitive.ObjectID) (*model.UserModel, error)

func GetUserByTelegramID

func GetUserByTelegramID(ctx context.Context, telegramID int64) (*model.UserModel, error)

func GetUserByUsername

func GetUserByUsername(ctx context.Context, username string) (*model.UserModel, error)

func IsAdmin

func IsAdmin(ctx context.Context, userID int64) (bool, error)

func ProcessPictureHashAndSizeAndUpdate

func ProcessPictureHashAndSizeAndUpdate(ctx context.Context, picture *types.Picture) error

func ProcessPicturesHashAndSizeAndUpdate

func ProcessPicturesHashAndSizeAndUpdate(ctx context.Context, bot *telego.Bot, message *telego.Message)

func QueryArtworksByTexts

func QueryArtworksByTexts(ctx context.Context, texts [][]string, r18 types.R18Type, limit int, convertOpts ...*adapter.AdapterOption) ([]*types.Artwork, error)

使用tag名, 标题, 描述, 作者名, 作者用户名 综合查询

对于每个关键词, 只要tag名, 标题, 描述, 作者名, 作者用户名中有一个匹配即认为匹配成功

关键词二维数组中, 每个一维数组中的关键词之间是或的关系, 不同一维数组中的关键词之间是与的关系

func QueryArtworksByTextsPage

func QueryArtworksByTextsPage(ctx context.Context, texts [][]string, r18 types.R18Type, page, pageSize int64, convertOpts ...*adapter.AdapterOption) ([]*types.Artwork, error)

func SetEtcData

func SetEtcData(ctx context.Context, key string, value interface{}) (*mongo.UpdateResult, error)

func StoragePictureRegularAndThumbAndUpdate

func StoragePictureRegularAndThumbAndUpdate(ctx context.Context, picture *model.PictureModel) error

func StoragePicturesRegularAndThumbAndUpdate

func StoragePicturesRegularAndThumbAndUpdate(ctx context.Context, bot *telego.Bot, message *telego.Message)

func TidyArtist

func TidyArtist(ctx context.Context)

func TidyArtworkPictureIndexByID

func TidyArtworkPictureIndexByID(ctx context.Context, artworkID primitive.ObjectID) error

用于删除图片后重整 artwork 的 picture 的 index

func UpdateArtworkR18ByID

func UpdateArtworkR18ByID(ctx context.Context, id primitive.ObjectID, r18 bool) error

func UpdateArtworkR18ByURL

func UpdateArtworkR18ByURL(ctx context.Context, sourceURL string, r18 bool) error

func UpdateArtworkTagsByURL

func UpdateArtworkTagsByURL(ctx context.Context, sourceURL string, tags []string) error

func UpdateArtworkTitleByURL

func UpdateArtworkTitleByURL(ctx context.Context, sourceURL, title string) error

func UpdateCachedArtwork

func UpdateCachedArtwork(ctx context.Context, artwork *model.CachedArtworksModel) error

func UpdateCachedArtworkStatusByURL

func UpdateCachedArtworkStatusByURL(ctx context.Context, sourceURL string, status types.ArtworkStatus) error

func UpdatePictureTelegramInfo

func UpdatePictureTelegramInfo(ctx context.Context, picture *types.Picture, telegramInfo *types.TelegramInfo) error

func UpdateUserSettings

func UpdateUserSettings(ctx context.Context, id primitive.ObjectID, settings *model.UserSettings) (*model.UserSettings, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL