Skip to content

Commit 68afb7e

Browse files
committed
feat: get data from db after modify
1 parent 626196a commit 68afb7e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

api/cosy/update.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import (
55
"github.com/0xJacky/Nginx-UI/model"
66
"github.com/gin-gonic/gin"
77
"gorm.io/gorm"
8-
"net/http"
8+
"gorm.io/gorm/clause"
9+
"net/http"
910
)
1011

1112
func (c *Ctx[T]) SetNextHandler(handler gin.HandlerFunc) *Ctx[T] {
@@ -74,6 +75,13 @@ func (c *Ctx[T]) Modify() {
7475
return
7576
}
7677

78+
err = db.Preload(clause.Associations).First(&c.Model, id).Error
79+
80+
if err != nil {
81+
c.AbortWithError(err)
82+
return
83+
}
84+
7785
if len(c.executedHookFunc) > 0 {
7886
for _, v := range c.executedHookFunc {
7987
v(c)

0 commit comments

Comments
 (0)