exportjob

package
v0.4.19 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetailExportJob

func DetailExportJob(ctx *gin.Context, req *DetailExportJobRequest, resp *DetailExportJobResponse)

DetailExportJob 获取导出任务

func MonitorExportJobRoutine

func MonitorExportJobRoutine()

MonitorExportJobRoutine 监控导出任务

Types

type DetailExportJobRequest

type DetailExportJobRequest struct {
	apiobj.BaseRequest
	Request struct {
		JobID string `json:"job_id"`
	}
}

DetailExportJobRequest 获取导出任务

type DetailExportJobResponse

type DetailExportJobResponse struct {
	apiobj.BaseResponse
	Response struct {
		JobID   string `json:"job_id"`
		FileURL string `json:"file_url"`
		Status  string `json:"status"`
		ErrMsg  string `json:"err_msg"`
	}
}

DetailExportJobResponse 获取导出任务返回

type ExportJob

type ExportJob struct {
	gorm.Model
	// JobUUID
	JobUUID string `gorm:"column:job_uuid;type:varchar(36);not null;index"`
	// UserID 用户ID
	UserID uint `gorm:"column:user_id;type:int;not null;index"`
	// Purpose 导出类型,按业务分类,需要和导出文件上传 storage.Storager 的类型一致
	Purpose config.FilePurpose `gorm:"column:purpose;type:varchar(255);not null;index"`
	// ExportStatus 导出状态
	ExportStatus ExportStatus `gorm:"column:export_status;type:varchar(20);not null;index"`
	// CostSeconds 耗时
	CostSeconds int `gorm:"column:cost_seconds;type:int;not null"`
	// TimeoutSeconds 超时时间
	TimeoutSeconds int `gorm:"column:timeout_seconds;type:int;not null"`
	// Output 输出路径, 使用 storage.FileInfo.StoragePath 获取
	Output string `gorm:"column:output;type:varchar(255);not null"`
	// ErrorMsg 错误信息
	ErrorMsg string `gorm:"column:error_msg;type:varchar(255)"`
}

ExportJob 导出任务

func CreateExportJob

func CreateExportJob(userID uint, purpose string, timeoutSeconds int) (*ExportJob, error)

CreateExportJob 新建导出任务

func GetJobByUUID

func GetJobByUUID(uuid string) (*ExportJob, error)

GetJobByUUID 获取任务

func UpdateJobStatus

func UpdateJobStatus(uuid string, output string, e error) (*ExportJob, error)

UpdateJobStatus 更新任务状态

func (ExportJob) TableName

func (ExportJob) TableName() string

TableName 表名

type ExportStatus

type ExportStatus = string

ExportStatus 导出状态

const (
	// ExportStatusPending 等待导出
	ExportStatusPending ExportStatus = "pending"
	// ExportStatusSuccess 成功
	ExportStatusSuccess ExportStatus = "success"
	// ExportStatusFailed 失败
	ExportStatusFailed ExportStatus = "failed"
)

Jump to

Keyboard shortcuts

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