feat(log): add UserSubscribeId to FilterSubscribeLogRequest for enhanced filtering
This commit is contained in:
parent
6460f2f2e1
commit
d477ba4772
@ -46,6 +46,7 @@ type (
|
|||||||
FilterSubscribeLogRequest {
|
FilterSubscribeLogRequest {
|
||||||
FilterLogParams
|
FilterLogParams
|
||||||
UserId int64 `form:"user_id,optional"`
|
UserId int64 `form:"user_id,optional"`
|
||||||
|
UserSubscribeId int64 `form:"user_subscribe_id,optional"`
|
||||||
}
|
}
|
||||||
FilterSubscribeLogResponse {
|
FilterSubscribeLogResponse {
|
||||||
Total int64 `json:"total"`
|
Total int64 `json:"total"`
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package log
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/perfect-panel/server/internal/model/log"
|
"github.com/perfect-panel/server/internal/model/log"
|
||||||
"github.com/perfect-panel/server/internal/svc"
|
"github.com/perfect-panel/server/internal/svc"
|
||||||
@ -17,7 +18,7 @@ type FilterSubscribeLogLogic struct {
|
|||||||
svcCtx *svc.ServiceContext
|
svcCtx *svc.ServiceContext
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter subscribe log
|
// NewFilterSubscribeLogLogic Filter subscribe log
|
||||||
func NewFilterSubscribeLogLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FilterSubscribeLogLogic {
|
func NewFilterSubscribeLogLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FilterSubscribeLogLogic {
|
||||||
return &FilterSubscribeLogLogic{
|
return &FilterSubscribeLogLogic{
|
||||||
Logger: logger.WithContext(ctx),
|
Logger: logger.WithContext(ctx),
|
||||||
@ -27,13 +28,19 @@ func NewFilterSubscribeLogLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *FilterSubscribeLogLogic) FilterSubscribeLog(req *types.FilterSubscribeLogRequest) (resp *types.FilterSubscribeLogResponse, err error) {
|
func (l *FilterSubscribeLogLogic) FilterSubscribeLog(req *types.FilterSubscribeLogRequest) (resp *types.FilterSubscribeLogResponse, err error) {
|
||||||
data, total, err := l.svcCtx.LogModel.FilterSystemLog(l.ctx, &log.FilterParams{
|
params := &log.FilterParams{
|
||||||
Page: req.Page,
|
Page: req.Page,
|
||||||
Size: req.Size,
|
Size: req.Size,
|
||||||
Type: log.TypeSubscribe.Uint8(),
|
Type: log.TypeSubscribe.Uint8(),
|
||||||
Data: req.Date,
|
Data: req.Date,
|
||||||
ObjectID: req.UserId,
|
ObjectID: req.UserId,
|
||||||
})
|
}
|
||||||
|
|
||||||
|
if req.UserSubscribeId != 0 {
|
||||||
|
params.Search = `"user_subscribe_id":` + strconv.FormatInt(req.UserSubscribeId, 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
data, total, err := l.svcCtx.LogModel.FilterSystemLog(l.ctx, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Errorf("[FilterSubscribeLog] failed to filter system log: %v", err.Error())
|
l.Errorf("[FilterSubscribeLog] failed to filter system log: %v", err.Error())
|
||||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "failed to filter system log")
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "failed to filter system log")
|
||||||
|
|||||||
@ -658,6 +658,7 @@ type FilterServerTrafficLogResponse struct {
|
|||||||
type FilterSubscribeLogRequest struct {
|
type FilterSubscribeLogRequest struct {
|
||||||
FilterLogParams
|
FilterLogParams
|
||||||
UserId int64 `form:"user_id,optional"`
|
UserId int64 `form:"user_id,optional"`
|
||||||
|
UserSubscribeId int64 `form:"user_subscribe_id,optional"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FilterSubscribeLogResponse struct {
|
type FilterSubscribeLogResponse struct {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user