145 lines
3.7 KiB
Go
145 lines
3.7 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.28.0
|
|
// source: sys_user_login_log.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const countSysUserLoginLogCondition = `-- name: CountSysUserLoginLogCondition :one
|
|
SELECT COUNT(*) FROM sys_user_login_log
|
|
WHERE created_at BETWEEN $1 AND $2
|
|
AND ($3::text = '' OR email ILIKE '%' || $3 || '%')
|
|
AND ($4::text = '' OR username ILIKE '%' || $4 || '%')
|
|
`
|
|
|
|
type CountSysUserLoginLogConditionParams struct {
|
|
StartAt time.Time `json:"start_at"`
|
|
EndAt time.Time `json:"end_at"`
|
|
Email string `json:"email"`
|
|
Username string `json:"username"`
|
|
}
|
|
|
|
func (q *Queries) CountSysUserLoginLogCondition(ctx context.Context, arg *CountSysUserLoginLogConditionParams) (int64, error) {
|
|
row := q.db.QueryRow(ctx, countSysUserLoginLogCondition,
|
|
arg.StartAt,
|
|
arg.EndAt,
|
|
arg.Email,
|
|
arg.Username,
|
|
)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const createSysUserLoginLog = `-- name: CreateSysUserLoginLog :exec
|
|
INSERT INTO sys_user_login_log (created_at,
|
|
email,
|
|
username,
|
|
user_uuid,
|
|
is_success,
|
|
message,
|
|
referer_url,
|
|
url,
|
|
os,
|
|
ip,
|
|
browser)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
|
|
`
|
|
|
|
type CreateSysUserLoginLogParams struct {
|
|
CreatedAt time.Time `json:"created_at"`
|
|
Email string `json:"email"`
|
|
Username string `json:"username"`
|
|
UserUuid uuid.UUID `json:"user_uuid"`
|
|
IsSuccess bool `json:"is_success"`
|
|
Message string `json:"message"`
|
|
RefererUrl string `json:"referer_url"`
|
|
Url string `json:"url"`
|
|
Os string `json:"os"`
|
|
Ip string `json:"ip"`
|
|
Browser string `json:"browser"`
|
|
}
|
|
|
|
func (q *Queries) CreateSysUserLoginLog(ctx context.Context, arg *CreateSysUserLoginLogParams) error {
|
|
_, err := q.db.Exec(ctx, createSysUserLoginLog,
|
|
arg.CreatedAt,
|
|
arg.Email,
|
|
arg.Username,
|
|
arg.UserUuid,
|
|
arg.IsSuccess,
|
|
arg.Message,
|
|
arg.RefererUrl,
|
|
arg.Url,
|
|
arg.Os,
|
|
arg.Ip,
|
|
arg.Browser,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const listSysUserLoginLogCondition = `-- name: ListSysUserLoginLogCondition :many
|
|
SELECT id, created_at, email, username, user_uuid, is_success, message, referer_url, url, os, ip, browser FROM sys_user_login_log
|
|
WHERE created_at BETWEEN $1 AND $2
|
|
AND ($3::text = '' OR email ILIKE '%' || $3 || '%')
|
|
AND ($4::text = '' OR username ILIKE '%' || $4 || '%')
|
|
ORDER BY created_at DESC
|
|
OFFSET $5
|
|
LIMIT $6
|
|
`
|
|
|
|
type ListSysUserLoginLogConditionParams struct {
|
|
StartAt time.Time `json:"start_at"`
|
|
EndAt time.Time `json:"end_at"`
|
|
Email string `json:"email"`
|
|
Username string `json:"username"`
|
|
Skip int32 `json:"skip"`
|
|
Size int32 `json:"size"`
|
|
}
|
|
|
|
func (q *Queries) ListSysUserLoginLogCondition(ctx context.Context, arg *ListSysUserLoginLogConditionParams) ([]*SysUserLoginLog, error) {
|
|
rows, err := q.db.Query(ctx, listSysUserLoginLogCondition,
|
|
arg.StartAt,
|
|
arg.EndAt,
|
|
arg.Email,
|
|
arg.Username,
|
|
arg.Skip,
|
|
arg.Size,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []*SysUserLoginLog{}
|
|
for rows.Next() {
|
|
var i SysUserLoginLog
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.Email,
|
|
&i.Username,
|
|
&i.UserUuid,
|
|
&i.IsSuccess,
|
|
&i.Message,
|
|
&i.RefererUrl,
|
|
&i.Url,
|
|
&i.Os,
|
|
&i.Ip,
|
|
&i.Browser,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, &i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|