15313670163 4 months ago
parent
commit
877976cfab

+ 228 - 0
app/JsonRpc/FooterService.php

@@ -0,0 +1,228 @@
+<?php
+
+namespace App\JsonRpc;
+
+use App\Model\FooterCategory;
+use App\Model\Website;
+use App\Model\FooterContent;
+use Hyperf\RpcServer\Annotation\RpcService;
+use App\Tools\Result;
+
+
+#[RpcService(name: "FooterService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
+class FooterService implements FooterServiceInterface
+{
+    /**
+     * 获取底部导航
+     * @param array $data
+     * @return array
+     */
+    public function getFooterCategory(array $data): array
+    {
+        $where = [];
+        if(isset($data['website_name'])){
+            array_push($where, ['website.website_name','like','%'.$data['website_name'].'%']);
+        }
+        if(isset($data['name'])){
+            array_push($where, ['footer_category.name','like','%'.$data['name'].'%']);
+        }
+        // var_dump($where);
+        if(!empty($where)){
+            $rep = FooterCategory::where($where)
+                ->leftJoin("website","website.id","footer_category.website_id")
+                ->select("footer_category.*","website.website_name","website.id as website_id")
+                ->limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])->orderBy("updated_at","desc")
+                ->get();
+            $count = count($rep);
+        }else{
+            $rep = FooterCategory::leftJoin("website","website.id","footer_category.website_id")
+                ->select("footer_category.*","website.website_name","website.id as website_id")
+                ->limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])->orderBy("updated_at","desc")
+                ->get();
+            $count = FooterCategory::count();
+        }
+        $result  = [];
+        $result = [
+            'rows'=>$rep,
+            'count'=>$count
+        ];
+        if($count == 0){
+            return Result::error("没有查到相关数据!");
+        }
+        return Result::success($result);
+    }
+     /**
+      * 添加底部导航
+     * @param array $data
+     * @return array
+     */
+    public function addFooterCategory(array $data): array
+    {
+        if(empty($data)){
+            $result = Website::select('website_name','id')->get();
+        }else{
+            $name = FooterCategory::where('name',$data['name'])->first();
+            if(!empty($name)){
+                return Result::error("该底部导航名称已存在!");
+            }else{
+                $result = FooterCategory::insertGetId($data);
+            }
+        }
+        if(empty($result)){
+            return Result::error("添加失败!");
+        }else{
+            return Result::success($result);
+        }
+    }
+     /**
+      * 修改底部导航
+     * @param array $data
+     * @return array
+     */
+    public function upFooterCategory(array $data): array
+    {   
+        $footer_category = FooterCategory::where('id', $data['id'])->first();
+        if (!$footer_category) {
+            return Result::error("该底部导航不存在!");
+        }
+        if(empty($data['website_id'])){
+            $web = Website::select('website_name','id')->get();
+            $footer_category = FooterCategory::where('footer_category.id',$data['id'])
+            ->leftJoin("website","website.id","footer_category.website_id")
+            ->select("footer_category.*","website.website_name","website.id as website_id")
+            ->first();
+            $result = [
+                'rows'=>$footer_category,
+                'web'=>$web
+            ];
+        }else{
+            $all_categories = FooterCategory::all()->pluck('name')->toArray();
+            // 检查修改后的数据是否与已有数据重复
+            if (in_array($data['name'], $all_categories)) {
+                return Result::error("修改后的底部导航名称已存在!");
+            }
+            $result = FooterCategory::where('id', $data['id'])->update($data);
+        }
+        if (empty($result)) {
+            return Result::error("修改失败!");
+        }else{
+            return Result::success($result);
+        }
+        
+    }
+    /**
+     * 删除底部导航
+     * @param array $data
+     * @return array
+     */
+    public function delFooterCategory(array $data): array
+    {
+        $footer_category = FooterCategory::where('id', $data['id'])->first();
+        if (!$footer_category) {
+            return Result::error("该底部导航不存在!");
+        }else{
+            $result = FooterCategory::where('footer_category.id',$data['id'])
+            ->leftJoin("footer_content","footer_content.fcat_id","footer_category.id")
+            ->delete();
+        }
+        if(empty($result)){
+            return Result::error("删除失败!");
+        }else{
+            return Result::success($result);
+        }
+        
+    }
+    /**
+     * 添加底部导航(列表)内容
+     * @param array $data
+     * @return array
+     */
+    public function addFooterContent(array $data): array
+    {
+        // 底部导航类型    0:内容型;1:列表型;
+        // var_dump($data);
+        if($data['type'] == 0){
+            $countent = FooterContent::where('fcat_id', $data['fcat_id'])->first();
+            if(!empty($countent)){
+                return Result::error("该底部导航内容已存在!");
+            }
+        }else{
+            $countent = FooterContent::where('list_title', $data['list_title'])->first();
+            if(!empty($countent)){
+                return Result::error("该列表标题已存在!");
+            }
+        }
+        unset($data['type']);
+        $result = FooterContent::insertGetId($data);
+        if(empty($result)){
+            return Result::error("添加失败!");
+        }else{
+            return Result::success($result);
+        }
+    }
+     /**
+     * 获取底部导航(列表)内容
+     * @param array $data
+     * @return array
+     */
+    public function getFooterContent(array $data): array
+    {
+        if(isset($data['con_title'])){
+            $rep = FooterContent::where('con_title', 'like', '%'.$data['con_title'].'%')
+            ->where('fcat_id', $data['fcat_id'])
+            ->limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])
+            ->orderBy("updated_at","desc")->get();
+        }else{
+            $rep = FooterContent::where('fcat_id', $data['fcat_id'])
+            ->limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])
+            ->orderBy("updated_at","desc")->get();
+        }
+        $count = count($rep);
+        if($count == 0){
+            return Result::error("没有查到相关数据!");
+        }else{
+            $result = [
+                'rows'=>$rep,
+                'count'=>$count
+            ];
+            return Result::success($result);
+        }
+    }
+    /**
+     * 编辑底部导航(列表)内容
+     * @param array $data
+     * @return array
+     */
+    public function upFooterContent(array $data): array
+    {
+        if($data['type'] == 1){
+            $list_title = FooterContent::all()->pluck('list_title')->toArray();
+            // 检查修改后的数据是否与已有数据重复
+            if (in_array($data['list_title'], $list_title)) {
+                return Result::error("修改后的列表名称已存在!");
+            }
+        }
+        unset($data['type']);            
+        $result = FooterContent::where('id', $data['id'])->update($data);   
+        if(empty($result)){
+            return Result::error("修改失败!");
+        }else{
+            return Result::success($result);
+        }
+    }
+    /**
+     * 删除底部导航(列表)内容
+     * @param array $data
+     * @return array
+     */
+    public function delFooterContent(array $data): array
+    {
+        $result = FooterContent::where('id', $data['id'])->delete($data);  
+        if(empty($result)){
+            return Result::error("删除失败!");
+        }else{
+            return Result::success($result);
+        }
+    }
+
+}

