feat:完善项目
This commit is contained in:
24
app/event/account.go
Normal file
24
app/event/account.go
Normal file
@ -0,0 +1,24 @@
|
||||
package event
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type AccountUserLoginProduce struct{}
|
||||
|
||||
// Handle 帐号登录事件
|
||||
func (this *AccountUserLoginProduce) Handle(arg ...interface{}) {
|
||||
tenantID := arg[0].(uint64)
|
||||
uid := arg[1].(uint64)
|
||||
equipment := arg[2].(string)
|
||||
ip := arg[3].(string)
|
||||
|
||||
mSysUserLoginLogs := model.NewSysUserLoginLog()
|
||||
mSysUserLoginLogs.TenantID = tenantID
|
||||
mSysUserLoginLogs.UID = uid
|
||||
mSysUserLoginLogs.Equipment = equipment
|
||||
mSysUserLoginLogs.IP = ip
|
||||
_ = model.Create(mSysUserLoginLogs)
|
||||
}
|
||||
|
||||
func NewAccountUserLoginProduce() *AccountUserLoginProduce {
|
||||
return &AccountUserLoginProduce{}
|
||||
}
|
25
app/event/log.go
Normal file
25
app/event/log.go
Normal file
@ -0,0 +1,25 @@
|
||||
package event
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type SysLogProduce struct{}
|
||||
|
||||
// Handle
|
||||
func (this *SysLogProduce) Handle(arg ...interface{}) {
|
||||
tenantID := arg[0].(uint64)
|
||||
uid := arg[1].(uint64)
|
||||
ip := arg[3].(string)
|
||||
|
||||
mSysLog := model.NewSysLog()
|
||||
mSysLog.TenantID = tenantID
|
||||
mSysLog.UID = uid
|
||||
mSysLog.Name = ""
|
||||
mSysLog.Method = ""
|
||||
mSysLog.Params = ""
|
||||
mSysLog.IP = ip
|
||||
_ = model.Create(mSysLog)
|
||||
}
|
||||
|
||||
func NewSysLogProduce() *SysLogProduce {
|
||||
return &SysLogProduce{}
|
||||
}
|
56
app/event/redis.go
Normal file
56
app/event/redis.go
Normal file
@ -0,0 +1,56 @@
|
||||
package event
|
||||
|
||||
import (
|
||||
"SciencesServer/serve/cache"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type (
|
||||
RedisHashProduce struct{}
|
||||
|
||||
RedisHashDestroy struct{}
|
||||
)
|
||||
|
||||
type (
|
||||
RedisListProduce struct{}
|
||||
|
||||
RedisListDestroy struct{}
|
||||
)
|
||||
|
||||
func (this *RedisHashProduce) Handle(args ...interface{}) {
|
||||
_ = cache.Cache.HSet(args[0].(string), args[1].(string), args[2])
|
||||
}
|
||||
|
||||
func NewRedisHashProduce() *RedisHashProduce {
|
||||
return &RedisHashProduce{}
|
||||
}
|
||||
|
||||
func (this *RedisHashDestroy) Handle(args ...interface{}) {
|
||||
fields := make([]string, 0)
|
||||
|
||||
for i := 1; i < len(args); i++ {
|
||||
fields = append(fields, args[i].(string))
|
||||
}
|
||||
_ = cache.Cache.HDel(args[0].(string), fields...)
|
||||
}
|
||||
|
||||
func NewRedisHashDestroy() *RedisHashDestroy {
|
||||
return &RedisHashDestroy{}
|
||||
}
|
||||
|
||||
func (this *RedisListProduce) Handle(args ...interface{}) {
|
||||
_ = cache.Cache.SAdd(args[0].(string), args[1:]...)
|
||||
}
|
||||
|
||||
func NewRedisListProduce() *RedisListProduce {
|
||||
return &RedisListProduce{}
|
||||
}
|
||||
|
||||
func (this *RedisListDestroy) Handle(args ...interface{}) {
|
||||
err := cache.Cache.SRem(args[0].(string), args[1:]...)
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
func NewRedisListDestroy() *RedisListDestroy {
|
||||
return &RedisListDestroy{}
|
||||
}
|
Reference in New Issue
Block a user