thread-master/apps/backend/internal/logic/checkups/get_checkup_logic.go

36 lines
841 B
Go
Raw Permalink Normal View History

2026-07-23 05:56:42 +00:00
package checkups
import (
"context"
"fmt"
"apps/backend/internal/logic/growthmap"
"apps/backend/internal/middleware"
"apps/backend/internal/svc"
"apps/backend/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type GetCheckupLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetCheckupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCheckupLogic {
return &GetCheckupLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
}
func (l *GetCheckupLogic) GetCheckup(req *types.GetCheckupReq) (*types.WeeklyCheckupPublic, error) {
uid, ok := middleware.UIDFrom(l.ctx)
if !ok || uid <= 0 {
return nil, fmt.Errorf("unauthorized")
}
c, err := l.svcCtx.Growth.GetCheckup(l.ctx, uid, req.Id)
if err != nil {
return nil, err
}
return growthmap.Checkup(c), nil
}