| @@ -0,0 +1,49 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\Custom\HelloTechno; | |||||
| use App\Codes\UserRole; | |||||
| use App\Exceptions\AppCommonException; | |||||
| use App\Http\Controllers\Web\IParam; | |||||
| use App\Util\Custom\HelloTechno\API; | |||||
| use Illuminate\Http\JsonResponse; | |||||
| use Illuminate\Http\Request; | |||||
| use Illuminate\Support\Arr; | |||||
| class ParkingByCodeController extends HelloTechnoController | |||||
| { | |||||
| public function name(): string | |||||
| { | |||||
| return "[HelloTechno専用]駐車場情報取得(駐車場管理コード指定)"; | |||||
| } | |||||
| public function description(): string | |||||
| { | |||||
| return "[HelloTechno専用]駐車場情報を取得する(駐車場管理コード指定)"; | |||||
| } | |||||
| public function __construct( | |||||
| protected ParkingByCodeParam $param, | |||||
| ) { | |||||
| parent::__construct(); | |||||
| $this->roleAllow(UserRole::NORMAL_ADMIN); | |||||
| } | |||||
| protected function getParam(): IParam | |||||
| { | |||||
| return $this->param; | |||||
| } | |||||
| protected function run(Request $request): JsonResponse | |||||
| { | |||||
| $param = $this->param; | |||||
| $parking = Arr::first(API::getParkings(null, $param->parkingManagementCode)); | |||||
| if ($parking === null) { | |||||
| throw new AppCommonException("駐車場情報取得不正"); | |||||
| } | |||||
| return $this->successResponse($parking); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,18 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\Custom\HelloTechno; | |||||
| use App\Http\Controllers\Web\BaseParam; | |||||
| /** | |||||
| * @property string $parkingManagementCode | |||||
| */ | |||||
| class ParkingByCodeParam extends BaseParam | |||||
| { | |||||
| public function rules(): array | |||||
| { | |||||
| return [ | |||||
| 'parking_management_code' => $this->str() | |||||
| ]; | |||||
| } | |||||
| } | |||||
| @@ -35,10 +35,12 @@ class API | |||||
| return static::get(static::getCustomersUrl(), $query); | return static::get(static::getCustomersUrl(), $query); | ||||
| } | } | ||||
| public static function getParkings(string $customerCode, ?string $parkingManagementCode = null) | |||||
| public static function getParkings(?string $customerCode, ?string $parkingManagementCode = null) | |||||
| { | { | ||||
| $query['customer_code'] = $customerCode; | |||||
| if ($customerCode) { | |||||
| $query['customer_code'] = $customerCode; | |||||
| } | |||||
| if ($parkingManagementCode) { | if ($parkingManagementCode) { | ||||
| $query['parking_management_code'] = $parkingManagementCode; | $query['parking_management_code'] = $parkingManagementCode; | ||||
| } | } | ||||
| @@ -43,6 +43,7 @@ RouteHelper::post('/user/change-password', App\Http\Controllers\Web\LoginUser\Ch | |||||
| // Custom for HelloTechno | // Custom for HelloTechno | ||||
| RouteHelper::get('/custom/hello-techno/customers', App\Http\Controllers\Web\Custom\HelloTechno\CustomersController::class); | RouteHelper::get('/custom/hello-techno/customers', App\Http\Controllers\Web\Custom\HelloTechno\CustomersController::class); | ||||
| RouteHelper::get('/custom/hello-techno/parkings', App\Http\Controllers\Web\Custom\HelloTechno\ParkingsController::class); | RouteHelper::get('/custom/hello-techno/parkings', App\Http\Controllers\Web\Custom\HelloTechno\ParkingsController::class); | ||||
| RouteHelper::get('/custom/hello-techno/parking/by-code', App\Http\Controllers\Web\Custom\HelloTechno\ParkingByCodeController::class); | |||||
| RouteHelper::get('/custom/hello-techno/adjust-data', App\Http\Controllers\Web\Custom\HelloTechno\AdjustDataController::class); | RouteHelper::get('/custom/hello-techno/adjust-data', App\Http\Controllers\Web\Custom\HelloTechno\AdjustDataController::class); | ||||
| // RouteHelper::get('/custom/hello-techno/adjust-data', App\Http\Controllers\Web\Custom\HelloTechno\CustomersController::class); | // RouteHelper::get('/custom/hello-techno/adjust-data', App\Http\Controllers\Web\Custom\HelloTechno\CustomersController::class); | ||||
| RouteHelper::get('/custom/hello-techno/receipt-issuing-orders', App\Http\Controllers\Web\Custom\HelloTechno\ReceiptIssuingOrdersController::class); | RouteHelper::get('/custom/hello-techno/receipt-issuing-orders', App\Http\Controllers\Web\Custom\HelloTechno\ReceiptIssuingOrdersController::class); | ||||