12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- namespace app\api\controller;
- use app\common\model\PlatformSwitch;
- use app\common\model\UserSearch;
- /**
- * @title 其他接口
- * @controller General
- * @group base
- */
- class General extends Base
- {
- public function initialize()
- {
- parent::initialize();
- parent::checkLogin();
- }
- /**
- * @title 用户搜索历史
- * @desc 用户搜索历史
- * @author qc
- * @method GET
- * @url /api/General/getSearchHistory
- * @header name:Authorization require:1 desc:Token
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @param name:type type:int default:-- desc:类型0=>"全部",1=>'视频',2=>'图文',3=>'资料',4=>'新闻',5=>'需求',6=>'问答',7=>'商品',8=>'招聘',9=>'供应商',10=>'供应商产品',
- * @return name:title type:string default:-- desc:标题
- * @return name:type type:int default:-- desc:类型0全局,1视频,2图文,3资料,4新闻,5需求
- */
- public function getSearchHistory()
- {
- $title = input('title');
- $type= input('type',-1);
- $where= [];
- $where [] = ['user_id','=',$this->user_id];
- if($title)$where [] = ['title','like','%'.$title.'%'];
- if($type > -1)$where [] = ['type','=',$type];
- $list = UserSearch::where($where)
- ->limit($this->off_set,$this->page_num)
- ->order('create_at desc,id desc')
- ->select()->toArray();
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 删除||清空搜索历史
- * @desc 删除||清空搜索历史
- * @author qc
- * @method POST
- * @url /api/General/delSearchHistory
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:0 desc:搜索记录id【不传值清空所有搜索记录】
- */
- public function delSearchHistory()
- {
- $id = input('post.id');
- $where= [];
- $where [] = ['user_id','=',$this->user_id];
- if($id)$where [] = ['id','=',$id];
- UserSearch::where($where)->delete();
- $this->success('删除成功');
- }
- /**
- * @title 以下接口为二期需求
- * @desc 以下接口为二期需求
- * @author qc
- * @url /api/General/secondPhase
- * @method
- * @return name:1 type:string default:-- desc:以下接口为二期需求
- */
- public function secondPhase(){}
- /**
- * @title 开关设置
- * @desc 【追更开关】
- * @author qc
- * @method POST
- * @url /api/General/switchSet
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int require:1 default:-- desc:记录id
- * @param name:type type:int require:1 default:-- desc:类型【1=>'问答通知开关',2=>'视频追更',3=>'图文追更',4=>'资料追更',5=>'供应商追更',6=>'招聘追更'】
- */
- public function switchSet()
- {
- $switch_status = PlatformSwitch::userSwitch($this->user_id,input('post.id',0),input('post.type',0));
- $switch_status ? $this->success('开启成功',['status'=>1]) : $this->success('关闭成功',['status'=>0]);
- }
- }
|