Skip to content

Commit

Permalink
fix: update cert model bug
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJacky committed Jun 18, 2024
1 parent 47d4013 commit 65befe2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 0 additions & 3 deletions api/certificate/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ func AddCert(c *gin.Context) {
}

err := certModel.Insert()

if err != nil {
api.ErrHandler(c, err)
return
Expand All @@ -124,7 +123,6 @@ func AddCert(c *gin.Context) {
}

err = content.WriteFile()

if err != nil {
api.ErrHandler(c, err)
return
Expand Down Expand Up @@ -180,7 +178,6 @@ func ModifyCert(c *gin.Context) {
}

err = content.WriteFile()

if err != nil {
api.ErrHandler(c, err)
return
Expand Down
4 changes: 3 additions & 1 deletion model/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/go-acme/lego/v4/certcrypto"
"github.com/go-acme/lego/v4/certificate"
"github.com/lib/pq"
"gorm.io/gorm/clause"
"os"
)

Expand Down Expand Up @@ -93,7 +94,8 @@ func GetAutoCertList() (c []*Cert) {
}

func (c *Cert) Updates(n *Cert) error {
return db.Model(&Cert{}).Where("id", c.ID).Updates(n).Error
return db.Model(c).Clauses(clause.Returning{}).
Where("id", c.ID).Updates(n).Error
}

func (c *Cert) Remove() error {
Expand Down

0 comments on commit 65befe2

Please sign in to comment.