zory 2 ماه پیش
والد
کامیت
c1551fbb01

+ 121 - 0
app/controller/admin/Article.php

@@ -0,0 +1,121 @@
+<?php
+
+namespace app\controller\admin;
+
+use app\extra\basic\Base;
+use app\extra\service\blue\ArticleService;
+use app\middleware\AuthMiddleware;
+use app\model\blue\BlueArticle;
+use DI\Attribute\Inject;
+use LinFly\Annotation\Route\Controller;
+use LinFly\Annotation\Route\Middleware;
+use LinFly\Annotation\Route\Route;
+use support\Request;
+use support\Response;
+
+
+#[Controller(prefix: "/api/article"),Middleware(AuthMiddleware::class)]
+class Article extends Base
+{
+
+    #[Inject]
+    protected BlueArticle $model;
+
+    #[Inject]
+    protected ArticleService $service;
+
+
+    #[Route(path: "list",methods: "get")]
+    public function getDataList(Request $request): Response
+    {
+        try {
+            $param = $request->all();
+            $list = $this->service->getList($param);
+            return successTrans("success.data",pageFormat($list),200);
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+
+    /**
+     * 编辑信息
+     * @param Request $request
+     * @return Response
+     */
+    #[Route(path: "save",methods: "post")]
+    public function setListData(Request $request): Response
+    {
+        try {
+            $param = $request->post();
+            if (isset($param['id'])) {
+                $factory = $this->model->where("id",$param['id'])->findOrEmpty();
+                if ($factory->isEmpty()) return errorTrans("error.data");
+            }
+            if (isset($param['category_path'])) {
+                $pathNum = count($param['category_path']);
+                $param['category'] = $param['category_path'][($pathNum-1)];
+                $param['category_path'] = json_encode($param['category_path']);
+            }
+            $param['attribute'] = empty($param['attribute']) ? [] : json_encode($param['attribute']);
+            $state = $this->model->setAutoData($param);
+            if (!$state) return errorTrans("error.data");
+            return successTrans("success.data");
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+    /**
+     * 批量操作
+     * @param Request $request
+     * @return Response
+     */
+    #[Route(path: "batch",methods: "post")]
+    public function setGoodsBatch(Request $request): Response
+    {
+        try {
+            $param = $this->_valid([
+                "id.require"        => "参数错误",
+                "value.require"     => "参数错误",
+                "field.require"     => "参数错误",
+                "type.require"      => "参数错误"
+            ],"post");
+            if (!is_array($param)) return error($param);
+            if ($param['type'] == "batch") {
+                $state = $this->model->where("id","in",$param['id'])->save([$param['field'] => $param['value']]);
+            } else {
+                $state = $this->model->where("id",$param['id'])->save([$param['field'] => $param['value']]);
+            }
+            if (!$state) return errorTrans("error.data");
+            return successTrans("success.data");
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+
+    /**
+     * 删除
+     * @param Request $request
+     * @return Response
+     */
+    #[Route(path: "del",methods: "post")]
+    public function delData(Request $request): Response
+    {
+        try {
+            $param = $this->_valid([
+                "id.require"        => "参数错误",
+            ],"post");
+            if (!is_array($param)) return error($param);
+            $data = $this->model->where("id",$param['id'])->findOrEmpty();
+            if ($data->isEmpty()) return errorTrans("empty.data");
+            $state = $data->delete();
+            if (!$state) return errorTrans("error.data");
+            return successTrans("success.data");
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+}

+ 115 - 0
app/controller/admin/Category.php

@@ -0,0 +1,115 @@
+<?php
+
+namespace app\controller\admin;
+
+use app\extra\basic\Base;
+use app\extra\service\blue\CategoryService;
+use app\extra\tools\DataExtend;
+use app\middleware\AuthMiddleware;
+use app\model\blue\BlueCategory;
+use DI\Attribute\Inject;
+use LinFly\Annotation\Route\Controller;
+use LinFly\Annotation\Route\Middleware;
+use LinFly\Annotation\Route\Route;
+use support\Request;
+use support\Response;
+
+#[Controller(prefix: "/api/category"),Middleware(AuthMiddleware::class)]
+class Category extends Base
+{
+
+    #[Inject]
+    protected BlueCategory $model;
+
+    #[Inject]
+    protected CategoryService $service;
+
+
+    #[Route(path: "list",methods: "get")]
+    public function getCategoryData(Request $request): Response
+    {
+        try {
+            $data = $this->service->getList($request->all());
+            $tree = DataExtend::arr2tree($data,"id","parent_id");
+            return successTrans(100010,$tree,200);
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+    /**
+     * 编辑信息
+     * @param Request $request
+     * @return Response
+     */
+    #[Route(path: "save",methods: "post")]
+    public function setListData(Request $request): Response
+    {
+        try {
+            $param = $request->post();
+            if (isset($param['id'])) {
+                $factory = $this->model->where("id",$param['id'])->findOrEmpty();
+                if ($factory->isEmpty()) return errorTrans("error.data");
+            }
+            $state = $this->model->setAutoData($param);
+            if (!$state) return errorTrans("error.data");
+            return successTrans("success.data");
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+    /**
+     * 批量操作
+     * @param Request $request
+     * @return Response
+     */
+    #[Route(path: "batch",methods: "post")]
+    public function setGoodsBatch(Request $request): Response
+    {
+        try {
+            $param = $this->_valid([
+                "id.require"        => "参数错误",
+                "value.require"     => "参数错误",
+                "field.require"     => "参数错误",
+                "type.require"      => "参数错误"
+            ],"post");
+            if (!is_array($param)) return error($param);
+            if ($param['type'] == "batch") {
+                $state = $this->model->where("id","in",$param['id'])->save([$param['field'] => $param['value']]);
+            } else {
+                $state = $this->model->where("id",$param['id'])->save([$param['field'] => $param['value']]);
+            }
+            if (!$state) return errorTrans("error.data");
+            return successTrans("success.data");
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+
+    /**
+     * 删除
+     * @param Request $request
+     * @return Response
+     */
+    #[Route(path: "del",methods: "post")]
+    public function delData(Request $request): Response
+    {
+        try {
+            $param = $this->_valid([
+                "id.require"        => "参数错误",
+            ],"post");
+            if (!is_array($param)) return error($param);
+            $data = $this->model->where("id",$param['id'])->findOrEmpty();
+            if ($data->isEmpty()) return errorTrans("empty.data");
+            $state = $data->delete();
+            if (!$state) return errorTrans("error.data");
+            return successTrans("success.data");
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+
+}

+ 47 - 0
app/controller/admin/Expert.php

@@ -0,0 +1,47 @@
+<?php
+
+namespace app\controller\admin;
+
+use app\extra\basic\Base;
+use app\extra\service\blue\ExpertService;
+use app\middleware\AuthMiddleware;
+use app\model\blue\BlueExpert;
+use DI\Attribute\Inject;
+use LinFly\Annotation\Route\Controller;
+use LinFly\Annotation\Route\Middleware;
+use LinFly\Annotation\Route\Route;
+use support\Request;
+use support\Response;
+
+/**
+ * 达人
+ */
+#[Controller(prefix: "/api/expert"),Middleware(AuthMiddleware::class)]
+class Expert extends Base
+{
+
+    #[Inject]
+    protected BlueExpert $model;
+
+    #[Inject]
+    protected ExpertService $service;
+
+    /**
+     *
+     * @param Request $request
+     * @return Response
+     */
+    #[Route(path: "list",methods: "get")]
+    public function getDataList(Request $request): Response
+    {
+        try {
+            $param = $request->all();
+            $list = $this->service->getList($param);
+            return successTrans("success.data",pageFormat($list),200);
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+    
+
+}

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

@@ -0,0 +1,70 @@
+<?php
+
+namespace app\controller\admin;
+
+use app\extra\basic\Base;
+use app\middleware\AuthMiddleware;
+use app\model\system\SystemConfig;
+use DI\Attribute\Inject;
+use LinFly\Annotation\Route\Controller;
+use LinFly\Annotation\Route\Middleware;
+use LinFly\Annotation\Route\Route;
+use support\Request;
+use support\Response;
+
+#[Controller(prefix: "/api/pages"),Middleware(AuthMiddleware::class)]
+class Pages extends Base
+{
+
+    #[Inject]
+    protected SystemConfig $model;
+
+    #[Route(path: "list",methods: "get")]
+    public function getPageList(): Response
+    {
+        try {
+            $data = $this->model->where("type","page")->field("type,desc,name")->select();
+            return success("pages",$data->toArray());
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+
+    #[Route(path: "detail",methods: "get")]
+    public function getPageDetail(): Response
+    {
+        try {
+            $param = $this->_valid([
+                "name.require"  => trans("empty.require")
+            ]);
+            if (!is_array($param)) return error($param);
+            $data = $this->model->where("type","page")->where("name",$param['name'])->findOrEmpty();
+            if ($data->isEmpty()) return errorTrans("empty.data");
+            return success("pages",$data->toArray());
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+
+    #[Route(path: "save",methods: "post")]
+    public function setPageData(Request $request): Response
+    {
+        try {
+            $param = $request->post();
+            $param['type'] = "page";
+            $data = $this->model->where("type","page")->where("name",$param['name'])->findOrEmpty();
+            if (!isset($param['id'])) {
+                if (!$data->isEmpty()) return errorTrans("empty.data");
+            }
+            print_r($param);
+            $state = $this->model->setAutoData($param);
+            if (!$state) return errorTrans("error.data");
+            return successTrans("success.data");
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+}

+ 4 - 3
app/controller/api/Page.php

@@ -18,7 +18,8 @@ class Page extends Base
     public function getAbout(Request $request)
     {
         try {
-
+            $data = sConf("page.about");
+            return json_encode(['code' => 1,'data' => $data],JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
         } catch (\Throwable $throwable) {
             return error($throwable->getMessage());
         }
@@ -30,7 +31,7 @@ class Page extends Base
     public function getPrivacy(Request $request)
     {
         try {
-            $data = sConf("service.privacy");
+            $data = sConf("page.privacy");
             return json_encode(['code' => 1,'data' => $data],JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
         } catch (\Throwable $throwable) {
             return error($throwable->getMessage());
@@ -42,7 +43,7 @@ class Page extends Base
     public function getAgreements(Request $request)
     {
         try {
-            $data = sConf("service.agreements");
+            $data = sConf("page.agreements");
             return json_encode(['code' => 1,'data' => $data],JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
         } catch (\Throwable $throwable) {
             return error($throwable->getMessage());

+ 0 - 8
app/extra/basic/Service.php

@@ -13,14 +13,6 @@ class Service
      */
     protected $mode = null;
 
-
-    /**
-     * 白名单
-     * @var array|string[]
-     */
-    protected array $mobileWhite = ["18665619195","18665619196","18665619197","18665619198","18665619199","18665619191","18665619192","18665619193","18665619194"];
-
-
     /**
      * 短信配置
      * @param int $type 1 系统配置 2 代理配置

+ 44 - 0
app/extra/service/blue/ArticleService.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace app\extra\service\blue;
+
+use app\extra\basic\Service;
+use app\model\blue\BlueArticle;
+use app\model\blue\BlueCategory;
+
+class ArticleService extends Service
+{
+
+
+
+    /**
+     * 列表
+     * @param array $param
+     */
+    public function getList(array $param = [])
+    {
+        $this->mode = new BlueArticle();
+        return $this->searchVal($param,$this->searchFilter($param))->with(['categoryJoin' => function($query){
+            $query->field("id,name");
+        }])->paginate([
+            "list_rows" => $param['pageSize'],
+            "page"      => $param['page']
+        ]);
+    }
+
+
+    /**
+     *
+     * @param array $param
+     * @return array
+     */
+    public function searchFilter(array $param = []): array
+    {
+        $filter = [];
+        !empty($param['type']) && $filter[] = ["type", '=', $param['type']];
+        !empty($param['status']) && $filter[] = ["status", '=', $param['status']];
+        !empty($param['name']) && $filter[] = ["name", 'like', "%{$param['name']}%"];
+        return $filter;
+    }
+
+}

+ 37 - 0
app/extra/service/blue/CategoryService.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace app\extra\service\blue;
+
+use app\extra\basic\Service;
+use app\model\blue\BlueCategory;
+
+class CategoryService extends Service
+{
+
+
+    /**
+     * 列表
+     * @param array $param
+     */
+    public function getList(array $param = [])
+    {
+        $this->mode = new BlueCategory();
+        return $this->searchVal($param,$this->searchFilter($param))->select()->toArray();
+    }
+
+
+    /**
+     *
+     * @param array $param
+     * @return array
+     */
+    public function searchFilter(array $param = []): array
+    {
+        $filter = [];
+        !empty($param['type']) && $filter[] = ["type", '=', $param['type']];
+        !empty($param['status']) && $filter[] = ["status", '=', $param['status']];
+        !empty($param['name']) && $filter[] = ["name", 'like', "%{$param['name']}%"];
+        return $filter;
+    }
+
+}

+ 41 - 0
app/extra/service/blue/ExpertService.php

@@ -0,0 +1,41 @@
+<?php
+
+namespace app\extra\service\blue;
+
+use app\extra\basic\Service;
+use app\model\blue\BlueExpert;
+
+class ExpertService extends Service
+{
+
+
+    /**
+     * 列表
+     * @param array $param
+     */
+    public function getList(array $param = [])
+    {
+        $this->mode = new BlueExpert();
+        return $this->searchVal($param,$this->searchFilter($param))->paginate([
+            "list_rows" => $param['pageSize'],
+            "page"      => $param['page']
+        ]);
+    }
+
+
+    /**
+     *
+     * @param array $param
+     * @return array
+     */
+    public function searchFilter(array $param = []): array
+    {
+        $filter = [];
+        !empty($param['type']) && $filter[] = ["type", '=', $param['type']];
+        !empty($param['status']) && $filter[] = ["status", '=', $param['status']];
+        !empty($param['name']) && $filter[] = ["name", 'like', "%{$param['name']}%"];
+        return $filter;
+    }
+
+
+}

+ 6 - 0
app/model/blue/BlueArticle.php

@@ -3,6 +3,7 @@
 namespace app\model\blue;
 
 use app\extra\basic\Model;
+use think\model\relation\HasOne;
 
 
 /**
@@ -39,4 +40,9 @@ class BlueArticle extends Model
     public bool $timestamps = false;
 
 
+    public function categoryJoin(): HasOne
+    {
+        return $this->hasOne(BlueCategory::class,"id","category");
+    }
+
 }

+ 57 - 0
app/model/blue/BlueExpert.php

@@ -0,0 +1,57 @@
+<?php
+
+namespace app\model\blue;
+
+use app\extra\basic\Model;
+use think\model\relation\HasOne;
+
+
+/**
+ * @property integer $id (主键)
+ * @property mixed $openid 
+ * @property string $truenname 
+ * @property string $mobile 
+ * @property string $idcard 
+ * @property string $city 
+ * @property mixed $city_path 
+ * @property integer $sex 1男2女
+ * @property integer $married 1已婚2未
+ * @property integer $child 1有2无
+ * @property mixed $create_at 创建时间
+ */
+class BlueExpert 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 = "blue_expert";
+    
+    /**
+     * 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;
+
+    public function open(): HasOne
+    {
+        return $this->hasOne(BlueUserOpen::class,"openid","openid");
+    }
+
+}

+ 49 - 0
app/model/blue/BlueExpertGroup.php

@@ -0,0 +1,49 @@
+<?php
+
+namespace app\model\blue;
+
+use app\extra\basic\Model;
+
+
+/**
+ * @property integer $id (主键)
+ * @property mixed $openid 
+ * @property string $truename 
+ * @property string $mobile 
+ * @property string $city 
+ * @property mixed $city_path 
+ * @property string $team 
+ * @property mixed $create_at 创建时间
+ */
+class BlueExpertGroup 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 = "blue_expert_group";
+    
+    /**
+     * 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;
+
+
+}