123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace app\service;
- use app\model\Grid;
- use app\model\User;
- use think\db\exception\DataNotFoundException;
- use think\db\exception\DbException;
- use think\db\exception\ModelNotFoundException;
- class GridService
- {
- public static function addGrid($info): bool
- {
- $grid =new Grid();
- return $grid->save($info);
- }
- public static function delGrid($info): bool
- {
- return Grid::destroy($info['id']);
- }
- public static function editGridInfo($info,$id): Grid
- {
- return Grid::update($info,["id"=>$id]);
- }
- /**
- * @throws ModelNotFoundException
- * @throws DataNotFoundException
- * @throws DbException
- */
- public static function getGridList($page, $xzqdm)
- {
- switch (strlen($xzqdm) ){
- case 4:
- $map[]=["xzqdm","like",'%'.$xzqdm.'%'];
- break;
- case 6:
- $map[] = ["xzqdm","like",'%'.$xzqdm.'%'];
- break;
- case 9:
- $map[] = ["xzqdm","like",'%'.$xzqdm.'%'];
- break;
- default:
- $map[]=[];
- }
- return (new Grid())->where($map)->page($page["page"],$page["size"])->select();
- }
- }
|