门店禁止自我关联
This commit is contained in:
@@ -783,11 +783,9 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
if linkStoreID != 0 {
|
if err = checkStoreHaveLinkedStore(storeID, linkStoreID); err != nil {
|
||||||
if err = checkStoreHaveLinkedStore(storeID); err != nil {
|
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
valid["linkStoreID"] = linkStoreID
|
valid["linkStoreID"] = linkStoreID
|
||||||
// globals.SugarLogger.Debug(linkStoreID)
|
// globals.SugarLogger.Debug(linkStoreID)
|
||||||
}
|
}
|
||||||
@@ -1012,9 +1010,13 @@ func EnableHaveRestStores(ctx *jxcontext.Context, isAsync, isContinueWhenError b
|
|||||||
return hint, err
|
return hint, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkStoreHaveLinkedStore(storeID int) (err error) {
|
func checkStoreHaveLinkedStore(storeID, linkStoreID int) (err error) {
|
||||||
storeList, err := dao.GetStoreLinkStores(dao.GetDB(), storeID)
|
if linkStoreID != 0 {
|
||||||
if err == nil {
|
if storeID == linkStoreID {
|
||||||
|
err = fmt.Errorf("不能自我关联")
|
||||||
|
} else {
|
||||||
|
storeList, err2 := dao.GetStoreLinkStores(dao.GetDB(), storeID)
|
||||||
|
if err = err2; err == nil {
|
||||||
if len(storeList) > 0 {
|
if len(storeList) > 0 {
|
||||||
var storeInfo []string
|
var storeInfo []string
|
||||||
for _, v := range storeList {
|
for _, v := range storeList {
|
||||||
@@ -1023,6 +1025,8 @@ func checkStoreHaveLinkedStore(storeID int) (err error) {
|
|||||||
err = fmt.Errorf("门店%d已经被其它门店(%s)关联,不能再关联至其它门店", storeID, strings.Join(storeInfo, ","))
|
err = fmt.Errorf("门店%d已经被其它门店(%s)关联,不能再关联至其它门店", storeID, strings.Join(storeInfo, ","))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1045,11 +1049,9 @@ func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (i
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
if realLinkStoreID != 0 {
|
if err = checkStoreHaveLinkedStore(storeExt.ID, realLinkStoreID); err != nil {
|
||||||
if err = checkStoreHaveLinkedStore(storeExt.ID); err != nil {
|
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
storeExt.LinkStoreID = realLinkStoreID
|
storeExt.LinkStoreID = realLinkStoreID
|
||||||
|
|
||||||
existingID := store.ID
|
existingID := store.ID
|
||||||
|
|||||||
Reference in New Issue
Block a user