|
|
@@ -0,0 +1,55 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\controller\admin;
|
|
|
+
|
|
|
+use app\extra\basic\Base;
|
|
|
+use app\extra\tools\CodeExtend;
|
|
|
+use app\middleware\AuthMiddleware;
|
|
|
+use app\model\cpa\CpaProduct;
|
|
|
+use app\service\cpa\ProductService;
|
|
|
+use DI\Attribute\Inject;
|
|
|
+use LinFly\Annotation\Attributes\Route\Controller;
|
|
|
+use LinFly\Annotation\Attributes\Route\GetMapping;
|
|
|
+use LinFly\Annotation\Attributes\Route\Middleware;
|
|
|
+use LinFly\Annotation\Attributes\Route\PostMapping;
|
|
|
+use support\Request;
|
|
|
+use support\Response;
|
|
|
+
|
|
|
+
|
|
|
+#[Controller("/api/product"),Middleware(AuthMiddleware::class)]
|
|
|
+class Product extends Base
|
|
|
+{
|
|
|
+
|
|
|
+
|
|
|
+ #[Inject]
|
|
|
+ protected ProductService $service;
|
|
|
+
|
|
|
+ #[Inject]
|
|
|
+ protected CpaProduct $model;
|
|
|
+
|
|
|
+ #[GetMapping('list')]
|
|
|
+ public function getDataList(Request $request): Response
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $param = $request->all();
|
|
|
+ $data = $this->service->setModel()->getList($param);
|
|
|
+ return successTrans("success.data",pageFormat($data),200);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ return error($th->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ #[PostMapping("save")]
|
|
|
+ public function setDepositData(Request $request): Response
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $param = $request->post();
|
|
|
+ $state = $this->model->setAutoData($param);
|
|
|
+ if (!$state) return errorTrans("error.data");
|
|
|
+ return successTrans("success.data");
|
|
|
+ } catch (\Throwable $throwable) {
|
|
|
+ return error($throwable->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|