object

package
v0.0.0-...-a91a185 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Config *viper.Viper
)
View Source
var ErrInvalidHex = fmt.Errorf("the provided hex string is not a valid ObjectID")

ErrInvalidHex indicates that a hex string cannot be converted to an ObjectID.

Functions

func AppToEntity

func AppToEntity(m App) *repository.App

func BucketToEntity

func BucketToEntity(m Bucket) *repository.Bucket

func DeleteAppById

func DeleteAppById(id int64) (int64, error)

func DeleteBucketById

func DeleteBucketById(id int64) (int64, error)

func GetDB

func GetDB() *xorm.Engine

func GetDatabases

func GetDatabases() map[string]*xorm.Engine

func InitDB

func InitDB(config *viper.Viper)

func InitNacos

func InitNacos()

func IsValidObjectID

func IsValidObjectID(s string) bool

IsValidObjectID returns true if the provided hex string represents a valid ObjectID and false if not.

func SyncDB

func SyncDB() error

Types

type App

type App struct {
	Id              int64  `json:"id"`
	AccessKeyId     string `json:"accessKeyId"`
	AccessKeySecret string `json:"accessKeySecret"`
	Endpoint        string `json:"endpoint"`
	InnerEndpoint   string `json:"innerEndpoint"`
	Status          int    `json:"status"`
	CreateTime      string `json:"createTime"`
	UpdateTime      string `json:"updateTime"`
}

func CreateApp

func CreateApp(m App) (*App, error)

func EntityToApp

func EntityToApp(entity repository.App) *App

func UpdateApp

func UpdateApp(m App) (*App, error)

type Bucket

type Bucket struct {
	Id            int64          `json:"id"`
	AppId         int64          `json:"appId"`
	BucketType    int            `json:"bucketType"`
	Name          string         `json:"name"`
	Domain        string         `json:"domain"`
	ProcessConfig *ProcessConfig `json:"processConfig"`
	Status        int            `json:"status"`
	CreateTime    string         `json:"createTime"`
	UpdateTime    string         `json:"updateTime"`
}

func CreateBucket

func CreateBucket(m Bucket) (*Bucket, error)

func EntityToBucket

func EntityToBucket(entity repository.Bucket) *Bucket

func UpdateBucket

func UpdateBucket(m Bucket) (*Bucket, error)

type File

type File struct {
	Id             int64  `json:"id"`
	BucketId       int64  `json:"bucketId"`
	BucketName     string `json:"bucketName"`
	Domain         string `json:"domain"`
	FileKey        string `json:"fileKey"`
	SourceFile     string `json:"sourceFile"`
	SourceFileSize int64  `json:"sourceFileSize"`
	SourceFileType string `json:"sourceFileType"`
	SourceFileAttr string `json:"sourceFileAttr"`
	Url            string `json:"url"`
	CreateTime     string `json:"createTime"`
	UpdateTime     string `json:"updateTime"`
}

func BatchCreateFile

func BatchCreateFile(files []File) ([]File, error)

func CreateFileData

func CreateFileData(file File) ([]File, error)

func SearchFiles

func SearchFiles(searchParam SearchFileParam) ([]File, error)

func UploadFile

func UploadFile(uploadFile OssUploadFile, file string) (*File, error)

type ObjectID

type ObjectID [12]byte

ObjectID is the BSON ObjectID type.

var NilObjectID ObjectID

NilObjectID is the zero value for ObjectID.

func NewObjectID

func NewObjectID() ObjectID

NewObjectID generates a new ObjectID.

func NewObjectIDFromTimestamp

func NewObjectIDFromTimestamp(timestamp time.Time) ObjectID

NewObjectIDFromTimestamp generates a new ObjectID based on the given time.

func ObjectIDFromHex

func ObjectIDFromHex(s string) (ObjectID, error)

ObjectIDFromHex creates a new ObjectID from a hex string. It returns an error if the hex string is not a valid ObjectID.

func (ObjectID) Hex

func (id ObjectID) Hex() string

Hex returns the hex encoding of the ObjectID as a string.

func (ObjectID) IsZero

func (id ObjectID) IsZero() bool

IsZero returns true if id is the empty ObjectID.

func (ObjectID) MarshalJSON

func (id ObjectID) MarshalJSON() ([]byte, error)

MarshalJSON returns the ObjectID as a string

func (ObjectID) MarshalText

func (id ObjectID) MarshalText() ([]byte, error)

MarshalText returns the ObjectID as UTF-8-encoded text. Implementing this allows us to use ObjectID as a map key when marshalling JSON. See https://pkg.go.dev/encoding#TextMarshaler

func (ObjectID) String

func (id ObjectID) String() string

func (ObjectID) Timestamp

