From b491fae6fe8e1da13a1f509083c552f1f585d8eb Mon Sep 17 00:00:00 2001 From: agiledragon Date: Sat, 14 Jul 2018 19:53:45 +0800 Subject: [PATCH] t to this --- cargo/domain/model/base/entity.go | 12 ++++++------ cargo/domain/model/cargo.go | 10 +++++----- cargo/domain/model/cargo_factory.go | 2 +- cargo/domain/service/cargo_service.go | 22 +++++++++++----------- cargo/infra/cargo_provider_impl.go | 2 +- cargo/infra/cargo_repo_impl.go | 8 ++++---- cargo/test/cargo_test.go | 22 +++++++++++----------- 7 files changed, 39 insertions(+), 39 deletions(-) diff --git a/cargo/domain/model/base/entity.go b/cargo/domain/model/base/entity.go index ca699f9..ad872ce 100644 --- a/cargo/domain/model/base/entity.go +++ b/cargo/domain/model/base/entity.go @@ -8,14 +8,14 @@ func NewEntity(id string) Entity { return Entity{id: id} } -func (t *Entity) Id() string { - return t.id +func (this *Entity) Id() string { + return this.id } -func (t *Entity) Equal(other *Entity) bool { - return t.id == other.id +func (this *Entity) Equal(other *Entity) bool { + return this.id == other.id } -func (t *Entity) NotEqual(other *Entity) bool { - return !t.Equal(other) +func (this *Entity) NotEqual(other *Entity) bool { + return !this.Equal(other) } diff --git a/cargo/domain/model/cargo.go b/cargo/domain/model/cargo.go index 5fa342c..ebfcc1c 100644 --- a/cargo/domain/model/cargo.go +++ b/cargo/domain/model/cargo.go @@ -13,11 +13,11 @@ func newCargo(cargoId string, delivery Delivery) *Cargo { return &Cargo{AggregateRoot: base.NewAggregateRoot(cargoId), Delivery: delivery} } -func (t *Cargo) Delay(days uint) { - afterDays := t.GetAfterDays() + days - t.Delivery = Delivery{AfterDays: afterDays} +func (this *Cargo) Delay(days uint) { + afterDays := this.GetAfterDays() + days + this.Delivery = Delivery{AfterDays: afterDays} } -func (t *Cargo) GetAfterDays() uint { - return t.Delivery.AfterDays +func (this *Cargo) GetAfterDays() uint { + return this.Delivery.AfterDays } diff --git a/cargo/domain/model/cargo_factory.go b/cargo/domain/model/cargo_factory.go index dcd76b8..67ed4c2 100644 --- a/cargo/domain/model/cargo_factory.go +++ b/cargo/domain/model/cargo_factory.go @@ -3,7 +3,7 @@ package model type CargoFactory struct { } -func (t CargoFactory) Create(cargoId string, afterDays uint) *Cargo { +func (this CargoFactory) Create(cargoId string, afterDays uint) *Cargo { delivery := Delivery{AfterDays: afterDays} return newCargo(cargoId, delivery) } diff --git a/cargo/domain/service/cargo_service.go b/cargo/domain/service/cargo_service.go index 9d6b5b4..4499b3f 100644 --- a/cargo/domain/service/cargo_service.go +++ b/cargo/domain/service/cargo_service.go @@ -21,30 +21,30 @@ func GetCargoService() *CargoService { return cs } -func (t *CargoService) Create(cargoId string, afterDays uint) { +func (this *CargoService) Create(cargoId string, afterDays uint) { cargo := model.CargoFactory{}.Create(cargoId, afterDays) - t.repo.Add(cargo) - t.provider.Confirm(cargo) + this.repo.Add(cargo) + this.provider.Confirm(cargo) } -func (t *CargoService) Delay(cargoId string, days uint) { - cargo := t.repo.Get(cargoId) +func (this *CargoService) Delay(cargoId string, days uint) { + cargo := this.repo.Get(cargoId) if cargo == nil { panic("not found cargo by cargoId") } cargo.Delay(days) - t.repo.Update(cargo) - t.provider.Confirm(cargo) + this.repo.Update(cargo) + this.provider.Confirm(cargo) } -func (t *CargoService) GetAfterDays(cargoId string) uint { - cargo := t.repo.Get(cargoId) +func (this *CargoService) GetAfterDays(cargoId string) uint { + cargo := this.repo.Get(cargoId) if cargo == nil { panic("not found cargo by cargoId") } return cargo.GetAfterDays() } -func (t *CargoService) DestroyCargo(cargoId string) { - t.repo.Remove(cargoId) +func (this *CargoService) DestroyCargo(cargoId string) { + this.repo.Remove(cargoId) } diff --git a/cargo/infra/cargo_provider_impl.go b/cargo/infra/cargo_provider_impl.go index 336c529..42a2c0e 100644 --- a/cargo/infra/cargo_provider_impl.go +++ b/cargo/infra/cargo_provider_impl.go @@ -5,6 +5,6 @@ import "github.com/agiledragon/ddd-sample-in-golang/cargo/domain/model" type CargoProviderImpl struct { } -func (t *CargoProviderImpl) Confirm(cargo *model.Cargo) { +func (this *CargoProviderImpl) Confirm(cargo *model.Cargo) { } diff --git a/cargo/infra/cargo_repo_impl.go b/cargo/infra/cargo_repo_impl.go index cd835e4..be3febe 100644 --- a/cargo/infra/cargo_repo_impl.go +++ b/cargo/infra/cargo_repo_impl.go @@ -5,18 +5,18 @@ import "github.com/agiledragon/ddd-sample-in-golang/cargo/domain/model" type CargoRepoImpl struct { } -func (t *CargoRepoImpl) Add(cargo *model.Cargo) { +func (this *CargoRepoImpl) Add(cargo *model.Cargo) { } -func (t *CargoRepoImpl) Get(cargoId string) *model.Cargo { +func (this *CargoRepoImpl) Get(cargoId string) *model.Cargo { return nil } -func (t *CargoRepoImpl) Update(cargo *model.Cargo) { +func (this *CargoRepoImpl) Update(cargo *model.Cargo) { } -func (t *CargoRepoImpl) Remove(CargoId string) { +func (this *CargoRepoImpl) Remove(CargoId string) { } diff --git a/cargo/test/cargo_test.go b/cargo/test/cargo_test.go index 5675a18..01bc162 100644 --- a/cargo/test/cargo_test.go +++ b/cargo/test/cargo_test.go @@ -12,29 +12,29 @@ type SpyCargoProvider struct { afterDays uint } -func (t *SpyCargoProvider) Confirm(cargo *model.Cargo) { - t.cargoId = cargo.Id() - t.afterDays = cargo.GetAfterDays() +func (this *SpyCargoProvider) Confirm(cargo *model.Cargo) { + this.cargoId = cargo.Id() + this.afterDays = cargo.GetAfterDays() } type FakeCargoRepo struct { cargoes map[string]*model.Cargo } -func (t *FakeCargoRepo) Add(cargo *model.Cargo) { - t.cargoes[cargo.Id()] = cargo +func (this *FakeCargoRepo) Add(cargo *model.Cargo) { + this.cargoes[cargo.Id()] = cargo } -func (t *FakeCargoRepo) Get(cargoId string) *model.Cargo { - return t.cargoes[cargoId] +func (this *FakeCargoRepo) Get(cargoId string) *model.Cargo { + return this.cargoes[cargoId] } -func (t *FakeCargoRepo) Update(cargo *model.Cargo) { - t.cargoes[cargo.Id()] = cargo +func (this *FakeCargoRepo) Update(cargo *model.Cargo) { + this.cargoes[cargo.Id()] = cargo } -func (t *FakeCargoRepo) Remove(cargoId string) { - delete(t.cargoes, cargoId) +func (this *FakeCargoRepo) Remove(cargoId string) { + delete(this.cargoes, cargoId) } func TestCargo(t *testing.T) {