GridService.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\service;
  3. use app\model\Grid;
  4. use app\model\User;
  5. use think\db\exception\DataNotFoundException;
  6. use think\db\exception\DbException;
  7. use think\db\exception\ModelNotFoundException;
  8. class GridService
  9. {
  10. public static function addGrid($info): bool
  11. {
  12. $grid =new Grid();
  13. return $grid->save($info);
  14. }
  15. public static function delGrid($info): bool
  16. {
  17. return Grid::destroy($info['id']);
  18. }
  19. public static function editGridInfo($info,$id): Grid
  20. {
  21. return Grid::update($info,["id"=>$id]);
  22. }
  23. /**
  24. * @throws ModelNotFoundException
  25. * @throws DataNotFoundException
  26. * @throws DbException
  27. */
  28. public static function getGridList($page, $xzqdm)
  29. {
  30. switch (strlen($xzqdm) ){
  31. case 4:
  32. $map[]=["xzqdm","like",'%'.$xzqdm.'%'];
  33. break;
  34. case 6:
  35. $map[] = ["xzqdm","like",'%'.$xzqdm.'%'];
  36. break;
  37. case 9:
  38. $map[] = ["xzqdm","like",'%'.$xzqdm.'%'];
  39. break;
  40. default:
  41. $map[]=[];
  42. }
  43. return (new Grid())->where($map)->page($page["page"],$page["size"])->select();
  44. }
  45. }