44 lines
1.0 KiB
Go
44 lines
1.0 KiB
Go
package radar
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"apps/backend/internal/logic/radarmap"
|
|
radarDomain "apps/backend/internal/module/radar/domain"
|
|
"apps/backend/internal/svc"
|
|
"apps/backend/internal/types"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GetServiceProfileLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewGetServiceProfileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetServiceProfileLogic {
|
|
return &GetServiceProfileLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *GetServiceProfileLogic) GetServiceProfile() (resp *types.ServiceProfilePublic, err error) {
|
|
uid, err := ownerUID(l.ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
p, err := l.svcCtx.Radar.GetServiceProfile(l.ctx, uid)
|
|
// 還沒建檔不是錯誤:表單要能開空的。誠實之處在 exists=false。
|
|
if errors.Is(err, radarDomain.ErrNotFound) {
|
|
return radarmap.ServiceProfile(nil), nil
|
|
}
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return radarmap.ServiceProfile(p), nil
|
|
}
|