common

package
v0.0.0-...-45e8f3b Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ZERO = iota
	ONE
	TWO
)
View Source
const (
	UNDELETED // 未删除
	DELETED   // 已删除
)
View Source
const (
	BUSINESS_SYSTEM_OP
	BUSINESS_ERROR_LOG
	BUSINESS_USER_LOGIN
	BUSINESS_GLOBAL_VISIT
	BUSINESS_ARTICLE_VISIT
	BUSINESS_ARTICLE_LIKE
	BUSINESS_ARTICLE_UNLIKE

	BUSINESS_ARTICLE_COMMENT
	BUSINESS_COMMENT_LIKE
	BUSINESS_COMMENT_UNLIKE

	BUSINESS_COMMENT_REPLY
	BUSINESS_REPLY_LIKE
	BUSINESS_REPLY_UNLIKE
)

business_kind * 1.系统操作;2.错误日志;3.用户登录;4.全站浏览;5.文章浏览;6.文章赞;7.文章踩;8.文章评论;9.评论赞;10.评论踩;11.评论回复;12.回复赞;13.回复踩

View Source
const (
	ARTICLE_NORMAL = iota + 1
	ARTICLE_ABOUT
	ARTICLE_NOTE
)

article kind

View Source
const (
	ADMIN = "admin"
	COLOR = "#000000"
	ITV   = 3600 * 24 // 有效时间
)
View Source
const (
	KEY_1 = "admin.pass"
	KEY_2 = "cmnt.open"
	KEY_3 = "cmnt.check"
)

quanta key

View Source
const (
	LV0 = iota // 游客
	LV1        // 普通
	LV2        // 观察者
	LV3        // 测试者
	LV4
	LV5
	LV6
	LV7
	LV8 // 管理员
	LV9 // 系统管理员
)
View Source
const (
	X_ID    = "i"
	X_ROLE  = "r"
	X_TIME  = "t"
	X_USER  = "x"
	X_TRACE = "c"
)
View Source
const PERMISSION = LV8
View Source
const USER_AGENT = "User-Agent"

Variables

View Source
var (
	Cfg   *viper.Viper
	DB    *sqlx.DB
	Redis *redis.Client
	Email *yuEmail
	Ylog  *ylog
)

Functions

func NewYlog

func NewYlog(level, timeFormat, outFile string) *ylog

func NewYuEmail

func NewYuEmail(email *gomail.Message) *yuEmail

Types

type BaseCache

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

基础缓存

func (*BaseCache) Error

func (s *BaseCache) Error(err error, param ...interface{}) bool

func (*BaseCache) Info

func (s *BaseCache) Info(param ...interface{})

func (*BaseCache) SetTracker

func (b *BaseCache) SetTracker(tracker *Tracker)

type BaseController

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

基础控制器

func (BaseController) Error

func (s BaseController) Error(traceId string, err error, param ...interface{}) bool

func (BaseController) Info

func (s BaseController) Info(traceId string, param ...interface{})

func (*BaseController) SetTracker

func (b *BaseController) SetTracker(tracker *Tracker)

type BaseDao

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

基础dao

func (*BaseDao) Error

func (s *BaseDao) Error(err error, param ...interface{}) bool

func (*BaseDao) Info

func (s *BaseDao) Info(param ...interface{})

func (*BaseDao) SetTracker

func (b *BaseDao) SetTracker(tracker *Tracker)

type BaseService

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

基础服务

func (*BaseService) Error

func (s *BaseService) Error(err error, param ...interface{}) bool

func (*BaseService) Info

func (s *BaseService) Info(param ...interface{})

func (*BaseService) SetTracker

func (b *BaseService) SetTracker(tracker *Tracker)

type MIF

type MIF = map[int]interface{}

type MII

type MII = map[int]int

type MIS

type MIS = map[int]string

type MSF

type MSF = map[string]interface{}

type MSI

type MSI = map[string]int

type MSS

type MSS = map[string]string

type MessageContent

type MessageContent struct {
	FromUserName string
	TimeDate     string
	Content      string
}

func NewMessageContent

func NewMessageContent(fromUserName, content string) *MessageContent

type Page

type Page struct {
	PageNum     int  `json:"pageNum" validate:"required,gt=0"`  // 当前页码
	PageSize    int  `json:"pageSize" validate:"required,gt=0"` // 每页记录条数
	Total       int  `json:"total"`                             // 记录总量
	PageMax     int  `json:"pageMax"`                           // 最大页码
	PrePage     int  `json:"prePage"`                           // 上一页码,如果没有为 0
	NextPage    int  `json:"nextPage"`                          // 下一页码,如果没有为 0
	HasPrePage  bool `json:"hasPrePage"`                        // 是否有上一页
	HasNextPage bool `json:"hasNextPage"`                       // 是否有下一页
	Remainder   int  `json:"remainder"`                         // 剩余数据量
	StartRow    int  `json:"-"`                                 // 记录开始行
	StopRow     int  `json:"-"`                                 // 记录结束行
	// contains filtered or unexported fields
}

func NewPage

func NewPage(pageNum, pageSize int) *Page

func NewPageAll

func NewPageAll() *Page

func NewPageOne

func NewPageOne() *Page

func (*Page) Next

func (p *Page) Next() bool

func (*Page) SetTotal

func (p *Page) SetTotal(total int)

type Tracker

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

func NewSimpleTracker

func NewSimpleTracker(traceId string) *Tracker

func NewTracker

func NewTracker(user *XUser, startTime time.Time, traceId, agent string) *Tracker

func (*Tracker) GetAgent

func (t *Tracker) GetAgent() string

func (*Tracker) GetStartTime

func (t *Tracker) GetStartTime() time.Time

func (*Tracker) GetTraceId

func (t *Tracker) GetTraceId() string

func (*Tracker) GetUser

func (t *Tracker) GetUser() *XUser

type XUser

type XUser struct {
	Id   int
	Role int
	Ip   string
}

func (*XUser) GetIp

func (x *XUser) GetIp() string

Jump to

Keyboard shortcuts

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