28 lines
1.3 KiB
Go
28 lines
1.3 KiB
Go
package models
|
|
|
|
import "app/cfg"
|
|
|
|
type Doc struct {
|
|
BaseModel
|
|
ProjectID string `json:"project_id" gorm:"column:project_id;type:varchar(255);not null"`
|
|
Name string `json:"name" gorm:"column:name;type:varchar(255);not null"`
|
|
Type string `json:"type" gorm:"column:type;type:varchar(50);not null"`
|
|
Description string `json:"description" gorm:"column:description;type:text"`
|
|
FilePath string `json:"file_path" gorm:"column:file_path;type:varchar(255)"`
|
|
FileType string `json:"file_type" gorm:"column:file_type;type:varchar(50)"`
|
|
FileSize int64 `json:"file_size" gorm:"column:file_size;type:bigint"`
|
|
FileName string `json:"file_name" gorm:"column:file_name;type:varchar(255)"`
|
|
AnalysisCompleted bool `json:"analysis_completed" gorm:"column:analysis_completed;type:boolean;default:false"`
|
|
AnalysisPercent int `json:"analysis_percent" gorm:"column:analysis_percent;type:int;default:0"`
|
|
AnalysisError string `json:"analysis_error" gorm:"column:analysis_error;type:text"`
|
|
Merged bool `json:"merged" gorm:"column:merged;type:boolean;default:false"`
|
|
}
|
|
|
|
func GetProjectIDByDocID(docID string) (string, error) {
|
|
var doc Doc
|
|
if err := cfg.DB().Where("id = ?", docID).First(&doc).Error; err != nil {
|
|
return "", err
|
|
}
|
|
return doc.ProjectID, nil
|
|
}
|