Caozuoguifan.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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']);
  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')
  39. ->where('company_id',$this->auth->company_id)
  40. ->where('type_id',$type_id)
  41. ->autopage()
  42. ->select();
  43. $this->success(1, $list);
  44. }
  45. //详情
  46. public function info(){
  47. $id = input('id',0);
  48. $list = Db::name('caozuoguifan')
  49. ->where('id',$id)
  50. ->find();
  51. $list = info_domain_image($list, ['image']);
  52. $this->success(1, $list);
  53. }
  54. }