diff --git a/.gitignore b/.gitignore index 9252942..16bc961 100644 --- a/.gitignore +++ b/.gitignore @@ -3,10 +3,8 @@ *-dev.yaml *.local.yaml /test/ -*.log .DS_Store *_test_config.go -*.log* /build/ *.p8 *.crt diff --git a/etc/ppanel.yaml b/etc/ppanel.yaml index 672d6e2..6978435 100644 --- a/etc/ppanel.yaml +++ b/etc/ppanel.yaml @@ -35,4 +35,4 @@ Redis: DB: 0 Administrator: Password: password - Email: admin@ppanel.dev + Email: admin@ppanel.dev \ No newline at end of file diff --git a/internal/handler/public/user/queryUserBalanceLogHandler.go b/internal/handler/public/user/queryUserBalanceLogHandler.go index 3e7e7f3..e2db34b 100644 --- a/internal/handler/public/user/queryUserBalanceLogHandler.go +++ b/internal/handler/public/user/queryUserBalanceLogHandler.go @@ -4,6 +4,7 @@ import ( "github.com/gin-gonic/gin" "github.com/perfect-panel/server/internal/logic/public/user" "github.com/perfect-panel/server/internal/svc" + "github.com/perfect-panel/server/internal/types" "github.com/perfect-panel/server/pkg/result" ) @@ -11,8 +12,15 @@ import ( func QueryUserBalanceLogHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) { return func(c *gin.Context) { + var req types.QueryUserBalanceLogListRequest + _ = c.ShouldBind(&req) + validateErr := svcCtx.Validate(&req) + if validateErr != nil { + result.ParamErrorResult(c, validateErr) + return + } l := user.NewQueryUserBalanceLogLogic(c.Request.Context(), svcCtx) - resp, err := l.QueryUserBalanceLog() + resp, err := l.QueryUserBalanceLog(&req) result.HttpResult(c, resp, err) } } diff --git a/internal/logic/public/user/queryUserBalanceLogLogic.go b/internal/logic/public/user/queryUserBalanceLogLogic.go index 2a3c72d..1a62213 100644 --- a/internal/logic/public/user/queryUserBalanceLogLogic.go +++ b/internal/logic/public/user/queryUserBalanceLogLogic.go @@ -31,7 +31,7 @@ func NewQueryUserBalanceLogLogic(ctx context.Context, svcCtx *svc.ServiceContext } } -func (l *QueryUserBalanceLogLogic) QueryUserBalanceLog() (resp *types.QueryUserBalanceLogListResponse, err error) { +func (l *QueryUserBalanceLogLogic) QueryUserBalanceLog(req *types.QueryUserBalanceLogListRequest) (resp *types.QueryUserBalanceLogListResponse, err error) { u, ok := l.ctx.Value(constant.CtxKeyUser).(*user.User) if !ok { logger.Error("current user is not found in context") @@ -41,7 +41,7 @@ func (l *QueryUserBalanceLogLogic) QueryUserBalanceLog() (resp *types.QueryUserB var total int64 // Query User Balance Log err = l.svcCtx.UserModel.Transaction(l.ctx, func(db *gorm.DB) error { - return db.Model(&user.BalanceLog{}).Order("created_at DESC").Where("user_id = ?", u.Id).Count(&total).Find(&data).Error + return db.Model(&user.BalanceLog{}).Order("created_at DESC").Where("user_id = ?", u.Id).Count(&total).Offset((req.Page - 1) * req.Size).Limit(req.Size).Find(&data).Error }) if err != nil { return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "Query User Balance Log failed: %v", err) diff --git a/internal/model/subscribe/model.go b/internal/model/subscribe/model.go index f3b1142..fc14aa4 100644 --- a/internal/model/subscribe/model.go +++ b/internal/model/subscribe/model.go @@ -87,7 +87,7 @@ func (m *customSubscribeModel) QuerySubscribeListByShow(ctx context.Context) ([] var list []*Subscribe err := m.QueryNoCacheCtx(ctx, &list, func(conn *gorm.DB, v interface{}) error { conn = conn.Model(&Subscribe{}) - return conn.Where("`show` = true").Find(v).Error + return conn.Where("`show` = true").Order("sort ASC").Find(v).Error }) return list, err } diff --git a/internal/types/types.go b/internal/types/types.go index 80f5fc1..3f7d336 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -1391,6 +1391,11 @@ type QueryUserAffiliateListRequest struct { Size int `form:"size"` } +type QueryUserBalanceLogListRequest struct { + Page int `form:"page"` + Size int `form:"size"` +} + type QueryUserAffiliateListResponse struct { List []UserAffiliate `json:"list"` Total int64 `json:"total"` diff --git a/logs/access.log b/logs/access.log new file mode 100644 index 0000000..e69de29 diff --git a/logs/error.log b/logs/error.log new file mode 100644 index 0000000..e69de29 diff --git a/logs/severe.log b/logs/severe.log new file mode 100644 index 0000000..e69de29 diff --git a/logs/slow.log b/logs/slow.log new file mode 100644 index 0000000..e69de29 diff --git a/logs/stat.log b/logs/stat.log new file mode 100644 index 0000000..e69de29 diff --git a/pkg/adapter/general/uri.go b/pkg/adapter/general/uri.go index 7a4ce72..86b9748 100644 --- a/pkg/adapter/general/uri.go +++ b/pkg/adapter/general/uri.go @@ -296,7 +296,7 @@ func AnyTLSUri(data proxy.Proxy, uuid string) string { u := url.URL{ Scheme: "anytls", User: url.User(uuid), - Host: net.JoinHostPort(data.Server, strconv.Itoa(anytls.Port)), + Host: net.JoinHostPort(data.Server, strconv.Itoa(data.Port)), // 修复:使用最终端口 data.Port RawQuery: query.Encode(), Fragment: data.Name, } diff --git a/queue/logic/subscription/checkSubscriptionLogic.go b/queue/logic/subscription/checkSubscriptionLogic.go index ef77130..52cd509 100644 --- a/queue/logic/subscription/checkSubscriptionLogic.go +++ b/queue/logic/subscription/checkSubscriptionLogic.go @@ -188,8 +188,10 @@ func (l *CheckSubscriptionLogic) sendTrafficNotify(ctx context.Context, subs []i } var result bytes.Buffer err = tpl.Execute(&result, map[string]interface{}{ - "SiteLogo": l.svc.Config.Site.SiteLogo, - "SiteName": l.svc.Config.Site.SiteName, + "SiteLogo": l.svc.Config.Site.SiteLogo, + "SiteName": l.svc.Config.Site.SiteName, + "UsedTraffic": sub.Upload + sub.Download, + "MaxTraffic": sub.Traffic, }) if err != nil { logger.Errorw("[CheckSubscription] Execute template failed", logger.Field("error", err.Error()))