feat: import services and standardize Go 1.26.5
This commit is contained in:
98
apps/base/fts/internal/models/fts_record.go
Normal file
98
apps/base/fts/internal/models/fts_record.go
Normal file
@@ -0,0 +1,98 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/database"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
/*
|
||||
* Object Storage Record
|
||||
* Comment: 文件存储库
|
||||
* Version: 10
|
||||
* Created: 2022-04-11 18:41:52 , Updated:0001-01-01 00:00:00
|
||||
*/
|
||||
type FtsRecord struct {
|
||||
ID uint `gorm:"column:id;primarykey;" json:"id"`
|
||||
Identity string `gorm:"column:identity;type:varchar(36);uniqueIndex;" json:"identity"` // 唯一标识,24位NanoID,36位为ULID
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:TIMESTAMP;" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:TIMESTAMP;" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:TIMESTAMP;index;" json:"deleted_at"`
|
||||
OwnerID uint `gorm:"column:owner_id;Index;"` // 用户id
|
||||
OwnerIdentity string `gorm:"column:owner_identity;type:varchar(36);Index;"` // 用户唯一标识,24位NanoID,36位为UUID
|
||||
Hash string `gorm:"column:hash;type:varchar(255);not null;" json:"hash"` // 文件hash值
|
||||
Name string `gorm:"column:name;type:varchar(255);not null;" json:"name"` // 文件源名称
|
||||
Ext string `gorm:"column:ext;type:varchar(255);not null;" json:"ext"` // 文件后缀
|
||||
Size uint64 `gorm:"column:size;default:0;" json:"size"` // 文件大小
|
||||
HandleCmd string `gorm:"column:handle_cmd;type:varchar(255);default:'';" json:"handle_cmd"` // 文件上传成功后操作命令
|
||||
HandleArgs string `gorm:"column:handle_args;type:varchar(255);default:'';" json:"handle_args"` // 操作参数
|
||||
|
||||
SaveName string `gorm:"column:save_name;type:varchar(500);default:'';" json:"save_name"` // 保存的文件名
|
||||
LocalPath string `gorm:"column:local_path;type:varchar(500);default:'';" json:"local_path"` // 本地路径
|
||||
OssPath string `gorm:"column:oss_path;type:varchar(500);default:'';" json:"oss_path"` // 对象存储路径
|
||||
ResultUrl string `gorm:"column:result_url;type:varchar(500);default:'';" json:"result_url"` // 处理结果路径
|
||||
|
||||
Status int8 `gorm:"default:0;index;"` // -1:准备清除,0待续,1无需处理,2准备处理,3处理中,4处理失败,5处理成功。
|
||||
}
|
||||
|
||||
func init() {
|
||||
database.MigrateTables = append(database.MigrateTables, &FtsRecord{})
|
||||
}
|
||||
|
||||
// TableName .
|
||||
func (table *FtsRecord) TableName() string {
|
||||
return "fts_record" //对应数据库表名
|
||||
}
|
||||
|
||||
// func GetFileList(page, size int, identity string) ([]types.Record, int64, error) {
|
||||
// var list = make([]types.Record, 0)
|
||||
// tx := DBService.Model(&FtsRecord{}).Select("id,identity,name,ext,size,local_path,oss_path,result_path,status").Where("passport_identity = ?", identity)
|
||||
// tx.Order("id").Limit(size).Offset((page - 1) * size).Find(&list)
|
||||
// cnt := tx.RowsAffected
|
||||
// err := tx.Error
|
||||
// return list, cnt, err
|
||||
// }
|
||||
// func GetFileDetails(identity string) (data *types.Record, cnt int64, err error) {
|
||||
// tx := DBService.Model(&FtsRecord{}).Select("id,identity,name,ext,size,local_path,oss_path,result_path,status").Where("identity = ?", identity).Scan(&data)
|
||||
// cnt = tx.RowsAffected
|
||||
// err = tx.Error
|
||||
|
||||
// return data, cnt, err
|
||||
// }
|
||||
|
||||
// func TableSql(tableName string) string {
|
||||
// sql := `
|
||||
// CREATE SEQUENCE IF NOT EXISTS fts_record_bigserial;
|
||||
// CREATE TABLE IF NOT EXISTS {TABLE_NAME} (
|
||||
// id INT DEFAULT nextval('fts_record_bigserial') PRIMARY KEY,
|
||||
// "identity" varchar(36) NULL,
|
||||
// passport_id int8 NULL,
|
||||
// passport_identity varchar(36) NULL,
|
||||
// hash varchar(255) NULL,
|
||||
// "name" varchar(255) NULL,
|
||||
// ext varchar(255) NULL,
|
||||
// "size" float8 NULL,
|
||||
// handle_cmd varchar(255) NULL,
|
||||
// handle_args varchar(255) NULL,
|
||||
// local_path varchar(255) NULL,
|
||||
// oss_path varchar(255) NULL,
|
||||
// result_path varchar(255) NULL,
|
||||
// status int2 NULL,
|
||||
// created_at timestamp(6) NULL,
|
||||
// updated_at timestamp(6) NULL,
|
||||
// deleted_at timestamp(6) NULL,
|
||||
// CONSTRAINT {TABLE_NAME}_pkey PRIMARY KEY (id)
|
||||
// );
|
||||
// COMMENT ON TABLE fts_record IS '文件存储库';
|
||||
|
||||
// CREATE UNIQUE INDEX idx_{TABLE_NAME}_identity ON {TABLE_NAME} USING btree (identity);
|
||||
|
||||
// CREATE INDEX idx_{TABLE_NAME}_passport_id ON {TABLE_NAME} USING btree (passport_id);
|
||||
// CREATE INDEX idx_{TABLE_NAME}_passport_identity ON {TABLE_NAME} USING btree (passport_identity);
|
||||
// CREATE INDEX idx_{TABLE_NAME}_passport_status ON {TABLE_NAME} USING btree (status);
|
||||
// `
|
||||
|
||||
// sql = strings.ReplaceAll(sql, "{TABLE_NAME}", tableName)
|
||||
// return sql
|
||||
// }
|
||||
6
apps/base/fts/internal/models/query.go
Normal file
6
apps/base/fts/internal/models/query.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package models
|
||||
|
||||
// 初始化数据
|
||||
func InitData() {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user