feat: add login log record

This commit is contained in:
engigu
2025-10-01 00:36:01 +08:00
parent cbda9baffe
commit baed8b4254
+2 -5
View File
@@ -1,14 +1,13 @@
package models
import "message-nest/pkg/util"
type LoginLog struct {
UUIDModel
ID uint `gorm:"autoIncrement;type:integer;primaryKey" json:"id"`
UserID int `json:"user_id" gorm:"type:int;index"`
Username string `json:"username" gorm:"type:varchar(100);default:'';index"`
IP string `json:"ip" gorm:"type:varchar(64);default:'';"`
UA string `json:"ua" gorm:"type:varchar(512);default:'';"`
CreatedAt util.Time `json:"created_on" gorm:"column:created_on;autoCreateTime"`
}
func AddLoginLog(userID int, username string, ip string, ua string) error {
@@ -24,5 +23,3 @@ func GetRecentLoginLogs(limit int) ([]LoginLog, error) {
err := db.Model(&LoginLog{}).Order("id DESC").Limit(limit).Find(&logs).Error
return logs, err
}