拆分商品模块服务和处理器职责
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package listing
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (s *Service) reviewRequired(ctx context.Context) (bool, error) {
|
||||
if s.config == nil {
|
||||
return false, nil
|
||||
}
|
||||
value, err := s.config.FindValue(ctx, reviewRequiredConfigKey)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
required, err := strconv.ParseBool(strings.TrimSpace(value))
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
return required, nil
|
||||
}
|
||||
|
||||
func (s *Service) publishRules(ctx context.Context) (publishRules, error) {
|
||||
rules := publishRules{FireLevelMin: defaultFireLevelMin}
|
||||
if s.config == nil {
|
||||
return rules, nil
|
||||
}
|
||||
value, err := s.config.FindValue(ctx, publishOptionsConfigKey)
|
||||
if err != nil {
|
||||
return rules, err
|
||||
}
|
||||
var raw struct {
|
||||
FireLevelMin int `json:"fire_level_min"`
|
||||
}
|
||||
if err := json.Unmarshal([]byte(value), &raw); err != nil {
|
||||
return rules, nil
|
||||
}
|
||||
if raw.FireLevelMin > 0 {
|
||||
rules.FireLevelMin = raw.FireLevelMin
|
||||
}
|
||||
return rules, nil
|
||||
}
|
||||
Reference in New Issue
Block a user