Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateToken(info *AdminJwtData, expiredSeconds int) (tokenString string, err error)
- func MongoInit()
- func RedisInit()
- func RefreshToken(tokenString string, expiredSeconds int) (string, error)
- type AdminJwtData
- type Claims
- type MongoObj
- func (m *MongoObj) Aggregate(db, tableName string, pipeline interface{}, opts ...*options.AggregateOptions) (*mongo.Cursor, error)
- func (m *MongoObj) CountDocuments(db, tableName string, filter interface{}) (int64, error)
- func (m *MongoObj) Find(db, tableName string, document, filter interface{}, ...) (int64, error)
- func (m *MongoObj) FindOne(db, tableName string, filter, document interface{}, ...) error
- func (m *MongoObj) InsertOne(db, tableName string, document interface{}) (*mongo.InsertOneResult, error)
- func (m *MongoObj) UpdateOne(db, tableName string, filter, document interface{}, ...) (*mongo.UpdateResult, error)
- type RedisOp
- func (c *RedisOp) Del(key string) error
- func (c *RedisOp) Exists(key string) bool
- func (c *RedisOp) Expire(key string, expired int) bool
- func (c *RedisOp) Get(key string) (result interface{}, err error)
- func (c *RedisOp) LPush(key string, value interface{}) error
- func (c *RedisOp) RPop(key string) (result interface{}, err error)
- func (c *RedisOp) Set(key string, value interface{}) error
- func (c *RedisOp) SetEx(key string, timeout time.Duration, value interface{}) error
- func (c *RedisOp) Ttl(key string) int64
Constants ¶
View Source
const ( KEY string = "JWT_ARY-START" DEFAULT_EXPIRE_SECONDS int = 7200 //默认过期时间 )
View Source
const ( CmsRoleKey = iota //0 后台角色 key CmsRouteKey // 1 后台路由 key CmsUserLoginKey // 2 后台用户登录 key JobTaskRunLog // 4 定时任务执行日志 MessageQueue // 4 消息通知和队列 )
Variables ¶
View Source
var (
MgoClient = &MongoObj{}
)
View Source
var RedisKeyList = map[int]string{ CmsRoleKey: "CmsRoleInfo", CmsRouteKey: "CmsRouteInfo", CmsUserLoginKey: "CmsUserLoginInfo_", JobTaskRunLog: "JobTaskRunLog", MessageQueue: "MessageQueue", }
redis key管理集合
View Source
var (
RedisObj = &RedisOp{}
)
Functions ¶
func GenerateToken ¶
func GenerateToken(info *AdminJwtData, expiredSeconds int) (tokenString string, err error)
获取jwt token
Types ¶
type AdminJwtData ¶
管理员 token数据
func ValidateToken ¶
func ValidateToken(tokenString string) (info *AdminJwtData, err error)
验证jwt token
type Claims ¶
type Claims struct { Admin *AdminJwtData jwt.StandardClaims }
JWT -- json web token HEADER PAYLOAD SIGNATURE This struct is the PAYLOAD
type MongoObj ¶
type MongoObj struct {
// contains filtered or unexported fields
}
func (*MongoObj) Aggregate ¶
func (m *MongoObj) Aggregate(db, tableName string, pipeline interface{}, opts ...*options.AggregateOptions) (*mongo.Cursor, error)
聚合查询
func (*MongoObj) CountDocuments ¶
func (*MongoObj) FindOne ¶
func (m *MongoObj) FindOne(db, tableName string, filter, document interface{}, opts ...*options.FindOneOptions) error
func (*MongoObj) InsertOne ¶
func (m *MongoObj) InsertOne(db, tableName string, document interface{}) (*mongo.InsertOneResult, error)
func (*MongoObj) UpdateOne ¶
func (m *MongoObj) UpdateOne(db, tableName string, filter, document interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
Click to show internal directories.
Click to hide internal directories.