-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
78 additions
and
25 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package image | ||
|
||
import ( | ||
userModel "gin_bbs/app/models/user" | ||
|
||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
// Store 上传图片 | ||
func Store(c *gin.Context, currentUser *userModel.User, tokenString string) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package image | ||
|
||
import ( | ||
"gin_bbs/app/models/user" | ||
"gin_bbs/database" | ||
) | ||
|
||
// Get - | ||
func Get(id int) (*Image, error) { | ||
i := &Image{} | ||
if err := database.DB.First(&i, id).Error; err != nil { | ||
return nil, err | ||
} | ||
|
||
return i, nil | ||
} | ||
|
||
// User 获取 user | ||
func (i *Image) User() (u *user.User, err error) { | ||
u, err = user.Get(int(i.UserID)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return u, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package image | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
var ( | ||
// Types image type | ||
Types = []string{"avatar", "topic"} | ||
) | ||
|
||
// Image - | ||
type Image struct { | ||
ID uint `gorm:"column:id;primary_key;AUTO_INCREMENT;not null"` | ||
Type string `gorm:"column:type;type:varchar(255);not null" sql:"index"` // 类型 (avatar,topic) | ||
UserID uint `gorm:"column:user_id;not null" sql:"index"` // 用户 id | ||
Path string `gorm:"column:path;type:varchar(255);not null"` // 图片路径 | ||
CreatedAt time.Time `gorm:"column:created_at"` | ||
UpdatedAt time.Time `gorm:"column:updated_at"` | ||
} | ||
|
||
// TableName 表名 | ||
func (Image) TableName() string { | ||
return "images" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters