Explorar o código

'2149009332-001'

zory hai 5 días
pai
achega
c80d3432d3

+ 60 - 0
app/controller/service/Quick.php

@@ -0,0 +1,60 @@
+<?php
+
+namespace app\controller\service;
+
+use app\extra\basic\Base;
+use app\middleware\AuthMiddleware;
+use app\model\saas\SaasQuick;
+use app\service\saas\QuickService;
+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/service/quick"),Middleware(AuthMiddleware::class)]
+class Quick extends Base
+{
+
+    #[Inject]
+    protected QuickService $service;
+
+    #[Inject]
+    protected SaasQuick $model;
+
+    #[GetMapping('list')]
+    public function getQuickList(Request $request): Response
+    {
+        try {
+            $param = $request->all();
+            $param['service_id'] = $request->user['id'];
+            $data = $this->service->setModel()->getList($param);
+            return successTrans(100010,pageFormat($data),200);
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+    #[PostMapping("save")]
+    public function setQuickData(Request $request): Response
+    {
+        try {
+            $param = $this->_valid([
+                "content.require"   => trans("empty.require")
+            ],$request->method());
+            if (!is_array($param)) return error($param);
+            $state = $this->model->insertGetId([
+                "service_id"    => $request->user['id'],
+                "content"       => $param['content']
+            ]);
+            if (!$state) return errorTrans("error.data");
+            return successTrans("success.data");
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+}

+ 46 - 0
app/model/saas/SaasQuick.php

@@ -0,0 +1,46 @@
+<?php
+
+namespace app\model\saas;
+
+use app\extra\basic\Model;
+
+
+/**
+ * @property integer $id (主键)
+ * @property integer $service_id 
+ * @property string $content 
+ * @property integer $type 1个人2团队
+ * @property mixed $create_at
+ */
+class SaasQuick extends Model
+{
+    /**
+     * The connection name for the model.
+     *
+     * @var string|null
+     */
+    protected $connection = 'mysql';
+    
+    /**
+     * The table associated with the model.
+     *
+     * @var string
+     */
+    protected string $table = "saas_quick";
+    
+    /**
+     * The primary key associated with the table.
+     *
+     * @var string
+     */
+    protected string $primaryKey = "id";
+    
+    /**
+     * Indicates if the model should be timestamped.
+     *
+     * @var bool
+     */
+    public bool $timestamps = false;
+
+
+}

+ 37 - 0
app/service/saas/QuickService.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace app\service\saas;
+
+use app\extra\basic\Service;
+use app\model\saas\SaasQuick;
+
+class QuickService extends Service
+{
+
+
+    /**
+     *
+     * @return $this
+     */
+    public function setModel()
+    {
+        $this->mode = (new SaasQuick);
+        return $this;
+    }
+
+
+    /**
+     *
+     * @param array $param
+     * @return array
+     */
+    public function searchFilter(array $param = []): array
+    {
+        $filter = [];
+        !empty($param['status']) && $filter[] = ["status", '=', $param['status']];
+        !empty($param['service_id']) && $filter[] = ["service_id", '=', $param['service_id']];
+        !empty($param['content']) && $filter[] = ["content", 'like', "%{$param['content']}%"];
+        return $filter;
+    }
+
+}