You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

aiinferdeployinstancemodel_gen.go 4.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // Code generated by goctl. DO NOT EDIT.
  2. package models
  3. import (
  4. "context"
  5. "database/sql"
  6. "fmt"
  7. "strings"
  8. "github.com/zeromicro/go-zero/core/stores/builder"
  9. "github.com/zeromicro/go-zero/core/stores/sqlc"
  10. "github.com/zeromicro/go-zero/core/stores/sqlx"
  11. "github.com/zeromicro/go-zero/core/stringx"
  12. )
  13. var (
  14. aiInferDeployInstanceFieldNames = builder.RawFieldNames(&AiInferDeployInstance{})
  15. aiInferDeployInstanceRows = strings.Join(aiInferDeployInstanceFieldNames, ",")
  16. aiInferDeployInstanceRowsExpectAutoSet = strings.Join(stringx.Remove(aiInferDeployInstanceFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
  17. aiInferDeployInstanceRowsWithPlaceHolder = strings.Join(stringx.Remove(aiInferDeployInstanceFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
  18. )
  19. type (
  20. aiInferDeployInstanceModel interface {
  21. Insert(ctx context.Context, data *AiInferDeployInstance) (sql.Result, error)
  22. FindOne(ctx context.Context, id int64) (*AiInferDeployInstance, error)
  23. Update(ctx context.Context, data *AiInferDeployInstance) error
  24. Delete(ctx context.Context, id int64) error
  25. }
  26. defaultAiInferDeployInstanceModel struct {
  27. conn sqlx.SqlConn
  28. table string
  29. }
  30. AiInferDeployInstance struct {
  31. Id int64 `db:"id"`
  32. InstanceId string `db:"instance_id"`
  33. InstanceName string `db:"instance_name"`
  34. AdapterId int64 `db:"adapter_id"`
  35. AdapterName string `db:"adapter_name"`
  36. ClusterId int64 `db:"cluster_id"`
  37. ClusterName string `db:"cluster_name"`
  38. ModelName string `db:"model_name"`
  39. ModelType string `db:"model_type"`
  40. InferCard string `db:"infer_card"`
  41. Status string `db:"status"`
  42. CreateTime string `db:"create_time"`
  43. UpdateTime string `db:"update_time"`
  44. ClusterType string `db:"cluster_type"`
  45. }
  46. )
  47. func newAiInferDeployInstanceModel(conn sqlx.SqlConn) *defaultAiInferDeployInstanceModel {
  48. return &defaultAiInferDeployInstanceModel{
  49. conn: conn,
  50. table: "`ai_infer_deploy_instance`",
  51. }
  52. }
  53. func (m *defaultAiInferDeployInstanceModel) withSession(session sqlx.Session) *defaultAiInferDeployInstanceModel {
  54. return &defaultAiInferDeployInstanceModel{
  55. conn: sqlx.NewSqlConnFromSession(session),
  56. table: "`ai_infer_deploy_instance`",
  57. }
  58. }
  59. func (m *defaultAiInferDeployInstanceModel) Delete(ctx context.Context, id int64) error {
  60. query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
  61. _, err := m.conn.ExecCtx(ctx, query, id)
  62. return err
  63. }
  64. func (m *defaultAiInferDeployInstanceModel) FindOne(ctx context.Context, id int64) (*AiInferDeployInstance, error) {
  65. query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", aiInferDeployInstanceRows, m.table)
  66. var resp AiInferDeployInstance
  67. err := m.conn.QueryRowCtx(ctx, &resp, query, id)
  68. switch err {
  69. case nil:
  70. return &resp, nil
  71. case sqlc.ErrNotFound:
  72. return nil, ErrNotFound
  73. default:
  74. return nil, err
  75. }
  76. }
  77. func (m *defaultAiInferDeployInstanceModel) Insert(ctx context.Context, data *AiInferDeployInstance) (sql.Result, error) {
  78. query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, aiInferDeployInstanceRowsExpectAutoSet)
  79. 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)
  80. return ret, err
  81. }
  82. func (m *defaultAiInferDeployInstanceModel) Update(ctx context.Context, data *AiInferDeployInstance) error {
  83. query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, aiInferDeployInstanceRowsWithPlaceHolder)
  84. _, 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)
  85. return err
  86. }
  87. func (m *defaultAiInferDeployInstanceModel) tableName() string {
  88. return m.table
  89. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.