1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use app\common\model\UniversityEventModel;
- use app\utils\Service\Tencent\TencentIm;
- use think\Db;
- /**
- * 老年大学 活动板块
- */
- class UniversityEvent extends Api
- {
- protected $noNeedLogin = [''];
- protected $noNeedRight = ['*'];
- // 活动列表
- public function list()
- {
- $user_id = $this->auth->id;
- $list = UniversityEventModel::with([
- 'apply' => function ($query) use ($user_id) {
- $query->field('id,event_id,user_id')->where('user_id', $user_id)->where('status', 1);
- }
- ])
- ->field('id,name,price,image,start_apply_time,end_apply_time,start_time,address')
- ->where('status', 1)
- ->order('id desc')
- ->autopage()
- ->select();
- foreach ($list as $k => $v) {
- $list[$k]['start_apply_time'] = date('Y-m-d H:i', $v['start_apply_time']);
- $list[$k]['end_apply_time'] = date('Y-m-d H:i', $v['end_apply_time']);
- $list[$k]['start_time'] = date('Y-m-d H:i', $v['start_time']);
- $list[$k]['apply'] = !empty($v['apply']) ? 1 : 0;
- }
- return $this->success('success',$list);
- }
- // 活动详情
- public function info()
- {
- $params = $this->request->param();
- if (empty($params['event_id'])){
- return $this->error('参数缺失');
- }
- $user_id = $this->auth->id;
- $info = UniversityEventModel::with([
- 'apply' => function ($query) use ($user_id) {
- $query->field('id,event_id,user_id')->where('user_id', $user_id)->where('status', 1);
- }
- ])
- ->field('id,name,price,image,images,start_apply_time,end_apply_time,start_time,address,content')
- ->where('id', $params['event_id'])
- ->where('status', 1)
- ->order('id desc')
- ->find();
- $info['start_apply_time'] = date('Y-m-d H:i', $info['start_apply_time']);
- $info['end_apply_time'] = date('Y-m-d H:i', $info['end_apply_time']);
- $info['start_time'] = date('Y-m-d H:i', $info['start_time']);
- $info['apply'] = !empty($info['apply']) ? 1 : 0;
- return $this->success('success',$info);
- }
- }
|