staff.go ~~~ // Insert 数据添加 func (Staff) Insert(ctx *gin.Context) { //data := &Staff{} var data Staff status ,_ := strconv.ParseInt(ctx.PostForm("status"),10,8) infoId,_ := strconv.ParseInt(ctx.PostForm("info_id"),10,8) data.Status = int(status) data.Nickname = ctx.PostForm("nickname") data.Account = ctx.PostForm("nickname") data.InfoId = int(infoId) data.Password = common.Md5(ctx.PostForm("password")) data.CreatedAt = common.GetDate() data.UpdatedAt = common.GetDate() db.DB.Table("staff").Create(&data) } ~~~ staffController.go ~~~ func (staff StaffController) Insert(ctx *gin.Context) { models.Staff{}.Insert(ctx) } ~~~