182 lines
4.3 KiB
PHP
182 lines
4.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Controller\Admin;
|
|
|
|
use App\Middleware\Admin\JwtAuthMiddleware;
|
|
use App\Request\Admin\categoryRequest;
|
|
use App\Request\Admin\GoodRequest;
|
|
use App\Service\Admin\Good\CategoryService;
|
|
use App\Service\Admin\Good\CycleService;
|
|
use App\Service\Admin\Good\SkuService;
|
|
use App\Service\Admin\Good\SpuService;
|
|
use Exception;
|
|
use Hyperf\HttpServer\Annotation\Controller;
|
|
use Hyperf\HttpServer\Annotation\Middlewares;
|
|
use Hyperf\HttpServer\Annotation\RequestMapping;
|
|
use Hyperf\Validation\Annotation\Scene;
|
|
|
|
#[Controller(prefix: "admin/good")]
|
|
#[Middlewares([
|
|
JwtAuthMiddleware::class,
|
|
])]
|
|
class GoodController
|
|
{
|
|
/**
|
|
* spu添加
|
|
* @param GoodRequest $request
|
|
* @return array
|
|
*/
|
|
#[RequestMapping(path: "add_spu", methods: "POST")]
|
|
#[Scene(scene: "add_spu")]
|
|
public function addSpu(GoodRequest $request): array
|
|
{
|
|
return (new SpuService)->add();
|
|
}
|
|
|
|
/**
|
|
* spu修改
|
|
* @param GoodRequest $request
|
|
* @return array
|
|
*/
|
|
#[RequestMapping(path: "edit_spu", methods: "POST")]
|
|
#[Scene(scene: "edit_spu")]
|
|
public function editSpu(GoodRequest $request): array
|
|
{
|
|
return (new SpuService)->edit();
|
|
}
|
|
|
|
/**
|
|
* spu删除
|
|
* @param GoodRequest $request
|
|
* @return array
|
|
* @throws Exception
|
|
*/
|
|
#[RequestMapping(path: "del_spu", methods: "GET")]
|
|
#[Scene(scene: "del_spu")]
|
|
public function delSpu(GoodRequest $request): array
|
|
{
|
|
return (new SpuService)->del();
|
|
}
|
|
|
|
/**
|
|
* spu详情
|
|
* @param GoodRequest $request
|
|
* @return array
|
|
*/
|
|
#[RequestMapping(path: "spu", methods: "GET")]
|
|
#[Scene(scene: "spu")]
|
|
public function spu(GoodRequest $request): array
|
|
{
|
|
return (new SpuService)->view();
|
|
}
|
|
|
|
/**
|
|
* spu列表
|
|
* @param GoodRequest $request
|
|
* @return array
|
|
*/
|
|
#[RequestMapping(path: "list_spu", methods: "GET")]
|
|
#[Scene(scene: "list_spu")]
|
|
public function spuList(GoodRequest $request): array
|
|
{
|
|
return (new SpuService)->handle();
|
|
}
|
|
|
|
/**
|
|
* sku 添加
|
|
* @param GoodRequest $request
|
|
* @return array
|
|
*/
|
|
#[RequestMapping(path: "add_sku", methods: "POST")]
|
|
#[Scene(scene: "add_sku")]
|
|
public function addSku(GoodRequest $request)
|
|
{
|
|
return (new SkuService)->add();
|
|
}
|
|
|
|
/**
|
|
* sku 修改
|
|
* @param GoodRequest $request
|
|
* @return array
|
|
*/
|
|
#[RequestMapping(path: "edit_sku", methods: "POST")]
|
|
#[Scene(scene: "edit_sku")]
|
|
public function editSku(GoodRequest $request): array
|
|
{
|
|
return (new SkuService)->edit();
|
|
}
|
|
|
|
/**
|
|
* sku 删除
|
|
* @param GoodRequest $request
|
|
* @return array
|
|
*/
|
|
#[RequestMapping(path: "del_sku", methods: "GET")]
|
|
#[Scene(scene: "del_sku")]
|
|
public function delSku(GoodRequest $request): array
|
|
{
|
|
return (new SkuService)->del();
|
|
}
|
|
|
|
/**
|
|
* sku 详情
|
|
* @param GoodRequest $request
|
|
* @return array
|
|
*/
|
|
#[RequestMapping(path: "sku", methods: "GET")]
|
|
#[Scene(scene: "sku")]
|
|
public function sku(GoodRequest $request): array
|
|
{
|
|
return (new SkuService)->view();
|
|
}
|
|
|
|
/**
|
|
* sku 列表
|
|
* @param GoodRequest $request
|
|
* @return array
|
|
*/
|
|
#[RequestMapping(path: "list_sku", methods: "GET")]
|
|
#[Scene(scene: "list_sku")]
|
|
public function skuList(GoodRequest $request): array
|
|
{
|
|
return (new SkuService)->handle();
|
|
}
|
|
|
|
/**
|
|
* cycle 列表
|
|
* @return array
|
|
*/
|
|
#[RequestMapping(path: "list_cycle", methods: "GET")]
|
|
public function cycleList(): array
|
|
{
|
|
return (new CycleService)->handle();
|
|
}
|
|
|
|
/**
|
|
* category 列表
|
|
* @param categoryRequest $request
|
|
* @return array
|
|
*/
|
|
#[RequestMapping(path: "list_category", methods: "GET")]
|
|
#[Scene(scene: "list_category")]
|
|
public function categoryList(categoryRequest $request): array
|
|
{
|
|
return (new CategoryService)->handle();
|
|
}
|
|
|
|
/**
|
|
* category 添加
|
|
* @param categoryRequest $request
|
|
* @return array
|
|
* @throws Exception
|
|
*/
|
|
#[RequestMapping(path: "add_category", methods: "POST")]
|
|
#[Scene(scene: "add_category")]
|
|
public function categoryAdd(categoryRequest $request)
|
|
{
|
|
return (new CategoryService)->add();
|
|
}
|
|
}
|