feat: add login log record
This commit is contained in:
+2
-5
@@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user