107 lines
3.7 KiB
Go
107 lines
3.7 KiB
Go
// 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 (
|
||
aiFieldNames = builder.RawFieldNames(&Ai{})
|
||
aiRows = strings.Join(aiFieldNames, ",")
|
||
aiRowsExpectAutoSet = strings.Join(stringx.Remove(aiFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||
aiRowsWithPlaceHolder = strings.Join(stringx.Remove(aiFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||
)
|
||
|
||
type (
|
||
aiModel interface {
|
||
Insert(ctx context.Context, data *Ai) (sql.Result, error)
|
||
FindOne(ctx context.Context, id int64) (*Ai, error)
|
||
FindOneByServiceNameProjectIdName(ctx context.Context, serviceName sql.NullString, projectId sql.NullString, name sql.NullString) (*Ai, error)
|
||
Update(ctx context.Context, data *Ai) error
|
||
Delete(ctx context.Context, id int64) error
|
||
}
|
||
|
||
defaultAiModel struct {
|
||
conn sqlx.SqlConn
|
||
table string
|
||
}
|
||
|
||
Ai struct {
|
||
Id int64 `db:"id"` // id
|
||
TaskId int64 `db:"task_id"` // 任务id
|
||
ParticipantId int64 `db:"participant_id"` // 集群静态信息id
|
||
ProjectId string `db:"project_id"` // 项目id
|
||
Name string `db:"name"` // 名称
|
||
Status string `db:"status"` // 状态
|
||
StartTime string `db:"start_time"` // 开始时间
|
||
RunningTime int64 `db:"running_time"` // 运行时间
|
||
CreatedBy int64 `db:"created_by"` // 创建人
|
||
CreatedTime sql.NullTime `db:"created_time"` // 创建时间
|
||
UpdatedBy int64 `db:"updated_by"` // 更新人
|
||
UpdatedTime sql.NullTime `db:"updated_time"` // 更新时间
|
||
DeletedFlag int64 `db:"deleted_flag"` // 是否删除(0-否,1-是)
|
||
Result string `db:"result"`
|
||
YamlString string `db:"yaml_string"`
|
||
JobId string `db:"job_id"`
|
||
Command string `db:"command"`
|
||
FlavorId string `db:"flavor_id"`
|
||
ImageUrl string `db:"image_url"`
|
||
SubscriptionId string `db:"subscription_id"`
|
||
ItemVersionId string `db:"itemVersion_id"`
|
||
}
|
||
)
|
||
|
||
func newAiModel(conn sqlx.SqlConn) *defaultAiModel {
|
||
return &defaultAiModel{
|
||
conn: conn,
|
||
table: "`ai`",
|
||
}
|
||
}
|
||
|
||
func (m *defaultAiModel) 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 *defaultAiModel) FindOne(ctx context.Context, id int64) (*Ai, error) {
|
||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", aiRows, m.table)
|
||
var resp Ai
|
||
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 *defaultAiModel) FindOneByServiceNameProjectIdName(ctx context.Context, serviceName sql.NullString, projectId sql.NullString, name sql.NullString) (*Ai, error) {
|
||
var resp Ai
|
||
query := fmt.Sprintf("select %s from %s where `service_name` = ? and `project_id` = ? and `name` = ? limit 1", aiRows, m.table)
|
||
err := m.conn.QueryRowCtx(ctx, &resp, query, serviceName, projectId, name)
|
||
switch err {
|
||
case nil:
|
||
return &resp, nil
|
||
case sqlc.ErrNotFound:
|
||
return nil, ErrNotFound
|
||
default:
|
||
return nil, err
|
||
}
|
||
}
|
||
|
||
func (m *defaultAiModel) tableName() string {
|
||
return m.table
|
||
}
|