1Panel/backend/app/dto/app.go

179 lines
4.2 KiB
Go
Raw Normal View History

package dto
2022-09-30 17:56:06 +08:00
import (
"encoding/json"
2022-11-22 22:47:38 +08:00
"time"
"github.com/1Panel-dev/1Panel/backend/app/model"
2022-09-30 17:56:06 +08:00
)
type AppRes struct {
Version string `json:"version"`
CanUpdate bool `json:"canUpdate"`
Items []*AppDTO `json:"items"`
Tags []model.Tag `json:"tags"`
Total int64 `json:"total"`
}
type AppDTO struct {
model.App
2022-09-23 16:33:55 +08:00
Versions []string `json:"versions"`
Tags []model.Tag `json:"tags"`
}
type AppDetailDTO struct {
model.AppDetail
Params interface{} `json:"params"`
}
type AppRequest struct {
PageInfo
2022-09-23 16:33:55 +08:00
Name string `json:"name"`
Tags []string `json:"tags"`
2022-11-02 15:19:14 +08:00
Type string `json:"type"`
}
type AppInstallRequest struct {
AppDetailId uint `json:"appDetailId" validate:"required"`
Params map[string]interface{} `json:"params"`
2022-09-26 18:20:21 +08:00
Name string `json:"name" validate:"required"`
2022-10-07 15:49:39 +08:00
Services map[string]string `json:"services"`
}
2022-11-18 16:14:23 +08:00
type CheckInstalled struct {
2022-11-23 16:59:06 +08:00
IsExist bool `json:"isExist"`
Name string `json:"name"`
App string `json:"app"`
Version string `json:"version"`
Status string `json:"status"`
CreatedAt time.Time `json:"createdAt"`
LastBackupAt string `json:"lastBackupAt"`
AppInstallID uint `json:"appInstallId"`
ContainerName string `json:"containerName"`
2022-11-18 16:14:23 +08:00
}
type AppInstalled struct {
model.AppInstall
2022-11-22 14:22:25 +08:00
Total int `json:"total"`
Ready int `json:"ready"`
AppName string `json:"appName"`
Icon string `json:"icon"`
CanUpdate bool `json:"canUpdate"`
}
type AppInstalledRequest struct {
PageInfo
2022-10-28 17:04:57 +08:00
Type string `json:"type"`
2022-11-28 13:50:53 +08:00
Name string `json:"name"`
}
2022-09-26 18:20:21 +08:00
2022-10-12 18:57:22 +08:00
type AppBackupRequest struct {
PageInfo
AppInstallID uint `json:"appInstallID"`
}
type AppBackupDeleteRequest struct {
Ids []uint `json:"ids"`
}
2022-09-26 18:20:21 +08:00
type AppOperate string
var (
Up AppOperate = "up"
Down AppOperate = "down"
Restart AppOperate = "restart"
2022-09-26 22:54:38 +08:00
Delete AppOperate = "delete"
Sync AppOperate = "sync"
2022-10-12 18:57:22 +08:00
Backup AppOperate = "backup"
2022-10-13 16:46:38 +08:00
Restore AppOperate = "restore"
2022-10-13 18:56:53 +08:00
Update AppOperate = "update"
2022-09-26 18:20:21 +08:00
)
type AppInstallOperate struct {
InstallId uint `json:"installId" validate:"required"`
2022-10-13 16:46:38 +08:00
BackupId uint `json:"backupId"`
2022-10-13 18:56:53 +08:00
DetailId uint `json:"detailId"`
2022-09-26 18:20:21 +08:00
Operate AppOperate `json:"operate" validate:"required"`
}
type PortUpdate struct {
Key string `json:"key"`
Name string `json:"name"`
Port int64 `json:"port"`
}
2022-10-07 15:49:39 +08:00
type AppService struct {
Label string `json:"label"`
Value string `json:"value"`
}
type AppDatabase struct {
ServiceName string `json:"PANEL_DB_HOST"`
DbName string `json:"PANEL_DB_NAME"`
DbUser string `json:"PANEL_DB_USER"`
Password string `json:"PANEL_DB_USER_PASSWORD"`
}
type AuthParam struct {
RootPassword string `json:"PANEL_DB_ROOT_PASSWORD"`
}
type ContainerExec struct {
ContainerName string `json:"containerName"`
DbParam AppDatabase `json:"dbParam"`
Auth AuthParam `json:"auth"`
}
2022-10-13 18:56:53 +08:00
2022-10-14 14:48:55 +08:00
type AppOssConfig struct {
Version string `json:"version"`
Package string `json:"package"`
}
2022-10-13 18:56:53 +08:00
type AppVersion struct {
Version string `json:"version"`
DetailId uint `json:"detailId"`
}
2022-10-14 14:48:55 +08:00
type AppList struct {
Version string `json:"version"`
Tags []Tag `json:"tags"`
Items []AppDefine `json:"items"`
}
type AppDefine struct {
2022-11-22 14:32:45 +08:00
Key string `json:"key"`
Name string `json:"name"`
Tags []string `json:"tags"`
Versions []string `json:"versions"`
2022-10-14 14:48:55 +08:00
Author string `json:"author"`
Source string `json:"source"`
ShortDesc string `json:"short_desc"`
Type string `json:"type"`
Required []string `json:"Required"`
CrossVersionUpdate bool `json:"crossVersionUpdate"`
2022-11-22 14:32:45 +08:00
Limit int `json:"limit"`
2022-10-14 14:48:55 +08:00
}
func (define AppDefine) GetRequired() string {
by, _ := json.Marshal(define.Required)
return string(by)
}
type Tag struct {
Key string `json:"key"`
Name string `json:"name"`
}
type AppForm struct {
FormFields []AppFormFields `json:"form_fields"`
}
type AppFormFields struct {
Type string `json:"type"`
LabelZh string `json:"label_zh"`
LabelEn string `json:"label_en"`
Required string `json:"required"`
Default string `json:"default"`
EnvKey string `json:"env_variable"`
}