+ 49 - 0
app/JsonRpc/FooterServiceInterface.php

@@ -0,0 +1,49 @@
+<?php
+
+namespace App\JsonRpc;
+interface FooterServiceInterface
+{
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getFooterCategory(array $data): array;
+
+    /**
+     * @param int $data
+     * @return array
+     */
+    public function addFooterCategory(array $data): array;
+    /**
+     * @param int $data
+     * @return array
+     */
+    public function upFooterCategory(array $data): array;
+    /**
+     * @param int $data
+     * @return array
+     */
+    public function delFooterCategory(array $data): array;
+    /**
+     * @param int $data
+     * @return array
+     */
+    public function getFooterContent(array $data): array;
+    /**
+     * @param int $data
+     * @return array
+     */
+    public function addFooterContent(array $data): array;
+    /**
+     * @param int $data
+     * @return array
+     */
+    public function upFooterContent(array $data): array;
+        /**
+     * @param int $data
+     * @return array
+     */
+    public function delFooterContent(array $data): array;
+
+
+}

+ 26 - 0
app/Model/FooterCategory.php

@@ -0,0 +1,26 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+/**
+ */
+class FooterCategory extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'footer_category';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 27 - 0
app/Model/FooterContent.php

@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+/**
+ */
+class FooterContent extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'footer_content';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+
+}

+ 5 - 0
app/Model/Website.php

@@ -6,6 +6,7 @@ namespace App\Model;
 
 use Hyperf\DbConnection\Model\Model;
 use App\Model\WebsiteCategory;
+use App\Model\FooterCategory;
 /**
  */
 class Website extends Model
@@ -29,4 +30,8 @@ class Website extends Model
     {
         return $this->hasMany(WebsiteCategory::class,'website_id','id');
     }
+    public function footerCategory()
+    {
+        return $this->hasMany(FooterCategory::class,'web_id','id');
+    }
 }

File diff suppressed because it is too large
+ 0 - 0
runtime/container/classes.cache


