1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace App\JsonRpc;
- use App\Model\District;
- use Hyperf\RpcServer\Annotation\RpcService;
- use App\Tools\Result;
- #[RpcService(name: "DistrictService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
- class DistrictService implements DistrictServiceInterface
- {
- /**
- * @param int $id
- * @return array
- */
- public function getDistrictInfo(int $id): array
- {
- $adInfo = District::query()->find($id);
- if (empty($adInfo)) {
- return Result::error("没有数据",0);
- }
- return Result::success($adInfo->toArray());
- }
- /**
- * @param string $keyword
- * @param int $page
- * @param int $pageSize
- * @return array
- */
- public function getDistrictList(string $keyword, int $pid=0): array
- {
- $where = [
- ['name','like','%'.$keyword.'%'],
- ['pid','=',$pid],
- ];
- $districtList = District::where($where)->get();
- if (empty($districtList)) {
- return Result::error("没有数据",0);
- }
- return Result::success($districtList->toArray());
- }
- }
|