master
Evan Chen 2021-12-19 03:23:21 +08:00
parent 337f2e910b
commit 21c77899ce
2 changed files with 7 additions and 0 deletions

View File

@ -28,6 +28,7 @@ type apiGrpNewReq struct {
Name string `json:"name" example:"user" binding:"required"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
GRPF1 string
}
func ApiGrpNew(c *gin.Context) {
@ -43,6 +44,7 @@ func ApiGrpNew(c *gin.Context) {
Name: data.Name,
Description: data.Description,
DisplayName: data.DisplayName,
GRPF1: data.GRPF1,
}
if err := DB.Create(grp).Error; err != nil {
panic(err)
@ -59,6 +61,7 @@ type apiGrpUpdateReq struct {
Name string `json:"name" binding:"required"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
GRPF1 string
}
func ApiGrpUpdate(c *gin.Context) {
@ -82,6 +85,7 @@ func ApiGrpUpdate(c *gin.Context) {
"name": data.Name,
"display_name": data.DisplayName,
"description": data.Description,
"grpf1": data.GRPF1,
})
if result.Error != nil {
panic(result.Error)

View File

@ -18,6 +18,9 @@ type Group struct {
DisplayName string
Description string
Users []*User `gorm:"many2many:user_groups;"`
//extra fields
GRPF1 string
}
func (grp *Group) BeforeSave(tx *gorm.DB) (err error) {