152 lines
3.3 KiB
Go
152 lines
3.3 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.28.0
|
|
// source: sys_config.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const countSysConfigCondition = `-- name: CountSysConfigCondition :one
|
|
SELECT COUNT(*) FROM sys_config
|
|
WHERE ($1::text = '' OR key ILIKE '%' || $1 || '%')
|
|
`
|
|
|
|
func (q *Queries) CountSysConfigCondition(ctx context.Context, key string) (int64, error) {
|
|
row := q.db.QueryRow(ctx, countSysConfigCondition, key)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const createSysConfig = `-- name: CreateSysConfig :exec
|
|
INSERT INTO sys_config (
|
|
key,
|
|
value
|
|
) VALUES (
|
|
$1, $2
|
|
)
|
|
`
|
|
|
|
type CreateSysConfigParams struct {
|
|
Key string `json:"key"`
|
|
Value []byte `json:"value"`
|
|
}
|
|
|
|
func (q *Queries) CreateSysConfig(ctx context.Context, arg *CreateSysConfigParams) error {
|
|
_, err := q.db.Exec(ctx, createSysConfig, arg.Key, arg.Value)
|
|
return err
|
|
}
|
|
|
|
const existsSysConfigByKey = `-- name: ExistsSysConfigByKey :one
|
|
SELECT EXISTS (
|
|
SELECT 1 FROM sys_config WHERE key = $1
|
|
)
|
|
`
|
|
|
|
func (q *Queries) ExistsSysConfigByKey(ctx context.Context, key string) (bool, error) {
|
|
row := q.db.QueryRow(ctx, existsSysConfigByKey, key)
|
|
var exists bool
|
|
err := row.Scan(&exists)
|
|
return exists, err
|
|
}
|
|
|
|
const getSysConfig = `-- name: GetSysConfig :one
|
|
SELECT id, key, value, created_at, updated_at
|
|
FROM sys_config
|
|
WHERE id = $1
|
|
LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetSysConfig(ctx context.Context, id int32) (*SysConfig, error) {
|
|
row := q.db.QueryRow(ctx, getSysConfig, id)
|
|
var i SysConfig
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Key,
|
|
&i.Value,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return &i, err
|
|
}
|
|
|
|
const getSysConfigByKey = `-- name: GetSysConfigByKey :one
|
|
SELECT id, key, value, created_at, updated_at
|
|
FROM sys_config
|
|
WHERE key = $1
|
|
LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetSysConfigByKey(ctx context.Context, key string) (*SysConfig, error) {
|
|
row := q.db.QueryRow(ctx, getSysConfigByKey, key)
|
|
var i SysConfig
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Key,
|
|
&i.Value,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return &i, err
|
|
}
|
|
|
|
const listSysConfigCondition = `-- name: ListSysConfigCondition :many
|
|
SELECT id, key, value, created_at, updated_at
|
|
FROM sys_config
|
|
WHERE ($1::text = '' OR key ILIKE '%' || $1 || '%')
|
|
ORDER BY created_at DESC
|
|
OFFSET $2
|
|
LIMIT $3
|
|
`
|
|
|
|
type ListSysConfigConditionParams struct {
|
|
Key string `json:"key"`
|
|
Skip int32 `json:"skip"`
|
|
Size int32 `json:"size"`
|
|
}
|
|
|
|
func (q *Queries) ListSysConfigCondition(ctx context.Context, arg *ListSysConfigConditionParams) ([]*SysConfig, error) {
|
|
rows, err := q.db.Query(ctx, listSysConfigCondition, arg.Key, arg.Skip, arg.Size)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []*SysConfig{}
|
|
for rows.Next() {
|
|
var i SysConfig
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Key,
|
|
&i.Value,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, &i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const updateSysConfigByKey = `-- name: UpdateSysConfigByKey :exec
|
|
UPDATE sys_config
|
|
SET value = $2
|
|
WHERE key = $1
|
|
`
|
|
|
|
type UpdateSysConfigByKeyParams struct {
|
|
Key string `json:"key"`
|
|
Value []byte `json:"value"`
|
|
}
|
|
|
|
func (q *Queries) UpdateSysConfigByKey(ctx context.Context, arg *UpdateSysConfigByKeyParams) error {
|
|
_, err := q.db.Exec(ctx, updateSysConfigByKey, arg.Key, arg.Value)
|
|
return err
|
|
}
|