优化GetMyStoreListNew的返回数据

This commit is contained in:
gazebo
2019-09-26 16:10:59 +08:00
parent 78930d9c1a
commit 0b2321e7a6

View File

@@ -368,7 +368,7 @@ func GetStoreList4User(ctx *jxcontext.Context, mobileNum, userID string) (storeL
return storeList, err
}
func GetMyStoreListNew(ctx *jxcontext.Context) (storeList []*dao.StoreWithCityName, errCode string, err error) {
func GetMyStoreListNew(ctx *jxcontext.Context) (storesInfo interface{}, errCode string, err error) {
if !auth2.IsV2Token(ctx.GetToken()) {
return nil, model.ErrCodeTokenIsInvalid, model.ErrTokenIsInvalid
}
@@ -376,8 +376,25 @@ func GetMyStoreListNew(ctx *jxcontext.Context) (storeList []*dao.StoreWithCityNa
if mobileNum == "" {
return nil, "", fmt.Errorf("不能得到用户手机号")
}
storeList, err = GetStoreList4User(ctx, mobileNum, userID)
return storeList, "", err
var storeList []*dao.StoreWithCityName
if storeList, err = GetStoreList4User(ctx, mobileNum, userID); err == nil && len(storeList) > 0 {
// todo应该用通过方法
mapDataList := make([]map[string]interface{}, len(storeList))
for k, v := range storeList {
mapDataList[k] = map[string]interface{}{
"id": v.ID,
"address": v.Address,
"cityName": v.CityName,
"name": v.Name,
"tel1": v.Tel1,
"tel2": v.Tel2,
"payeeName": v.PayeeName,
"status": v.Status,
}
}
storesInfo = mapDataList
}
return storesInfo, "", err
}
func GetStoreRoleList(ctx *jxcontext.Context) (roleList []*authz.RoleInfo, err error) {