Skip to content

Commit

Permalink
fix: fix bug when init plan and pricing and record (#2934)
Browse files Browse the repository at this point in the history
* fix: fix potential bugs in init data

* fix: improve code format

* fix: fix bug when init plan and pricing and record
  • Loading branch information
dacongda committed May 7, 2024
1 parent d24ddd4 commit c302dc7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions object/init_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ func initDefinedPlan(plan *Plan) {
panic(err)
}
if !affected {
panic("Fail to delete enforcer")
panic("Fail to delete plan")
}
}
plan.CreatedTime = util.GetCurrentTime()
Expand All @@ -677,7 +677,7 @@ func initDefinedPlan(plan *Plan) {
}

func initDefinedPricing(pricing *Pricing) {
existed, err := getPlan(pricing.Owner, pricing.Name)
existed, err := getPricing(pricing.Owner, pricing.Name)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -719,6 +719,7 @@ func initDefinedInvitation(invitation *Invitation) {
}

func initDefinedRecord(record *casvisorsdk.Record) {
record.Id = 0
record.CreatedTime = util.GetCurrentTime()
_ = AddRecord(record)
}
Expand Down
2 changes: 1 addition & 1 deletion object/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func AddPlan(plan *Plan) (bool, error) {
}

func DeletePlan(plan *Plan) (bool, error) {
affected, err := ormer.Engine.ID(core.PK{plan.Owner, plan.Name}).Delete(plan)
affected, err := ormer.Engine.ID(core.PK{plan.Owner, plan.Name}).Delete(Plan{})
if err != nil {
return false, err
}
Expand Down
2 changes: 1 addition & 1 deletion object/pricing.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func AddPricing(pricing *Pricing) (bool, error) {
}

func DeletePricing(pricing *Pricing) (bool, error) {
affected, err := ormer.Engine.ID(core.PK{pricing.Owner, pricing.Name}).Delete(pricing)
affected, err := ormer.Engine.ID(core.PK{pricing.Owner, pricing.Name}).Delete(Pricing{})
if err != nil {
return false, err
}
Expand Down

0 comments on commit c302dc7

Please sign in to comment.