update 计算利润率支持多个id
All checks were successful
Build image / build (push) Successful in 45s

This commit is contained in:
timerzz 2025-03-28 11:01:32 +08:00
parent fe2702fb58
commit 5845828066

View File

@ -4,12 +4,14 @@ import (
"context"
"fmt"
"strconv"
"strings"
"gitea.timerzz.com/kedaya_haitao/common/pkg/subscribe"
"gitea.timerzz.com/kedaya_haitao/common/structs/storage"
"gitea.timerzz.com/kedaya_haitao/common/structs/utils"
"github.com/golang/glog"
"github.com/redis/go-redis/v9"
"golang.org/x/sync/errgroup"
)
type Controller struct {
@ -38,6 +40,19 @@ func (c *Controller) Run() error {
// 处理接受到的信息
func (c *Controller) Rate(ctx context.Context, idString string) error {
var ids = strings.Split(idString, ",")
var wg errgroup.Group
for _, id := range ids {
var i = id
wg.Go(func() error {
return c.rate(ctx, i)
})
}
return wg.Wait()
}
// 处理接收到的信息
func (c *Controller) rate(ctx context.Context, idString string) error {
i, _ := strconv.Atoi(idString)
if i <= 0 {
return fmt.Errorf("接收到的id不正确%s", idString)