updated deployinstance model
Former-commit-id: 542a8cc8d92e872673cdf1f6af30142ac382011a
This commit is contained in:
parent
61d4ea3af7
commit
4f8da64f71
|
@ -372,3 +372,48 @@ func (s *AiStorage) AddNoticeInfo(adapterId string, adapterName string, clusterI
|
||||||
logx.Errorf("Task creation failure, err: %v", result.Error)
|
logx.Errorf("Task creation failure, err: %v", result.Error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *AiStorage) SaveInferDeployInstance() (int64, error) {
|
||||||
|
startTime := time.Now().Format(time.RFC3339)
|
||||||
|
// 构建主任务结构体
|
||||||
|
insModel := models.AiInferDeployInstance{
|
||||||
|
InstanceId: "",
|
||||||
|
InstanceName: "",
|
||||||
|
AdapterId: 123,
|
||||||
|
AdapterName: "",
|
||||||
|
ClusterId: 123,
|
||||||
|
ClusterName: "",
|
||||||
|
ModelName: "",
|
||||||
|
ModelType: "",
|
||||||
|
InferCard: "",
|
||||||
|
Status: constants.Saved,
|
||||||
|
CreateTime: startTime,
|
||||||
|
UpdateTime: startTime,
|
||||||
|
}
|
||||||
|
// 保存任务数据到数据库
|
||||||
|
tx := s.DbEngin.Table("ai_infer_deploy_instance").Create(&insModel)
|
||||||
|
if tx.Error != nil {
|
||||||
|
return 0, tx.Error
|
||||||
|
}
|
||||||
|
return insModel.Id, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *AiStorage) UpdateInferDeployInstance(instance *models.AiInferDeployInstance) error {
|
||||||
|
instance.UpdateTime = time.Now().Format(time.RFC3339)
|
||||||
|
tx := s.DbEngin.Table("ai_infer_deploy_instance").Updates(instance)
|
||||||
|
if tx.Error != nil {
|
||||||
|
logx.Errorf(tx.Error.Error())
|
||||||
|
return tx.Error
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *AiStorage) GetInferDeployInstanceById(id int64) (*models.AiInferDeployInstance, error) {
|
||||||
|
var deployIns models.AiInferDeployInstance
|
||||||
|
tx := s.DbEngin.Raw("select * from ai_infer_deploy_instance where `id` = ?", id).Scan(&deployIns)
|
||||||
|
if tx.Error != nil {
|
||||||
|
logx.Errorf(tx.Error.Error())
|
||||||
|
return nil, tx.Error
|
||||||
|
}
|
||||||
|
return &deployIns, nil
|
||||||
|
}
|
||||||
|
|
|
@ -35,19 +35,19 @@ type (
|
||||||
}
|
}
|
||||||
|
|
||||||
AiInferDeployInstance struct {
|
AiInferDeployInstance struct {
|
||||||
Id int64 `db:"id"`
|
Id int64 `db:"id"`
|
||||||
InstanceId sql.NullString `db:"instance_id"`
|
InstanceId string `db:"instance_id"`
|
||||||
InstanceName sql.NullString `db:"instance_name"`
|
InstanceName string `db:"instance_name"`
|
||||||
AdapterId sql.NullInt64 `db:"adapter_id"`
|
AdapterId int64 `db:"adapter_id"`
|
||||||
AdapterName sql.NullString `db:"adapter_name"`
|
AdapterName string `db:"adapter_name"`
|
||||||
ClusterId sql.NullInt64 `db:"cluster_id"`
|
ClusterId int64 `db:"cluster_id"`
|
||||||
ClusterName sql.NullString `db:"cluster_name"`
|
ClusterName string `db:"cluster_name"`
|
||||||
ModelName sql.NullString `db:"model_name"`
|
ModelName string `db:"model_name"`
|
||||||
ModelType sql.NullString `db:"model_type"`
|
ModelType string `db:"model_type"`
|
||||||
InferCard sql.NullString `db:"infer_card"`
|
InferCard string `db:"infer_card"`
|
||||||
Status sql.NullString `db:"status"`
|
Status string `db:"status"`
|
||||||
CreateTime sql.NullString `db:"create_time"`
|
CreateTime string `db:"create_time"`
|
||||||
UpdateTime sql.NullString `db:"update_time"`
|
UpdateTime string `db:"update_time"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue