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.

aiinstancecentermodel_gen.go 3.8 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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/sqlx"
  10. "github.com/zeromicro/go-zero/core/stringx"
  11. )
  12. var (
  13. aiInstanceCenterFieldNames = builder.RawFieldNames(&AiInstanceCenter{})
  14. aiInstanceCenterRows = strings.Join(aiInstanceCenterFieldNames, ",")
  15. aiInstanceCenterRowsExpectAutoSet = strings.Join(stringx.Remove(aiInstanceCenterFieldNames, "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
  16. aiInstanceCenterRowsWithPlaceHolder = strings.Join(stringx.Remove(aiInstanceCenterFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
  17. )
  18. type (
  19. aiInstanceCenterModel interface {
  20. Insert(ctx context.Context, data *AiInstanceCenter) (sql.Result, error)
  21. FindOne(ctx context.Context, id int64) (*AiInstanceCenter, error)
  22. Update(ctx context.Context, data *AiInstanceCenter) error
  23. Delete(ctx context.Context, id int64) error
  24. }
  25. defaultAiInstanceCenterModel struct {
  26. conn sqlx.SqlConn
  27. table string
  28. }
  29. AiInstanceCenter struct {
  30. Id int64 `db:"id"` // 平台唯一id
  31. LogoPath string `db:"logo_path"` // logo图像的位置
  32. InstanceName string `db:"instance_name"` // 实例名称
  33. InstanceType int32 `db:"instance_type"` // 实例类型(1是应用实例,2是模型实例)
  34. InstanceClass string `db:"instance_class"` // 实例类别
  35. InstanceClassChinese string `db:"instance_class_chinese"` // 实例类别中文描述
  36. Description string `db:"description"` // 描述
  37. Version string `db:"version"` // 版本
  38. CreateTime string `db:"create_time"` // 创建时间
  39. UpdateTime string `db:"update_time"` // 更新时间
  40. }
  41. )
  42. func newAiInstanceCenterModel(conn sqlx.SqlConn) *defaultAiInstanceCenterModel {
  43. return &defaultAiInstanceCenterModel{
  44. conn: conn,
  45. table: "`ai_instance_center`",
  46. }
  47. }
  48. func (m *defaultAiInstanceCenterModel) Delete(ctx context.Context, id int64) error {
  49. query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
  50. _, err := m.conn.ExecCtx(ctx, query, id)
  51. return err
  52. }
  53. func (m *defaultAiInstanceCenterModel) FindOne(ctx context.Context, id int64) (*AiInstanceCenter, error) {
  54. query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", aiInstanceCenterRows, m.table)
  55. var resp AiInstanceCenter
  56. err := m.conn.QueryRowCtx(ctx, &resp, query, id)
  57. switch err {
  58. case nil:
  59. return &resp, nil
  60. case sqlx.ErrNotFound:
  61. return nil, ErrNotFound
  62. default:
  63. return nil, err
  64. }
  65. }
  66. func (m *defaultAiInstanceCenterModel) Insert(ctx context.Context, data *AiInstanceCenter) (sql.Result, error) {
  67. query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?)", m.table, aiInstanceCenterRowsExpectAutoSet)
  68. ret, err := m.conn.ExecCtx(ctx, query, data.Id, data.LogoPath, data.InstanceName, data.InstanceType, data.InstanceClass, data.InstanceClassChinese, data.Description, data.Version)
  69. return ret, err
  70. }
  71. func (m *defaultAiInstanceCenterModel) Update(ctx context.Context, data *AiInstanceCenter) error {
  72. query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, aiInstanceCenterRowsWithPlaceHolder)
  73. _, err := m.conn.ExecCtx(ctx, query, data.LogoPath, data.InstanceName, data.InstanceType, data.InstanceClass, data.InstanceClassChinese, data.Description, data.Version, data.Id)
  74. return err
  75. }
  76. func (m *defaultAiInstanceCenterModel) tableName() string {
  77. return m.table
  78. }

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.