fantahsea

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddDirGalleryImageEventBus = "fantahsea.dir.gallery.image.add"
	NotifyFileDeletedEventBus  = "fantahsea.notify.file.deleted"
)
View Source
const (
	NORMAL  ImgStatus = "NORMAL"
	DELETED ImgStatus = "DELETED"

	// 40mb is the maximum size for an image
	IMAGE_SIZE_THRESHOLD int64 = 40 * 1048576
)
View Source
const (
	ManageFileCode = "manage-files"
	ManageFileName = "Manage files"
)

Variables

This section is empty.

Functions

func BatchTransferAsync

func BatchTransferAsync(rail miso.Rail, cmd TransferGalleryImageReq, user common.User) (any, error)

func CreateGalleryAccess

func CreateGalleryAccess(userNo string, galleryNo string, operator string) error

Assign user access to the gallery

func CreateGalleryForDir

func CreateGalleryForDir(rail miso.Rail, cmd CreateGalleryForDirCmd) (string, error)

Create a new Gallery for dir

func CreateGalleryImage

func CreateGalleryImage(rail miso.Rail, cmd CreateGalleryImageCmd, userNo string, username string) error

Create a gallery image record

func DeleteGallery

func DeleteGallery(rail miso.Rail, cmd DeleteGalleryCmd, user common.User) error

Delete a gallery

func DeleteGalleryImage

func DeleteGalleryImage(rail miso.Rail, fileKey string) error

func DownloadFile

func DownloadFile(c miso.Rail, tmpToken string, absPath string) error

Download file from mini-fstore

func FindGalleryCreator

func FindGalleryCreator(rail miso.Rail, galleryNo string) (*string, error)

Find Gallery's creator by gallery_no

func GalleryExists

func GalleryExists(galleryNo string) (bool, error)

Check if the gallery exists

func GalleryNoOfDir

func GalleryNoOfDir(dirFileKey string) (string, error)

func GetFstoreTmpToken

func GetFstoreTmpToken(c miso.Rail, fileId string, filename string) (string, error)

func GrantGalleryAccessToUser

func GrantGalleryAccessToUser(rail miso.Rail, cmd PermitGalleryAccessCmd, user common.User) error

Grant user's access to the gallery, only the owner can do so

func GuessIsImage

func GuessIsImage(rail miso.Rail, f FileInfoResp) bool

Guess whether a file is an image

func HasAccessToGallery

func HasAccessToGallery(userNo string, galleryNo string) (bool, error)

Check if user has access to the gallery

func IsGalleryNameUsed

func IsGalleryNameUsed(name string, userNo string) (bool, error)

Check if the name is already used by current user

func ListOwnedGalleryBriefs

func ListOwnedGalleryBriefs(rail miso.Rail, user common.User) (*[]VGalleryBrief, error)

List owned gallery briefs

func OnCreateGalleryImgEvent

func OnCreateGalleryImgEvent(rail miso.Rail, evt CreateGalleryImgEvent) error

func OnNotifyFileDeletedEvent

func OnNotifyFileDeletedEvent(rail miso.Rail, evt NotifyFileDeletedEvent) error

func PrepareEventBus

func PrepareEventBus(rail miso.Rail) error

func RegisterRoutes

func RegisterRoutes(rail miso.Rail) error

func RemoveGalleryAccess

func RemoveGalleryAccess(rail miso.Rail, tx *gorm.DB, cmd RemoveGalleryAccessCmd, user common.User) error

func TransferImagesInDir

func TransferImagesInDir(rail miso.Rail, cmd TransferGalleryImageInDirReq, user common.User) error

Transfer images in dir

func UpdateGallery

func UpdateGallery(rail miso.Rail, cmd UpdateGalleryCmd, user common.User) error

Update a Gallery

func ValidateFileKey

func ValidateFileKey(c miso.Rail, fileKey string, userId int) (bool, error)

Validate the file key, return true if it's valid else false

Types

type BatchGenFileKeyItem

type BatchGenFileKeyItem struct {
	FileId   string `json:"fileId"`
	Filename string `json:"filename"`
}

type BatchGenFileKeyReq

type BatchGenFileKeyReq struct {
	Items []BatchGenFileKeyItem `json:"items"`
}

type BatchGenFileKeyResp

type BatchGenFileKeyResp struct {
	FileId  string `json:"fileId"`
	TempKey string `json:"tempKey"`
}

func BatchGetFstoreTmpToken

