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.

hpcapptemplatemodel_gen.go 3.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // Code generated by goctl. DO NOT EDIT.
  2. // versions:
  3. // goctl version: 1.8.1
  4. package models
  5. import (
  6. "context"
  7. "database/sql"
  8. "fmt"
  9. "gorm.io/gorm"
  10. "strings"
  11. "time"
  12. "github.com/zeromicro/go-zero/core/stores/builder"
  13. "github.com/zeromicro/go-zero/core/stores/sqlx"
  14. "github.com/zeromicro/go-zero/core/stringx"
  15. )
  16. var (
  17. hpcAppTemplateFieldNames = builder.RawFieldNames(&HpcAppTemplate{})
  18. hpcAppTemplateRows = strings.Join(hpcAppTemplateFieldNames, ",")
  19. hpcAppTemplateRowsExpectAutoSet = strings.Join(stringx.Remove(hpcAppTemplateFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
  20. hpcAppTemplateRowsWithPlaceHolder = strings.Join(stringx.Remove(hpcAppTemplateFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
  21. )
  22. type (
  23. hpcAppTemplateModel interface {
  24. Insert(ctx context.Context, data *HpcAppTemplate) (sql.Result, error)
  25. FindOne(ctx context.Context, id int64) (*HpcAppTemplate, error)
  26. Update(ctx context.Context, data *HpcAppTemplate) error
  27. Delete(ctx context.Context, id int64) error
  28. }
  29. defaultHpcAppTemplateModel struct {
  30. conn sqlx.SqlConn
  31. table string
  32. }
  33. HpcAppTemplate struct {
  34. Id int64 `db:"id"`
  35. Name string `db:"name"` // 模板名称
  36. App string `db:"app"` // 应用名称
  37. AppType string `db:"app_type"` // 应用类型
  38. ClusterId int64 `db:"cluster_id"` // 集群id
  39. Content string `db:"content"` // 模板内容
  40. Description string `db:"description"` // 模板描述
  41. Status int64 `db:"status"` // 状态0-禁用, 1-启用
  42. CreateTime time.Time `db:"create_time" json:"createTime"` // 创建时间
  43. UpdateTime time.Time `db:"update_time" json:"updateTime"` // 更新时间
  44. DeletedAt gorm.DeletedAt `db:"deleted_at" json:"-"` // 删除时间
  45. }
  46. )
  47. func newHpcAppTemplateModel(conn sqlx.SqlConn) *defaultHpcAppTemplateModel {
  48. return &defaultHpcAppTemplateModel{
  49. conn: conn,
  50. table: "`hpc_app_template`",
  51. }
  52. }
  53. func (m *defaultHpcAppTemplateModel) Delete(ctx context.Context, id int64) error {
  54. query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
  55. _, err := m.conn.ExecCtx(ctx, query, id)
  56. return err
  57. }
  58. func (m *defaultHpcAppTemplateModel) FindOne(ctx context.Context, id int64) (*HpcAppTemplate, error) {
  59. query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", hpcAppTemplateRows, m.table)
  60. var resp HpcAppTemplate
  61. err := m.conn.QueryRowCtx(ctx, &resp, query, id)
  62. switch err {
  63. case nil:
  64. return &resp, nil
  65. case sqlx.ErrNotFound:
  66. return nil, ErrNotFound
  67. default:
  68. return nil, err
  69. }
  70. }
  71. func (m *defaultHpcAppTemplateModel) Insert(ctx context.Context, data *HpcAppTemplate) (sql.Result, error) {
  72. query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?)", m.table, hpcAppTemplateRowsExpectAutoSet)
  73. ret, err := m.conn.ExecCtx(ctx, query, data.Name, data.App, data.AppType, data.ClusterId, data.Content, data.Description, data.Status, data.DeletedAt)
  74. return ret, err
  75. }
  76. func (m *defaultHpcAppTemplateModel) Update(ctx context.Context, data *HpcAppTemplate) error {
  77. query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, hpcAppTemplateRowsWithPlaceHolder)
  78. _, err := m.conn.ExecCtx(ctx, query, data.Name, data.App, data.AppType, data.ClusterId, data.Content, data.Description, data.Status, data.DeletedAt, data.Id)
  79. return err
  80. }
  81. func (m *defaultHpcAppTemplateModel) tableName() string {
  82. return m.table
  83. }

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.