- 配置类型增加银行
This commit is contained in:
@@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case model.ConfigTypeBank:
|
||||||
|
if value != "" {
|
||||||
|
if model.BankName[value] == "" {
|
||||||
|
err = fmt.Errorf("些银行代码:%s不支持,请联系开发", value)
|
||||||
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
err = fmt.Errorf("当前只支持价格包配置:%s", model.ConfigTypePricePack)
|
err = fmt.Errorf("当前只支持配置:%s, 传入的配置类型:%s", utils.Format4Output(model.ConfigTypeList, true), configType)
|
||||||
}
|
}
|
||||||
return
|
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,22 +237,25 @@ 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
|
||||||
}
|
}
|
||||||
db := dao.GetDB()
|
switch configType {
|
||||||
storeMapList, err := dao.GetStoresMapList(db, nil, nil, model.StoreStatusAll, model.StoreIsSyncYes, key)
|
case model.ConfigTypePricePack:
|
||||||
if err != nil {
|
db := dao.GetDB()
|
||||||
return err
|
storeMapList, err := dao.GetStoresMapList(db, nil, nil, model.StoreStatusAll, model.StoreIsSyncYes, key)
|
||||||
}
|
if err != nil {
|
||||||
if len(storeMapList) > 0 {
|
return err
|
||||||
var storeInfo []string
|
|
||||||
for _, v := range storeMapList {
|
|
||||||
storeInfo = append(storeInfo, fmt.Sprintf("门店:%d, 平台:%s", v.StoreID, model.VendorChineseNames[v.VendorID]))
|
|
||||||
}
|
}
|
||||||
return fmt.Errorf("还有门店在使用价格包:%s,门店信息:%s", key, strings.Join(storeInfo, ","))
|
if len(storeMapList) > 0 {
|
||||||
|
var storeInfo []string
|
||||||
|
for _, v := range storeMapList {
|
||||||
|
storeInfo = append(storeInfo, fmt.Sprintf("门店:%d, 平台:%s", v.StoreID, model.VendorChineseNames[v.VendorID]))
|
||||||
|
}
|
||||||
|
return fmt.Errorf("还有门店在使用价格包:%s,门店信息:%s", key, strings.Join(storeInfo, ","))
|
||||||
|
}
|
||||||
|
_, err = dao.DeleteEntityLogically(db, &model.NewConfig{}, nil, ctx.GetUserName(), map[string]interface{}{
|
||||||
|
"Key": key,
|
||||||
|
"Type": configType,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
_, err = dao.DeleteEntityLogically(db, &model.NewConfig{}, nil, ctx.GetUserName(), map[string]interface{}{
|
|
||||||
"Key": key,
|
|
||||||
"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)
|
||||||
|
}
|
||||||
|
|||||||
@@ -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"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user