| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace app\api\controller\service;
- use app\common\controller\Api;
- /**
- * 首页接口
- */
- class Follow extends Api
- {
- protected $noNeedLogin = [''];
- protected $noNeedRight = ['*'];
- /**
- * 更新关注状态
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public function handleFollow()
- {
- if (!$this->request->isPost()) {
- $this->error('请求方式异常');
- }
- $uid = $this->auth->id;
- $type = input('type/d','');
- $state = input('state/d',0);
- $follow_id = input('follow_id/d','');
- $info = model('app\api\model\service\Follow')->where(['user_id'=>$uid,'follow_id'=>$follow_id,'type'=>$type])->field('id,state')->find();
- ($info && $info['state'] == $state) && $this->error('关注状态异常');
- $re = \app\api\model\service\Follow::updateFollow(['user_id'=>$uid,'type'=>$type,'follow_id'=>$follow_id,'state'=>$state],$info);
- if(!$re)
- {
- $this->error('状态更新异常');
- }
- $this->success('关注状态已更新');
- }
- public function getList()
- {
- if (!$this->request->isPost()) {
- $this->error('请求方式异常');
- }
- $post = input('post.','','trim,strip_tags');
- $post['user_id'] = $this->auth->id;
- $list = \app\api\model\service\Follow::getList($post);
- $this->success('信息返回成功',$list);
- }
- }
|