Documentation ¶
Index ¶
- Constants
- type Authorization
- type ConversionPayLoad
- type Images
- type Interface
- type Service
- func (s *Service) Conversion(ctx context.Context, payload ConversionPayLoad) (string, error)
- func (s *Service) ConvertToType(sourceImage io.ReadSeeker, targetFormat string, ratio int) (io.ReadSeeker, error)
- func (s *Service) CreateUser(ctx context.Context, user models.User) (id int, err error)
- func (s *Service) DownloadImageFromID(fileID string) (string, error)
- func (s *Service) GenerateToken(ctx context.Context, email, password string) (string, error)
- func (s *Service) GetImageByID(ctx context.Context, id string) (models.Images, error)
- func (s *Service) GetRequestFromID(ctx context.Context, userID int) ([]models.Request, error)
- func (s *Service) InsertImage(ctx context.Context, filename, format string) (string, error)
- func (s *Service) ParseToken(accessToken string) (int, error)
- func (s *Service) RequestsHistory(ctx context.Context, sourceFormat, targetFormat, imageID, filename string, ...) (string, error)
- func (s *Service) UpdateRequest(ctx context.Context, status, imageID, targetID string) error
Constants ¶
const ( // JPG is for validation jpg image. JPG = "jpg" // PNG is for validation png image. PNG = "png" // JPEG is for validation jpeg image. JPEG = "jpeg" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authorization ¶
type Authorization interface { CreateUser(ctx context.Context, user models.User) (int, error) GenerateToken(ctx context.Context, email, password string) (string, error) ParseToken(accessToken string) (int, error) }
Authorization contains methods for authorization of a user.
type ConversionPayLoad ¶
type ConversionPayLoad struct { SourceFormat string TargetFormat string Filename string Ratio int File multipart.File UsersID int }
ConversionPayLoad is payload for Conversion.
type Images ¶
type Images interface { InsertImage(ctx context.Context, filename, format string) (string, error) RequestsHistory(ctx context.Context, sourceFormat, targetFormat, imageID, filename string, userID, ratio int) (string, error) GetRequestFromID(ctx context.Context, userID int) ([]models.Request, error) UpdateRequest(ctx context.Context, status, imageID, targetID string) error GetImageByID(ctx context.Context, id string) (models.Images, error) Conversion(ctx context.Context, payload ConversionPayLoad) (string, error) DownloadImageFromID(fileID string) (string, error) }
Images contains methods for images.
type Interface ¶
type Interface interface { Authorization Images }
Interface holds Authorization and Images interfaces.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service contains repository and storages interfaces.
func New ¶
func New(repo repository.RepoInterface, storages storage.StoragesInterface) *Service
New is constructor for Service.
func (*Service) Conversion ¶
Conversion func is for all conversion logic.
func (*Service) ConvertToType ¶
func (s *Service) ConvertToType(sourceImage io.ReadSeeker, targetFormat string, ratio int) (io.ReadSeeker, error)
ConvertToType converts JPG to PNG image and vice versa and compress images with the compression ratio specified by the user.
func (*Service) CreateUser ¶
CreateUser method creates user.
func (*Service) DownloadImageFromID ¶
DownloadImageFromID downloads image from id of it.
func (*Service) GenerateToken ¶
GenerateToken generates jwt token for user.
func (*Service) GetImageByID ¶
GetImageByID get information of image by id.
func (*Service) GetRequestFromID ¶
GetRequestFromID gets request from user id.
func (*Service) InsertImage ¶
InsertImage inserts image information to database.
func (*Service) ParseToken ¶
ParseToken parses token.