- checkConfig
This commit is contained in:
@@ -204,7 +204,7 @@ func SendMsg2Somebody(ctx *jxcontext.Context, mobileNum, verifyCode, msgType, ms
|
||||
return err
|
||||
}
|
||||
|
||||
func checkConfig(configType, key, value string) (err error) {
|
||||
func checkConfig(opFlag int, configType, key, value string) (err error) {
|
||||
switch configType {
|
||||
case model.ConfigTypePricePack:
|
||||
if value != "" {
|
||||
@@ -221,7 +221,9 @@ func checkConfig(configType, key, value string) (err error) {
|
||||
}
|
||||
case model.ConfigTypeRole:
|
||||
case model.ConfigTypeSys:
|
||||
err = fmt.Errorf("系统参数只支持修改,不支持自由添加")
|
||||
if opFlag&(model.SyncFlagNewMask|model.SyncFlagDeletedMask) != 0 {
|
||||
err = fmt.Errorf("系统参数只支持修改,不支持自由添加")
|
||||
}
|
||||
default:
|
||||
err = fmt.Errorf("当前只支持配置:%s, 传入的配置类型:%s", utils.Format4Output(model.ConfigTypeName, true), configType)
|
||||
}
|
||||
@@ -229,7 +231,7 @@ func checkConfig(configType, key, value string) (err error) {
|
||||
}
|
||||
|
||||
func AddConfig(ctx *jxcontext.Context, key, configType, value string) (err error) {
|
||||
if err = checkConfig(configType, key, value); err != nil {
|
||||
if err = checkConfig(model.SyncFlagNewMask, configType, key, value); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -244,7 +246,7 @@ func AddConfig(ctx *jxcontext.Context, key, configType, value string) (err error
|
||||
}
|
||||
|
||||
func DeleteConfig(ctx *jxcontext.Context, key, configType string) (err error) {
|
||||
if err = checkConfig(configType, key, ""); err != nil {
|
||||
if err = checkConfig(model.SyncFlagDeletedMask, configType, key, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
db := dao.GetDB()
|
||||
@@ -299,7 +301,7 @@ func UpdateConfig(ctx *jxcontext.Context, key, configType, value string) (err er
|
||||
if key == "" {
|
||||
return fmt.Errorf("修改配置必须给定key")
|
||||
}
|
||||
if err = checkConfig(configType, key, value); err != nil {
|
||||
if err = checkConfig(model.SyncFlagModifiedMask, configType, key, value); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user