Skip to content

Commit

Permalink
refactor(logistics): 重构物流模块
Browse files Browse the repository at this point in the history
- 修改物流运费模板相关代码,优化数据传输对象和枚举类
- 重命名部分文件和类,统一命名规范- 添加物流公司的领域模型和仓储接口
- 调整数据库迁移文件,修正字段注释
  • Loading branch information
liushoukun committed Nov 12, 2024
1 parent fb20294 commit 48ae6a3
Show file tree
Hide file tree
Showing 16 changed files with 73 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ public function up() : void
// 运费
Schema::create('logistics_companies', function (Blueprint $table) {
$table->id();
$table->string('name')->comment('名称');
$table->string('code')->comment('编码');
$table->string('name')->comment('名称');
$table->string('letter')->nullable()->comment('首字母');
$table->string('logo')->nullable()->comment('名称');
$table->string('logo')->nullable()->comment('图标');
$table->string('tel')->nullable()->comment('电话');
$table->string('url')->nullable()->comment('网址');
$table->timestamps();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use RedJasmine\Logistics\DataTransferObjects\FreightTemplates\FreightTemplateDTO;
use RedJasmine\Logistics\Domain\Models\LogisticsFreightTemplate;
use RedJasmine\Logistics\Domain\Models\LogisticsFreightTemplateFeeRegion;
use RedJasmine\Logistics\Domain\Models\LogisticsFreightTemplateFreeRegion;
use RedJasmine\Logistics\FreightTemplateService;
use RedJasmine\Logistics\Models\LogisticsFreightTemplate;
use RedJasmine\Logistics\Models\LogisticsFreightTemplateFeeRegion;
use RedJasmine\Logistics\Models\LogisticsFreightTemplateFreeRegion;
use RedJasmine\Logistics\Pipelines\FreightTemplates\FreightTemplateValidatePipeline;
use RedJasmine\Support\Foundation\Service\Action;
use Throwable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use RedJasmine\Logistics\DataTransferObjects\FreightTemplates\FreightTemplateDTO;
use RedJasmine\Logistics\Domain\Models\LogisticsFreightTemplate;
use RedJasmine\Logistics\Domain\Models\LogisticsFreightTemplateFeeRegion;
use RedJasmine\Logistics\Domain\Models\LogisticsFreightTemplateFreeRegion;
use RedJasmine\Logistics\FreightTemplateService;
use RedJasmine\Logistics\Models\LogisticsFreightTemplate;
use RedJasmine\Logistics\Models\LogisticsFreightTemplateFeeRegion;
use RedJasmine\Logistics\Models\LogisticsFreightTemplateFreeRegion;
use RedJasmine\Logistics\Pipelines\FreightTemplates\FreightTemplateValidatePipeline;
use RedJasmine\Support\Foundation\Service\Action;
use Throwable;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace RedJasmine\Logistics\Application\Services;

use RedJasmine\Support\Application\ApplicationCommandService;

class LogisticsCompanyCommandService extends ApplicationCommandService
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace RedJasmine\Logistics\DataTransferObjects\FreightTemplates;

use RedJasmine\Logistics\Enums\FreightTemplates\FreightChargeTypeEnum;
use RedJasmine\Support\Data\Data;
use Spatie\LaravelData\DataCollection;

Expand All @@ -11,7 +10,7 @@ class FreightTemplateDTO extends Data

public string $name;

public FreightChargeTypeEnum $chargeType;
public \RedJasmine\Logistics\Domain\Models\Enums\FreightTemplates\FreightChargeTypeEnum $chargeType;

public bool $isFree;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace RedJasmine\Logistics\Enums\FreightTemplates;
namespace RedJasmine\Logistics\Domain\Models\Enums\FreightTemplates;

use RedJasmine\Support\Helpers\Enums\EnumsHelper;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<?php

namespace RedJasmine\Logistics\Models;
namespace RedJasmine\Logistics\Domain\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use RedJasmine\Support\Domain\Models\Traits\HasOperator;

class LogisticsCompany extends Model
{

use HasOperator;

protected $fillable = [
'code',
'name',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace RedJasmine\Logistics\Models;
namespace RedJasmine\Logistics\Domain\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use RedJasmine\Logistics\Enums\FreightTemplates\FreightChargeTypeEnum;
use RedJasmine\Logistics\Domain\Models\Enums\FreightTemplates\FreightChargeTypeEnum;
use RedJasmine\Support\Traits\Models\HasOperator;
use RedJasmine\Support\Traits\Models\HasOwner;
use RedJasmine\Support\Traits\Models\WithDTO;


class LogisticsFreightTemplate extends Model
{
Expand All @@ -18,7 +18,6 @@ class LogisticsFreightTemplate extends Model

use HasOperator;

use WithDTO;

public $incrementing = false;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace RedJasmine\Logistics\Models;
namespace RedJasmine\Logistics\Domain\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace RedJasmine\Logistics\Models;
namespace RedJasmine\Logistics\Domain\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace RedJasmine\Logistics\Domain\Repositories;

use RedJasmine\Support\Domain\Repositories\ReadRepositoryInterface;

interface LogisticsCompanyReadRepositoryInterface extends ReadRepositoryInterface
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace RedJasmine\Logistics\Domain\Repositories;

use RedJasmine\Support\Domain\Repositories\RepositoryInterface;

interface LogisticsCompanyRepositoryInterface extends RepositoryInterface
{

}
4 changes: 1 addition & 3 deletions packages/logistics/src/FreightTemplateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
namespace RedJasmine\Logistics;


use Exception;
use RedJasmine\Logistics\Actions\FreightTemplates\FreightTemplateUpdateAction;
use RedJasmine\Logistics\DataTransferObjects\FreightTemplates\FreightTemplateDTO;
use RedJasmine\Logistics\Models\LogisticsFreightTemplate;
use RedJasmine\Logistics\Domain\Models\LogisticsFreightTemplate;
use RedJasmine\Support\Foundation\Service\Service;
use RedJasmine\Support\Foundation\Service\ServiceAwareAction;
use RedJasmine\Support\Helpers\ID\Snowflake;

/**
* @see FreightTemplateCreateAction::execute()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace RedJasmine\Logistics\Infrastructure\Repositories;

use RedJasmine\Logistics\Domain\Models\LogisticsCompany;
use RedJasmine\Logistics\Domain\Repositories\LogisticsCompanyRepositoryInterface;
use RedJasmine\Support\Infrastructure\Repositories\Eloquent\EloquentRepository;

/**
* @method LogisticsCompany find($id)
*/
class LogisticsCompanyRepository extends EloquentRepository implements LogisticsCompanyRepositoryInterface
{

/**
* @var $eloquentModelClass class-string
*/
protected static string $eloquentModelClass = LogisticsCompany::class;

}
2 changes: 1 addition & 1 deletion packages/logistics/src/LogisticsCompanyService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace RedJasmine\Logistics;

use RedJasmine\Logistics\Models\LogisticsCompany;
use RedJasmine\Logistics\Domain\Models\LogisticsCompany;
use RedJasmine\Support\Foundation\Service\Service;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Closure;
use Illuminate\Support\Facades\Validator;
use RedJasmine\Logistics\Models\LogisticsFreightTemplate;
use RedJasmine\Logistics\Domain\Models\LogisticsFreightTemplate;
use RedJasmine\Region\Rules\RegionsExistRule;

class FreightTemplateValidatePipeline
Expand Down

0 comments on commit 48ae6a3

Please sign in to comment.