mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
fix: fix bug when init plan and pricing and record (#2934)
* fix: fix potential bugs in init data * fix: improve code format * fix: fix bug when init plan and pricing and record
This commit is contained in:
parent
d24ddd4f1c
commit
c302dc7b8e
@ -666,7 +666,7 @@ func initDefinedPlan(plan *Plan) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if !affected {
|
if !affected {
|
||||||
panic("Fail to delete enforcer")
|
panic("Fail to delete plan")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plan.CreatedTime = util.GetCurrentTime()
|
plan.CreatedTime = util.GetCurrentTime()
|
||||||
@ -677,7 +677,7 @@ func initDefinedPlan(plan *Plan) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func initDefinedPricing(pricing *Pricing) {
|
func initDefinedPricing(pricing *Pricing) {
|
||||||
existed, err := getPlan(pricing.Owner, pricing.Name)
|
existed, err := getPricing(pricing.Owner, pricing.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -719,6 +719,7 @@ func initDefinedInvitation(invitation *Invitation) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func initDefinedRecord(record *casvisorsdk.Record) {
|
func initDefinedRecord(record *casvisorsdk.Record) {
|
||||||
|
record.Id = 0
|
||||||
record.CreatedTime = util.GetCurrentTime()
|
record.CreatedTime = util.GetCurrentTime()
|
||||||
_ = AddRecord(record)
|
_ = AddRecord(record)
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ func AddPlan(plan *Plan) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DeletePlan(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 {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ func AddPricing(pricing *Pricing) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DeletePricing(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 {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user