admin

package
v0.0.0-...-4e81a15 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2017 License: GPL-3.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// TokenExpireAt 管理员Token过期时间
	TokenExpireAt = 60 * time.Minute

	// LogTypeSendUserGift 赠送礼品券
	LogTypeSendUserGift = "SENDUSERGIFT"
	// LogTypeOfflineRecharge 线下充值
	LogTypeOfflineRecharge = "OFFLINERECHARGE"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminDB

type AdminDB struct {
	DB *sqlx.DB
}

func (*AdminDB) Delete

func (db *AdminDB) Delete(adminID int) error

Delete 删除管理员

func (*AdminDB) Exists

func (db *AdminDB) Exists(mobileNumber string) (bool, error)

Exists 管理员是否存在,通过Mobile

func (*AdminDB) GetByID

func (db *AdminDB) GetByID(adminID int) (*AdminUser, error)

GetByID 获取管理员

func (*AdminDB) GetByMobile

func (db *AdminDB) GetByMobile(mobileNumber string) (*AdminUser, error)

GetByMobile 获取管理员,通过Mobile

func (*AdminDB) GetByToken

func (db *AdminDB) GetByToken(token string) (*AdminUser, error)

GetByToken 获取管理员,通过Token

func (*AdminDB) GetRoleByID

func (db *AdminDB) GetRoleByID(roleID int) (*Role, error)

GetRoleByID 获取角色

func (*AdminDB) Insert

func (db *AdminDB) Insert(a *InsertAdminUserParam) (int, error)

Insert 添加管理员管理员

func (*AdminDB) InsertLog

func (db *AdminDB) InsertLog(adminID int, logType, targetID, content string) error

InsertLog 插入管理员操作记录

func (*AdminDB) List

func (db *AdminDB) List() ([]AdminUser, error)

List 列出所有管理员管理员

func (*AdminDB) ListFuncByIDArr

func (db *AdminDB) ListFuncByIDArr(funcsIDs []int) ([]Func, error)

ListFuncByIDArr 列出指定功能

func (*AdminDB) ListLog

func (db *AdminDB) ListLog(logType, targetID string) ([]AdminLog, error)

ListLog 列出指定日志

func (*AdminDB) Update

func (db *AdminDB) Update(a *UpdateAdminUserParam) error

Update 更新管理员

func (*AdminDB) UpdateToken

func (db *AdminDB) UpdateToken(adminID int, ip string) (string, time.Time, time.Time, string, error)

UpdateToken 更新Token

func (*AdminDB) UpdateTokenExpireAt

func (db *AdminDB) UpdateTokenExpireAt(adminID int) (time.Time, error)

UpdateTokenExpireAt 更新Token过期时间

type AdminLog

type AdminLog struct {
	AdminID    int       `json:"adminID" db:"admin_id"`       // 管理员ID
	LogType    string    `json:"logType" db:"log_type"`       // 日志类型
	TargetID   string    `json:"targetID" db:"target_id"`     // 日志目标ID
	Content    string    `json:"content" db:"content"`        // 日志内容
	CreateTime time.Time `json:"createTime" db:"create_time"` // 创建时间

	AdminUser *AdminUser `json:"adminUser"` // 操作管理员
}

AdminLog 管理员操作记录

type AdminTx

type AdminTx struct {
	Tx *sqlx.Tx
}

func (*AdminTx) InsertLog

func (tx *AdminTx) InsertLog(adminID int, logType, targetID, content string) error

InsertLog 插入管理员操作记录

type AdminUser

type AdminUser struct {
	AdminID      int       `json:"adminID" db:"admin_id"`           // 管理员ID
	Active       bool      `json:"active" db:"active"`              // 是否可用
	Nickname     string    `json:"nickname" db:"nickname"`          // 昵称
	MobileNumber string    `json:"mobileNumber" db:"mobile_number"` // 手机号
	Password     string    `json:"password" db:"password"`          // 密码
	LastIP       string    `json:"lastIP" db:"last_ip"`             // 最后登录ip
	Token        string    `json:"token" db:"token"`                // token
	RoleID       int       `json:"roleID" db:"role_id"`             // 角色ID
	ExpireAt     time.Time `json:"expireAt" db:"expire_at"`         // token过期时间
	CreateTime   time.Time `json:"createTime" db:"create_time"`     // 创建时间
	UpdateTime   time.Time `json:"updateTime" db:"update_time"`     // 更新时间
	LoginTime    time.Time `json:"loginTime" db:"login_time"`       // 最后登录时间
	Role         Role      `json:"role"`                            // 角色
	FuncList     []Func    `json:"funcList"`                        // 功能
}

AdminUser 管理员结构体

type Func

type Func struct {
	FuncID     int       `json:"funcID" db:"func_id"`         // 功能id
	Active     bool      `json:"active" db:"active"`          // 是否可用
	Label      string    `json:"label" db:"label"`            // 功能名称
	ParentID   int       `json:"parentID" db:"parent_id"`     // 父功能id,根结父功能id为0
	Children   int       `json:"children" db:"children"`      // 子功能数量
	Level      int       `json:"level" db:"level"`            // 功能层级0、1
	URL        string    `json:"url" db:"url"`                // 功能地址
	CreateTime time.Time `json:"createTime" db:"create_time"` // 创建时间
	UpdateTime time.Time `json:"updateTime" db:"update_time"` // 更新时间
	Feature    string    `json:"feature" db:"feature"`        // Feature
	Focus      string    `json:"focus" db:"focus"`            // Focus
}

Func 功能结构体

type InsertAdminUserParam

type InsertAdminUserParam struct {
	Nickname     string `json:"nickname" form:"nickname"`         // 昵称
	MobileNumber string `json:"mobileNumber" form:"mobileNumber"` // 手机号
	Password     string `json:"password" form:"password"`         // 密码
	RoleID       int    `json:"roleID" form:"roleID"`             // 角色ID
}

InsertAdminUserParam 插入AdminUser参数

type Role

type Role struct {
	RoleID      int       `json:"roleID" db:"role_id"`          // 角色ID
	Active      bool      `json:"active" db:"active"`           // 是否可用
	Label       string    `json:"label" db:"label"`             // 角色名称
	Description string    `json:"description" db:"description"` // 描述
	FuncList    string    `json:"funcList" db:"func_list"`      // 功能列表,下划线分割
	CreateTime  time.Time `json:"createTime" db:"create_time"`  // 创建时间
	UpdateTime  time.Time `json:"updateTime" db:"update_time"`  // 更新时间
}

Role 角色结构体

type UpdateAdminUserParam

type UpdateAdminUserParam struct {
	AdminID  int    `json:"adminID" form:"adminID"`   // 管理员ID
	Nickname string `json:"nickname" form:"nickname"` // 昵称
	Password string `json:"password" form:"password"` // 密码
}

UpdateAdminUserParam 更新AdminUser参数

Jump to

Keyboard shortcuts

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