Zory 2 недель назад
Родитель
Сommit
c930746b25

+ 51 - 0
app/controller/admin/Pages.php

@@ -0,0 +1,51 @@
+<?php
+
+namespace app\controller\admin;
+
+use app\extra\basic\Base;
+use app\middleware\AuthMiddleware;
+use app\model\cpa\CpaPage;
+use app\service\cpa\PageService;
+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/pages"),Middleware(AuthMiddleware::class)]
+class Pages extends Base
+{
+
+    #[Inject]
+    protected PageService $service;
+
+    #[Inject]
+    protected CpaPage $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());
+        }
+    }
+}

+ 55 - 0
app/controller/admin/Product.php

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

+ 35 - 0
app/service/cpa/PageService.php

@@ -0,0 +1,35 @@
+<?php
+
+namespace app\service\cpa;
+
+use app\extra\basic\Service;
+use app\model\cpa\CpaPage;
+
+class PageService extends Service
+{
+
+    /**
+     *
+     * @return $this
+     */
+    public function setModel(): static
+    {
+        $this->mode = (new CpaPage);
+        return $this;
+    }
+
+    /**
+     *
+     * @param array $param
+     * @return array
+     */
+    public function searchFilter(array $param = []): array
+    {
+        $filter = [];
+        !empty($param['status']) && $filter[] = ["status", '=', $param['status']];
+        !empty($param['code']) && $filter[] = ["link_code", 'like', "%{$param['code']}%"];
+        !empty($param['name']) && $filter[] = ["title", 'like', "%{$param['name']}%"];
+        return $filter;
+    }
+
+}

+ 35 - 0
app/service/cpa/ProductService.php

@@ -0,0 +1,35 @@
+<?php
+
+namespace app\service\cpa;
+
+use app\extra\basic\Service;
+use app\model\cpa\CpaProduct;
+
+class ProductService extends Service
+{
+
+    /**
+     *
+     * @return $this
+     */
+    public function setModel(): static
+    {
+        $this->mode = (new CpaProduct);
+        return $this;
+    }
+
+    /**
+     *
+     * @param array $param
+     * @return array
+     */
+    public function searchFilter(array $param = []): array
+    {
+        $filter = [];
+        !empty($param['status']) && $filter[] = ["status", '=', $param['status']];
+        !empty($param['code']) && $filter[] = ["code", '=', $param['code']];
+        !empty($param['name']) && $filter[] = ["poi_name", 'like', "%{$param['name']}%"];
+        return $filter;
+    }
+
+}

+ 1 - 1
app/service/system/UserService.php

@@ -12,7 +12,7 @@ class UserService extends Service
      *
      * @return $this
      */
-    public function setModel()
+    public function setModel(): static
     {
         $this->mode = (new SystemUser);
         return $this;

+ 10 - 0
app/view/index.html

@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Title</title>
+</head>
+<body>
+
+</body>
+</html>

+ 0 - 14
app/view/index/view.html

@@ -1,14 +0,0 @@
-<!doctype html>
-<html>
-<head>
-    <meta charset="utf-8">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge">
-    <meta name="viewport" content="width=device-width, initial-scale=1">
-    <link rel="shortcut icon" href="/favicon.ico"/>
-    <title>webman</title>
-
-</head>
-<body>
-hello <?=htmlspecialchars($name)?>
-</body>
-</html>