service

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: AGPL-3.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefault

func SetDefault(s *Service)

func WithContext

func WithContext(ctx context.Context, serv *Service) context.Context

Types

type Option

type Option func(*Service)

type Service

type Service struct {
	// contains filtered or unexported fields
}

func Default

func Default() *Service

func FromContext

func FromContext(ctx context.Context) *Service

func NewService

func NewService(
	repos repo.Repositories,
	searcher search.Searcher,
	tagger tagging.Tagger,
	storageMap map[shared.StorageType]storage.Storage,
	sourceMap map[shared.SourceType]source.ArtworkSource,
	storCfg runtimecfg.StorageConfig,
	opts ...Option,
) *Service

func (*Service) AddApiKeyQuota

func (s *Service) AddApiKeyQuota(ctx context.Context, key string, quota int) error

func (*Service) AddTagAlias

func (s *Service) AddTagAlias(ctx context.Context, tagID ouid.OUID, alias []string) (*entity.Tag, error)

为已有 tag 添加别名

同时检查是否有其他 tag 的 name 为所指定的别名之一, 在添加完成后, 删除这些 tag, 并将其对应的 artwork 添加这个新的 tag (即传入的tagID)

func (*Service) CancelDeletedByURL

func (s *Service) CancelDeletedByURL(ctx context.Context, sourceURL string) error

func (*Service) CheckAdminPermissionByTgID

func (s *Service) CheckAdminPermissionByTgID(ctx context.Context, userID int64, permissions ...shared.Permission) bool

func (*Service) CheckDeletedByURL

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

func (*Service) Cleanup

func (s *Service) Cleanup(ctx context.Context) error

func (*Service) CountArtworks

func (s *Service) CountArtworks(ctx context.Context, r18 shared.R18Type) (int64, error)

func (*Service) CreateAdmin

func (s *Service) CreateAdmin(ctx context.Context, tgID int64, permissions []shared.Permission) error

func (*Service) CreateApiKey

func (s *Service) CreateApiKey(ctx context.Context, key string, quota int, permissions []shared.Permission, description string) (*entity.ApiKey, error)

func (*Service) CreateArtwork

func (s *Service) CreateArtwork(ctx context.Context, cmd *command.ArtworkCreation) (*entity.Artwork, error)

func (*Service) CreateCachedArtwork

func (s *Service) CreateCachedArtwork(ctx context.Context, ent *entity.CachedArtwork) (*entity.CachedArtwork, error)

func (*Service) CreateOrUpdateAdmin

func (s *Service) CreateOrUpdateAdmin(ctx context.Context, tgid int64, permissions []shared.Permission) error

func (*Service) DeleteAdminByTgID

func (s *Service) DeleteAdminByTgID(ctx context.Context, tgid int64) error

func (*Service) DeleteApiKey

func (s *Service) DeleteApiKey(ctx context.Context, key string) error

func (*Service) DeleteArtworkByID

func (s *Service) DeleteArtworkByID(ctx context.Context, id ouid.OUID) error

func (*Service) DeleteArtworkByURL

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

func (*Service) DeleteCachedArtworkByURL

func (s *Service) DeleteCachedArtworkByURL(ctx context.Context, sourceURL string) error

func (*Service) DeletePictureByID

func (s *Service) DeletePictureByID(ctx context.Context, id ouid.OUID) error

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

删除后对 artwork 的 pictures 的 index 进行重整, 并在 cached_artwork 中将对应的图片标记为隐藏

func (*Service) FetchArtworkInfo

func (s *Service) FetchArtworkInfo(ctx context.Context, sourceURL string) (*dto.FetchedArtwork, error)

func (*Service) FindSimilarArtworks

func (s *Service) FindSimilarArtworks(ctx context.Context, que *query.ArtworkSimilar) ([]*entity.Artwork, error)

func (*Service) FindSourceURL

func (s *Service) FindSourceURL(text string) string

func (*Service) GetAdminByTelegramID

func (s *Service) GetAdminByTelegramID(ctx context.Context, tgid int64) (*entity.Admin, error)

func (*Service) GetAdminGroupIDs

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

func (*Service) GetAdminUserIDs

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

func (*Service) GetApiKeyByKey

func (s *Service) GetApiKeyByKey(ctx context.Context, key string) (*entity.ApiKey, error)

func (*Service) GetArtistByID

func (s *Service) GetArtistByID(ctx context.Context, id ouid.OUID) (*entity.Artist, error)

func (*Service) GetArtworkByID

func (s *Service) GetArtworkByID(ctx context.Context, id ouid.OUID) (*entity.Artwork, error)

func (*Service) GetArtworkByURL

func (s *Service) GetArtworkByURL(ctx context.Context, sourceURL string) (*entity.Artwork, error)

func (*Service) GetCachedArtworkByURL

func (s *Service) GetCachedArtworkByURL(ctx context.Context, sourceURL string) (*entity.CachedArtwork, error)

func (*Service) GetDeletedByURL

func (s *Service) GetDeletedByURL(ctx context.Context, sourceURL string) (*entity.DeletedRecord, error)

func (*Service) GetOrFetchCachedArtwork

func (s *Service) GetOrFetchCachedArtwork(ctx context.Context, sourceURL string) (*entity.CachedArtwork, error)

