拓展类型
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package repo
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"work_cation/models"
|
||||
)
|
||||
|
||||
type baseCardRepo struct{}
|
||||
|
||||
var BaseCard *baseCardRepo
|
||||
|
||||
func (*baseCardRepo) FindAll(db *gorm.DB) []models.BaseCard {
|
||||
var cards []models.BaseCard
|
||||
db.Find(&cards)
|
||||
return cards
|
||||
}
|
||||
|
||||
func (*baseCardRepo) Create(db *gorm.DB, baseCard *models.BaseCard) error {
|
||||
return db.Create(baseCard).Error
|
||||
}
|
||||
@@ -15,6 +15,12 @@ func (*erlangCard) FindAll(db *gorm.DB) []models.ErlangCards {
|
||||
return cards
|
||||
}
|
||||
|
||||
func (*erlangCard) Find(db *gorm.DB, uuid string) models.ErlangCards {
|
||||
var card models.ErlangCards
|
||||
db.Where("uuid = ?", uuid).First(&card)
|
||||
return card
|
||||
}
|
||||
|
||||
func (*erlangCard) Create(db *gorm.DB, erlangCard *models.ErlangCards) error {
|
||||
return db.Create(erlangCard).Error
|
||||
}
|
||||
|
||||
+3
-1
@@ -13,14 +13,16 @@ var User *userRepo
|
||||
|
||||
func (*userRepo) GetUserInfo(db *gorm.DB) *models.Users {
|
||||
var users models.Users
|
||||
db.Find(&users)
|
||||
ip := utils.IP.Get192Ip()
|
||||
db.Where("ip = ?", ip).Find(&users)
|
||||
|
||||
if users.Ip != ip {
|
||||
current, err := user.Current()
|
||||
if err != nil {
|
||||
current = &user.User{Name: ip}
|
||||
}
|
||||
users = models.Users{
|
||||
ID: utils.Uuid.CreateUUID(),
|
||||
Ip: ip,
|
||||
Name: current.Username,
|
||||
Avatar: "",
|
||||
|
||||
Reference in New Issue
Block a user