limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])->orderBy("code","asc")->get(); $count = District::where($where)->count(); $result = [ 'rows'=>$rep, 'count'=>$count ]; }else{ $result = District::where($data)->orderBy("code","asc")->get(); } return $result?Result::success($result):Result::error("没有查到数据"); } /** * @param array $data * @return array */ public function getUserLevelList(array $data): array { $where = []; if(isset($data['keyWord'])){ $where = [ ['name','like','%'.$data['keyWord'].'%'] ]; } $result = []; if(isset($data['pageSize'])){ $rep = LevelUser::where($where)->limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])->orderBy("id","asc")->get(); $count = LevelUser::where($where)->count(); $result = [ 'rows'=>$rep, 'count'=>$count ]; }else{ $result = LevelUser::orderBy("id","asc")->get(); } return $result?Result::success($result):Result::error("没有查到数据"); } /** * 添加用户等级 * @param array $data * @return array */ public function addUserLevel(array $data) :array { LevelUser::insertGetId($data); return Result::success([]); } /** * 更新等级 * @param array $data * @return array */ public function updateUserLevel(array $data) :array { $result = LevelUser::where(['id'=>$data['id']])->update($data); if ($result) { return Result::success($result); } return Result::error("更新失败"); } /** * 删除等级 * @param array $data * @return array */ public function delUserLevel(array $data) :array { $result = LevelUser::where(['id'=>$data['id']])->delete(); if ($result) { return Result::success($result); } return Result::error("删除失败"); } }