123456789101112131415161718192021222324252627282930 |
- package sheep
- import (
- "context"
- operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
- "gitee.com/xuyiping_admin/pkg/xerr"
- "tmr-watch/module"
- )
- func UpdateOrCreateTmrGear(ctx context.Context, req *operationPb.UpdateOrCreateTmrGearRequest) error {
- if len(req.Params) <= 0 {
- return xerr.Customf("参数错误: params")
- }
- if len(req.TmrId) <= 0 {
- return xerr.Customf("参数错误: tmr_id")
- }
- revList := make(map[int32]struct{})
- for _, v := range req.Params {
- if _, ok := revList[v.Rev]; ok {
- return xerr.Customf("不能出现同样转速的数据")
- }
- revList[v.Rev] = struct{}{}
- }
- if err := module.CreateOrUpdateTmrGear(ctx, req); err != nil {
- return xerr.WithStack(err)
- }
- return nil
- }
|