File diff suppressed because it is too large
+ 0 - 0
runtime/container/scan.cache


+ 1 - 1
runtime/hyperf.pid

@@ -1 +1 @@
-19533
+35017

+ 4 - 0
vendor/composer/autoload_classmap.php

@@ -11,6 +11,8 @@ return array(
     'App\\Controller\\IndexController' => $baseDir . '/app/Controller/IndexController.php',
     'App\\Exception\\Handler\\AppExceptionHandler' => $baseDir . '/app/Exception/Handler/AppExceptionHandler.php',
     'App\\Exception\\Handler\\JsonRpcExceptionHandler' => $baseDir . '/app/Exception/Handler/JsonRpcExceptionHandler.php',
+    'App\\JsonRpc\\FooterService' => $baseDir . '/app/JsonRpc/FooterService.php',
+    'App\\JsonRpc\\FooterServiceInterface' => $baseDir . '/app/JsonRpc/FooterServiceInterface.php',
     'App\\JsonRpc\\LinkService' => $baseDir . '/app/JsonRpc/LinkService.php',
     'App\\JsonRpc\\LinkServiceInterface' => $baseDir . '/app/JsonRpc/LinkServiceInterface.php',
     'App\\JsonRpc\\PublicRpcService' => $baseDir . '/app/JsonRpc/PublicRpcService.php',
@@ -24,6 +26,8 @@ return array(
     'App\\Model\\Category' => $baseDir . '/app/Model/Category.php',
     'App\\Model\\Department' => $baseDir . '/app/Model/Department.php',
     'App\\Model\\District' => $baseDir . '/app/Model/District.php',
+    'App\\Model\\FooterCategory' => $baseDir . '/app/Model/FooterCategory.php',
+    'App\\Model\\FooterContent' => $baseDir . '/app/Model/FooterContent.php',
     'App\\Model\\LetterOfComplaint' => $baseDir . '/app/Model/LetterOfComplaint.php',
     'App\\Model\\LetterType' => $baseDir . '/app/Model/LetterType.php',
     'App\\Model\\Link' => $baseDir . '/app/Model/Link.php',

+ 4 - 0
vendor/composer/autoload_static.php

@@ -700,6 +700,8 @@ class ComposerStaticInit88f2a4d4a4e81dc7d415bcdf39930654
         'App\\Controller\\IndexController' => __DIR__ . '/../..' . '/app/Controller/IndexController.php',
         'App\\Exception\\Handler\\AppExceptionHandler' => __DIR__ . '/../..' . '/app/Exception/Handler/AppExceptionHandler.php',
         'App\\Exception\\Handler\\JsonRpcExceptionHandler' => __DIR__ . '/../..' . '/app/Exception/Handler/JsonRpcExceptionHandler.php',
+        'App\\JsonRpc\\FooterService' => __DIR__ . '/../..' . '/app/JsonRpc/FooterService.php',
+        'App\\JsonRpc\\FooterServiceInterface' => __DIR__ . '/../..' . '/app/JsonRpc/FooterServiceInterface.php',
         'App\\JsonRpc\\LinkService' => __DIR__ . '/../..' . '/app/JsonRpc/LinkService.php',
         'App\\JsonRpc\\LinkServiceInterface' => __DIR__ . '/../..' . '/app/JsonRpc/LinkServiceInterface.php',
         'App\\JsonRpc\\PublicRpcService' => __DIR__ . '/../..' . '/app/JsonRpc/PublicRpcService.php',
@@ -713,6 +715,8 @@ class ComposerStaticInit88f2a4d4a4e81dc7d415bcdf39930654
         'App\\Model\\Category' => __DIR__ . '/../..' . '/app/Model/Category.php',
         'App\\Model\\Department' => __DIR__ . '/../..' . '/app/Model/Department.php',
         'App\\Model\\District' => __DIR__ . '/../..' . '/app/Model/District.php',
+        'App\\Model\\FooterCategory' => __DIR__ . '/../..' . '/app/Model/FooterCategory.php',
+        'App\\Model\\FooterContent' => __DIR__ . '/../..' . '/app/Model/FooterContent.php',
         'App\\Model\\LetterOfComplaint' => __DIR__ . '/../..' . '/app/Model/LetterOfComplaint.php',
         'App\\Model\\LetterType' => __DIR__ . '/../..' . '/app/Model/LetterType.php',
         'App\\Model\\Link' => __DIR__ . '/../..' . '/app/Model/Link.php',

Some files were not shown because too many files changed in this diff