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.

app.go 8.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. package schsdk
  2. import (
  3. cdssdk "gitlink.org.cn/cloudream/common/sdks/storage"
  4. "time"
  5. )
  6. type App struct {
  7. ID int64 `gorm:"primaryKey;autoIncrement;column:id" json:"id,string"`
  8. Name string `gorm:"column:name;type:varchar(200);not null" json:"name"` // 应用名称
  9. Description string `gorm:"column:description;type:varchar(500);default:null" json:"description"` // 应用描述
  10. Version string `gorm:"column:version;type:varchar(100);not null" json:"version"` // 应用版本
  11. Status string `gorm:"column:status;type:tinyint(1);default:1;not null" json:"status"` // 应用状态 (0:禁用, 1:正常)
  12. UserID cdssdk.UserID `gorm:"column:user_id;type:bigint;default:null" json:"userID"` // 创建者
  13. CreatedAt time.Time `gorm:"column:created_at;type:timestamp;default:CURRENT_TIMESTAMP" json:"createdAt"` // 创建时间
  14. UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;default:null;onUpdate:CURRENT_TIMESTAMP" json:"updatedAt"` // 更新时间
  15. DeletedAt time.Time `gorm:"column:deleted_at;type:timestamp;default:null" json:"-"` // 删除时间
  16. }
  17. func (App) TableName() string {
  18. return "apps"
  19. }
  20. type AppInstanceDao struct {
  21. ID int64 `gorm:"primaryKey;autoIncrement;column:id" json:"id"` // 实例ID
  22. Name string `gorm:"column:name;type:varchar(200);not null" json:"name"` // 实例名称
  23. Description string `gorm:"column:description;type:varchar(500);default:null" json:"description"` // 实例描述
  24. Content string `gorm:"column:content;type:text;default:null" json:"content"` // 实例内容
  25. AppID int64 `gorm:"column:app_id;type:bigint;not null" json:"appID"` // 关联应用ID
  26. AppName string `json:"appName"` // 应用名称
  27. UserID cdssdk.UserID `gorm:"column:user_id;type:bigint;default:null" json:"userID"` // 创建者
  28. CreatedAt time.Time `gorm:"column:created_at;type:timestamp;default:CURRENT_TIMESTAMP" json:"createdAt"` // 创建时间
  29. UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;default:null;onUpdate:CURRENT_TIMESTAMP" json:"updatedAt"` // 更新时间
  30. DeletedAt time.Time `gorm:"column:deleted_at;type:timestamp;default:null" json:"-"` // 删除时间
  31. //回显
  32. AppRunRecords []AppRunRecordDao `gorm:"foreignKey:AppInstanceID;references:ID" json:"appRunRecords"` //运行记录
  33. Status string `json:"status"` //应用状态
  34. Role string `json:"role"` //应用角色
  35. }
  36. func (AppInstanceDao) TableName() string {
  37. return "app_instances"
  38. }
  39. type AppInstance struct {
  40. ID int64 `json:"id"` // 实例ID
  41. Name string `json:"name"` // 实例名称
  42. Description string `json:"description"` // 实例描述
  43. Content AppInfo `json:"content"` // 实例内容
  44. AppID int64 `json:"appID,string"` // 关联应用ID
  45. AppName string `json:"appName"` // 应用名称
  46. UserID cdssdk.UserID `json:"userID"` // 创建者
  47. CreatedAt time.Time `json:"createdAt"` // 创建时间
  48. UpdatedAt time.Time `json:"updatedAt"` // 更新时间
  49. DeletedAt time.Time `json:"-"` // 删除时间
  50. //回显
  51. AppRunRecords []AppRunRecordDao `gorm:"foreignKey:AppInstanceID;references:ID" json:"appRunRecords"` //运行记录
  52. Status string `json:"status"` //应用状态
  53. Role string `gorm:"-" json:"role"` //应用角色
  54. }
  55. type AppRunRecordDao struct {
  56. ID int64 `gorm:"primaryKey;autoIncrement;column:id" json:"id"` // 运行记录ID
  57. AppInstanceID AppInstanceID `gorm:"column:app_instance_id;type:bigint;not null" json:"appInstanceID"` // 关联应用实例ID
  58. Content string `gorm:"column:content;type:text;default:null" json:"content"` // 运行内容
  59. Status string `gorm:"column:status;type:varchar(100);not null" json:"status"` // 运行状态
  60. RunLog string `gorm:"column:run_log;type:text;default:null" json:"runLog"` // 运行日志
  61. RunID JobSetID `gorm:"column:run_id;type:varchar(100);default:null" json:"runID"` // 运行ID
  62. RunOutput string `gorm:"column:run_output;type:text;default:null" json:"runOutput"` // 运行输出
  63. UserID cdssdk.UserID `gorm:"column:user_id;type:bigint;default:null" json:"userID"` // 创建者
  64. CreatedAt time.Time `gorm:"column:created_at;type:timestamp;default:CURRENT_TIMESTAMP" json:"createdAt"` // 创建时间
  65. UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;default:null;onUpdate:CURRENT_TIMESTAMP" json:"updatedAt"` // 更新时间
  66. DeletedAt time.Time `gorm:"column:deleted_at;type:timestamp;default:null" json:"-"` // 删除时间
  67. AppRecordParams []AppRecordParam `gorm:"foreignKey:RecordID;references:ID" json:"appRecordParams"` // 运行记录参数
  68. }
  69. func (AppRunRecordDao) TableName() string {
  70. return "app_run_records"
  71. }
  72. type AppRunRecord struct {
  73. ID int64 `gorm:"primaryKey;autoIncrement;column:id" json:"id"` // 运行记录ID
  74. AppInstanceID AppInstanceID `gorm:"column:app_instance_id;type:bigint;not null" json:"appInstanceID"` // 关联应用实例ID
  75. Content AppInfo `gorm:"column:content;type:text;default:null" json:"content"` // 运行内容
  76. Status string `gorm:"column:status;type:varchar(100);not null" json:"status"` // 运行状态
  77. RunLog string `gorm:"column:run_log;type:text;default:null" json:"runLog"` // 运行日志
  78. RunID JobSetID `gorm:"column:run_id;type:varchar(100);default:null" json:"runID"` // 运行ID
  79. RunOutput string `gorm:"column:run_output;type:text;default:null" json:"runOutput"` // 运行输出
  80. UserID cdssdk.UserID `gorm:"column:user_id;type:bigint;default:null" json:"userID"` // 创建者
  81. CreatedAt time.Time `gorm:"column:created_at;type:timestamp;default:CURRENT_TIMESTAMP" json:"createdAt"` // 创建时间
  82. UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;default:null;onUpdate:CURRENT_TIMESTAMP" json:"updatedAt"` // 更新时间
  83. DeletedAt time.Time `gorm:"column:deleted_at;type:timestamp;default:null" json:"-"` // 删除时间
  84. AppRecordParams []AppRecordParam `gorm:"foreignKey:RecordID;references:ID" json:"appRecordParams"` // 运行记录参数
  85. }
  86. type AppRecordParam struct {
  87. RecordID int64 `gorm:"column:record_id;type:bigint;not null" json:"recordID"` // 应用运行记录ID
  88. InstanceID AppInstanceID `gorm:"column:instance_id;type:bigint;not null" json:"instanceID"` // 应用实例ID
  89. RunID JobSetID `gorm:"column:run_id;type:varchar(100);not null" json:"runID"` // 运行ID
  90. ParamKey string `gorm:"column:param_key;type:varchar(1000);default:null" json:"paramKey"` // 参数键
  91. ParamValue string `gorm:"column:param_value;type:varchar(1000);default:null" json:"paramValue"` // 参数值
  92. }
  93. func (AppRecordParam) TableName() string {
  94. return "app_record_params"
  95. }