作者 开飞机的舒克

修改逻辑

... ... @@ -5,6 +5,7 @@ namespace app\api\controller;
use app\common\controller\Api;
use app\common\model\Active;
use app\common\model\Item;
use app\common\model\Ronda;
/**
* 活动接口
... ... @@ -121,15 +122,14 @@ class Activity extends Api
if (empty($cid)) {
$this->error('参数错误', ['status' => 2]);
}
$data = db('ronda r')
->join('campus c','c.id = r.campus_id')
->field('r.id as rid,c.title as campus_title,r.title as ronda_title,r.holdtime as ronda_holdtime')
->where('r.campus_id',$cid)
->paginate(10,false)
->each(function ($item,$key){
$item['holdtime'] = date('Y-m-d',$item['ronda_holdtime']);
return $item;
});
$data = db('ronda')
->where('campus_id',$cid)
->select();
foreach ($data as $k => $v){
$data[$k]['holdtime'] = date('Y-m-d',$v['holdtime']);
$data[$k]['images'] = cdnurl($v['images'],true);
$data[$k]['details'] = strip_tags($v['details']);
}
$this->success('获取场次列表成功', $data);
}
... ... @@ -156,8 +156,12 @@ class Activity extends Api
if (empty($rid)) {
$this->error('参数错误', ['status' => 2]);
}
$model = new Item();
$data = collection($model->whereIn('ronda_ids',$rid)->select())->toArray();
$model = new Ronda();
$list = $model->where('id',$rid)->value('item_ids');
$item = explode(',',$list);
foreach ($item as $k){
$data[] = db('item')->where('id',$k)->find();
}
$this->success('获取项目列表成功', $data);
}
... ... @@ -216,8 +220,6 @@ class Activity extends Api
$where['id'] = $id;
$model = new Item();
$data = $model->where($where)->find();
//$data['holdtime'] = date('Y-m-d',$data['holdtime']);
$data['details'] = strip_tags($data['details']);
$this->success('获取项目详情成功', $data);
}
... ...
... ... @@ -20,6 +20,8 @@ class Item extends Model
'radar_text',
];
public function getImagesAttr($value,$data){
$images = explode(',',$data['images']);
foreach ($images as $k){
... ...
<?php
namespace app\common\model;
use think\Model;
class Ronda extends Model
{
// 表名
protected $name = 'ronda';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
// 追加属性
protected $append = [
];
}
\ No newline at end of file
... ...