SeatinggroupsController.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace app\admin\controller\kefu;
  3. use think\exception\ValidateException;
  4. use app\model\kefu\Seatinggroups;
  5. class SeatinggroupsController extends Base
  6. {
  7. function index()
  8. {
  9. $keyword = input('post.keyword', '', 'serach_in');
  10. $status = input('post.status', '', 'serach_in');
  11. $weid = weid();
  12. $where = [];
  13. $where['weid'] = $weid;
  14. if ($status !== '') {
  15. $where['status'] = $status;
  16. }
  17. $field = 'id,title,touxiang,status,px';
  18. $query = Seatinggroups::where($where);
  19. if (!empty($keyword)) {
  20. $query->where('title', 'like', '%' . $keyword . '%');
  21. }
  22. $res = $query->field($field)
  23. ->order('id desc')
  24. ->paginate(getpage())->toArray();
  25. $data['data'] = $res;
  26. return $this->json($data);
  27. }
  28. function listUpdate()
  29. {
  30. $data = only('id,status');
  31. if (!$data['id']) throw new ValidateException('参数错误');
  32. Seatinggroups::update($data);
  33. return $this->json(['msg' => '操作成功']);
  34. }
  35. public function update()
  36. {
  37. $id = $this->request->post('id');
  38. $data = input('post.');
  39. if (empty($id)) {
  40. $weid = weid();
  41. $data['weid'] = $weid;
  42. $res = Seatinggroups::create($data);
  43. return $this->json(['msg' => '添加成功', 'data' => $res->id]);
  44. } else {
  45. Seatinggroups::update($data);
  46. return $this->json(['msg' => '修改成功']);
  47. }
  48. }
  49. function getInfo()
  50. {
  51. $id = $this->request->post('id', '', 'serach_in');
  52. if (!$id) $this->error('参数错误');
  53. $res = Seatinggroups::find($id);
  54. return $this->json(['data' => $res]);
  55. }
  56. function delete()
  57. {
  58. return $this->del(new Seatinggroups());
  59. }
  60. }