表单数据持久化
This commit is contained in:
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user