v1.1
This commit is contained in:
@@ -58,26 +58,26 @@ type APIResponseData struct {
|
||||
}
|
||||
|
||||
// ProcessRequests 处理请求
|
||||
func (a *ApiRequestService) ProcessRequests(params []byte, productID int64) ([]byte, error) {
|
||||
func (a *ApiRequestService) ProcessRequests(params []byte, productID string) ([]byte, error) {
|
||||
var ctx, cancel = context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
build := a.productFeatureModel.SelectBuilder().Where(squirrel.Eq{
|
||||
"product_id": productID,
|
||||
})
|
||||
build := a.productFeatureModel.SelectBuilder().Where(squirrel.Eq{
|
||||
"product_id": productID,
|
||||
})
|
||||
productFeatureList, findProductFeatureErr := a.productFeatureModel.FindAll(ctx, build, "")
|
||||
if findProductFeatureErr != nil {
|
||||
return nil, findProductFeatureErr
|
||||
}
|
||||
var featureIDs []int64
|
||||
isImportantMap := make(map[int64]int64, len(productFeatureList))
|
||||
var featureIDs []string
|
||||
isImportantMap := make(map[string]int64, len(productFeatureList))
|
||||
for _, pf := range productFeatureList {
|
||||
featureIDs = append(featureIDs, pf.FeatureId)
|
||||
isImportantMap[pf.FeatureId] = pf.IsImportant
|
||||
featureIDs = append(featureIDs, pf.FeatureId)
|
||||
isImportantMap[pf.FeatureId] = pf.IsImportant
|
||||
}
|
||||
if len(featureIDs) == 0 {
|
||||
return nil, errors.New("featureIDs 是空的")
|
||||
}
|
||||
builder := a.featureModel.SelectBuilder().Where(squirrel.Eq{"id": featureIDs})
|
||||
builder := a.featureModel.SelectBuilder().Where(squirrel.Eq{"id": featureIDs})
|
||||
featureList, findFeatureErr := a.featureModel.FindAll(ctx, builder, "")
|
||||
if findFeatureErr != nil {
|
||||
return nil, findFeatureErr
|
||||
@@ -114,7 +114,7 @@ func (a *ApiRequestService) ProcessRequests(params []byte, productID int64) ([]b
|
||||
preprocessErr error
|
||||
)
|
||||
// 若 isImportantMap[feature.ID] == 1,则表示需要在出错时重试
|
||||
isImportant := isImportantMap[feature.Id] == 1
|
||||
isImportant := isImportantMap[feature.Id] == 1
|
||||
tryCount := 0
|
||||
for {
|
||||
tryCount++
|
||||
|
||||
Reference in New Issue
Block a user