chore: 并入 iotlcm-openapi 历史到 openapi/(原提交 3b05d5a)

This commit is contained in:
MiFaZhan
2026-11-02 13:28:02 +08:00
484 changed files with 34732 additions and 0 deletions
@@ -0,0 +1,36 @@
package common
import (
"context"
"database/sql"
"errors"
"github.com/gogf/gf/v2/errors/gerror"
"git.5iot.com/iotlcm-public/iotlcm-openapi/internal/consts"
"git.5iot.com/iotlcm-public/iotlcm-openapi/internal/dao"
"git.5iot.com/iotlcm-public/iotlcm-openapi/internal/model/entity"
)
func (s *sCommon) findTrafficCutoffBatch(ctx context.Context, tenantID string, deptID int64, idempotencyKey string) (*entity.BatchMain, error) {
var batch entity.BatchMain
columns := dao.BatchMain.Columns()
err := dao.BatchMain.Ctx(ctx).
Where(columns.TenantId, tenantID).
Where(columns.DeptId, deptID).
Where(columns.BatchType, consts.BatchTypeTrafficCutoffConfig).
Where("JSON_UNQUOTE(JSON_EXTRACT("+columns.BatchInfo+", '$.idempotencyKey')) = ?", idempotencyKey).
OrderDesc(columns.Id).
Limit(1).
Scan(&batch)
if errors.Is(err, sql.ErrNoRows) {
return nil, nil
}
if err != nil {
return nil, gerror.Wrap(err, "查询达量断网配置幂等批次失败")
}
if batch.Id == 0 {
return nil, nil
}
return &batch, nil
}