models

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangePasswordRequest added in v0.1.3

type ChangePasswordRequest struct {
	OldPassword string `json:"old_password" binding:"required"`
	NewPassword string `json:"new_password" binding:"required,min=6"`
}

type ClusterListResponse added in v0.3.1

type ClusterListResponse struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Server      string `json:"server"`
	Version     string `json:"version"`
	Status      string `json:"status"`
	Source      string `json:"source"`
	Environment string `json:"environment"`
}

type ClusterResponse added in v0.3.1

type ClusterResponse struct {
	ID          string            `json:"id"`
	Name        string            `json:"name"`
	Provider    string            `json:"provider"`
	Description string            `json:"description"`
	Environment string            `json:"environment"`
	Region      string            `json:"region"`
	Version     string            `json:"version"`
	Status      string            `json:"status"`
	Source      string            `json:"source"`
	Labels      map[string]string `json:"labels"`
	CreatedAt   time.Time         `json:"created_at"`
	UpdatedAt   time.Time         `json:"updated_at"`
}

type CreateClusterRequest added in v0.3.1

type CreateClusterRequest struct {
	Name           string `json:"name" binding:"required"`
	KubeconfigData string `json:"kubeconfigData" binding:"required"` // Base64 编码的 kubeconfig 字符串
	Provider       string `json:"provider"`
	Description    string `json:"description"`
	Environment    string `json:"environment"`
	Region         string `json:"region"`
}

type CreateUserRequest added in v0.1.2

type CreateUserRequest struct {
	Username        string `json:"username"`
	ConfirmPassword string `json:"confirmPassword"`
	Password        string `json:"password"`
	Email           string `json:"email"`
	Roles           string `json:"roles"`
}

type CreateUserResponse added in v0.1.2

type CreateUserResponse struct {
	Username string `json:"username"`
	Email    string `json:"email"`
	Roles    string `json:"roles"`
	Status   string `json:"status"`
}

type LoginRequest added in v0.1.2

type LoginRequest struct {
	Username string `json:"username" binding:"required,min=3,max=50"`
	Password string `json:"password" binding:"required,min=6"`
}

LoginRequest

type LoginResponse added in v0.1.2

type LoginResponse struct {
	Token     string       `json:"token"`
	ExpiresAt time.Time    `json:"expires_at"`
	User      UserResponse `json:"user"`
}

type RegisterRequest added in v0.1.3

type RegisterRequest struct {
	Username string `json:"username" binding:"required,min=3,max=50"`
	Email    string `json:"email" binding:"required,email"`
	Password string `json:"password" binding:"required,min=6"`
}

LoginResponse 登录成功后返回 jwt token

type ResourceSummary

type ResourceSummary struct {
	Nodes             *int `json:"nodes"`
	Namespaces        *int `json:"namespaces"`
	Pods              *int `json:"pods"`
	Deployments       *int `json:"deployments"`
	Services          *int `json:"services"`
	PersistentVolumes *int `json:"persistentVolumes"`
	Pvcs              *int `json:"pvcs"` // PersistentVolumeClaims
	StatefulSets      *int `json:"statefulSets"`
	DaemonSets        *int `json:"daemonSets"`
	ConfigMaps        *int `json:"configMaps"`
	Secrets           *int `json:"secrets"`
	Ingresses         *int `json:"ingresses"`
}

ResourceSummary represents the count of various cluster resources. Use pointers to distinguish between a count of 0 and a failure to retrieve count.

type UpdateClusterRequest added in v0.3.1

type UpdateClusterRequest struct {
	Name           string            `json:"name"`
	Provider       string            `json:"provider"`
	Description    string            `json:"description"`
	Environment    string            `json:"environment"`
	Region         string            `json:"region"`
	Status         string            `json:"status"`
	Labels         map[string]string `json:"labels"`
	KubeconfigData string            `json:"kubeconfigData,omitempty"`
}

type UpdateProfileRequest added in v0.1.3

type UpdateProfileRequest struct {
	Email string `json:"email" binding:"required,email"`
}

type User added in v0.1.2

type User struct {
	ID        uint           `json:"id" gorm:"primaryKey"`
	Username  string         `json:"username" gorm:"uniqueIndex;not null;size:50"`
	Email     string         `json:"email" gorm:"uniqueIndex;not null;size:100"`
	Password  string         `json:"-" gorm:"not null"`
	Role      string         `json:"role" gorm:"default:user;size:20"`
	IsActive  bool           `json:"is_active" gorm:"default:true"`
	LastLogin *time.Time     `json:"last_login"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}

User 用户模型

func (*User) BeforeCreate added in v0.1.3

func (u *User) BeforeCreate(tx *gorm.DB) error

BeforeCreate GORM钩子:创建前加密密码

func (*User) CheckPassword added in v0.1.3

func (u *User) CheckPassword(password string) bool

CheckPassword 验证密码

func (*User) HashPassword added in v0.1.3

func (u *User) HashPassword() error

HashPassword 加密密码

func (*User) IsAdmin added in v0.1.3

func (u *User) IsAdmin() bool

IsAdmin 检查是否为管理员

func (User) TableName added in v0.1.2

func (User) TableName() string

TableName 指定表名

func (*User) ToResponse added in v0.1.3

func (u *User) ToResponse() UserResponse

ToResponse 转换为响应格式

type UserResponse added in v0.1.3

type UserResponse struct {
	ID        uint       `json:"id"`
	Username  string     `json:"username"`
	Email     string     `json:"email"`
	Role      string     `json:"role"`
	IsActive  bool       `json:"is_active"`
	LastLogin *time.Time `json:"last_login"`
	CreatedAt time.Time  `json:"created_at"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL