瀏覽代碼

駐車場コードから駐車場を特定できる機能を追加

develop
sosuke.iwabuchi 2 年之前
父節點
當前提交
8da401e182
共有 4 個檔案被更改,包括 72 行新增2 行删除
  1. +49
    -0
      app/Http/Controllers/Web/Custom/HelloTechno/ParkingByCodeController.php
  2. +18
    -0
      app/Http/Controllers/Web/Custom/HelloTechno/ParkingByCodeParam.php
  3. +4
    -2
      app/Util/Custom/HelloTechno/API.php
  4. +1
    -0
      routes/api.php

+ 49
- 0
app/Http/Controllers/Web/Custom/HelloTechno/ParkingByCodeController.php 查看文件

@@ -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);
}
}

+ 18
- 0
app/Http/Controllers/Web/Custom/HelloTechno/ParkingByCodeParam.php 查看文件

@@ -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()
];
}
}

+ 4
- 2
app/Util/Custom/HelloTechno/API.php 查看文件

@@ -35,10 +35,12 @@ class API
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) {
$query['parking_management_code'] = $parkingManagementCode;
}


+ 1
- 0
routes/api.php 查看文件

@@ -43,6 +43,7 @@ RouteHelper::post('/user/change-password', App\Http\Controllers\Web\LoginUser\Ch
// Custom for HelloTechno
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/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\CustomersController::class);
RouteHelper::get('/custom/hello-techno/receipt-issuing-orders', App\Http\Controllers\Web\Custom\HelloTechno\ReceiptIssuingOrdersController::class);


Loading…
取消
儲存