zory 2 hafta önce
ebeveyn
işleme
6fad5482fd

+ 2 - 0
.idea/cpa-api.iml

@@ -5,6 +5,7 @@
       <sourceFolder url="file://$MODULE_DIR$/." isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/./app" isTestSource="false" packagePrefix="app\" />
       <sourceFolder url="file://$MODULE_DIR$/./app/view/components" isTestSource="false" packagePrefix="app\View\Components\" />
+      <sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
       <excludeFolder url="file://$MODULE_DIR$/vendor/aliyuncs/oss-sdk-php" />
       <excludeFolder url="file://$MODULE_DIR$/vendor/brick/math" />
       <excludeFolder url="file://$MODULE_DIR$/vendor/cakephp/chronos" />
@@ -140,6 +141,7 @@
       <excludeFolder url="file://$MODULE_DIR$/vendor/workerman/workerman" />
       <excludeFolder url="file://$MODULE_DIR$/vendor/x2nx/webman-migrate" />
       <excludeFolder url="file://$MODULE_DIR$/vendor/yzh52521/easyhttp" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/cakephp/event" />
     </content>
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />

+ 7 - 1
.idea/php.xml

@@ -147,14 +147,20 @@
       <path value="$PROJECT_DIR$/vendor/markbaker/matrix" />
       <path value="$PROJECT_DIR$/vendor/markbaker/complex" />
       <path value="$PROJECT_DIR$/vendor/league/container" />
+      <path value="$PROJECT_DIR$/vendor/cakephp/event" />
     </include_path>
   </component>
-  <component name="PhpProjectSharedConfiguration" php_language_level="8.2">
+  <component name="PhpProjectSharedConfiguration" php_language_level="8.1">
     <option name="suggestChangeDefaultLanguageLevel" value="false" />
   </component>
   <component name="PhpStanOptionsConfiguration">
     <option name="transferred" value="true" />
   </component>
+  <component name="PhpUnit">
+    <phpunit_settings>
+      <PhpUnitSettings custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" />
+    </phpunit_settings>
+  </component>
   <component name="PsalmOptionsConfiguration">
     <option name="transferred" value="true" />
   </component>

+ 50 - 0
app/command/ShopwwiAuthCommand.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace app\command;
+
+use Shopwwi\WebmanAuth\Facade\Str;
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Output\OutputInterface;
+
+
+class ShopwwiAuthCommand extends Command
+{
+    protected static $defaultName = 'shopwwi:auth';
+    protected static $defaultDescription = 'shopwwi auth';
+
+    /**
+     * @return void
+     */
+    protected function configure()
+    {
+        $this->addArgument('name', InputArgument::OPTIONAL, 'Name description');
+    }
+
+    /**
+     * @param InputInterface $input
+     * @param OutputInterface $output
+     * @return int
+     */
+    protected function execute(InputInterface $input, OutputInterface $output)
+    {
+        $name = $input->getArgument('name');
+        $output->writeln('生成jwtKey 开始');
+        $key = Str::random(64);
+        file_put_contents(base_path()."/config/plugin/shopwwi/auth/app.php", str_replace(
+            "'access_secret_key' => '".config('plugin.shopwwi.auth.app.jwt.access_secret_key')."'",
+            "'access_secret_key' => '".$key."'",
+            file_get_contents(base_path()."/config/plugin/shopwwi/auth/app.php")
+        ));
+        file_put_contents(base_path()."/config/plugin/shopwwi/auth/app.php", str_replace(
+            "'refresh_secret_key' => '".config('plugin.shopwwi.auth.app.jwt.refresh_secret_key')."'",
+            "'refresh_secret_key' => '".$key."'",
+            file_get_contents(base_path()."/config/plugin/shopwwi/auth/app.php")
+        ));
+        $output->writeln('生成jwtKey 结束'.$key);
+        return self::SUCCESS;
+    }
+
+}

+ 37 - 0
database/factories/UsersFactory.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace Database\Factories;
+
+use Illuminate\Database\Eloquent\Factories\Factory;
+use Illuminate\Support\Str;
+
+/**
+ * @extends \Illuminate\Database\Eloquent\Factories\Factory<\app\model\Users>
+ */
+class UsersFactory extends Factory
+{
+    /**
+     * Define the model's default state.
+     *
+     * @return array<string, mixed>
+     */
+    public function definition(): array
+    {
+        return [
+            'name' => uniqid() . mt_rand(1,100),
+            'email' => uniqid() . mt_rand(1,100) . '@example.com',
+            'email_verified_at' => time(),
+            'password' => uniqid() . mt_rand(1,100),
+            'remember_token' => Str::random(10),
+        ];
+    }
+    /**
+     * Indicate that the model's email address should be unverified.
+     */
+    public function unverified(): static
+    {
+        return $this->state(fn (array $attributes) => [
+            'email_verified_at' => null,
+        ]);
+    }
+}

+ 33 - 0
database/migrations/2025_01_07_213244_users.php

@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use support\Db;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     */
+    public function up(): void
+    {
+        Db::schema()->create('users', function (Blueprint $table) {
+            $table->id();
+            $table->string('name');
+            $table->string('email')->unique();
+            $table->timestamp('email_verified_at')->nullable();
+            $table->string('password');
+            $table->rememberToken();
+            $table->timestamps();
+            $table->softDeletes();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Db::schema()->dropIfExists('users');
+    }
+};

+ 29 - 0
database/migrations/2026_01_14_120641_create_province_city_area_table.php

@@ -0,0 +1,29 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use support\Db;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     */
+    public function up(): void
+    {
+        Db::schema()->create('province_city_area', function (Blueprint $table) {
+            $table->increments('id');
+            $table->string('name')->default('')->comment('省市县名称');
+            $table->string('parent_id')->default(0)->comment('父级id');
+            $table->enum('type', ['province', 'city', 'area', 'street'])->default('province')->comment('类型');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Db::schema()->dropIfExists('province_city_area');
+    }
+};

+ 40 - 0
database/seeders/DatabaseSeeder.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace Database\Seeders;
+
+use http\Client\Curl\User;
+use Illuminate\Database\Eloquent\Factories\Factory;
+
+use app\model\Users;
+// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
+use Illuminate\Database\Seeder;
+use Illuminate\Support\Str;
+use support\Db;
+
+class DatabaseSeeder extends Seeder
+{
+    public function __construct()
+    {
+        Factory::guessFactoryNamesUsing(function (string $modelName) {
+            return 'Database\\Factories\\' . class_basename($modelName) . 'Factory';
+        });
+        Factory::guessModelNamesUsing(function (Factory $factory) {
+            return 'app\\model\\' . str_replace('Factory', '', class_basename($factory));
+        });
+    }
+
+    /**
+     * Seed the application's database.
+     */
+    public function run(): void
+    {
+        /*
+         * [
+            'name' => 'admin',
+            'email' => Str::random(10).'@qq.com',
+            'password' => ('<PASSWORD>')
+        ]
+         */
+        Users::factory(10)->create();
+    }
+}