common

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2021 License: AGPL-3.0 Imports: 16 Imported by: 0

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 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 *gin.Context, scopeInfo ScopeInfo, name apistructs.TemplateName, res *StandardResult, ctx map[string]interface{}) *apistructs.Audit

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

type Page

type Page struct {
	SerialVersionUID *int64 `json:"serialVersionUID"`
	PageSize         int64  `json:"pageSize"`
	CurPage          int64  `json:"curPage"`
	TotalNum         int64  `json:"totalNum"`
	StartIndex       int64  `json:"startIndex"`
	EndIndex         int64  `json:"endIndex"`
}

func NewPage

func NewPage() *Page

func NewPage2

func NewPage2(PageSize int64, CurPage int64) *Page

func NewPage3

func NewPage3(PageSize int64, CurPage int64, TotalNum int64) *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{} `json:"result"`
	Page   *Page       `json:"page"`
}

func (PageQuery) Convert

func (query PageQuery) Convert() NewPageQuery

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