func (*Service) GetPictureByID

func (s *Service) GetPictureByID(ctx context.Context, id ouid.OUID) (*entity.Picture, error)

func (*Service) GetTagByName

func (s *Service) GetTagByName(ctx context.Context, name string) (*entity.Tag, error)

func (*Service) GetTagByNameWithAlias

func (s *Service) GetTagByNameWithAlias(ctx context.Context, name string) (*entity.Tag, error)

func (*Service) HideCachedArtworkPicture

func (s *Service) HideCachedArtworkPicture(ctx context.Context, cachedArt *entity.CachedArtwork, picIndex int) error

func (*Service) IncreaseApiKeyUsed

func (s *Service) IncreaseApiKeyUsed(ctx context.Context, key string) error

func (*Service) IsAdminByTgID

func (s *Service) IsAdminByTgID(ctx context.Context, tgid int64) (bool, error)

func (*Service) PredictAndUpdateArtworkTags

func (s *Service) PredictAndUpdateArtworkTags(ctx context.Context, artworkID ouid.OUID) error

func (*Service) PrettyFileName

func (s *Service) PrettyFileName(artwork shared.ArtworkLike, picture shared.PictureLike) string

func (*Service) QueryArtworks

func (s *Service) QueryArtworks(ctx context.Context, que query.ArtworksDB) ([]*entity.Artwork, error)

func (*Service) QueryPicturesByPhash

func (s *Service) QueryPicturesByPhash(ctx context.Context, que query.PicturesPhash) ([]*entity.Picture, error)

func (*Service) RandomPictures

func (s *Service) RandomPictures(ctx context.Context, limit int) ([]*entity.Picture, error)

func (*Service) RandomTags

func (s *Service) RandomTags(ctx context.Context, limit int) ([]*entity.Tag, error)

func (*Service) ReIndexArtworks added in v1.6.0

func (s *Service) ReIndexArtworks(ctx context.Context, ids []ouid.OUID) error

func (*Service) SavePicture

func (s *Service) SavePicture(ctx context.Context, pic *entity.Picture) error

only used for updates, do not use for create

func (*Service) SearchArtworks

func (s *Service) SearchArtworks(ctx context.Context, que *query.ArtworkSearch) ([]*entity.Artwork, error)

func (*Service) ShouldTagNewArtwork

func (s *Service) ShouldTagNewArtwork() bool

func (*Service) Source

func (s *Service) Source(sourceType shared.SourceType) source.ArtworkSource

func (*Service) Sources

func (s *Service) Sources() map[shared.SourceType]source.ArtworkSource

func (*Service) StorageDelete

func (s *Service) StorageDelete(ctx context.Context, detail shared.StorageDetail) error

func (*Service) StorageDeleteArtworkFiles added in v1.5.0

func (s *Service) StorageDeleteArtworkFiles(ctx context.Context, artwork *entity.Artwork) error

删除作品的全部文件, 用于删除作品后调用

func (*Service) StorageDeleteByInfo

func (s *Service) StorageDeleteByInfo(ctx context.Context, info shared.StorageInfo) error

func (*Service) StorageGetFile

func (s *Service) StorageGetFile(ctx context.Context, detail shared.StorageDetail) (*osutil.File, error)

func (*Service) StorageSaveAllSize

func (s *Service) StorageSaveAllSize(ctx context.Context, inputPath, storDirPath, fileName string) (*shared.StorageInfo, error)

func (*Service) StorageSaveOriginal

func (s *Service) StorageSaveOriginal(ctx context.Context, file io.Reader, storDirPath, fileName string) (*shared.StorageDetail, error)

func (*Service) StorageStreamFile

func (s *Service) StorageStreamFile(ctx context.Context, detail shared.StorageDetail, w io.Writer) error

func (*Service) Tagger

func (s *Service) Tagger() tagging.Tagger

func (*Service) UpdateArtworkR18ByID

func (s *Service) UpdateArtworkR18ByID(ctx context.Context, id ouid.OUID, r18 bool) error

func (*Service) UpdateArtworkR18ByURL

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

func (*Service) UpdateArtworkTagsByURL

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

func (*Service) UpdateArtworkTitleByURL

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

func (*Service) UpdateCachedArtwork

func (s *Service) UpdateCachedArtwork(ctx context.Context, data *entity.CachedArtworkData) error

func (*Service) UpdateCachedArtworkStatusByURL

func (s *Service) UpdateCachedArtworkStatusByURL(ctx context.Context, sourceURL string, status shared.ArtworkStatus) error

func (*Service) UpdatePictureTelegramInfo

func (s *Service) UpdatePictureTelegramInfo(ctx context.Context, id ouid.OUID, tgInfo *shared.TelegramInfo) error

func (*Service) UpdateUgoiraTelegramInfo

func (s *Service) UpdateUgoiraTelegramInfo(ctx context.Context, id ouid.OUID, tgInfo *shared.TelegramInfo) error

func (*Service) UpdateVideoTelegramInfo added in v1.5.0

func (s *Service) UpdateVideoTelegramInfo(ctx context.Context, id ouid.OUID, tgInfo *shared.TelegramInfo) error

Jump to

Keyboard shortcuts

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