package system import ( "context" "time" "management/internal/erpserver/model/dto" ) type LoginLogRepository interface { Create(ctx context.Context, obj *LoginLog) error GetLatest(ctx context.Context, email string) ([]*LoginLog, error) Count(ctx context.Context, filter dto.SearchDto) (int64, error) List(ctx context.Context, filter dto.SearchDto) ([]*LoginLog, error) HistoricalLogin(ctx context.Context, email string, createdAt time.Time) ([]*LoginLog, error) } type LoginLog struct { ID int64 `db:"id" json:"id"` CreatedAt time.Time `db:"created_at" json:"created_at"` Email string `db:"email" json:"email"` IsSuccess bool `db:"is_success" json:"is_success"` Message string `db:"message" json:"message"` RefererUrl string `db:"referer_url" json:"referer_url"` Url string `db:"url" json:"url"` Os string `db:"os" json:"os"` Ip string `db:"ip" json:"ip"` Browser string `db:"browser" json:"browser"` } func NewLoginLog(email, os, ip, browser, url, referer string) *LoginLog { return &LoginLog{ CreatedAt: time.Now(), Email: email, IsSuccess: false, RefererUrl: referer, Url: url, Os: os, Ip: ip, Browser: browser, } } func (l *LoginLog) SetMessage(message string) *LoginLog { l.Message = message return l } func (l *LoginLog) SetOk(message string) *LoginLog { l.Message = message l.IsSuccess = true return l }