提交 v1.3.0 beta

This commit is contained in:
dushixiang
2022-10-23 20:05:13 +08:00
parent 4ff4d37442
commit 112435199a
329 changed files with 18340 additions and 58458 deletions

View File

@ -4,9 +4,12 @@ import (
"context"
"time"
"next-terminal/server/dto"
"next-terminal/server/model"
)
var LoginLogRepository = new(loginLogRepository)
type loginLogRepository struct {
baseRepository
}
@ -84,3 +87,18 @@ func (r loginLogRepository) FindById(c context.Context, id string) (o model.Logi
func (r loginLogRepository) Update(c context.Context, o *model.LoginLog) error {
return r.GetDB(c).Updates(o).Error
}
func (r loginLogRepository) CountByState(c context.Context, state string) (total int64, err error) {
err = r.GetDB(c).Where("state = ?", state).Find(&model.LoginLog{}).Count(&total).Error
return
}
func (r loginLogRepository) CountWithGroupByLoginTime(c context.Context, loginTime time.Time) (counter []dto.DateCounter, err error) {
err = r.GetDB(c).Table("login_logs").Select("date(login_time) as date, count(id) as value").Where("login_time > ?", loginTime).Group("date(login_time)").Scan(&counter).Error
return
}
func (r loginLogRepository) CountWithGroupByLoginTimeAndUsername(c context.Context, loginTime time.Time) (counter []dto.DateCounter, err error) {
err = r.GetDB(c).Table("login_logs").Select("date(login_time) as date, count(distinct(username)) as value").Where("login_time > ?", loginTime).Group("date(login_time), username").Scan(&counter).Error
return
}