add deployinstance model
Former-commit-id: 0beb6347de0ee3d21ea1033d692602010f74acca
This commit is contained in:
parent
4e63d24aa4
commit
d24f5dd7a8
|
@ -0,0 +1,24 @@
|
|||
package models
|
||||
|
||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
|
||||
var _ AiInferDeployInstanceModel = (*customAiInferDeployInstanceModel)(nil)
|
||||
|
||||
type (
|
||||
// AiInferDeployInstanceModel is an interface to be customized, add more methods here,
|
||||
// and implement the added methods in customAiInferDeployInstanceModel.
|
||||
AiInferDeployInstanceModel interface {
|
||||
aiInferDeployInstanceModel
|
||||
}
|
||||
|
||||
customAiInferDeployInstanceModel struct {
|
||||
*defaultAiInferDeployInstanceModel
|
||||
}
|
||||
)
|
||||
|
||||
// NewAiInferDeployInstanceModel returns a model for the database table.
|
||||
func NewAiInferDeployInstanceModel(conn sqlx.SqlConn) AiInferDeployInstanceModel {
|
||||
return &customAiInferDeployInstanceModel{
|
||||
defaultAiInferDeployInstanceModel: newAiInferDeployInstanceModel(conn),
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
// Code generated by goctl. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/stores/builder"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/core/stringx"
|
||||
)
|
||||
|
||||
var (
|
||||
aiInferDeployInstanceFieldNames = builder.RawFieldNames(&AiInferDeployInstance{})
|
||||
aiInferDeployInstanceRows = strings.Join(aiInferDeployInstanceFieldNames, ",")
|
||||
aiInferDeployInstanceRowsExpectAutoSet = strings.Join(stringx.Remove(aiInferDeployInstanceFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||||
aiInferDeployInstanceRowsWithPlaceHolder = strings.Join(stringx.Remove(aiInferDeployInstanceFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||||
)
|
||||
|
||||
type (
|
||||
aiInferDeployInstanceModel interface {
|
||||
Insert(ctx context.Context, data *AiInferDeployInstance) (sql.Result, error)
|
||||
FindOne(ctx context.Context, id int64) (*AiInferDeployInstance, error)
|
||||
Update(ctx context.Context, data *AiInferDeployInstance) error
|
||||
Delete(ctx context.Context, id int64) error
|
||||
}
|
||||
|
||||
defaultAiInferDeployInstanceModel struct {
|
||||
conn sqlx.SqlConn
|
||||
table string
|
||||
}
|
||||
|
||||
AiInferDeployInstance struct {
|
||||
Id int64 `db:"id"`
|
||||
InstanceId sql.NullString `db:"instance_id"`
|
||||
InstanceName sql.NullString `db:"instance_name"`
|
||||
AdapterId sql.NullInt64 `db:"adapter_id"`
|
||||
AdapterName sql.NullString `db:"adapter_name"`
|
||||
ClusterId sql.NullInt64 `db:"cluster_id"`
|
||||
ClusterName sql.NullString `db:"cluster_name"`
|
||||
ModelName sql.NullString `db:"model_name"`
|
||||
ModelType sql.NullString `db:"model_type"`
|
||||
InferCard sql.NullString `db:"infer_card"`
|
||||
Status sql.NullString `db:"status"`
|
||||
CreateTime sql.NullString `db:"create_time"`
|
||||
UpdateTime sql.NullString `db:"update_time"`
|
||||
}
|
||||
)
|
||||
|
||||
func newAiInferDeployInstanceModel(conn sqlx.SqlConn) *defaultAiInferDeployInstanceModel {
|
||||
return &defaultAiInferDeployInstanceModel{
|
||||
conn: conn,
|
||||
table: "`ai_infer_deploy_instance`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultAiInferDeployInstanceModel) withSession(session sqlx.Session) *defaultAiInferDeployInstanceModel {
|
||||
return &defaultAiInferDeployInstanceModel{
|
||||
conn: sqlx.NewSqlConnFromSession(session),
|
||||
table: "`ai_infer_deploy_instance`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultAiInferDeployInstanceModel) Delete(ctx context.Context, id int64) error {
|
||||
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||||
_, err := m.conn.ExecCtx(ctx, query, id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultAiInferDeployInstanceModel) FindOne(ctx context.Context, id int64) (*AiInferDeployInstance, error) {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", aiInferDeployInstanceRows, m.table)
|
||||
var resp AiInferDeployInstance
|
||||
err := m.conn.QueryRowCtx(ctx, &resp, query, id)
|
||||
switch err {
|
||||
case nil:
|
||||
return &resp, nil
|
||||
case sqlc.ErrNotFound:
|
||||
return nil, ErrNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultAiInferDeployInstanceModel) Insert(ctx context.Context, data *AiInferDeployInstance) (sql.Result, error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, aiInferDeployInstanceRowsExpectAutoSet)
|
||||
ret, err := m.conn.ExecCtx(ctx, query, data.InstanceId, data.InstanceName, data.AdapterId, data.AdapterName, data.ClusterId, data.ClusterName, data.ModelName, data.ModelType, data.InferCard, data.Status)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (m *defaultAiInferDeployInstanceModel) Update(ctx context.Context, data *AiInferDeployInstance) error {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, aiInferDeployInstanceRowsWithPlaceHolder)
|
||||
_, err := m.conn.ExecCtx(ctx, query, data.InstanceId, data.InstanceName, data.AdapterId, data.AdapterName, data.ClusterId, data.ClusterName, data.ModelName, data.ModelType, data.InferCard, data.Status, data.Id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultAiInferDeployInstanceModel) tableName() string {
|
||||
return m.table
|
||||
}
|
Loading…
Reference in New Issue