123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663 |
- <?php
- namespace app\api\controller;
- use app\common\model\ArticleCommentLike;
- use app\common\model\PlatformDemand;
- use app\common\model\DemandComment;
- use app\common\model\PlatformLike;
- use app\common\model\User;
- use app\common\model\UserCollect;
- use app\common\model\UserDemand;
- use app\common\model\UserMessage;
- use app\common\model\UserSearch;
- use app\common\model\UserTrack;
- use library\tools\Data;
- use think\Db;
- /**
- * @title 需求【也叫项目。。。】
- * @controller Demand
- * @group base
- */
- class Demand extends Base
- {
- // 需要登录的
- protected $need_login = [
- 'demandComment',
- 'demandSecondComment',
- 'commentTags',
- 'commitDemand',
- 'getMyDemandList',
- 'getMyDemandDetail',
- 'delMyDemand',
- ];
- public function initialize()
- {
- parent::initialize();
- parent::setUid();
- }
- /**
- * @title 需求接口说明
- * @desc 需求接口说明
- * @author qc
- * @url /api/Demand/classIntro
- * @method GET
- */
- public function classIntro(){}
- /**
- * @title 需求推荐
- * @desc 需求推荐
- * @author qc
- * @method GET
- * @url /api/Demand/getRecommendList
- * @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:is_over type:int default:20 desc:是否解决或开源【0否,1是,2开源】
- * @return name:title type:string default:-- desc:标题
- * @return name:content type:string default:-- desc:内容
- * @return name:cover type:array default:-- desc:封面
- * @return name:money type:float default:-- desc:价格
- * @return name:app_name type:string default:-- desc:发布方名称
- * @return name:app_logo type:string default:-- desc:发布方头像
- * @return name:is_over type:int default:-- desc:是否解决或开源【0否,1是,2开源】
- *
- */
- public function getRecommendList()
- {
- $search_log = UserSearch::getSearchTitle($this->user_id,5);
- $app_name = sysconf('app_name');
- $app_logo = sysconf('app_logo');
- $search_arr = [];
- $is_over = input('is_over',0);
- $where_str = 'b.id > 0';
- foreach ($search_log as $t){
- $search_arr[] = " b.title like '".'%'.$t."%'" .' ';
- $search_arr[] = " b.label like '".'%'.$t."%'" .' ';
- }
- if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr);
- $field = 'a.id,cover,money,user_id,label,title,cover,is_over,content,IFNULL(is_recommend,0) is_recommend ';
- $table = 'dd_platform_demand';
- $order_by_two = 'id';
- $sql = "SELECT $field FROM " .$table . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM $table b WHERE ( $where_str )) AS c ON c.id = a.id WHERE a.is_deleted = 0 AND a.status = 1 AND a.is_over = ".$is_over ." ORDER BY is_recommend DESC , $order_by_two desc LIMIT {$this->off_set},{$this->page_num}";
- $list = Db::query($sql);
- array_walk($list,function (&$v,$k)use ($app_name,$app_logo){
- if(!$v['user_id']){
- $v['app_name'] = $app_name;
- $v['app_logo'] = $app_logo;
- }else{
- $user_info = User::where('id',$v['user_id'])->field('name,headimg')->find();
- $v['app_name'] = $user_info ? $user_info->name : '';
- $v['app_logo'] = $user_info ? $user_info->headimg : '';
- }
- $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
- $v['cover_arr'] = explode('|',trim($v['cover'],'|'));
- });
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 需求列表【平台】
- * @desc 需求列表【平台】
- * @author qc
- * @method GET
- * @url /api/Demand/getDemandList
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:is_over type:int default:-1 desc:是否解决或开源【0否,1是,2开源】
- * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @return name:title type:string default:-- desc:标题
- * @return name:content type:string default:-- desc:需求
- * @return name:images type:string default:-- desc:图片【多张|隔开】
- * @return name:user_name type:string default:-- desc:名称
- * @return name:headimg type:string default:-- desc:头像
- * @return name:money type:float default:-- desc:金额
- * @return name:is_over type:int default:-- desc:是否解决或开源【0否,1是,2开源】
- * @param name:company type:string default:0 desc:公司名
- * @param name:company_logo type:string default:0 desc:公司logo
- */
- public function getDemandList()
- {
- $title = input('get.title');
- $is_tj = input('get.is_tj',0);
- $is_over = input('get.is_over',-1);
- $sort_type = input('get.sort_type',1);
- $sel_where =[];
- $sel_where[] = ['d.is_deleted','=',0];
- $sel_where[] = ['d.status','=',1];
- if($title) $sel_where[] = ['d.title|d.label','like','%'.$title.'%'];
- if($is_over > -1) $sel_where[] = ['d.is_over','=',$is_over];
- if($title && $this->user_id) UserSearch::saveSearchTitle($this->user_id,$title,5);
- $where_str = '';
- if($is_tj) {
- $search_log = UserSearch::getSearchTitle($this->user_id,5);
- $search_arr = [];
- foreach ($search_log as $t){
- $search_arr[] = " d.title like '".'%'.$t."%'" .' ';
- }
- if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr);
- }
- $app_name = sysconf('app_name');
- $app_log = sysconf('app_log');
- switch ($sort_type) {
- case 1:
- $order = ['sort'=>'desc','id'=>'desc'];
- break;
- case 2:
- $order = ['id'=>'asc','sort'=>'desc'];
- break;
- case 3:
- $order = ['id'=>'desc','sort'=>'desc'];
- break;
- }
- $list = PlatformDemand::where($sel_where)
- ->field('d.*,u.name user_name,u.headimg')
- ->alias('d')
- ->leftJoin('store_member u','u.id = d.user_id')
- ->when($where_str,function ($query)use ($where_str){if($where_str) $query->where($where_str);})
- ->order($order)
- ->limit($this->off_set,$this->page_num)->select()->toArray();
- array_walk($list,function (&$v)use ($app_name,$app_log){
- if(!$v['user_name']) $v['user_name'] = $app_name;
- if(!$v['headimg']) $v['headimg'] = $app_log;
- });
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 需求详情【平台】
- * @desc 需求详情【平台】
- * @author qc
- * @method GET
- * @url /api/Demand/getDemandInfo
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:-- desc:平台发布需求id
- * @return name:title type:string default:-- desc:标题
- * @return name:content type:string default:-- desc:需求
- * @return name:images type:string default:-- desc:图片【多张|隔开】
- * @return name:user_name type:string default:-- desc:名称
- * @return name:headimg type:string default:-- desc:头像
- * @return name:money type:float default:-- desc:金额
- * @return name:is_over type:int default:-- desc:是否解决或开源【0否,1是,2开源】
- * @param name:company type:string default:0 desc:公司名
- * @param name:company_logo type:string default:0 desc:公司logo
- * @return name:like_num type:int default:-- desc:点赞数量
- * @return name:is_like type:int default:-- desc:是否点赞(0否1是)
- * @return name:is_collect type:int default:-- desc:是否收藏(0否1是)
- * @return name:collect_num type:int default:-- desc:收藏量
- * @return name:app_name type:string default:-- desc:发布方名称
- * @return name:app_logo type:string default:-- desc:发布方头像
- */
- public function getDemandInfo()
- {
- $detail = PlatformDemand::where('id',input('get.id'))->find();
- $app_name = sysconf('app_name');
- $app_logo = sysconf('app_logo');
- if(!$detail || $detail->is_deleted == 1) $this->error('该需求已删除');
- $detail = $detail->toArray();
- $detail['label_name'] = $detail['label'] ? explode(',',trim($detail['label'],',')) : null;
- $detail['like_num'] = PlatformLike::getPraiseNum($detail['id'],9);
- $detail['is_like'] = PlatformLike::checkTags($this->user_id, $detail['id'], 9);
- $detail['is_collect'] = UserCollect::checkCollectByType($this->user_id,10,$detail['id']);
- $detail['collect_num'] = UserCollect::getCollectNum(10,$detail['id']);
- UserTrack::crateTrack($this->user_id,11,input('get.id'),0);
- if(!$detail['user_id']){
- $detail['app_name'] = $app_name;
- $detail['app_logo'] = $app_logo;
- }else{
- $user_info = $this->userInfo('name,headimg');
- $detail['app_name'] = $user_info['name'];
- $detail['app_logo'] = $user_info['headimg'];
- }
- $this->success('ok',['detail'=>$detail]);
- }
- /**
- * @title 获取需求评论列表
- * @desc 获取需求评论列表
- * @author qc
- * @method GET
- * @url /api/Demand/getDemandCommentList
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:-- desc:需求id
- * @param name:sort_type type:int default:1 desc:排序规则1时间2热点
- * @param name:page type:int default:-- desc:页数
- * @return name:name type:string default:-- desc:会员名称
- * @return name:headimg type:string default:-- desc:会员头像
- * @return name:content type:string default:-- desc:内容
- * @return name:parent type:array default:-- desc:评论上一级(数据同上【一维数组】)
- * @return name:children type:array default:-- desc:二级评论(数据同上【二维数组】)
- * @return name:like_num type:int default:-- desc:点赞数量
- * @return name:is_like type:int default:-- desc:是否点赞(0否1是)
- * @return name:total_num type:int default:-- desc:总评论数(仅一级)
- */
- public function getDemandCommentList()
- {
- $where = [];
- $where[] = ['c.first_id','=',input('get.id')];
- $where[] = ['c.is_deleted','=',0];
- $where[] = ['c.type','=',1];
- $user_id = $this->user_id;
- $sort_type= input('sort_type',1);
- $order = $sort_type == 1 ? 'c.id desc' : 'c.like_times desc';
- $list =DemandComment::where($where)
- ->alias('c')
- ->field('c.*,u.name,u.headimg')
- ->leftJoin('store_member u','u.id = c.user_id')
- ->order($order)
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- array_walk($list,function (&$val,$k)use($user_id){
- $children = DemandComment::where(['c.pid'=>$val['id'],'c.is_deleted'=>0])
- ->alias('c')->field('c.*,u.name,u.headimg')
- ->leftJoin('store_member u','u.id = c.user_id')
- ->order('c.id asc')
- ->select()->toArray();
- $val['children'] = $children ? $children : null;
- $val['like_num'] = PlatformLike::getPraiseNum($val['id'],6);
- $val['is_like'] = PlatformLike::where(['like_id'=>$val['id'],'user_id'=>$user_id,'type'=>6])->count();
- $parent = DemandComment::where(['c.id'=>$val['pid'],'c.is_deleted'=>0])
- ->alias('c')->field('c.*,u.name,u.headimg')
- ->leftJoin('store_member u','u.id = c.user_id')
- ->find();
- $val['parent'] = $parent ? $parent->toArray() : null;
- });
- $total_num = DemandComment::where($where)->alias('c')->count();
- $this->success('ok',['list'=>$list,'total_num'=>$total_num]);
- }
- /**
- * @title 以下接口调用验证登录【需要header传Authorization】
- * @desc
- * @author qc
- * @method
- * @url /api/Demand/needLogin
- */
- public function needLogin(){}
- /**
- * @title 需求评论
- * @desc 需求评论
- * @author qc
- * @method POST
- * @url /api/Demand/demandComment
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:1 desc:需求id
- * @param name:content type:string default:-- desc:内容
- * @return name:name type:string default:-- desc:会员名称
- * @return name:headimg type:string default:-- desc:会员头像
- * @return name:content type:string default:-- desc:内容
- * @return name:create_at type:string default:-- desc:时间
- */
- public function demandComment()
- {
- $id = input('post.id');
- $content = input('post.content',0);
- if(!$content) $this->error('请输入评论内容');
- $send_user = PlatformDemand::where('id',$id)->value('user_id');
- $user_info = $this->userInfo('name');
- if($send_user) UserMessage:: sendUserMessage($send_user,'demand',4,0,$this->user_id,$id,$user_info['name'].'评论了您的需求');
- $res = DemandComment::create(['user_id'=>$this->user_id,'content'=>$content,'first_id'=>$id,'type'=>1]);
- $detail =DemandComment::where('p.id',$res->id)
- ->alias('p')
- ->field('p.id,p.content,p.create_at,u.name,u.headimg')
- ->leftJoin('store_member u','u.id = p.user_id')
- ->find()->toArray();
- $this->success('评论成功',['detail'=>$detail]);
- }
- /**
- * @title 需求二级评论
- * @desc 需求二级评论
- * @author qc
- * @method POST
- * @url /api/Demand/demandSecondComment
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:1 desc:评论id
- * @param name:content type:string default:-- desc:内容
- * @return name:name type:string default:-- desc:会员名称
- * @return name:headimg type:string default:-- desc:会员头像
- * @return name:content type:string default:-- desc:内容
- */
- public function demandSecondComment()
- {
- $comment = DemandComment::where('id',input('post.id'))->find()->toArray();
- $user_info = $this->userInfo('name');
- UserMessage:: sendUserMessage($comment['user_id'],'demand',3,0,$this->user_id,$comment['id'],$user_info['name'].'回复了您的评论');
- $send_user = PlatformDemand::where('id',$comment['first_id'])->value('user_id');
- if($send_user) UserMessage::sendUserMessage($send_user,'demand',4,0,$this->user_id,$comment['first_id'],$user_info['name'].'评论了您的需求');
- unset($comment['id']);
- unset($comment['create_at']);
- $comment['pid'] = input('post.id');
- $comment['user_id'] = $this->user_id;
- $comment['content'] = input('post.content');
- $comment['lev']++;
- if(!$comment['source_id']) $comment['source_id'] = input('post.id');
- $res = DemandComment::create($comment);
- $detail = DemandComment::where('p.id',$res->id)
- ->alias('p')
- ->field('p.id,p.content,p.create_at,u.name,u.headimg')
- ->leftJoin('store_member u','u.id = p.user_id')
- ->find()->toArray();
- $this->success('评论成功',['detail'=>$detail]);
- }
- /**
- * @title 需求点赞||取消点赞[需求]
- * @desc 评论
- * @author qc
- * @method POST
- * @url /api/Demand/demandTags
- * @header name:Authorization require:1 desc:Token
- * @param name:demand_id type:int default:1 desc:需求id
- * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
- */
- public function demandTags()
- {
- $ret_val = PlatformLike::userTags($this->user_id,input('post.demand_id'),9);
- $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]);
- }
- /**
- * @title 评论点赞||取消点赞[评论]
- * @desc 评论
- * @author qc
- * @method POST
- * @url /api/Demand/commentTags
- * @header name:Authorization require:1 desc:Token
- * @param name:comment_id type:int default:1 desc:评论记录id
- * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
- */
- public function commentTags()
- {
- $ret_val = PlatformLike::userTags($this->user_id,input('post.comment_id'),6);
- $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]);
- }
- /**
- * @title 收藏||取消收藏
- * @desc 用户收藏
- * @author qc
- * @method POST
- * @url /api/Demand/demandCollect
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int require:1 default:-- desc:需求id
- * @param name:status type:int default:0 desc:收藏状态(0取消收藏【未收藏】,1收藏)
- */
- public function demandCollect(){
- $coll_status = UserCollect::plateCollect($this->user_id,10,input('post.id',0));
- $coll_status ? $this->success('收藏成功',['status'=>1]) : $this->success('取消收藏成功',['status'=>0]);
- }
- /**
- * @title 用户提交||修改需求【用户】
- * @desc 用户提交||修改需求
- * @author qc
- * @method POST
- * @url /api/Demand/commitDemand
- * @param name:id type:int default:-- desc:修改必传[添加不传,或是null或是空]
- * @param name:title type:string default:-- desc:标题
- * @param name:content type:string default:1 desc:内容
- * @param name:money type:float default:0 desc:价格【设计图没有,可以不传】
- * @param name:label type:string default:0 desc:标签【多个逗号隔开】
- * @param name:cover type:string default:0 desc:封面【一张】
- * @param name:images type:string default:0 desc:图片【多张|隔开】
- * @param name:company type:string default:0 desc:公司名
- * @param name:company_logo type:string default:0 desc:公司logo
- */
- public function commitDemand()
- {
- $title = input('post.title');
- $content = input('post.content');
- $money = input('post.money');
- $cover = input('post.cover');
- $images = input('post.images');
- $label = input('post.label');
- $id = input('post.id');
- $company = input('post.company');
- $company_logo = input('post.company_logo');
- if(!$title || !$content) $this->error('标题和需求内容必填');
- if($id) {
- $demand_status = UserDemand::where('id',$id)->value('status');
- if($demand_status == 1) $this->error('已审核通过,不允许修改');
- }
- $res = Data::save('UserDemand',[
- 'title'=>$title,
- 'content'=>$content,
- 'user_id'=>$this->user_id,
- 'money'=>$money,
- 'id'=>$id ? $id : null,
- 'cover'=>$cover,
- 'images'=>$images,
- 'label'=>$label,
- 'company'=>$company,
- 'company_logo'=>$company_logo,
- ],'user_id',['user_id'=>$this->user_id,'id'=>$id]);
- UserMessage::sendUserMessage($this->user_id,'demand',1,0,0,$id ? $id: intval($res));
- $this->success('提交成功,请等待审核');
- }
- /**
- * @title 获取我的需求列表【我的发布】
- * @desc 获取我的图文列表【我的发布】
- * @author qc
- * @method GET
- * @url /api/Demand/getMyDemandList
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @return name:title type:string default:-- desc:标题
- * @return name:content type:string default:-- desc:需求
- * @return name:status type:int default:-- desc:0待审核1审核通过2审核未通过
- * @return name:remark type:string default:-- desc:审核备注
- * @return name:money type:float default:0 desc:价格【设计图没有,可以不传】
- * @return name:cover type:string default:0 desc:封面【一张】
- * @return name:images type:string default:0 desc:图片【多张|隔开】
- * @return name:images_arr type:array default:null desc:图片【多张】
- * @return name:company type:string default:0 desc:公司名
- * @return name:company_logo type:string default:0 desc:公司logo
- */
- public function getMyDemandList()
- {
- $sel_where = [];
- $sel_where[] = ['is_deleted','=',0];
- $sel_where[] = ['user_id','=',$this->user_id];
- $title = input('get.title');
- if($title) $sel_where[] = ['title|label','like','%'.$title.'%'];
- $list = UserDemand::where($sel_where)
- ->field('id,title,content,status,remark,cover,images,money,company,company_logo')
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$lv){
- $lv['images_arr'] = $lv['images'] ? explode('|',$lv['images']) : null;
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取我的需求详情【用户】
- * @desc 获取我的需求详情【用户】
- * @author qc
- * @method GET
- * @url /api/Demand/getMyDemandDetail
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:0 desc:需求记录id
- * @return name:title type:string default:-- desc:标题
- * @return name:content type:string default:-- desc:需求
- * @return name:status type:int default:-- desc:0待审核1审核通过2审核未通过
- * @return name:remark type:string default:-- desc:审核备注
- * @return name:money type:float default:-- desc:金额
- * @return name:cover type:string default:0 desc:封面【一张】
- * @return name:images type:string default:0 desc:图片【多张|隔开】
- * @return name:images_arr type:array default:null desc:图片【多张】
- * @return name:company type:string default:0 desc:公司名
- * @return name:company_logo type:string default:0 desc:公司logo
- */
- public function getMyDemandDetail()
- {
- $detail = UserDemand::where(['user_id'=>$this->user_id,'id'=>input('get.id')])->find();
- if(!$detail || $detail->is_deleted == 1) $this->error('该需求已删除');
- $detail = $detail->toArray();
- $detail['label_name'] = $detail['label'] ? explode(',',trim($detail['label'],',')) : null;
- $detail['images_arr'] = $detail['images'] ? explode('|',$detail['images']) : null;
- $this->success('ok',['detail'=>$detail]);
- }
-
- /**
- * @title 删除我的需求【用户】
- * @desc 删除我的需求【用户】
- * @author qc
- * @method POST
- * @url /api/Demand/delMyDemand
- * @param name:id type:int default:-- desc:需求记录id
- */
- public function delMyDemand()
- {
- UserDemand::where(['id'=>input('post.id'),'user_id'=>$this->user_id])->delete();
- $this->success('删除成功');
- }
- /**
- * @title 我的点赞列表【需求】
- * @desc 我的点赞
- * @author qc
- * @method GET
- * @url /api/Demand/getTagsDemand
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- *
- * @return name:title type:string default:-- desc:标题
- * @return name:demand_id type:string default:-- desc:需求id
- * @return name:cover type:string default:-- desc:封面
- * @return name:content type:string default:-- desc:内容
- * @return name:company type:string default:-- desc:公司
- * @return name:company_logo type:string default:-- desc:公司logo
- * @return name:money type:string default:-- desc:价格
- * @return name:is_over type:int default:-1 desc:是否解决或开源【0否,1是,2开源】
- */
- public function getTagsDemand()
- {
- $sel_where = [];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.type','=',9];
- $list = PlatformLike::where($sel_where)
- ->alias('t')
- ->field('t.id,t.create_at,t.like_id demand_id,i.title,i.cover,i.content,company,money,is_over,company_logo')
- ->leftJoin('PlatformDemand i','t.like_id = i.id')
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 我的浏览历史【需求】
- * @desc 我的浏览历史
- * @author qc
- * @method GET
- * @url /api/Demand/getDemandTrack
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- *
- * @return name:title type:string default:-- desc:标题
- * @return name:demand_id type:string default:-- desc:需求id
- * @return name:cover type:string default:-- desc:封面
- * @return name:content type:string default:-- desc:内容
- * @return name:company type:string default:-- desc:公司
- * @return name:company_logo type:string default:-- desc:公司logo
- * @return name:money type:string default:-- desc:价格
- * @return name:is_over type:int default:-1 desc:是否解决或开源【0否,1是,2开源】
- * @return name:time type:string default:-- desc:时间
- */
- public function getDemandTrack()
- {
- $sel_where = [];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.type','=',11];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
- $list = UserTrack::where($sel_where)
- ->alias('t')
- ->field('t.id,t.update_int,t.first_id demand_id,i.title,i.cover,i.content,company,money,is_over,company_logo')
- ->leftJoin('PlatformDemand i','t.first_id = i.id')
- ->order('update_int desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['time'] = date("Y-m-d H:i:s",$v['update_int']);
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 我的收藏列表【需求】
- * @desc 我的收藏列表
- * @author qc
- * @method GET
- * @url /api/Demand/getCollectDemand
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- *
- * @return name:title type:string default:-- desc:标题
- * @return name:demand_id type:string default:-- desc:需求id
- * @return name:cover type:string default:-- desc:封面
- * @return name:content type:string default:-- desc:内容
- * @return name:company type:string default:-- desc:公司
- * @return name:company_logo type:string default:-- desc:公司logo
- * @return name:money type:string default:-- desc:价格
- * @return name:is_over type:int default:-1 desc:是否解决或开源【0否,1是,2开源】
- */
- public function getCollectDemand()
- {
- $sel_where = [];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.coll_type','=',10];
- $list = UserCollect::where($sel_where)
- ->alias('t')
- ->field('t.id,t.create_at,t.coll_id demand_id,i.title,i.cover,i.content,company,money,is_over,company_logo')
- ->leftJoin('PlatformDemand i','t.coll_id = i.id')
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- $this->success('ok',['list'=>$list]);
- }
- }
|