38 lines
958 B
Go
38 lines
958 B
Go
|
|
package radar
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"apps/backend/internal/svc"
|
||
|
|
"apps/backend/internal/types"
|
||
|
|
|
||
|
|
"github.com/zeromicro/go-zero/core/logx"
|
||
|
|
)
|
||
|
|
|
||
|
|
type DeleteArchivedWatchLogic struct {
|
||
|
|
logx.Logger
|
||
|
|
ctx context.Context
|
||
|
|
svcCtx *svc.ServiceContext
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewDeleteArchivedWatchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteArchivedWatchLogic {
|
||
|
|
return &DeleteArchivedWatchLogic{
|
||
|
|
Logger: logx.WithContext(ctx),
|
||
|
|
ctx: ctx,
|
||
|
|
svcCtx: svcCtx,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// DeleteArchivedWatch permanently removes only an already archived watch.
|
||
|
|
// Its sweeps and opportunities remain available as historical records.
|
||
|
|
func (l *DeleteArchivedWatchLogic) DeleteArchivedWatch(req *types.WatchIdReq) (*types.OkData, error) {
|
||
|
|
uid, err := ownerUID(l.ctx)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
if err := l.svcCtx.Radar.DeleteArchivedWatch(l.ctx, uid, req.Id); err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
return &types.OkData{Ok: true, Message: "archived watch deleted"}, nil
|
||
|
|
}
|