+ Store添加MarketManRole与OperatorRole

- GetStoreListByMobileOrStoreIDs支持按Store.MarketManRole与OperatorRole来得到门店列表
This commit is contained in:
gazebo
2019-08-08 15:46:32 +08:00
parent 03dd787375
commit 60f3ec9c3b
3 changed files with 33 additions and 11 deletions

View File

@@ -162,17 +162,32 @@ func GetUsers(ctx *jxcontext.Context, userType int, keyword string, userIDs []st
return dao.GetUsers(dao.GetDB(), userType, keyword, userIDs, userID2, mobile)
}
func GetStoreList4User(ctx *jxcontext.Context, mobileNum, userID string) (storeList []*dao.StoreWithCityName, err error) {
roleList, err := api2.RoleMan.GetUserRoleList(userID)
if err != nil {
return nil, err
}
var (
storeIDs []int
shortRoleNameList []string
)
for _, v := range roleList {
if v.StoreID == 0 {
shortRoleNameList = append(shortRoleNameList, v.Name)
} else {
storeIDs = append(storeIDs, v.StoreID)
}
}
storeList, err = dao.GetStoreListByMobileOrStoreIDs(dao.GetDB(), mobileNum, shortRoleNameList, storeIDs)
return storeList, err
}
func GetMyStoreListNew(ctx *jxcontext.Context) (storeList []*dao.StoreWithCityName, err error) {
mobileNum, userID := ctx.GetMobileAndUserID()
if mobileNum == "" {
return nil, fmt.Errorf("不能得到用户手机号")
}
roleList, err := api2.RoleMan.GetUserRoleList(userID)
if err != nil {
return nil, err
}
storeList, err = dao.GetStoreListByMobileOrStoreIDs(dao.GetDB(), mobileNum, authz.RoleList2StoreIDList(roleList))
return storeList, err
return GetStoreList4User(ctx, mobileNum, userID)
}
func GetStoreRoleList(ctx *jxcontext.Context) (roleList []*authz.RoleInfo, err error) {