表单数据持久化

This commit is contained in:
2024-09-13 18:19:27 +08:00
parent 951572a1f5
commit 250ffb4e20
9 changed files with 186 additions and 86 deletions
-20
View File
@@ -1,20 +0,0 @@
package repo
import (
"gorm.io/gorm"
"work_cation/models"
)
type ErlangCard struct{}
var ErlangCardRepo *ErlangCard
func (*ErlangCard) FindAll(db *gorm.DB) []models.ErlangCards {
var cards []models.ErlangCards
db.Find(&cards)
return cards
}
func (*ErlangCard) Create(db *gorm.DB, erlangCard *models.ErlangCards) error {
return db.Create(erlangCard).Error
}
-35
View File
@@ -1,35 +0,0 @@
package repo
import (
"gorm.io/gorm"
"os/user"
"work_cation/models"
"work_cation/pkg/utils"
)
type User struct{}
var UserRepo *User
func (*User) GetUserInfo(db *gorm.DB) *models.Users {
var users models.Users
db.Find(&users)
ip := utils.Get192Ip()
if users.Ip != ip {
current, err := user.Current()
if err != nil {
current = &user.User{Name: ip}
}
users = models.Users{
Ip: ip,
Name: current.Username,
Avatar: "",
Cover: "",
Email: "",
Phone: "",
Address: "友嘉",
}
db.Create(&users)
}
return &users
}