pusher/biz/service/push.go

31 lines
684 B
Go
Raw Normal View History

2024-05-17 18:02:10 +08:00
package service
import (
"context"
2024-05-20 17:57:25 +08:00
"fmt"
2024-05-17 18:02:10 +08:00
push "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/push"
2024-05-20 17:57:25 +08:00
"gitea.timerzz.com/kedaya_haitao/pusher/pushers"
2024-05-17 18:02:10 +08:00
)
type PushService struct {
ctx context.Context
} // NewPushService new PushService
func NewPushService(ctx context.Context) *PushService {
return &PushService{ctx: ctx}
}
// Run create note info
2024-05-20 17:57:25 +08:00
func (s *PushService) Run(req *push.PushReq) (resp *push.Resp, err error) {
2024-05-17 18:02:10 +08:00
// Finish your business logic.
2024-05-20 17:57:25 +08:00
if len(req.Ids) == 0 {
return nil, fmt.Errorf("缺少id")
}
resp = push.NewResp()
err = pushers.Push(s.ctx, req.Ids, req.Title, req.Content)
if err != nil {
resp.Code = 100
resp.Msg = err.Error()
}
2024-05-17 18:02:10 +08:00
return
}