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.

aideployinstancetaskmodel_gen.go 3.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. aiDeployInstanceTaskFieldNames = builder.RawFieldNames(&AiDeployInstanceTask{})
  15. aiDeployInstanceTaskRows = strings.Join(aiDeployInstanceTaskFieldNames, ",")
  16. aiDeployInstanceTaskRowsExpectAutoSet = strings.Join(stringx.Remove(aiDeployInstanceTaskFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
  17. aiDeployInstanceTaskRowsWithPlaceHolder = strings.Join(stringx.Remove(aiDeployInstanceTaskFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
  18. )
  19. type (
  20. aiDeployInstanceTaskModel interface {
  21. Insert(ctx context.Context, data *AiDeployInstanceTask) (sql.Result, error)
  22. FindOne(ctx context.Context, id int64) (*AiDeployInstanceTask, error)
  23. Update(ctx context.Context, data *AiDeployInstanceTask) error
  24. Delete(ctx context.Context, id int64) error
  25. }
  26. defaultAiDeployInstanceTaskModel struct {
  27. conn sqlx.SqlConn
  28. table string
  29. }
  30. AiDeployInstanceTask struct {
  31. Id int64 `db:"id"`
  32. Name string `db:"name"`
  33. UserId int64 `db:"user_id"`
  34. ModelName string `db:"model_name"`
  35. ModelType string `db:"model_type"`
  36. Desc string `db:"desc"`
  37. CreateTime string `db:"create_time"`
  38. UpdateTime string `db:"update_time"`
  39. }
  40. )
  41. func newAiDeployInstanceTaskModel(conn sqlx.SqlConn) *defaultAiDeployInstanceTaskModel {
  42. return &defaultAiDeployInstanceTaskModel{
  43. conn: conn,
  44. table: "`ai_deploy_instance_task`",
  45. }
  46. }
  47. func (m *defaultAiDeployInstanceTaskModel) Delete(ctx context.Context, id int64) error {
  48. query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
  49. _, err := m.conn.ExecCtx(ctx, query, id)
  50. return err
  51. }
  52. func (m *defaultAiDeployInstanceTaskModel) FindOne(ctx context.Context, id int64) (*AiDeployInstanceTask, error) {
  53. query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", aiDeployInstanceTaskRows, m.table)
  54. var resp AiDeployInstanceTask
  55. err := m.conn.QueryRowCtx(ctx, &resp, query, id)
  56. switch err {
  57. case nil:
  58. return &resp, nil
  59. case sqlc.ErrNotFound:
  60. return nil, ErrNotFound
  61. default:
  62. return nil, err
  63. }
  64. }
  65. func (m *defaultAiDeployInstanceTaskModel) Insert(ctx context.Context, data *AiDeployInstanceTask) (sql.Result, error) {
  66. query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?)", m.table, aiDeployInstanceTaskRowsExpectAutoSet)
  67. ret, err := m.conn.ExecCtx(ctx, query, data.Name, data.ModelName, data.ModelType, data.Desc)
  68. return ret, err
  69. }
  70. func (m *defaultAiDeployInstanceTaskModel) Update(ctx context.Context, data *AiDeployInstanceTask) error {
  71. query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, aiDeployInstanceTaskRowsWithPlaceHolder)
  72. _, err := m.conn.ExecCtx(ctx, query, data.Name, data.ModelName, data.ModelType, data.Desc, data.Id)
  73. return err
  74. }
  75. func (m *defaultAiDeployInstanceTaskModel) tableName() string {
  76. return m.table
  77. }

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.