返回数据格式优化

feat/task1-c-wallet
devil_gong 2019-02-27 17:48:59 +08:00
parent a46c5c5be9
commit 84b5fcb648
2 changed files with 7 additions and 6 deletions

View File

@ -50,17 +50,17 @@ class Search extends Common
SearchService::SearchAdd($this->data_post);
// 获取数据
$result = SearchService::GoodsList($this->data_post);
$ret = SearchService::GoodsList($this->data_post);
// 分类
if(!empty($this->data_post['category_id']))
{
$result['category'] = GoodsService::GoodsCategoryRow(['id'=>$this->data_post['category_id']]);
$ret['data']['category'] = GoodsService::GoodsCategoryRow(['id'=>$this->data_post['category_id']]);
} else {
$result['category'] = [];
$ret['data']['category'] = [];
}
return DataReturn('success', 0, $result);
return $ret;
}
}
?>

View File

@ -130,10 +130,11 @@ class SearchService
$page = intval(input('page', 1));
$n = 10;
$m = intval(($page-1)*$n);
$result['data'] = GoodsService::CategoryGoodsList(['where'=>$where, 'm'=>$m, 'n'=>$n, 'order_by'=>$order_by]);
$goods = GoodsService::CategoryGoodsList(['where'=>$where, 'm'=>$m, 'n'=>$n, 'order_by'=>$order_by]);
$result['data'] = $goods['data'];
$result['page_total'] = ceil($result['total']/$n);
}
return $result;
return DataReturn('处理成功', 0, $result);
}
/**