forked from free-lancers/electricity_bill_calc_service
enhance(meter):恢复对于表计类型的解析错误提示,并在表计类型解析出现错误的时候停下来。
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -19,19 +20,18 @@ const (
|
||||
METER_INSTALLATION_TENEMENT int16 = iota
|
||||
METER_INSTALLATION_PARK
|
||||
METER_INSTALLATION_POOLING
|
||||
METER_INSTALLATION_UNDEFINED = 99
|
||||
)
|
||||
|
||||
func ParseMeterInstallationType(s string) int16 {
|
||||
func ParseMeterInstallationType(s string) (int16, error) {
|
||||
switch {
|
||||
case strings.Contains(s, "商户"):
|
||||
return METER_INSTALLATION_TENEMENT
|
||||
return METER_INSTALLATION_TENEMENT, nil
|
||||
case strings.Contains(s, "公共"):
|
||||
return METER_INSTALLATION_PARK
|
||||
return METER_INSTALLATION_PARK, nil
|
||||
case strings.Contains(s, "楼道"):
|
||||
return METER_INSTALLATION_POOLING
|
||||
return METER_INSTALLATION_POOLING, nil
|
||||
default:
|
||||
return METER_INSTALLATION_UNDEFINED
|
||||
return -1, fmt.Errorf("提供了一个无法识别的表计类型: %s", s)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user