- 配置类型增加银行

This commit is contained in:
gazebo
2019-07-25 11:46:32 +08:00
parent a07e84c776
commit 7f6ec1b9de
3 changed files with 41 additions and 18 deletions

View File

@@ -83,6 +83,7 @@ func InitServiceInfo(version string, buildTime time.Time, gitCommit string) {
"actStatusName": model.ActStatusName, "actStatusName": model.ActStatusName,
"actCreateTypeName": model.ActCreateTypeName, "actCreateTypeName": model.ActCreateTypeName,
"storeAuditStatusName": model.StoreAuditStatusName, "storeAuditStatusName": model.StoreAuditStatusName,
"configTypeList": model.ConfigTypeList,
}, },
} }
Init() Init()
@@ -205,10 +206,16 @@ func checkConfig(configType, value string) (err error) {
err = fmt.Errorf("配置:%s不合法", value) err = fmt.Errorf("配置:%s不合法", value)
} }
} }
default: case model.ConfigTypeBank:
err = fmt.Errorf("当前只支持价格包配置:%s", model.ConfigTypePricePack) if value != "" {
if model.BankName[value] == "" {
err = fmt.Errorf("些银行代码:%s不支持请联系开发", value)
} }
return }
default:
err = fmt.Errorf("当前只支持配置:%s, 传入的配置类型:%s", utils.Format4Output(model.ConfigTypeList, true), configType)
}
return err
} }
func AddConfig(ctx *jxcontext.Context, key, configType, value string) (err error) { func AddConfig(ctx *jxcontext.Context, key, configType, value string) (err error) {
@@ -230,6 +237,8 @@ func DeleteConfig(ctx *jxcontext.Context, key, configType string) (err error) {
if err = checkConfig(configType, ""); err != nil { if err = checkConfig(configType, ""); err != nil {
return err return err
} }
switch configType {
case model.ConfigTypePricePack:
db := dao.GetDB() db := dao.GetDB()
storeMapList, err := dao.GetStoresMapList(db, nil, nil, model.StoreStatusAll, model.StoreIsSyncYes, key) storeMapList, err := dao.GetStoresMapList(db, nil, nil, model.StoreStatusAll, model.StoreIsSyncYes, key)
if err != nil { if err != nil {
@@ -246,6 +255,7 @@ func DeleteConfig(ctx *jxcontext.Context, key, configType string) (err error) {
"Key": key, "Key": key,
"Type": configType, "Type": configType,
}) })
}
return err return err
} }
@@ -291,3 +301,7 @@ func UpdateConfig(ctx *jxcontext.Context, key, configType, value string) (err er
dao.Commit(db) dao.Commit(db)
return err return err
} }
func QueryConfigs(key, configType, keyword string) (configList []*model.NewConfig, err error) {
return dao.QueryConfigs(dao.GetDB(), key, configType, keyword)
}

View File

@@ -3,6 +3,15 @@ package model
const ( const (
ConfigTypeSys = "Sys" ConfigTypeSys = "Sys"
ConfigTypePricePack = "PricePack" ConfigTypePricePack = "PricePack"
ConfigTypeBank = "Bank"
)
var (
ConfigTypeList = []string{
ConfigTypeSys,
ConfigTypePricePack,
ConfigTypeBank,
}
) )
type NewConfig struct { type NewConfig struct {
@@ -16,5 +25,6 @@ type NewConfig struct {
func (*NewConfig) TableUnique() [][]string { func (*NewConfig) TableUnique() [][]string {
return [][]string{ return [][]string{
[]string{"Key", "Type", "DeletedAt"}, []string{"Key", "Type", "DeletedAt"},
[]string{"Type", "Key", "DeletedAt"},
} }
} }

View File

@@ -6,7 +6,6 @@ import (
"git.rosy.net.cn/jx-callback/business/jxstore/cms" "git.rosy.net.cn/jx-callback/business/jxstore/cms"
"git.rosy.net.cn/jx-callback/business/jxutils" "git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/jxutils/configindb" "git.rosy.net.cn/jx-callback/business/jxutils/configindb"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/business/msghub" "git.rosy.net.cn/jx-callback/business/msghub"
"git.rosy.net.cn/jx-callback/globals/api" "git.rosy.net.cn/jx-callback/globals/api"
"github.com/astaxie/beego" "github.com/astaxie/beego"
@@ -276,7 +275,7 @@ func (c *CmsController) UpdateConfig() {
// @router /QueryConfigs [get] // @router /QueryConfigs [get]
func (c *CmsController) QueryConfigs() { func (c *CmsController) QueryConfigs() {
c.callQueryConfigs(func(params *tCmsQueryConfigsParams) (retVal interface{}, errCode string, err error) { c.callQueryConfigs(func(params *tCmsQueryConfigsParams) (retVal interface{}, errCode string, err error) {
retVal, err = dao.QueryConfigs(dao.GetDB(), params.Key, params.Type, params.Keyword) retVal, err = cms.QueryConfigs(params.Key, params.Type, params.Keyword)
return retVal, "", err return retVal, "", err
}) })
} }