161 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			161 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Code generated by sqlc. DO NOT EDIT.
 | |
| // versions:
 | |
| //   sqlc v1.27.0
 | |
| // source: sys_audit_log.sql
 | |
| 
 | |
| package db
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 	"time"
 | |
| 
 | |
| 	"github.com/google/uuid"
 | |
| )
 | |
| 
 | |
| const countSysAuditLogCondition = `-- name: CountSysAuditLogCondition :one
 | |
| SELECT COUNT(*) FROM sys_audit_log
 | |
| WHERE created_at BETWEEN $1 AND $2
 | |
|     AND ($3::text = '' OR email ILIKE '%' || $3 || '%')
 | |
|     AND ($4::text = '' OR username ILIKE '%' || $4 || '%')
 | |
| `
 | |
| 
 | |
| type CountSysAuditLogConditionParams struct {
 | |
| 	StartAt  time.Time `json:"start_at"`
 | |
| 	EndAt    time.Time `json:"end_at"`
 | |
| 	Email    string    `json:"email"`
 | |
| 	Username string    `json:"username"`
 | |
| }
 | |
| 
 | |
| func (q *Queries) CountSysAuditLogCondition(ctx context.Context, arg *CountSysAuditLogConditionParams) (int64, error) {
 | |
| 	row := q.db.QueryRow(ctx, countSysAuditLogCondition,
 | |
| 		arg.StartAt,
 | |
| 		arg.EndAt,
 | |
| 		arg.Email,
 | |
| 		arg.Username,
 | |
| 	)
 | |
| 	var count int64
 | |
| 	err := row.Scan(&count)
 | |
| 	return count, err
 | |
| }
 | |
| 
 | |
| const createSysAuditLog = `-- name: CreateSysAuditLog :exec
 | |
| INSERT INTO sys_audit_log (created_at,
 | |
|                                 email,
 | |
|                                 username,
 | |
|                                 user_uuid,
 | |
|                                 start_at,
 | |
|                                 end_at,
 | |
|                                 duration,
 | |
|                                 url,
 | |
|                                 method,
 | |
|                                 parameters,
 | |
|                                 referer_url,
 | |
|                                 os,
 | |
|                                 ip,
 | |
|                                 browser,
 | |
|                                 remark)
 | |
| VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15)
 | |
| `
 | |
| 
 | |
| type CreateSysAuditLogParams struct {
 | |
| 	CreatedAt  time.Time `json:"created_at"`
 | |
| 	Email      string    `json:"email"`
 | |
| 	Username   string    `json:"username"`
 | |
| 	UserUuid   uuid.UUID `json:"user_uuid"`
 | |
| 	StartAt    time.Time `json:"start_at"`
 | |
| 	EndAt      time.Time `json:"end_at"`
 | |
| 	Duration   string    `json:"duration"`
 | |
| 	Url        string    `json:"url"`
 | |
| 	Method     string    `json:"method"`
 | |
| 	Parameters string    `json:"parameters"`
 | |
| 	RefererUrl string    `json:"referer_url"`
 | |
| 	Os         string    `json:"os"`
 | |
| 	Ip         string    `json:"ip"`
 | |
| 	Browser    string    `json:"browser"`
 | |
| 	Remark     string    `json:"remark"`
 | |
| }
 | |
| 
 | |
| func (q *Queries) CreateSysAuditLog(ctx context.Context, arg *CreateSysAuditLogParams) error {
 | |
| 	_, err := q.db.Exec(ctx, createSysAuditLog,
 | |
| 		arg.CreatedAt,
 | |
| 		arg.Email,
 | |
| 		arg.Username,
 | |
| 		arg.UserUuid,
 | |
| 		arg.StartAt,
 | |
| 		arg.EndAt,
 | |
| 		arg.Duration,
 | |
| 		arg.Url,
 | |
| 		arg.Method,
 | |
| 		arg.Parameters,
 | |
| 		arg.RefererUrl,
 | |
| 		arg.Os,
 | |
| 		arg.Ip,
 | |
| 		arg.Browser,
 | |
| 		arg.Remark,
 | |
| 	)
 | |
| 	return err
 | |
| }
 | |
| 
 | |
| const listSysAuditLogCondition = `-- name: ListSysAuditLogCondition :many
 | |
| SELECT id, created_at, email, username, user_uuid, start_at, end_at, duration, url, method, parameters, referer_url, os, ip, browser, remark FROM sys_audit_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 ListSysAuditLogConditionParams 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) ListSysAuditLogCondition(ctx context.Context, arg *ListSysAuditLogConditionParams) ([]*SysAuditLog, error) {
 | |
| 	rows, err := q.db.Query(ctx, listSysAuditLogCondition,
 | |
| 		arg.StartAt,
 | |
| 		arg.EndAt,
 | |
| 		arg.Email,
 | |
| 		arg.Username,
 | |
| 		arg.Skip,
 | |
| 		arg.Size,
 | |
| 	)
 | |
| 	if err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 	defer rows.Close()
 | |
| 	items := []*SysAuditLog{}
 | |
| 	for rows.Next() {
 | |
| 		var i SysAuditLog
 | |
| 		if err := rows.Scan(
 | |
| 			&i.ID,
 | |
| 			&i.CreatedAt,
 | |
| 			&i.Email,
 | |
| 			&i.Username,
 | |
| 			&i.UserUuid,
 | |
| 			&i.StartAt,
 | |
| 			&i.EndAt,
 | |
| 			&i.Duration,
 | |
| 			&i.Url,
 | |
| 			&i.Method,
 | |
| 			&i.Parameters,
 | |
| 			&i.RefererUrl,
 | |
| 			&i.Os,
 | |
| 			&i.Ip,
 | |
| 			&i.Browser,
 | |
| 			&i.Remark,
 | |
| 		); err != nil {
 | |
| 			return nil, err
 | |
| 		}
 | |
| 		items = append(items, &i)
 | |
| 	}
 | |
| 	if err := rows.Err(); err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 	return items, nil
 | |
| }
 |