feat: 更换配置文件实现包
This commit is contained in:
@@ -1,15 +1,10 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"autoLogin/models/util"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
type Settings struct {
|
||||
DemoMode bool `json:"demo_mode"`
|
||||
Dns string `json:"dns"`
|
||||
Guardian uint `json:"guardian"`
|
||||
Daemon bool `json:"daemon"`
|
||||
Timeout uint `json:"timeout"`
|
||||
DemoMode bool `json:"demo_mode"`
|
||||
Guardian uint `json:"guardian"`
|
||||
Daemon bool `json:"daemon"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
@@ -31,33 +26,3 @@ func (a *Config) Generate() *LoginInfo {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Config) FillDefault() *Config {
|
||||
var m = map[interface{}]map[string]interface{}{
|
||||
&a.From: {
|
||||
"Domain": "www.msftconnecttest.com",
|
||||
"UserType": "cmcc",
|
||||
},
|
||||
&a.Meta: {
|
||||
"N": "200",
|
||||
"Type": "1",
|
||||
"Acid": "5",
|
||||
"Enc": "srun_bx1",
|
||||
},
|
||||
&a.Settings: {
|
||||
"Dns": "1.2.4.8",
|
||||
},
|
||||
}
|
||||
|
||||
for q, w := range m {
|
||||
t := reflect.ValueOf(q).Elem()
|
||||
for k, v := range w {
|
||||
tt := t.FieldByName(k)
|
||||
if util.Reflect.IsEmpty(tt) {
|
||||
tt.Set(reflect.ValueOf(v))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user