services

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddToBlacklist

func AddToBlacklist(db *gorm.DB, token string, expiration time.Time) error

AddToBlacklist

func CleanupBlacklist

func CleanupBlacklist(db *gorm.DB) error

CleanupBlacklist

func GetFileType

func GetFileType(File *multipart.FileHeader) (string, string, error)

func GetImageDimensions

func GetImageDimensions(File *multipart.FileHeader) (string, int, int, error)

func GetThumbnails

func GetThumbnails(dateDir, fileUUID string, maxThumbSize uint, MimeType string, File *multipart.FileHeader, ostorage storage.Storage) (string, int, int, int64, error)

func IsInBlacklist

func IsInBlacklist(db *gorm.DB, token string) (bool, error)

IsInBlacklist

Types

type AlbumResponse

type AlbumResponse struct {
	ID             uint      `json:"id"`
	UserID         uint      `json:"user_id"`
	Name           string    `json:"name"`
	Description    string    `json:"description"`
	CoverImage     string    `json:"cover_image"`
	ImageCount     int       `json:"image_count"`
	GalleryEnabled bool      `json:"gallery_enabled"`
	SerialNumber   int       `json:"serial_number"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

type AlbumService

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

func NewAlbumService

func NewAlbumService(db *gorm.DB) *AlbumService

func (*AlbumService) CreateAlbum

func (s *AlbumService) CreateAlbum(name string, description string, galleryEnabled bool, userID uint, serialNumber int) (*AlbumResponse, error)

func (*AlbumService) DeleteAlbum

func (s *AlbumService) DeleteAlbum(id uint, userID uint) error

func (*AlbumService) GetAlbum

func (s *AlbumService) GetAlbum(id uint, userID uint) (*AlbumResponse, error)

func (*AlbumService) GetAlbumImages

func (s *AlbumService) GetAlbumImages(id uint, userID uint, page, pageSize, offset int) (*GetAlbumImagesResponse, error)

func (*AlbumService) GetAlbums

func (s *AlbumService) GetAlbums(userID uint, page, pageSize, offset int) (*GetAlbumsResponse, error)

func (*AlbumService) GetNotInAnyAlbum

func (s *AlbumService) GetNotInAnyAlbum(userID uint, page, pageSize, offset int) (*GetAlbumImagesResponse, error)

func (*AlbumService) UpdateAlbum

func (s *AlbumService) UpdateAlbum(id uint, userID uint, name string, description string, galleryEnabled bool, serialNumber int) (*AlbumResponse, error)

type AuthService

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

func NewAuthService

func NewAuthService(db *gorm.DB, mailService *mail.MailService, cfg *config.Config) *AuthService

func (*AuthService) Login

func (s *AuthService) Login(username, password string, jwtCfg *config.JWTConfig) (*LoginResponse, error)

func (*AuthService) Logout

func (s *AuthService) Logout(refreshToken string, jwtCfg *config.JWTConfig) error

Logout 用户登出

func (*AuthService) RefreshToken

func (s *AuthService) RefreshToken(refreshToken string, jwtCfg *config.JWTConfig) (*TokenResponse, error)

func (*AuthService) Register

func (s *AuthService) Register(username, password, email, locale string) (string, error)

func (*AuthService) RequestPasswordReset

func (s *AuthService) RequestPasswordReset(email, locale string) error

func (*AuthService) ResetPassword

func (s *AuthService) ResetPassword(email, code, newPassword string) error

func (*AuthService) VerifyEmail

func (s *AuthService) VerifyEmail(token string) error

func (*AuthService) VerifyPasswordResetCode

func (s *AuthService) VerifyPasswordResetCode(email, code string) error

type GalleryImageResponse

type GalleryImageResponse struct {
	FileName        string   `json:"file_name"`
	OriginalName    string   `json:"original_name"`
	Tags            []string `json:"tags" gorm:"serializer:json"`
	FileURL         string   `json:"file_url"`
	FileSize        int64    `json:"file_size"`
	Width           int      `json:"width"`
	Height          int      `json:"height"`
	ThumbnailURL    string   `json:"thumbnail_url"`
	ThumbnailSize   int64    `json:"thumbnail_size"`
	ThumbnailWidth  int      `json:"thumbnail_width"`
	ThumbnailHeight int      `json:"thumbnail_height"`
	MimeType        string   `json:"mime_type"`
}

type GalleryService

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

func NewGalleryService

func NewGalleryService(db *gorm.DB) *GalleryService

func (*GalleryService) GetGallery

func (s *GalleryService) GetGallery(currentUserID uint) (*GetAlbumsResponse, error)

func (*GalleryService) GetGalleryImages

func (s *GalleryService) GetGalleryImages(currentUserID uint, albumID uint, page, pageSize, offset int) (*GetGalleryImagesResponse, error)

func (*GalleryService) SearchGalleryImages

func (s *GalleryService) SearchGalleryImages(currentUserID uint, query string, page, pageSize, offset int) (*GetGalleryImagesResponse, error)

type GetAlbumImagesResponse

type GetAlbumImagesResponse struct {
	Images   []ImageResponse `json:"images"`
	Total    int64           `json:"total"`
	Page     int             `json:"page"`
	PageSize int             `json:"page_size"`
}

type GetAlbumsResponse

type GetAlbumsResponse struct {
	Albums   []AlbumResponse `json:"albums"`
	Total    int64           `json:"total"`
	Page     int             `json:"page"`
	PageSize int             `json:"page_size"`
}

type GetGalleryImagesResponse

type GetGalleryImagesResponse struct {
	Images   []GalleryImageResponse `json:"images"`
	Total    int64                  `json:"total"`
	Page     int                    `json:"page"`
	PageSize int                    `json:"page_size"`
}

type GetImagesResponse

type GetImagesResponse struct {
	Images   []ImageResponse `json:"images"`
	Total    int64           `json:"total"`
	Page     int             `json:"page"`
	PageSize int             `json:"page_size"`
}

type ImageResponse

type ImageResponse struct {
	ID              uint            `json:"id"`
	FileName        string          `json:"file_name"`
	OriginalName    string          `json:"original_name"`
	Tags            []string        `json:"tags" gorm:"serializer:json"`
	FileURL         string          `json:"file_url"`
	FileSize        int64           `json:"file_size"`
	Width           int             `json:"width"`
	Height          int             `json:"height"`
	ThumbnailURL    string          `json:"thumbnail_url"`
	ThumbnailSize   int64           `json:"thumbnail_size"`
	ThumbnailWidth  int             `json:"thumbnail_width"`
	ThumbnailHeight int             `json:"thumbnail_height"`
	CreatedAt       time.Time       `json:"created_at"`
	UpdatedAt       time.Time       `json:"updated_at"`
	MimeType        string          `json:"mime_type"`
	UserID          uint            `json:"user_id"`
	Albums          []AlbumResponse `json:"albums"`
	StorageName     string          `json:"storage_name"`
}

func MakeImageWithAlbum

func MakeImageWithAlbum(imageModel models.Image) ImageResponse

func MakeImagesWithAlbum

func MakeImagesWithAlbum(imageModels []models.Image) []ImageResponse

type ImageService

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

func NewImageService

func NewImageService(db *gorm.DB, cfg *config.Config) *ImageService

func (*ImageService) AddImageToAlbum

func (s *ImageService) AddImageToAlbum(currentUserID uint, imageID uint, albumID uint) error

func (*ImageService) DeleteImage

func (s *ImageService) DeleteImage(currentUserID uint, imageID uint) error

func (*ImageService) GetImage

func (s *ImageService) GetImage(currentUserID uint, imageID uint) (*ImageResponse, error)

func (*ImageService) GetImages

func (s *ImageService) GetImages(currentUserID uint, page int, pageSize int) (*GetImagesResponse, error)

func (*ImageService) RemoveImageFromAlbum

func (s *ImageService) RemoveImageFromAlbum(currentUserID uint, imageID uint, albumID uint) error

func (*ImageService) SearchImagesByTagsOrTitle

func (s *ImageService) SearchImagesByTagsOrTitle(currentUserID uint, searchKey string, page int, pageSize int) (*GetImagesResponse, error)

func (*ImageService) UpdateImage

func (s *ImageService) UpdateImage(currentUserID uint, imageID uint, originalName string, tags []string) (*ImageResponse, error)

func (*ImageService) UploadImage

func (s *ImageService) UploadImage(currentUserID uint, AlbumIDs []uint, tags []string, files []*multipart.FileHeader) error

func (*ImageService) UploadImageLimitCheck

func (s *ImageService) UploadImageLimitCheck(currentUserID uint, files []*multipart.FileHeader) error

type LoginResponse

type LoginResponse struct {
	User          models.User   `json:"user"`
	TokenResponse TokenResponse `json:"token_response"`
}

type StorageUsage

type StorageUsage struct {
	TotalSize  int64 `json:"total_size"`
	ImageCount int   `json:"image_count"`
}

type TagCloudItem

type TagCloudItem struct {
	Tag   string `json:"tag"`
	Count int    `json:"count"`
}

type TokenResponse

type TokenResponse struct {
	AccessToken      string `json:"access_token"`
	RefreshToken     string `json:"refresh_token"`
	ExpiresIn        int    `json:"expires_in"`
	RefreshExpiresIn int    `json:"refresh_expires_in"`
}

TokenResponse 令牌响应结构体

type UserService

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

func NewUserService

func NewUserService(db *gorm.DB, cfg *config.Config) *UserService

func (*UserService) GetImagesTagsCloud

func (s *UserService) GetImagesTagsCloud(userID uint) ([]TagCloudItem, error)

GetImagesTagsCloud 获取用户图片标签云

func (*UserService) GetMe

func (s *UserService) GetMe(currentUserID uint) (*models.User, error)

func (*UserService) GetStorageUsage

func (s *UserService) GetStorageUsage(userID uint) (*StorageUsage, error)

GetStorageUsage 获取用户存储空间使用情况

func (*UserService) UpdateMe

func (s *UserService) UpdateMe(currentUserID uint, username, password string) (*models.User, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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