func BatchGetFstoreTmpToken(c miso.Rail, req BatchGenFileKeyReq) ([]BatchGenFileKeyResp, error)

type CreateGalleryCmd

type CreateGalleryCmd struct {
	Name string `json:"name" validation:"notEmpty"`
}

type CreateGalleryForDirCmd

type CreateGalleryForDirCmd struct {
	DirName    string
	DirFileKey string
	Username   string
	UserNo     string
}

type CreateGalleryImageCmd

type CreateGalleryImageCmd struct {
	GalleryNo string `json:"galleryNo"`
	Name      string `json:"name"`
	FileKey   string `json:"fileKey"`
}

type CreateGalleryImgEvent

type CreateGalleryImgEvent struct {
	Username     string `json:"username"`
	UserNo       string `json:"userNo"`
	DirFileKey   string `json:"dirFileKey"`
	DirName      string `json:"dirName"`
	ImageName    string `json:"imageName"`
	ImageFileKey string `json:"imageFileKey"`
}

type DeleteGalleryCmd

type DeleteGalleryCmd struct {
	GalleryNo string `json:"galleryNo" validation:"notEmpty"`
}

type FileInfoResp

type FileInfoResp struct {

	/** name of the file */
	Name string `json:"name"`

	/** file's uuid */
	Uuid string `json:"uuid"`

	/** size of file in bytes */
	SizeInBytes int64 `json:"sizeInBytes"`

	/** uploader id, i.e., user.id */
	UploaderId int `json:"uploaderId"`

	/** uploader name */
	UploaderName string `json:"uploaderName"`

	/** when the file is deleted */
	IsDeleted bool `json:"isDeleted"`

	/** file type: FILE, DIR */
	FileType FileType `json:"fileType"`

	/** parent file's uuid */
	ParentFile string `json:"parentFile"`

	LocalPath string `json:"localPath"`

	FstoreFileId string `json:"fstoreFileId"`

	Thumbnail string `json:"thumbnail"` // also a mini-fstore file_id
}

type FileType

type FileType string
const (
	DIR  FileType = "DIR"
	FILE FileType = "FILE"
)

type FindUserReq

type FindUserReq struct {
	UserId   *int    `json:"userId"`
	UserNo   *string `json:"userNo"`
	Username *string `json:"username"`
}
type Gallery struct {
	ID         int64
	GalleryNo  string
	UserNo     string
	Name       string
	DirFileKey string
	CreateTime time.Time
	CreateBy   string
	UpdateTime time.Time
	UpdateBy   string
	IsDel      common.IS_DEL
}

Gallery

func CreateGallery

func CreateGallery(rail miso.Rail, cmd CreateGalleryCmd, user common.User) (*Gallery, error)

Create a new Gallery

func FindGallery

func FindGallery(galleryNo string) (*Gallery, error)

Find Gallery by gallery_no

func (Gallery) TableName

func (Gallery) TableName() string

type GalleryImage

type GalleryImage struct {
	ID         int64
	GalleryNo  string
	ImageNo    string
	Name       string
	FileKey    string
	Status     ImgStatus
	CreateTime time.Time
	CreateBy   string
	UpdateTime time.Time
	UpdateBy   string
	IsDel      common.IS_DEL
}

Image that belongs to a Gallery

func (GalleryImage) TableName

func (GalleryImage) TableName() string

type GalleryUserAccess

type GalleryUserAccess struct {
	ID         int64
	GalleryNo  string
	UserNo     string
	CreateTime time.Time
	CreateBy   string
	UpdateTime time.Time
	UpdateBy   string
	IsDel      common.IS_DEL
}

User's access to a Gallery

func (GalleryUserAccess) TableName

func (GalleryUserAccess) TableName() string

type GenFileTempTokenReq

type GenFileTempTokenReq struct {
	Filekeys    []string `json:"fileKeys"`
	ExpireInMin int      `json:"expireInMin"`
}

type GenFileTempTokenResp

type GenFileTempTokenResp struct {
	miso.Resp
	Data map[string]string `json:"data"`
}

type GetFileInfoResp

type GetFileInfoResp struct {
	miso.Resp
	Data *FileInfoResp `json:"data"`
}

func GetFileInfo

func GetFileInfo(c miso.Rail, fileKey string) (*GetFileInfoResp, error)

Get file info from file-service

type ImageInfo

type ImageInfo struct {
	ThumbnailToken  string `json:"thumbnailToken"`
	FileTempToken   string `json:"fileTempToken"`
	ImageFileId     string `json:"-"`
	ThumbnailFileId string `json:"-"`
}

