123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605 |
- <?php
- namespace app\api\controller;
- use app\common\model\DatumCate;
- use app\common\model\DatumIntro;
- use app\common\model\DatumLike;
- use app\common\model\DatumUrl;
- use app\common\model\User;
- use app\common\model\UserCollect;
- use app\common\model\UserDatum;
- use app\common\model\UserDownload;
- use app\common\model\UserLevelRank;
- use app\common\model\UserMessage;
- use app\common\model\UserSearch;
- use app\common\model\UserTrack;
- use library\tools\Data;
- use think\Db;
- /**
- * @title 资料
- * @controller Datum
- * @group base
- */
- class Datum extends Base
- {
- // 需要登录的
- protected $need_login = [
- 'datumTransmit',
- 'datumRead',
- 'datumCollect',
- 'datumTags',
- 'userReferDatum',
- 'getMyDatumList',
- 'getUserDatumDetail',
- 'delUserDatum',
- 'getDownloadDatum',
- 'getLearnHistory',
- 'getDatumCollect',
- ];
- public function initialize()
- {
- parent::initialize();
- parent::setUid();
- }
- /**
- * @title 资料接口说明
- * @desc 资料接口说明
- * @author qc
- * @url /api/Datum/classIntro
- * @method GET
- * @return name:1 type:string default:-- desc:单一资料与系列资料区别,type值(1是单一,2是系列),数据:url_arr二维数组数据数量不一样(单一的只有一个,系列的可以是多个)【可以将单一资料看做只有一条记录的系列资料!!!!】
- * @return name:2 type:string default:-- desc:单一资料详情的字段(除id)与url_arr数组的第一个同字段名的值相同
- * @return name:3 type:string default:-- desc:系列资料详情的字段(除id)与url_arr数组的其中一个同字段名的值相同
- * @return name:4 type:string default:-- desc:关于是否的字段(0否,1是)
- * @return name:5 type:string default:-- desc:url_id是详情或列表url_arr下的id
- */
- public function classIntro(){ }
- /**
- * @title 获取资料目录
- * @desc 获取资料目录
- * @author qc
- * @url /api/Datum/getDatumCate
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @return name:id type:int default:-- desc:id
- * @return name:title type:string default:0 desc:名称
- * @return name:datum_list type:array default:0 desc:目录下的资料
- * @return name:datum_list.id type:int default:0 desc:资料记录
- * @return name:datum_list.title type:int default:0 desc:资料标题
- */
- public function getDatumCate()
- {
- $list = DatumCate::field('id,title')->where('is_deleted',0)->select()->toArray();
- foreach ($list as &$v) {
- $v['datum_list'] = DatumIntro::field('id,title')->where(['datum_cate'=>$v['id']])->select()->toArray();
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 资料推荐
- * @desc 资料推荐
- * @author qc
- * @method GET
- * @url /api/Datum/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:每页数
- * @return name:id type:string default:-- desc:资料item_id
- * @return name:title type:string default:-- desc:标题
- * @return name:datum_id type:string default:-- desc:系列id
- * @return name:is_vip type:int default:-- desc:是否是vip(0否,1是)
- * @return name:read_num type:int default:-- desc:阅读量
- * @return name:down_num type:int default:-- desc:下载量
- * @return name:url type:int default:-- desc:资料路径
- */
- public function getRecommendList()
- {
- $search_log = UserSearch::getSearchTitle($this->user_id,3);
- $search_arr = [];
- $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,a.title,a.user_id,a.down_num,a.read_num,a.is_vip,a.datum_id,a.url ,IFNULL(is_recommend,0) is_recommend ';
- $table = 'dd_datum_url';
- $order_by_two = 'a.read_num';
- $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 LEFT JOIN dd_datum_intro as k ON k.id = a.datum_id WHERE a.status = 1 AND a.is_deleted = 0 AND k.status = 1 AND k.is_deleted = 0 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){
- });
- $this->success('ok',['list'=>$list,'sql'=>$sql]);
- }
- /**
- * @title 获取资料列表(平台发布)
- * @desc 获取资料列表
- * @author qc
- * @method GET
- * @url /api/Datum/getDatumList
- * @header name:Authorization require:1 desc:Token
- * @param name:type type:int default:0 desc:类型1单个2系列
- * @param name:is_tj type:int default:0 desc:是否推荐0否1是
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
- * @return name:id type:int default:-- desc:[请求/api/Datum/getDatumDetail用,请求资料模块其他接口参数:url_id]
- * @return name:title type:string default:-- desc:标题
- * @return name:type type:int default:0 desc:类型1单个2系列
- * @return name:datum_url type:string default:-- desc:资料地址
- * @return name:is_vip type:int default:-- desc:是否是vip(0否,1是)
- * @return name:is_over type:int default:-- desc:是否完结(0否,1是)
- * @return name:label type:string default:-- desc:标签
- * @return name:is_collect type:int default:-- desc:是否收藏
- * @return name:url_arr type:array default:-- desc:资料
- * @return name:url_arr.title type:string default:-- desc:资料标题
- * @return name:url_arr.is_vip type:int default:-- desc:是否是vip
- * @return name:url_arr.url type:string default:-- desc:资料地址
- */
- public function getDatumList()
- {
- $sel_where = [];
- $title = input('get.title');
- $type = input('get.type',0);
- $is_tj = input('get.is_tj',0);
- $sort_type = input('get.sort_type',1);
- $sel_where[] = ['is_deleted','=',0];
- $sel_where[] = ['status','=',1];
- $sel_where[] = ['url_num','>',0];
- if($title) $sel_where[] = ['title|label','like','%'.$title.'%'];
- if($type) $sel_where[] = ['type','=',$type];
- 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;
- }
- if($title && $this->user_id) UserSearch::saveSearchTitle($this->user_id,$title,3);
- $where_str = 'id > 0';
- if($is_tj) {
- $search_log = UserSearch::getSearchTitle($this->user_id,3);
- $search_arr = [];
- foreach ($search_log as $t){
- $search_arr[] = " title like '".'%'.$t."%'" .' ';
- }
- if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr);
- }
- $list = DatumIntro::where($sel_where)->with('urlArr')
- ->limit($this->off_set,$this->page_num)
- ->where($where_str)
- ->order($order)
- ->select()->toArray();
- array_walk($list,function (&$v,$k){
- $v['is_collect'] = UserCollect::checkCollectByType($this->user_id,2,$v['id']);
- $v['down_num'] = array_sum(array_column($v['url_arr'],'down_num'));
- });
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取资料详情(平台)
- * @desc 获取资料详情
- * @author qc
- * @method GET
- * @url /api/Datum/getDatumDetail
- * @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:datum_url type:string default:-- desc:资料地址
- * @return name:down_num type:string default:-- desc:下载量
- * @return name:url_arr type:array default:-- desc:资料
- * @return name:url_arr.id type:int default:-- desc:[请求/api/Datum/getDatumItemInfo用,请求资料模块其他接口参数:url_id]
- * @return name:url_arr.title type:string default:-- desc:资料标题
- * @return name:url_arr.is_vip type:int default:-- desc:是否是vip
- * @return name:url_arr.url type:string default:-- desc:资料地址
- * @return name:url_arr.is_collect type:int default:-- desc:是否收藏
- * @return name:url_arr.collect_num type:int default:-- desc:收藏量
- * @return name:url_arr.down_num type:int default:-- desc:下载量
- */
- public function getDatumDetail()
- {
- $sel_where = [];
- $sel_where[] = ['id','=',input('get.id')];
- $detail = DatumIntro::where($sel_where)->with('urlArr')->find()->toArray();
- if($detail['is_deleted'] == 1 || $detail['status'] == 0)$this->error('该资料已下线');
- $level_id = UserLevelRank::getUserVip($this->user_id);
- foreach ($detail['url_arr'] as &$dv) {
- if($dv['is_vip'] && !$level_id) $dv['url'] = '';
- $dv['is_collect'] = UserCollect::checkCollectByType($this->user_id,2,$detail['id'],$dv['id']);
- $dv['collect_num'] = UserCollect::where(['user_id'=>$this->user_id,'coll_type'=>1,'coll_id'=>$detail['id'],'children_id'=>$dv['id']])->count();
- }
- $detail['read_num'] = array_sum(array_column($detail['url_arr'],'read_num'));
- $detail['down_num'] = array_sum(array_column($detail['url_arr'],'down_num'));
- $this->success('ok',['detail'=>$detail]);
- }
- /**
- * @title 获取资料ITEM详情(平台)
- * @desc 获取资料ITEM详情
- * @author qc
- * @method GET
- * @url /api/Datum/getDatumItemInfo
- * @header name:Authorization require:1 desc:Token
- * @param name:url_id type:int default:0 desc:url_id
- * @return name:title type:string default:-- desc:资料标题
- * @return name:is_vip type:int default:-- desc:是否是vip
- * @return name:cover type:string default:-- desc:封面
- * @return name:images type:int default:-- desc:图片
- * @return name:content type:int default:-- desc:内容
- * @return name:transmit_num type:int default:-- desc:转发量
- * @return name:read_num type:int default:-- desc:阅读量
- * @return name:collect_num type:int default:-- desc:收藏量
- * @return name:down_num type:int default:-- desc:下载量
- * @return name:is_collect type:int default:-- desc:是否收藏
- */
- public function getDatumItemInfo()
- {
- $url_id = input('get.url_id');
- $detail = DatumUrl::where('id',$url_id)->find()->toArray();
- $detail['collect_num'] = UserCollect::where(['coll_type'=>2,'coll_id'=>$detail['datum_id'],'children_id'=>$detail['id']])->count();
- $detail['is_collect'] = UserCollect::checkCollectByType($this->user_id,2,$detail['datum_id'],$detail['id']);
- UserTrack::crateTrack($this->user_id,2,$detail['datum_id'],$url_id);
- $this->success('ok',['detail'=>$detail]);
- }
-
- /**
- * @title 资料转发(转发数量统计)
- * @desc 转发成功后调用
- * @author qc
- * @method POST
- * @url /api/Datum/datumTransmit
- * @header name:Authorization require:1 desc:Token
- * @param name:datum_id type:int default:-- desc:资料id
- * @param name:url_id type:int default:-- desc:url_id
- */
- public function datumTransmit()
- {
- $datum_id= input('post.datum_id');
- $url_id = input('post.url_id',0);
- DatumUrl::where('id',$url_id)->setInc('transmit_num');
- $this->success('ok');
- }
- /**
- * @title 资料下载(资料下载数量统计)
- * @desc 资料下载
- * @author qc
- * @method POST
- * @url /api/Datum/datumDownload
- * @header name:Authorization require:1 desc:Token
- * @param name:datum_id type:int default:-- desc:资料id
- * @param name:url_id type:int default:-- desc:url_id
- */
- public function datumDownload()
- {
- $datum_id= input('post.datum_id');
- $url_id = input('post.url_id',0);
- Data::save('UserDownload',['user_id'=>$this->user_id,'first_id'=>$datum_id,'second_id'=>$url_id]);
- DatumUrl::where('id',$url_id)->setInc('down_num');
- $this->success('ok');
- }
- /**
- * @title 资料阅读(阅读数量统计)
- * @desc 资料阅读
- * @author qc
- * @method POST
- * @url /api/Datum/datumRead
- * @header name:Authorization require:1 desc:Token
- * @param name:url_id type:int default:-- desc:url_arr的id
- */
- public function datumRead()
- {
- $url_id = input('post.url_id',0);
- DatumUrl::where('id',$url_id)->setInc('read_num');
- $this->success('ok');
- }
- /**
- * @title 资料收藏||取消收藏
- * @desc 用户收藏
- * @author qc
- * @method POST
- * @url /api/Datum/datumCollect
- * @header name:Authorization require:1 desc:Token
- * @param name:datum_id type:int require:1 default:-- desc:记录id[资料id]
- * @param name:url_id type:int default:1 desc:url_id
- * @return name:status type:int default:0 desc:收藏状态(0取消收藏【未收藏】,1收藏)
- */
- public function datumCollect()
- {
- $coll_type = input('post.coll_type',2);
- $coll_id = input('post.datum_id',0);
- $url_id = input('post.url_id',0);
- if(!$coll_id || !$url_id) $this->error('参数错误');
- $collect_check = UserCollect::checkCollectByType($this->user_id,$coll_type,$coll_id,$url_id);
- if($collect_check) {
- UserCollect::where(['user_id'=>$this->user_id,'coll_type'=>$coll_type,'coll_id'=>$coll_id,'children_id'=>$url_id])->delete();
- $this->success('取消收藏成功',['status'=>0]);
- }else{
- Data::save('UserCollect', [
- 'user_id'=>$this->user_id,
- 'coll_type'=>$coll_type,
- 'coll_id'=>$coll_id,
- 'children_id'=>$url_id,
- 'create_int'=>time()],'user_id',['user_id'=>$this->user_id,'coll_type'=>$coll_type, 'coll_id'=>$coll_id,'children_id'=>$url_id]);
- $this->success('收藏成功',['status'=>1]);
- }
- }
- /**
- * @title 资料点赞||取消点赞
- * @desc 点赞||取消点赞
- * @author qc
- * @method POST
- * @url /api/Datum/datumTags
- * @header name:Authorization require:1 desc:Token
- * @param name:datum_id type:int default:1 desc:资料id
- * @param name:url_id type:int default:1 desc:url_id
- * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
- */
- public function datumTags()
- {
- $datum_id = input('post.datum_id');
- $url_id = input('post.url_id');
- $ret_val = 0;
- $check_tags = DatumLike::where(['user_id'=>$this->user_id,'datum_id'=>$datum_id,'url_id'=>$url_id])->value('id');
- if($check_tags) {
- DatumLike::where(['user_id'=>$this->user_id,'datum_id'=>$datum_id,'url_id'=>$url_id])->delete();
- }else{
- Data::save('DatumLike',
- ['user_id'=>$this->user_id,'datum_id'=>$datum_id,'url_id'=>$url_id],'user_id',
- ['user_id'=>$this->user_id,'datum_id'=>$datum_id,'url_id'=>$url_id]);
- $ret_val = 1;
- }
- $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]);
- }
-
- /**
- * @title 用户提交或修改资料【个人】
- * @desc 用户提交或修改资料【个人】
- * @author qc
- * @method POST
- * @url /api/Datum/userReferDatum
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:-- desc:id(修改时必传)
- * @param name:title type:string default:-- desc:标题
- * @param name:datum_url type:string default:-- desc:资料地址
- * @param name:desc type:string default:-- desc:简介
- * @param name:label type:string default:-- desc:资料标签id(多个用逗号隔开)
- */
- public function userReferDatum()
- {
- $id = input('post.id',0);
- $title = input('post.title');
- $desc = input('post.desc');
- $datum_url = input('post.datum_url');
- $label = input('post.label');
- if(!$datum_url) $this->error('请上传资料');
- if($id){
- $check_status = UserDatum::where('id',$id)->value('status');
- if($check_status == 1) $this->error('已审核通过,不允许修改');
- }
- $data = [
- 'title' => $title,
- 'user_id' => $this->user_id,
- 'desc' => $desc,
- 'datum_url' => $datum_url,
- 'label' => $label,
- 'status' => 0,
- 'remark' => '',
- ];
- if($id) $data['id'] = $id;
- if($id){
- UserDatum::where('id',$id)->update($data);
- }else{
- $res= UserDatum::create($data) ;
- }
- UserMessage::sendUserMessage($this->user_id,'datum',1,0,0,$id ? $id:$res->id);
- $this->success('提交成功,请等待审核',['id'=> $id ? :$res->id]);
- }
- /**
- * @title 获取我的资料列表【个人】
- * @desc 获取我的资料列表【个人】
- * @author qc
- * @method GET
- * @url /api/Datum/getMyDatumList
- * @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:desc type:string default:-- desc:简介
- * @return name:datum_url type:string default:-- desc:资料地址
- * @return name:status type:int default:-- desc:0待审核1审核通过2审核未通过
- * @return name:remark type:string default:-- desc:审核备注
- * @return name:label type:string default:-- desc:标签
- */
- public function getMyDatumList()
- {
- $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 = UserDatum::where($sel_where)
- ->field('id,title,desc,datum_url,status,remark,label')
- ->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/Datum/getUserDatumDetail
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:string default:-- desc:记录id
- * @return name:title type:string default:-- desc:标题
- * @return name:desc type:string default:-- desc:简介
- * @return name:datum_url type:string default:-- desc:资料地址
- * @return name:status type:int default:-- desc:0待审核1审核通过2审核未通过
- * @return name:remark type:string default:-- desc:审核备注
- * @return name:label type:string default:-- desc:标签
- * @return name:label_name type:array default:-- desc:标签数组
- */
- public function getUserDatumDetail()
- {
- $detail =UserDatum::where('id',input('get.id'))->field('id,title,desc,datum_url,status,remark,label')->find();
- if(!$detail) $this->error('资料有误');
- $detail['label_name'] =$detail['label'] ? $detail['label_name'] = explode(',',trim($detail['label'],',')) : null;
- $this->success('ok',['detail'=>$detail->toArray()]);
- }
- /**
- * @title 用户删除资料记录【个人】
- * @desc 用户删除资料记录【个人】
- * @author qc
- * @method POST
- * @url /api/Datum/delUserDatum
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:-- desc:id
- */
- public function delUserDatum()
- {
- UserDatum::where(['user_id'=>$this->user_id,'id'=>input('post.id')])->delete();
- $this->success('删除成功');
- }
- /**
- * @title 获取下载资料列表
- * @desc 获取下载资料列表
- * @author qc
- * @method GET
- * @url /api/Datum/getDownloadDatum
- * @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:datum_id type:int default:-- desc:资料id
- * @return name:url_id type:int default:-- desc:item_id
- * @return name:is_vip type:int default:-- desc:是否vip[0否1是]
- * @return name:url type:string default:-- desc:资料路径
- */
- public function getDownloadDatum()
- {
- $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','=',1];
- $list = UserDownload::where($sel_where)
- ->alias('t')
- ->field('t.id,t.create_at,t.first_id datum_id,t.second_id url_id,i.title,i.is_vip,i.url')
- ->leftJoin('DatumUrl i','t.second_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/Datum/getLearnHistory
- * @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:datum_id type:int default:-- desc:资料id
- * @return name:url_id type:int default:-- desc:item_id
- * @return name:is_vip type:int default:-- desc:是否vip[0否1是]
- * @return name:url type:string default:-- desc:资料路径
- */
- public function getLearnHistory()
- {
- $sel_where = [];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.type','=',2];
- $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 datum_id,t.second_id url_id,i.title,i.url,i.is_vip')
- ->leftJoin('DatumUrl i','t.second_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/Datum/getDatumCollect
- * @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:datum_id type:string default:-- desc:资料id
- * @return name:url_id type:string default:-- desc:url_id
- * @return name:url type:string default:-- desc:资料路径
- * @return name:create_at type:string default:-- desc:时间
- */
- public function getDatumCollect()
- {
- $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','=',2];
- $list = UserCollect::where($sel_where)
- ->alias('t')
- ->field('t.id,t.create_at,t.coll_id datum_id,t.children_id url_id,i.title,i.url,i.is_vip')
- ->leftJoin('DatumUrl i','t.children_id = i.id')
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- $this->success('ok',['list'=>$list]);
- }
- }
|