imageinfo.go 361 B

123456789101112131415
  1. package models
  2. import "github.com/jinzhu/gorm"
  3. type ImageInfo struct {
  4. UserId string `json:"user_id"`
  5. Path string `json:"path"`
  6. URL string `json:"url"`
  7. }
  8. func (image *ImageInfo) Save(db *gorm.DB) error {
  9. sql := "INSERT INTO image_info(user_id, path, url) VALUES (?,?,?)"
  10. err := db.Exec(sql, image.UserId, image.Path, image.URL).Error
  11. return err
  12. }