base

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERROR   = -1
	SUCCESS = 1
)

Variables

This section is empty.

Functions

func Fail

func Fail(c *gin.Context)

func FailWithDetailed

func FailWithDetailed(data interface{}, message string, c *gin.Context)

func FailWithMessage

func FailWithMessage(message string, c *gin.Context)

func Ok

func Ok(c *gin.Context)

func OkWithData

func OkWithData(data interface{}, c *gin.Context)

func OkWithDetailed

func OkWithDetailed(data interface{}, message string, c *gin.Context)

func OkWithMessage

func OkWithMessage(message string, c *gin.Context)

func Result

func Result(code int, data interface{}, msg string, c *gin.Context)

Types

type CabinInReceive

type CabinInReceive struct {
	PType    string `json:"pType"`    //
	Source   string `json:"source"`   //
	Resource string `json:"resource"` // 路径
	Domain   string `json:"domain"`   //
	Method   string `json:"method"`   //
}

CabinInReceive Cabin structure for input parameters

type DevopsModel

type DevopsModel struct {
	ID          uint           `gorm:"primaryKey;column:id;type:bigint;not null" json:"id"` // 主键
	CreatedTime LocalTime      `json:"created_time"`
	UpdatedTime LocalTime      `json:"updatedTime"`
	DeletedTime gorm.DeletedAt `json:"-"`
}

type LocalTime

type LocalTime struct {
	time.Time
}

LocalTime 自定义时间处理

func (LocalTime) MarshalJSON

func (t LocalTime) MarshalJSON() ([]byte, error)

func (*LocalTime) Scan

func (t *LocalTime) Scan(v interface{}) error

Scan value time.Time

func (LocalTime) Value

func (t LocalTime) Value() (driver.Value, error)

Value insert timestamp into mysql need this function.

type PageRequest

type PageRequest struct {
	Page     int64    `json:"page"`
	PageSize int64    `json:"pageSize"`
	Filter   []string `json:"filter"`
}

type PageResult

type PageResult struct {
	List     interface{} `json:"list"`
	Total    int64       `json:"total"`
	Page     int64       `json:"page"`
	PageSize int64       `json:"pageSize"`
}

type Repository

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

Repository prepare for domain

func NewRepository

func NewRepository(db *gorm.DB, dstStruct interface{}) *Repository

func (*Repository) Counts

func (r *Repository) Counts(dst *int64, filter ...interface{}) error

Counts 根据条件获取列表

func (*Repository) Delete

func (r *Repository) Delete(dst interface{}, filter ...interface{}) error

func (*Repository) Find

func (r *Repository) Find(dst interface{}, filter ...interface{}) error

Find 根据条件获取全部

func (*Repository) First

func (r *Repository) First(dst interface{}, filter interface{}) error

First 根据条件查询第一条记录

func (*Repository) GetDB

func (r *Repository) GetDB() *gorm.DB

func (*Repository) Last

func (r *Repository) Last(dst interface{}, filter interface{}) error

Last 随机获取一条记录

func (*Repository) List

func (r *Repository) List(dst interface{}, pageSize int64, page int64, filter ...interface{}) error

List 根据条件获取列表

func (*Repository) Save

func (r *Repository) Save(data interface{}) error

func (*Repository) SetRepository

func (r *Repository) SetRepository(model interface{}) *Repository

func (*Repository) Take

func (r *Repository) Take(dst interface{}, filter interface{}) error

Take 随机获取一条记录

type Response

type Response struct {
	Code int         `json:"code"`
	Data interface{} `json:"data"`
	Msg  string      `json:"msg"`
}

type Token

type Token struct {
	Value string
}

func (*Token) GetRequestMetadata

func (t *Token) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)

GetRequestMetadata 获取当前请求认证所需的元数据

func (*Token) RequireTransportSecurity

func (t *Token) RequireTransportSecurity() bool

RequireTransportSecurity 是否需要基于 TLS 认证进行安全传输

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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