resource

package
v1.0.23 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PageResourceRequest

type PageResourceRequest struct {
	Page     uint32  `json:"page"`
	PageSize uint32  `json:"page_size"`
	ServerId *uint32 `json:"server_id"`
	Keyword  *string `json:"keyword"`
	Tag      *string `json:"tag"`
}

type Repo

type Repo interface {
	GetResource(ctx kratosx.Context, id uint32) (*Resource, error)
	GetResourceByKeyword(ctx kratosx.Context, key string) (*Resource, error)
	PageResource(ctx kratosx.Context, req *PageResourceRequest) ([]*Resource, uint32, error)
	AddResource(ctx kratosx.Context, c *Resource) (uint32, error)
	UpdateResource(ctx kratosx.Context, c *Resource) error
	DeleteResource(ctx kratosx.Context, uint322 uint32) error
	GetResourceValues(ctx kratosx.Context, rid uint32) ([]*ResourceValue, error)
	UpdateResourceValue(ctx kratosx.Context, rv *ResourceValue) error
	GetResourceServerIds(ctx kratosx.Context, id uint32) ([]uint32, error)
	AllResourceValue(ctx kratosx.Context, eid, sid uint32) ([]*ResourceValue, error)
	AllResourceField(ctx kratosx.Context, sid uint32) ([]string, error)
	CheckResourceValue(ctx kratosx.Context, rid uint32, value string) error
}

type Resource

type Resource struct {
	ktypes.BaseModel
	Keyword         string            `json:"keyword"`
	Description     string            `json:"description"`
	Fields          string            `json:"fields"`
	Tag             string            `json:"tag"`
	Private         *bool             `json:"private"`
	ResourceServers []*ResourceServer `json:"resource_servers"`
}

type ResourceServer

type ResourceServer struct {
	ktypes.CreateModel
	ServerId   uint32 `json:"server_id"`
	ResourceId uint32 `json:"resource_id"`
}

type ResourceValue

type ResourceValue struct {
	ktypes.BaseModel
	EnvId      uint32    `json:"env_id"`
	ResourceId uint32    `json:"resource_id"`
	Value      string    `json:"value"`
	Resource   *Resource `json:"resource" gorm:"foreignKey:resource_id;references:id"`
}

type UseCase

type UseCase struct {
	// contains filtered or unexported fields
}

func NewUseCase

func NewUseCase(config *config.Config, repo Repo) *UseCase

func (*UseCase) AddResource

func (u *UseCase) AddResource(ctx kratosx.Context, resource *Resource) (uint32, error)

AddResource 添加资源信息

func (*UseCase) AllResourceField

func (u *UseCase) AllResourceField(ctx kratosx.Context, sid uint32) ([]string, error)

AllResourceField 获取指定服务资源的字段

func (*UseCase) DeleteResource

func (u *UseCase) DeleteResource(ctx kratosx.Context, id uint32) error

DeleteResource 删除资源信息

func (*UseCase) GetResource

func (u *UseCase) GetResource(ctx kratosx.Context, id uint32) (*Resource, error)

GetResource 获取指定资源信息

func (*UseCase) GetResourceByKeyword

func (u *UseCase) GetResourceByKeyword(ctx kratosx.Context, keyword string) (*Resource, error)

GetResourceByKeyword 获取指定标识的资源信息

func (*UseCase) GetResourceServerIds

func (u *UseCase) GetResourceServerIds(ctx kratosx.Context, rid uint32) ([]uint32, error)

GetResourceServerIds 获取指定资源的关联服务id

func (*UseCase) GetResourceValues

func (u *UseCase) GetResourceValues(ctx kratosx.Context, rid uint32) ([]*ResourceValue, error)

GetResourceValues 获取指定资源的所有环境值

func (*UseCase) PageResource

func (u *UseCase) PageResource(ctx kratosx.Context, req *PageResourceRequest) ([]*Resource, uint32, error)

PageResource 获取分页资源信息

func (*UseCase) UpdateResource

func (u *UseCase) UpdateResource(ctx kratosx.Context, resource *Resource) error

UpdateResource 更新资源信息

func (*UseCase) UpdateResourceValue

func (u *UseCase) UpdateResourceValue(ctx kratosx.Context, rv *ResourceValue) error

UpdateResourceValue 更新指定资源的值

Jump to

Keyboard shortcuts

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