type ImgStatus

type ImgStatus string

GalleryImage.status (doesn't really matter anymore)

type ListFilesInDirResp

type ListFilesInDirResp struct {
	miso.Resp
	// list of file key
	Data []string `json:"data"`
}

func ListFilesInDir

func ListFilesInDir(c miso.Rail, fileKey string, limit int, page int) (*ListFilesInDirResp, error)

List files in dir from vfm

type ListGalleriesCmd

type ListGalleriesCmd struct {
	Paging miso.Paging `json:"pagingVo"`
}

type ListGalleriesResp

type ListGalleriesResp struct {
	Paging    miso.Paging `json:"pagingVo"`
	Galleries []VGallery  `json:"galleries"`
}

func ListGalleries

func ListGalleries(rail miso.Rail, cmd ListGalleriesCmd, user common.User) (ListGalleriesResp, error)

List Galleries

type ListGalleryImagesCmd

type ListGalleryImagesCmd struct {
	GalleryNo   string `json:"galleryNo" validation:"notEmpty"`
	miso.Paging `json:"pagingVo"`
}

type ListGalleryImagesResp

type ListGalleryImagesResp struct {
	Images []ImageInfo `json:"images"`
	Paging miso.Paging `json:"pagingVo"`
}

func ListGalleryImages

func ListGalleryImages(rail miso.Rail, cmd ListGalleryImagesCmd, user common.User) (*ListGalleryImagesResp, error)

List gallery images

type ListGrantedGalleryAccessCmd

type ListGrantedGalleryAccessCmd struct {
	GalleryNo string `json:"galleryNo" validation:"notEmpty"`
	PagingVo  miso.Paging
}

type ListedGalleryAccessRes

type ListedGalleryAccessRes struct {
	Id         int
	GalleryNo  string
	UserNo     string
	Username   string
	CreateTime miso.ETime
}

type NotifyFileDeletedEvent

type NotifyFileDeletedEvent struct {
	FileKey string `json:"fileKey"`
}

type PermitGalleryAccessCmd

type PermitGalleryAccessCmd struct {
	GalleryNo string `validation:"notEmpty"`
	Username  string `validation:"notEmpty"`
}

type RemoveGalleryAccessCmd

type RemoveGalleryAccessCmd struct {
	GalleryNo string `json:"galleryNo" validation:"notEmpty"`
	UserNo    string `json:"userNo" validation:"notEmpty"`
}

type ThumbnailInfo

type ThumbnailInfo struct {
	Name string
	Path string
}

type TransferGalleryImageInDirReq

type TransferGalleryImageInDirReq struct {
	// gallery no
	GalleryNo string `json:"galleryNo" validation:"notEmpty"`

	// file key of the directory
	FileKey string `json:"fileKey" validation:"notEmpty"`
}

type TransferGalleryImageReq

type TransferGalleryImageReq struct {
	Images []CreateGalleryImageCmd
}

type UpdateGUAIsDelCmd

type UpdateGUAIsDelCmd struct {
	GalleryNo string
	UserNo    string
	IsDelFrom common.IS_DEL
	IsDelTo   common.IS_DEL
	UpdateBy  string
}

type UpdateGalleryCmd

type UpdateGalleryCmd struct {
	GalleryNo string `json:"galleryNo" validation:"notEmpty"`
	Name      string `json:"name" validation:"notEmpty"`
}

type UserInfo

type UserInfo struct {
	Id       int
	Username string
	UserNo   string
}

func FindUser

func FindUser(rail miso.Rail, req FindUserReq) (UserInfo, error)

type VGallery

type VGallery struct {
	ID            int64      `json:"id"`
	GalleryNo     string     `json:"galleryNo"`
	UserNo        string     `json:"userNo"`
	Name          string     `json:"name"`
	CreateTime    miso.ETime `json:"-"`
	UpdateTime    miso.ETime `json:"-"`
	CreateBy      string     `json:"createBy"`
	UpdateBy      string     `json:"updateBy"`
	IsOwner       bool       `json:"isOwner"`
	CreateTimeStr string     `json:"createTime"`
	UpdateTimeStr string     `json:"updateTime"`
}

type VGalleryBrief

type VGalleryBrief struct {
	GalleryNo string `json:"galleryNo"`
	Name      string `json:"name"`
}

type ValidateFileKeyResp

type ValidateFileKeyResp struct {
	miso.Resp
	Data bool `json:"data"`
}

Jump to

Keyboard shortcuts

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