修改接口
This commit is contained in:
parent
981844a25a
commit
a0ebd8e0a1
@ -24,7 +24,8 @@ class MallNews extends Api
|
||||
{
|
||||
if($this->request->isGet()) {
|
||||
$id = $this->request->get('id');
|
||||
$data = MallNewsLogic::detail($id);
|
||||
$mall_type = $this->request->get('mall_type');
|
||||
$data = MallNewsLogic::detail($id, $mall_type);
|
||||
return JsonServer::success('获取成功', $data);
|
||||
}else{
|
||||
return JsonServer::error('请求方式错误');
|
||||
|
||||
@ -9,6 +9,7 @@ use think\facade\Config;
|
||||
use think\facade\Db;
|
||||
use app\common\model\MallNews;
|
||||
use app\common\model\MallNewsFile;
|
||||
use app\common\model\MallNewsShop;
|
||||
|
||||
class MallNewsLogic extends Logic
|
||||
{
|
||||
@ -43,27 +44,41 @@ class MallNewsLogic extends Logic
|
||||
];
|
||||
}
|
||||
|
||||
public static function detail($id)
|
||||
public static function detail($id, $mall_type)
|
||||
{
|
||||
$mall_news = MallNews::with('files')
|
||||
->where(['id' => $id, 'delete_time' => 0])
|
||||
->find()->toArray();
|
||||
if ($mall_type == 1) {
|
||||
$mall_news = MallNewsShop::where(['id' => $id, 'delete_time' => 0])->find()->toArray();
|
||||
if ($mall_news['shop_id'] > 0) {
|
||||
$mall_news['shop'] = Goods::where(['id' => $mall_news['shop_id']])->field('name, image, min_price')->find()->toArray();
|
||||
}
|
||||
|
||||
if ($mall_news['shop_id'] > 0) {
|
||||
$mall_news['shop'] = Goods::where(['id' => $mall_news['shop_id']])->field('name, image, min_price')->find()->toArray();
|
||||
}
|
||||
$file = MallNewsFile::where(['mall_news_shop_id' => $id])->field('mall_news_shop_id, src')->select()->toArray();
|
||||
foreach ($file as &$v) {
|
||||
$v['src'] = UrlServer::getFileUrl('uploads/images/' . $v['src']);
|
||||
}
|
||||
|
||||
if (isset($mall_news['files'])) {
|
||||
foreach ($mall_news['files'] as &$v) {
|
||||
if ($mall_news['type'] == 0) {
|
||||
$v['src'] = UrlServer::getFileUrl('uploads/images/' . $v['src']);
|
||||
} else {
|
||||
$v['src'] = Config::get('aliyunoss.domain') . self::$FILE_VIDEO_PATH . '/'. $v['src'];
|
||||
$mall_news['files'] = $file;
|
||||
} else {
|
||||
$mall_news = MallNews::with('files')
|
||||
->where(['id' => $id, 'delete_time' => 0])
|
||||
->find()->toArray();
|
||||
|
||||
if ($mall_news['shop_id'] > 0) {
|
||||
$mall_news['shop'] = Goods::where(['id' => $mall_news['shop_id']])->field('name, image, min_price')->find()->toArray();
|
||||
}
|
||||
|
||||
if (isset($mall_news['files'])) {
|
||||
foreach ($mall_news['files'] as &$v) {
|
||||
if ($mall_news['type'] == 0) {
|
||||
$v['src'] = UrlServer::getFileUrl('uploads/images/' . $v['src']);
|
||||
} else {
|
||||
$v['src'] = Config::get('aliyunoss.domain') . self::$FILE_VIDEO_PATH . '/'. $v['src'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $mall_news;
|
||||
|
||||
}
|
||||
|
||||
private static function content(&$arg)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user