12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- use fast\Tree;
- /**
- * 技术规范
- */
- class Jishuguifan extends Api
- {
- protected $noNeedLogin = ['*'];
- protected $noNeedRight = ['*'];
- //所有一级
- public function index()
- {
- $keyword = input('keyword','');
- $where_search = [];
- if(!empty($keyword)){
- $where_search['name'] = ['LIKE','%'.$keyword.'%'];
- }
- //
- $list = Db::name('jishuguifan')->field('id,name,ismenu,image,createtime')
- ->where('company_id',$this->auth->company_id)
- ->where('pid',0)
- ->order('id' , 'asc')
- ->autopage()
- ->select();
- $list = list_domain_image($list,['image']);
- $this->success(1, $list);
- }
- //二级
- public function lists(){
- $tid = input('id',0);
- $list = Db::name('jishuguifan')->field('id,pid,name,image,ismenu,createtime')
- ->where('company_id',$this->auth->company_id)
- ->where('tid',$tid)
- ->select();
- $list = list_domain_image($list,['image']);
- $tree = Tree::instance();
- $tree->init($list, 'pid');
- $tree->icon = ['','',''];
- // $tree->icon = ['','',''];
- $tree->nbsp = 'nbsp';
- $treedata = $tree->getTreeList($tree->getTreeArray($tid), 'name');
- /*$result = [];
- foreach ($treedata as $k => $v) {
- $result[$v['id']] = $v;
- }*/
- $this->success(1, $treedata);
- }
- //详情
- public function info(){
- $id = input('id',0);
- $info = Db::name('jishuguifan')
- ->where('id',$id)
- ->find();
- $info = info_domain_image($info,['file','image']);
- //上一篇
- $up_id = 0;
- $up = Db::name('jishuguifan')->where('tid',$info['tid'])->where('ismenu',0)->where('id','<',$info['id'])->order('id desc')->value('id');
- if($up){
- $up_id = $up;
- }
- //下一篇
- $down_id = 0;
- $down = Db::name('jishuguifan')->where('tid',$info['tid'])->where('ismenu',0)->where('id','>',$info['id'])->order('id asc')->value('id');
- if($down){
- $down_id = $down;
- }
- $rs = [
- 'info' => $info,
- 'up_id' => $up_id,
- 'down_id' => $down_id,
- ];
- $this->success(1, $rs);
- }
- }
|