chat_document.go 1.7 KB
package domain

import (
	"context"
	"gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/transaction"
)

type ChatDocument struct {
	Id        int64  // 唯一标识
	Name      string // 文件命
	FileType  string // 文件类型 markdown\pdf\txt\doc&docx
	Status    int    // 1.使用中、0.待处理、2.预处理中、3.处理失败
	Metadata  DocumentMetadata
	CreatedAt int64 `json:",omitempty"`
	UpdatedAt int64 `json:",omitempty"`
	DeletedAt int64 `json:",omitempty"`
	Version   int   `json:",omitempty"`
}

const (
	Enable  = 1
	Disable = 2
)

const (
	StatusInUsed      = 1
	StatusWaitProcess = 0
	StatusPreProcess  = 2
	StatusProcessFail = 3
)

type DocumentMetadata struct {
	OriginFileName string  `json:",omitempty"` // 源文件命
	Ext            string  `json:",omitempty"` // 格式
	FileId         string  `json:",omitempty"` // 星火文件ID
	FileUrl        string  `json:",omitempty"` // 文件地址
	FileSize       float64 `json:",omitempty"` // 文件大小
}

type ChatDocumentRepository interface {
	Insert(ctx context.Context, conn transaction.Conn, dm *ChatDocument) (*ChatDocument, error)
	Update(ctx context.Context, conn transaction.Conn, dm *ChatDocument) (*ChatDocument, error)
	UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *ChatDocument) (*ChatDocument, error)
	Delete(ctx context.Context, conn transaction.Conn, dm *ChatDocument) (*ChatDocument, error)
	FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ChatDocument, error)
	FindOneUnscoped(ctx context.Context, conn transaction.Conn, id int64) (*ChatDocument, error)
	Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ChatDocument, error)
}