Sfoglia il codice sorgente

refactor: 统一代码风格

runphp 2 settimane fa
parent
commit
a17b97ca21

+ 2 - 1
database/migrations/20250712022607_extension_eav_value.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 use Phinx\Migration\AbstractMigration;
@@ -39,7 +40,7 @@ class ExtensionEavValue extends AbstractMigration
             ->addColumn('value_text', 'text', ['comment' => '文本值'])
             ->addColumn('value_datetime', 'datetime', ['comment' => '日期时间值'])
             ->addIndex(['entity_id', 'attribute_id'], ['name' => 'entity_id_attribute_id'])
-            ->addIndex(['entity_id', 'entity_type_id'],['name' => 'idx_entity_id_entity_type_id'])
+            ->addIndex(['entity_id', 'entity_type_id'], ['name' => 'idx_entity_id_entity_type_id'])
             ->addTimestamps('create_time', 'update_time')
             ->addColumn('delete_time', 'timestamp', ['null' => true, 'comment' => '删除时间'])
             ->create();

+ 1 - 0
database/migrations/20250712025652_extension_eav_attribute_option.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 use Phinx\Migration\AbstractMigration;

+ 1 - 0
info.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 return [

+ 2 - 1
route/admin.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 use SixShop\Eav\Controller\{AttributeOptionController,
@@ -18,4 +19,4 @@ Route::resource('attribute_option', AttributeOptionController::class)->middlewar
 ]);
 Route::resource('value', ValueController::class)->middleware([
     'auth'
-]);
+]);

+ 3 - 3
route/api.php

@@ -1,12 +1,12 @@
 <?php
-declare(strict_types= 1);
+
+declare(strict_types=1);
 
 use SixShop\Eav\Controller\AttributeOptionController;
 use SixShop\Eav\Controller\EntityAttributeController;
 use SixShop\Eav\Controller\ValueController;
 use think\facade\Route;
 
-
 Route::get('entity_attribute', [EntityAttributeController::class, 'index']);
 Route::get('attribute_option', [AttributeOptionController::class, 'index']);
-Route::get('value', [ValueController::class, 'index']);
+Route::get('value', [ValueController::class, 'index']);

+ 4 - 4
src/Controller/AttributeOptionController.php

@@ -1,13 +1,13 @@
 <?php
+
 declare(strict_types=1);
-namespace SixShop\Eav\Controller;
 
+namespace SixShop\Eav\Controller;
 
 use SixShop\Core\Request;
 use SixShop\Eav\Entity\EavAttributeOptionEntity;
 use think\Response;
 
-
 use function SixShop\Core\success_response;
 
 class AttributeOptionController
@@ -15,7 +15,7 @@ class AttributeOptionController
     public function index(Request $request, EavAttributeOptionEntity $entity): Response
     {
         $attributeId = $request->get('attribute_id/d');
-        return success_response($entity->where(['attribute_id' =>$attributeId])->select());
+        return success_response($entity->where(['attribute_id' => $attributeId])->select());
     }
 
     public function save(Request $request, EavAttributeOptionEntity $entity): Response
@@ -31,4 +31,4 @@ class AttributeOptionController
     {
         return success_response($entity->destroy($id));
     }
-}
+}

+ 3 - 1
src/Controller/EntityAttributeController.php

@@ -1,5 +1,7 @@
 <?php
+
 declare(strict_types=1);
+
 namespace SixShop\Eav\Controller;
 
 use SixShop\Core\Request;
@@ -44,4 +46,4 @@ class EntityAttributeController
 
         return success_response();
     }
-}
+}

+ 3 - 1
src/Controller/EntityTypeController.php

@@ -1,5 +1,7 @@
 <?php
+
 declare(strict_types=1);
+
 namespace SixShop\Eav\Controller;
 
 use SixShop\Core\Request;
@@ -40,4 +42,4 @@ class EntityTypeController
     {
         return success_response($entity->destroy($id));
     }
-}
+}

+ 5 - 4
src/Controller/ValueController.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 namespace SixShop\Eav\Controller;
@@ -50,19 +51,19 @@ class ValueController
         if (empty($data)) {
             return error_response('参数错误');
         }
-        
+
         // 期望的数据格式:{ entity_id, entity_type_id, values: [{ attribute_id, value }, ...] }
         if (!isset($data['values']) || !is_array($data['values'])) {
             return error_response('数据格式错误,需要 values 数组');
         }
-        
+
         $entityId = $data['entity_id'] ?? 0;
         $entityTypeId = $data['entity_type_id'] ?? 0;
-        
+
         if (!$entityId || !$entityTypeId) {
             return error_response('缺少实体 ID 或实体类型 ID');
         }
-        
+
         // 批量写入
         foreach ($data['values'] as $item) {
             if (

+ 2 - 1
src/Entity/EavAttributeEntity.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 namespace SixShop\Eav\Entity;
@@ -7,4 +8,4 @@ use SixShop\Core\Entity\BaseEntity;
 
 class EavAttributeEntity extends BaseEntity
 {
-}
+}

+ 2 - 2
src/Entity/EavAttributeOptionEntity.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 namespace SixShop\Eav\Entity;
@@ -7,5 +8,4 @@ use SixShop\Core\Entity\BaseEntity;
 
 class EavAttributeOptionEntity extends BaseEntity
 {
-
-}
+}

+ 2 - 1
src/Entity/EavEntityTypeEntity.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 namespace SixShop\Eav\Entity;
@@ -14,4 +15,4 @@ class EavEntityTypeEntity extends Entity
             'modelClass' => EavEntityTypeModel::class,
         ];
     }
-}
+}

+ 2 - 2
src/Entity/EavValueEntity.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 namespace SixShop\Eav\Entity;
@@ -7,5 +8,4 @@ use SixShop\Core\Entity\BaseEntity;
 
 class EavValueEntity extends BaseEntity
 {
-
-}
+}

+ 2 - 3
src/Extension.php

@@ -1,16 +1,15 @@
 <?php
+
 declare(strict_types=1);
 
 namespace SixShop\Eav;
 
-
 use SixShop\Core\ExtensionAbstract;
 
 class Extension extends ExtensionAbstract
 {
-
     protected function getBaseDir(): string
     {
         return dirname(__DIR__);
     }
-}
+}

+ 2 - 0
src/Model/EavAttributeModel.php

@@ -1,5 +1,7 @@
 <?php
+
 declare(strict_types=1);
+
 namespace SixShop\Eav\Model;
 
 use think\Model;

+ 1 - 0
src/Model/EavAttributeOptionModel.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 namespace SixShop\Eav\Model;

+ 2 - 0
src/Model/EavEntityTypeModel.php

@@ -1,5 +1,7 @@
 <?php
+
 declare(strict_types=1);
+
 namespace SixShop\Eav\Model;
 
 use think\Model;

+ 2 - 0
src/Model/EavValueModel.php

@@ -1,5 +1,7 @@
 <?php
+
 declare(strict_types=1);
+
 namespace SixShop\Eav\Model;
 
 use think\Model;

+ 1 - 0
src/Service/EavValueService.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 namespace SixShop\Eav\Service;