42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package radar
|
||
|
||
import (
|
||
"context"
|
||
|
||
"apps/backend/internal/svc"
|
||
"apps/backend/internal/types"
|
||
|
||
"github.com/zeromicro/go-zero/core/logx"
|
||
)
|
||
|
||
type SuggestWatchTermsLogic struct {
|
||
logx.Logger
|
||
ctx context.Context
|
||
svcCtx *svc.ServiceContext
|
||
}
|
||
|
||
func NewSuggestWatchTermsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SuggestWatchTermsLogic {
|
||
return &SuggestWatchTermsLogic{
|
||
Logger: logx.WithContext(ctx),
|
||
ctx: ctx,
|
||
svcCtx: svcCtx,
|
||
}
|
||
}
|
||
|
||
// SuggestWatchTerms 只回建議,不寫入任何 watch:使用者要逐條決定採不採用(RW-03)。
|
||
func (l *SuggestWatchTermsLogic) SuggestWatchTerms(req *types.SuggestWatchTermsReq) (resp *types.WatchSuggestData, err error) {
|
||
uid, err := ownerUID(l.ctx)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
list, err := l.svcCtx.Radar.SuggestWatchTerms(l.ctx, uid, req.Limit)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
out := make([]types.WatchTermSuggestion, 0, len(list))
|
||
for _, s := range list {
|
||
out = append(out, types.WatchTermSuggestion{Term: s.Term, Reason: s.Reason, Usage: s.Usage})
|
||
}
|
||
return &types.WatchSuggestData{List: out}, nil
|
||
}
|