拓展类型

This commit is contained in:
2024-09-25 17:45:38 +08:00
parent a0e898e46c
commit 3b69ba93ad
15 changed files with 214 additions and 40 deletions
+20
View File
@@ -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
}
+6
View File
@@ -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
View File
@@ -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: "",