common

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: Apache-2.0 Imports: 30 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DEFAULT_PAGE_SIZE int64 = 15
	DEFAULT_TOTAL_NUM int64 = 0
)
View Source
var AccessLog *logrus.Logger
View Source
var ErrorLog = logrus.StandardLogger()

Functions

func AccessLogWrap added in v1.3.0

func AccessLogWrap(log *logrus.Logger) transport.ServiceOption

func AccessWrap

func AccessWrap(log *logrus.Logger) gin.HandlerFunc

Logger is the logrus logger handler

func AsyncRuntimeError

func AsyncRuntimeError(runtimeId, humanLog, primevalLog string)

func InitLogger

func InitLogger()

func LogFileRotate

func LogFileRotate(logger *logrus.Logger, logPath string, maxAge time.Duration, rotationTime time.Duration, prettyPrint bool)

func MakeAuditInfo

func MakeAuditInfo(reqCtx context.Context, scopeInfo ScopeInfo, name apistructs.TemplateName, errInfo error, ctx map[string]interface{}) *apistructs.Audit

func NewPage

func NewPage() *pb.Page

func NewPage2

func NewPage2(PageSize int64, CurPage int64) *pb.Page

func NewPage3

func NewPage3(PageSize int64, CurPage int64, TotalNum int64) *pb.Page

Types

type ErrInfo

type ErrInfo struct {
	Code  string `json:"code,omitempty"`
	Msg   string `json:"msg,omitempty"`
	EnMsg string `json:"-"`
}

type LineHook

type LineHook struct {
	Field string
	Skip  int

	Formatter func(file, function string, line int) string
	// contains filtered or unexported fields
}

func NewLineHook

func NewLineHook(levels ...logrus.Level) *LineHook

func (*LineHook) Fire

func (hook *LineHook) Fire(entry *logrus.Entry) error

func (*LineHook) Levels

func (hook *LineHook) Levels() []logrus.Level

type NewPageQuery

type NewPageQuery struct {
	List  interface{} `json:"list"`
	Total int64       `json:"total"`
}

func NewPages

func NewPages(list interface{}, total int64) NewPageQuery

func (NewPageQuery) ToPbPage added in v1.3.0

func (query NewPageQuery) ToPbPage() *pb.NewPageResult

type Page

type Page pb.Page

func (*Page) GetCurPage

func (page *Page) GetCurPage() int64

*

  • 获取分页当前页码

func (*Page) GetEndIndex

func (page *Page) GetEndIndex() int64

func (*Page) GetPageSize

func (page *Page) GetPageSize() int64

*

  • 获取每页条数

func (*Page) GetStartIndex

func (page *Page) GetStartIndex() int64

func (*Page) GetTotalNum

func (page *Page) GetTotalNum() int64

*

  • 获取查询结果总条数

func (*Page) GetTotalPageNum

func (page *Page) GetTotalPageNum() int64

*

  • 获取分页后页面总数

func (*Page) SetCurPage

func (page *Page) SetCurPage(num int64)

*

  • 设置当前页码

func (*Page) SetPageSize

func (page *Page) SetPageSize(size int64)

*

  • 设置每页条数

func (*Page) SetTotalNum

func (page *Page) SetTotalNum(num int64)

*

  • 设置结果总条数

type PageQuery

type PageQuery struct {
	Result interface{}
	Page   *pb.Page
}

func GetPageQuery added in v1.3.0

func GetPageQuery(page *Page, list interface{}) PageQuery

func (PageQuery) Convert

func (query PageQuery) Convert() NewPageQuery

func (PageQuery) ToPbPage added in v1.3.0

func (query PageQuery) ToPbPage() *pb.PageResult

type ScopeInfo

type ScopeInfo struct {
	ProjectId   string
	Workspace   string
	AppId       string
	ServiceName string
	RuntimeName string
}

type StandardResult

type StandardResult struct {
	Success bool        `json:"success"`
	Data    interface{} `json:"data"`
	Err     *ErrInfo    `json:"err"`
}

func NewStandardResult

func NewStandardResult(succ ...bool) *StandardResult

func (*StandardResult) SetErrorInfo

func (result *StandardResult) SetErrorInfo(errInfo *ErrInfo) *StandardResult

func (*StandardResult) SetReturnCode

func (result *StandardResult) SetReturnCode(returnCode StandaredReturnCode) *StandardResult

func (*StandardResult) SetSuccessAndData

func (result *StandardResult) SetSuccessAndData(data interface{}) *StandardResult

func (*StandardResult) SwitchLang

func (result *StandardResult) SwitchLang(c *gin.Context) *StandardResult

type StandaredReturnCode

type StandaredReturnCode interface {
	GetCode() string
	GetMessage() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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