Caozuoguifan.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /**
  6. * 操作规范
  7. */
  8. class Caozuoguifan extends Api
  9. {
  10. protected $noNeedLogin = ['*'];
  11. protected $noNeedRight = ['*'];
  12. public function index()
  13. {
  14. //所有分类
  15. $typelist = Db::name('caozuoguifan_type')
  16. ->where('company_id',$this->auth->company_id)
  17. ->order('id' , 'asc')
  18. ->select();
  19. //第一个分类的内容
  20. $list = [];
  21. if(!empty($typelist)){
  22. $list = Db::name('caozuoguifan')->field('content',true)
  23. ->where('company_id',$this->auth->company_id)
  24. ->where('type_id',$typelist[0]['id'])
  25. ->autopage()
  26. ->select();
  27. $list = list_domain_image($list,['image','videofile']);
  28. }
  29. $rs = [
  30. 'typelist' => $typelist,
  31. 'list' => $list,
  32. ];
  33. $this->success(1, $rs);
  34. }
  35. //操作规范
  36. public function lists(){
  37. $type_id = input('type_id',0);
  38. $list = Db::name('caozuoguifan')->field('content',true)
  39. ->where('company_id',$this->auth->company_id)
  40. ->where('type_id',$type_id)
  41. ->autopage()
  42. ->select();
  43. $list = list_domain_image($list,['image','videofile']);
  44. $this->success(1, $list);
  45. }
  46. //详情
  47. public function info(){
  48. $id = input('id',0);
  49. $list = Db::name('caozuoguifan')
  50. ->where('id',$id)
  51. ->find();
  52. $list = info_domain_image($list, ['image','videofile']);
  53. $this->success(1, $list);
  54. }
  55. }