12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- namespace app\api\controller\worker;
- use app\common\controller\Apiw;
- use think\Db;
- use fast\Tree;
- /**
- * 我的
- */
- class Usercenter extends Apiw
- {
- protected $noNeedLogin = ['collect_list','download_list'];
- protected $noNeedRight = ['*'];
- public function collect_list(){
- $table = input('type','jishuguifan');
- //验证表名
- $table_name = [
- 'jishuguifan',
- 'news',
- 'caozuoguifan',
- ];
- if(!in_array($table,$table_name)){
- $this->error();
- }
- //拿收藏的ids
- $where = [
- 'worker_id' => $this->auth->id,
- 'table' => $table,
- ];
- $table_ids = Db::name('worker_collect')->where($where)->group('table_id')->column('table_id');
- if(!empty($table_ids)){
- $ids_str = implode(',',$table_ids);
- //字段
- $table_field = [
- 'jishuguifan' => 'id,name,ismenu',
- 'news' => 'id,title,image,createtime',
- 'caozuoguifan' => 'id,title,image,createtime',
- ];
- $list = Db::name($table)->field($table_field[$table])
- ->where('id','IN',$table_ids)
- ->orderRaw('field(id,'.$ids_str.')')
- ->autopage()
- ->select();
- $list = list_domain_image($list,['image']);
- }else{
- $list = [];
- }
- $this->success(1, $list);
- }
- //下载功能
- public function download_list(){
- $list = Db::name('worker_download')->alias('down')
- ->join('jishuguifan j','down.table_id = j.id','LEFT')
- ->field('j.id,j.name,j.ismenu,down.updatetime')
- ->where('down.worker_id',$this->auth->id)
- ->autopage()
- ->group('down.table_id')
- ->select();
- $this->success(1,$list);
- }
- }
|