This commit is contained in:
parent
4907853667
commit
69028898a4
@ -4,7 +4,7 @@ Debug: true # 是否开启调试模式, 默认: false
|
||||
|
||||
JwtAuth: # JWT认证配置
|
||||
AccessSecret: CHANGE_ME_TO_A_RANDOM_SECRET # 访问令牌密钥, 请修改为随机字符串
|
||||
AccessExpire: 604800 # 访问令牌过期时间,单位秒, 默认: 604800 (7天)
|
||||
AccessExpire: 31536000 # 访问令牌过期时间,单位秒, 默认: 31536000 (365天); 用户每次活跃请求自动续期
|
||||
|
||||
Logger: # 日志配置
|
||||
FilePath: logs/ppanel.log # 日志文件路径
|
||||
|
||||
@ -61,7 +61,7 @@ type RedisConfig struct {
|
||||
|
||||
type JwtAuth struct {
|
||||
AccessSecret string `yaml:"AccessSecret"`
|
||||
AccessExpire int64 `yaml:"AccessExpire" default:"604800"`
|
||||
AccessExpire int64 `yaml:"AccessExpire" default:"31536000"` // JWT 签发有效期,单位秒,默认 365 天
|
||||
}
|
||||
|
||||
type Verify struct {
|
||||
|
||||
@ -38,11 +38,12 @@ func (l *GetUserListLogic) GetUserList(req *types.GetUserListRequest) (*types.Ge
|
||||
SubscribeId: req.SubscribeId,
|
||||
UserSubscribeId: req.UserSubscribeId,
|
||||
ShortCode: req.ShortCode,
|
||||
DeviceId: req.DeviceId,
|
||||
FamilyJoined: req.FamilyJoined,
|
||||
FamilyStatus: req.FamilyStatus,
|
||||
FamilyOwnerUserId: req.FamilyOwnerUserId,
|
||||
FamilyId: req.FamilyId,
|
||||
Order: "DESC",
|
||||
Order: req.SortOrder,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "GetUserListLogic failed: %v", err.Error())
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/perfect-panel/server/pkg/constant"
|
||||
|
||||
@ -67,6 +68,9 @@ func AuthMiddleware(svc *svc.ServiceContext) func(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// sliding session: refresh TTL on every active request
|
||||
svc.Redis.Expire(c, sessionIdCacheKey, time.Duration(svc.Config.JwtAuth.AccessExpire)*time.Second)
|
||||
|
||||
userInfo, err := svc.UserModel.FindOne(c, userId)
|
||||
if err != nil {
|
||||
logger.WithContext(c.Request.Context()).Debug("[AuthMiddleware] UserModel FindOne", logger.Field("error", err.Error()), logger.Field("userId", userId))
|
||||
|
||||
@ -63,6 +63,7 @@ type UserFilterParams struct {
|
||||
SubscribeId *int64
|
||||
UserSubscribeId *int64
|
||||
ShortCode string
|
||||
DeviceId *int64
|
||||
FamilyJoined *bool
|
||||
FamilyStatus string
|
||||
FamilyOwnerUserId *int64
|
||||
@ -187,6 +188,10 @@ func (m *customUserModel) QueryPageList(ctx context.Context, page, size int, fil
|
||||
conn = conn.Joins("LEFT JOIN user_device ON user.id = user_device.user_id").
|
||||
Where("user_device.short_code LIKE ?", "%"+filter.ShortCode+"%")
|
||||
}
|
||||
if filter.DeviceId != nil {
|
||||
conn = conn.Joins("LEFT JOIN user_device ud ON ud.user_id = user.id").
|
||||
Where("ud.id = ?", *filter.DeviceId)
|
||||
}
|
||||
|
||||
if filter.FamilyJoined != nil {
|
||||
if *filter.FamilyJoined {
|
||||
@ -228,7 +233,13 @@ func (m *customUserModel) QueryPageList(ctx context.Context, page, size int, fil
|
||||
}
|
||||
|
||||
if filter.Order != "" {
|
||||
conn = conn.Order(fmt.Sprintf("user.id %s", filter.Order))
|
||||
order := strings.ToUpper(filter.Order)
|
||||
if order != "ASC" && order != "DESC" {
|
||||
order = "DESC"
|
||||
}
|
||||
conn = conn.Order(fmt.Sprintf("user.id %s", order))
|
||||
} else {
|
||||
conn = conn.Order("user.id DESC")
|
||||
}
|
||||
if filter.Unscoped {
|
||||
conn = conn.Unscoped()
|
||||
|
||||
@ -1317,10 +1317,12 @@ type GetUserListRequest struct {
|
||||
SubscribeId *int64 `form:"subscribe_id,omitempty"`
|
||||
UserSubscribeId *int64 `form:"user_subscribe_id,omitempty"`
|
||||
ShortCode string `form:"short_code,omitempty"`
|
||||
DeviceId *int64 `form:"device_id,omitempty"`
|
||||
FamilyJoined *bool `form:"family_joined,omitempty"`
|
||||
FamilyStatus string `form:"family_status,omitempty"`
|
||||
FamilyOwnerUserId *int64 `form:"family_owner_user_id,omitempty"`
|
||||
FamilyId *int64 `form:"family_id,omitempty"`
|
||||
SortOrder string `form:"sort_order,omitempty"` // asc or desc, default desc
|
||||
}
|
||||
|
||||
type GetUserListResponse struct {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user