Template.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\controller\api;
  3. use laytp\controller\Api;
  4. use laytp\library\Random;
  5. use laytp\library\Tree;
  6. use think\facade\Db;
  7. /**
  8. * AI相关
  9. * @ApiWeigh (90)
  10. */
  11. class Template extends Api
  12. {
  13. protected function _initialize()
  14. {
  15. $this->model = new \app\model\Template();
  16. }
  17. public $noNeedLogin = [
  18. "list",
  19. "info"
  20. ];
  21. // 使用记录
  22. public function list()
  23. {
  24. global $_GPC;
  25. $template = [];
  26. $where = ['status'=>1,'uniacid'=>$_GPC['uniacid']];
  27. $order = ['sort' => 'DESC','id'=>'DESC'];
  28. $sourceData =\app\model\Template::where($where)->order($order);
  29. $menuTreeObj = Tree::instance();
  30. $menuTreeObj->init($sourceData->select()->toArray());
  31. $data = $menuTreeObj->getRootTrees();
  32. return $this->success('数据获取成功', $data);
  33. }
  34. public function info()
  35. {
  36. global $_GPC;
  37. $id = $this->request->param('id');
  38. $info = $this->model->find($id);
  39. if(!$info){
  40. return $this->error('详情获取失败');
  41. }
  42. return $this->success('获取成功', $info);
  43. }
  44. }