Skip to content

Commit

Permalink
t to this
Browse files Browse the repository at this point in the history
  • Loading branch information
agiledragon committed Jul 14, 2018
1 parent f99758f commit b491fae
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 39 deletions.
12 changes: 6 additions & 6 deletions cargo/domain/model/base/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
10 changes: 5 additions & 5 deletions cargo/domain/model/cargo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion cargo/domain/model/cargo_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
22 changes: 11 additions & 11 deletions cargo/domain/service/cargo_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion cargo/infra/cargo_provider_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

}
8 changes: 4 additions & 4 deletions cargo/infra/cargo_repo_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

}
22 changes: 11 additions & 11 deletions cargo/test/cargo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b491fae

Please sign in to comment.