FilesController.php 912 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace app\admin\controller;
  3. use think\exception\ValidateException;
  4. use app\model\Files;
  5. use app\model\FilesCate;
  6. class FilesController extends Base
  7. {
  8. function index()
  9. {
  10. $weid = weid();
  11. $keyword = input('post.keyword', '', 'serach_in');
  12. $query = Files::where(['weid' => $weid]);
  13. if (!empty($keyword)) {
  14. $query->where('title', 'like', '%' . $keyword . '%');
  15. }
  16. $res = $query->order('sort asc,id asc')
  17. ->paginate(getpage())
  18. ->toArray();
  19. $data['data'] = $res;
  20. return $this->json($data);
  21. }
  22. function listUpdate()
  23. {
  24. $data = only('id,status,sort');
  25. if (!$data['id']) throw new ValidateException('参数错误');
  26. Files::update($data);
  27. return $this->json(['msg' => '操作成功']);
  28. }
  29. function delete()
  30. {
  31. return $this->del(new Files());
  32. }
  33. function getField()
  34. {
  35. $data['cidarray'] = FilesCate::getpagearray();
  36. return $this->json(['data' => $data]);
  37. }
  38. }