func (id ObjectID) Timestamp() time.Time

Timestamp extracts the time part of the ObjectId.

func (*ObjectID) UnmarshalJSON

func (id *ObjectID) UnmarshalJSON(b []byte) error

UnmarshalJSON populates the byte slice with the ObjectID. If the byte slice is 24 bytes long, it will be populated with the hex representation of the ObjectID. If the byte slice is twelve bytes long, it will be populated with the BSON representation of the ObjectID. This method also accepts empty strings and decodes them as NilObjectID. For any other inputs, an error will be returned.

func (*ObjectID) UnmarshalText

func (id *ObjectID) UnmarshalText(b []byte) error

UnmarshalText populates the byte slice with the ObjectID. Implementing this allows us to use ObjectID as a map key when unmarshalling JSON. See https://pkg.go.dev/encoding#TextUnmarshaler

type OssUploadFile

type OssUploadFile struct {
	Bucket            string         `json:"bucket" form:"bucket"`                       //bucket名称
	Prefix            string         `json:"prefix" form:"prefix"`                       //文件前缀
	FileKey           string         `json:"fileKey" form:"fileKey"`                     //文件key
	SourceFile        string         `json:"sourceFile" form:"sourceFile"`               //源文件
	SourceFileSize    int64          `json:"sourceFileSize" form:"sourceFileSize"`       //源文件大小
	SourceFileType    string         `json:"sourceFileType" form:"sourceFileType"`       //源文件类型
	SourceFileAttr    string         `json:"sourceFileAttr" form:"sourceFileAttr"`       //源文件属性
	UseSourceFilename int            `json:"useSourceFilename" form:"useSourceFilename"` //是否使用源文件名
	ExpiredInSec      int64          `json:"expiredInSec" form:"expiredInSec"`           //过期秒数
	ProcessParams     []ProcessParam `json:"processParams"`                              //处理参数
	ProcessParamsStr  string         `form:"processParams"`                              //处理参数
}

type OssUploadToken

type OssUploadToken struct {
	FileId      int64  `json:"fileId"`      //文件ID
	UploadUrl   string `json:"uploadUrl"`   //上传地址
	AccessKeyId string `json:"accessKeyId"` //OSS秘钥ID
	Policy      string `json:"policy"`      //策略
	Signature   string `json:"signature"`   //签名
	Key         string `json:"key"`         //文件键值
	Url         string `json:"url"`         //文件地址
}

func GetUploadToken

func GetUploadToken(uploadFile OssUploadFile) (*OssUploadToken, error)

type PageParam

type PageParam struct {
	PageIndex int `json:"pageIndex"`
	PageSize  int `json:"pageSize"`
}

func (*PageParam) Start

func (pageParam *PageParam) Start() int

type PageResult

type PageResult struct {
	Total      int64 `json:"total"`
	TotalPages int64 `json:"totalPages"`
	Data       []any `json:"data"`
}

func NewPageResult

func NewPageResult() *PageResult

func SearchApps

func SearchApps(searchParam PageParam) (PageResult, error)

func SearchBuckets

func SearchBuckets(searchParam PageParam) (PageResult, error)

func SearchPageFiles

func SearchPageFiles(searchParam SearchFilePageParam) (PageResult, error)

func (*PageResult) GetTotalPages

func (m *PageResult) GetTotalPages(pageSize int) int64

type ProcessConfig

type ProcessConfig struct {
	Expression    string         `json:"expression"`    // 表达式
	ProcessParams []ProcessParam `json:"processParams"` //处理参数
}

type ProcessParam

type ProcessParam struct {
	Name   string   `json:"name" form:"name"`     //处理名称
	Params []string `json:"params" form:"params"` //处理参数
}

type RestResult

type RestResult struct {
	Status  int    `json:"status"`
	Code    string `json:"code"`
	Data    any    `json:"data"`
	Message string `json:"message"`
}

type SearchFilePageParam

type SearchFilePageParam struct {
	PageParam
	SearchFileParam
}

type SearchFileParam

type SearchFileParam struct {
	Ids           []int64        `json:"ids"`           //文件ID集合
	FileKeys      []string       `json:"fileKeys"`      //文件key集合
	Buckets       []string       `json:"buckets"`       //bucket集合
	ExpiredInSec  int64          `json:"expiredInSec"`  //过期秒数
	ProcessParams []ProcessParam `json:"processParams"` //处理参数
}

type UploadFileRequest

type UploadFileRequest struct {
	SourceFile string `json:"sourceFile"` //原文件名
}

type WebResult

type WebResult struct {
	Code  string `json:"code"`
	Msg   string `json:"msg"`
	Data  any    `json:"data"`
	Total int64  `json:"total"`
}

Jump to

Keyboard shortcuts

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