Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
a7386882
Commit
a7386882
authored
Apr 28, 2026
by
陈曦
Browse files
merge capture requests branch to upstream follow
parents
110702d4
55891dff
Pipeline
#82303
passed with stage
in 3 minutes and 44 seconds
Changes
56
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
REQUEST_CAPTURE_CHANGES.md
0 → 100644
View file @
a7386882
# Request/Response Capture 功能变更报告
> **功能概述:** 对指定 API Key 开启请求体与响应体的双路采集,支持数据库和 NFS 两种存储方式,
> 覆盖 Claude / OpenAI / Gemini 全部网关路径。支持通过管理员 API 动态开关,变更立即生效(缓存强制失效)。
---
## 一、数据库迁移
**文件:`backend/migrations/108_request_capture_log.sql`**
```
sql
-- api_keys 新增开关字段
ALTER
TABLE
api_keys
ADD
COLUMN
IF
NOT
EXISTS
capture_requests
boolean
NOT
NULL
DEFAULT
false
;
-- 按月分区的捕获日志表
CREATE
TABLE
IF
NOT
EXISTS
request_capture_logs
(
id
bigserial
NOT
NULL
,
api_key_id
bigint
NOT
NULL
,
user_id
bigint
NOT
NULL
,
request_id
varchar
(
64
),
path
varchar
(
100
),
method
varchar
(
10
),
ip_address
varchar
(
45
),
request_body
text
,
response_body
text
,
nfs_file_path
varchar
(
500
),
created_at
timestamptz
NOT
NULL
DEFAULT
now
(),
PRIMARY
KEY
(
id
,
created_at
)
)
PARTITION
BY
RANGE
(
created_at
);
CREATE
INDEX
IF
NOT
EXISTS
idx_rcl_api_key_created
ON
request_capture_logs
(
api_key_id
,
created_at
DESC
);
CREATE
INDEX
IF
NOT
EXISTS
idx_rcl_user_id
ON
request_capture_logs
(
user_id
);
```
预建前、当、后三个月分区,后续需定期维护新分区。
---
## 二、配置
### 2.1 `backend/internal/config/config.go`(新增结构体)
```
go
type
RequestCaptureConfig
struct
{
NFSPath
string
`mapstructure:"nfs_path"`
WorkerTimeoutSeconds
int
`mapstructure:"worker_timeout_seconds"`
}
```
### 2.2 `backend/config.yaml`(新增块)
```
yaml
request_capture
:
nfs_path
:
"
"
# 留空则跳过 NFS,仅写 DB
worker_timeout_seconds
:
5
```
### 2.3 `deploy/.env.example`(新增两行)
```
env
REQUEST_CAPTURE_NFS_PATH=
REQUEST_CAPTURE_WORKER_TIMEOUT_SECONDS=5
```
> viper 使用 `AutomaticEnv()` + `SetEnvKeyReplacer(".", "_")`,
> 环境变量 `REQUEST_CAPTURE_NFS_PATH` 自动映射到 `request_capture.nfs_path`。
---
## 三、核心服务
### 3.1 `backend/internal/service/request_capture_service.go`(全新文件)
| 方法 | 行为 |
|---|---|
|
`Capture(apiKeyID, userID, requestID, path, method, ipAddr, body)`
|
**同步**
写 DB(返回 captureID),
**异步**
写 NFS 请求文件 |
|
`CaptureResponse(captureID, responseBody)`
|
**全异步**
:更新 DB
`response_body`
+ 写 NFS 响应文件 |
|
`nfsResponseFilePath(requestPath)`
|
`xxx.json`
→
`xxx_response.json`
|
|
`writeResponseToNFS(...)`
| 写
`nfsResponseEnvelope{capture_id, created_at, body}`
|
**关键设计:**
-
`Capture()`
是
**同步**
DB 写入,保证调用方拿到 captureID 后立即可用于
`CaptureResponse()`
-
`CaptureResponse()`
是
**全异步**
(goroutine),不阻塞响应链路
-
`sync.Map`
以
`captureID`
为 key 暂存 nfsFilePath,
`LoadAndDelete`
一次性消费,避免内存泄漏
-
`captureID == 0`
时
`CaptureResponse()`
静默跳过(DB 写失败时的降级)
-
NFS 响应文件
`Body`
字段类型为
`any`
:先用
`json.Valid()`
判断——合法 JSON(非流式)用
`json.RawMessage`
保留结构,否则(流式纯文本)直接存
`string`
,避免编码失败
**NFS 文件组织结构:**
```
{nfsPath}/
└── {YYYY-MM-DD}/
└── {apiKeyID}/
├── {unixNano}_{requestID}.json ← 请求体
└── {unixNano}_{requestID}_response.json ← 响应体
```
**NFS 文件格式:**
```
json
//
请求文件
{
"api_key_id"
:
42
,
"user_id"
:
1
,
"request_id"
:
"req-xxx"
,
"created_at"
:
"2024-01-01T00:00:00Z"
,
"path"
:
"/v1/messages"
,
"method"
:
"POST"
,
"ip_address"
:
"1.2.3.4"
,
"body"
:
{
"model"
:
"claude-3-5-haiku-20241022"
,
"messages"
:
[
...
]
}
}
//
响应文件(非流式:body
为
JSON
对象;流式:body
为纯文本字符串)
{
"capture_id"
:
123
,
"created_at"
:
"2024-01-01T00:00:01Z"
,
"body"
:
{
"id"
:
"msg_xxx"
,
"content"
:
[
...
]
}
}
```
### 3.2 `backend/internal/repository/request_capture_log_repo.go`(全新文件)
```
go
Create
(
ctx
,
params
CreateRequestCaptureLogParams
)
(
int64
,
error
)
UpdateResponseBody
(
ctx
,
id
int64
,
responseBody
string
)
error
```
---
## 四、认证缓存层(关键修复)
### 4.1 问题根因
`capture_requests`
字段要在每次请求认证时读取。认证路径经过三层缓存,字段必须在每一层都正确传递,否则即使数据库更新了,运行时读到的也是旧值
`false`
。
### 4.2 `backend/internal/repository/api_key_repo.go`
**修复 1:`GetByKeyForAuth` Select 白名单补充字段**
```
go
// 之前缺失,导致认证路径查出来的字段值恒为 false
apikey
.
FieldCaptureRequests
,
// ← 新增
```
**修复 2:`Update()` 方法持久化字段**
```
go
builder
.
SetCaptureRequests
(
key
.
CaptureRequests
)
// ← 新增,否则 Update 不会写入该列
```
### 4.3 `backend/internal/service/api_key_auth_cache.go`
```
go
// APIKeyAuthSnapshot 新增字段
CaptureRequests
bool
`json:"capture_requests"`
```
### 4.4 `backend/internal/service/api_key_auth_cache_impl.go`
```
go
// 版本号从 7 升到 8,使所有旧快照(不含该字段)在 Redis 中自动失效
const
apiKeyAuthSnapshotVersion
=
8
// v8: added CaptureRequests on api key snapshot
// snapshotFromAPIKey:DB → 快照
CaptureRequests
:
apiKey
.
CaptureRequests
,
// snapshotToAPIKey:快照 → 运行时 APIKey 对象
CaptureRequests
:
snapshot
.
CaptureRequests
,
```
**缓存 TTL 参考:**
-
L1 in-memory(ristretto):15 秒
-
L2 Redis:300 秒(5 分钟)
版本号升级后,所有 Redis 中的旧快照会因版本不匹配而被丢弃,强制回源 DB。
---
## 五、Context Buffer(流式响应文本采集)
**`backend/internal/pkg/ctxkey/ctxkey.go`(新增常量)**
```
go
// ResponseCaptureBuffer 流式响应中收集 assistant 文本,供 request_capture 使用。
// 值类型为 *strings.Builder,由 handler 层注入,service 层只负责追加文本。
ResponseCaptureBuffer
Key
=
"ctx_response_capture_buffer"
```
**流式文本采集流程:**
```
1. handler 判断 apiKey.CaptureRequests && captureID > 0
↓
2. 注入 *strings.Builder 到 context(WithValue)
↓
3. service streaming handler 解析 SSE 事件
在 content_block_delta + text_delta 事件中 captureBuilder.WriteString(text)
↓
4. Forward() / forwardXxx() 读取 builder.String()
赋值给 ForwardResult.ResponseBody
↓
5. handler 在 Forward() 返回后调用 CaptureResponse(captureID, result.ResponseBody)
```
---
## 六、各端点覆盖详情
### 6.1 `POST /v1/messages` → Anthropic 账号
| 文件 | 变更 |
|---|---|
|
`handler/gateway_handler.go`
|
`Capture()`
保存 captureID;流式注入
`ResponseCaptureBuffer`
;Anthropic & Gemini success path 调用
`CaptureResponse()`
|
|
`service/gateway_service.go`
|
`ForwardResult`
新增
`ResponseBody string`
;非流式读响应字节;流式三条路径均读 context buffer |
**gateway_service.go 三条流式路径(均已覆盖):**
-
`handleStreamingResponseAnthropicAPIKeyPassthrough`
(Anthropic API Key 直传流式)
-
`handleStreamingResponseForClaude`
(OAuth 账号流式)
-
`handleNonStreamingResponseAnthropicAPIKeyPassthrough`
(Anthropic 非流式,返回签名改为
`(string, *ClaudeUsage, error)`
)
### 6.2 `POST /v1/messages` → Bedrock 账号
| 文件 | 变更 |
|---|---|
|
`service/bedrock_stream.go`
| 从 context 读取
`captureBuilder`
;在
`content_block_delta + text_delta`
中追加文本 |
|
`service/gateway_service.go`
(
`forwardBedrock`
) | 非流式使用
`handleBedrockNonStreamingResponse`
返回的 string;流式读 context buffer;
`ForwardResult.ResponseBody`
填充 |
|
`service/gateway_service.go`
(
`handleBedrockNonStreamingResponse`
) | 签名改为
`(string, *ClaudeUsage, error)`
,返回
`string(body)`
|
### 6.3 `POST /v1/messages` → Antigravity(Gemini)账号
| 文件 | 变更 |
|---|---|
|
`handler/gateway_handler.go`
| 复用 6.1 的
`captureID`
+
`CaptureResponse`
调用 |
|
`service/antigravity_gateway_service.go`
| 四条路径均已覆盖(见下) |
**antigravity_gateway_service.go 四条路径:**
| 函数 | 类型 | 采集方式 |
|---|---|---|
|
`handleClaudeStreamToNonStreaming`
| Claude→非流式输出 |
`responseBody = string(claudeResp)`
|
|
`handleClaudeStreamingResponse`
| Claude→流式输出 | 从 context buffer 读(
`candidates[0].content.parts[0].text`
) |
|
`handleGeminiStreamToNonStreaming`
| Gemini→非流式输出 |
`strings.Join(collectedTextParts, "")`
|
|
`handleGeminiStreamingResponse`
| Gemini→流式输出 | 从 context buffer 读(遍历
`candidates[0].content.parts[*].text`
) |
`streamUpstreamResponse`
函数签名新增
`ctx context.Context`
参数,两处调用点同步更新。
### 6.4 `POST /v1/messages` → GeminiMessagesCompat 账号
| 文件 | 变更 |
|---|---|
|
`handler/gateway_handler.go`
| 复用 6.1 的
`captureID`
+
`CaptureResponse`
调用 |
|
`service/gemini_messages_compat_service.go`
|
`geminiStreamResult`
新增
`responseBody string`
|
|
`handleStreamingResponse`
|
`responseBody = seenText`
(函数内已有文本累积) |
|
`handleNonStreamingResponse`
| 签名改为
`(string, *ClaudeUsage, error)`
;
`c.JSON`
改为
`json.Marshal + c.Data`
,填充
`ResponseBody`
|
|
`Forward()`
| 三条 non-streaming 子路径均填
`responseBody`
;
`ForwardResult.ResponseBody`
填充 |
### 6.5 `POST /openai/v1/chat/completions`
| 文件 | 变更 |
|---|---|
|
`handler/openai_chat_completions.go`
|
`Capture()`
+
`CaptureResponse()`
|
|
`service/openai_gateway_chat_completions.go`
| 非流式:marshal
`ccResp`
;流式:
`textBuilder`
收集
`Delta.Content`
|
### 6.6 `POST /openai/v1/responses`(Codex path)
| 文件 | 变更 |
|---|---|
|
`handler/openai_gateway_handler.go`
(
`Responses`
函数) |
`captureID`
变量声明保存返回值;success block 调用
`CaptureResponse()`
|
|
`service/gateway_forward_as_responses.go`
| 流式:
`textBuilder`
收集
`content_block_delta + text_delta`
|
### 6.7 `POST /openai/v1/responses`(Messages path)→ Anthropic 路由
| 文件 | 变更 |
|---|---|
|
`handler/openai_gateway_handler.go`
(
`Messages`
函数) |
**新增**
`captureID`
声明及
`Capture()`
调用;success block 调用
`CaptureResponse()`
|
|
`service/openai_gateway_messages.go`
(
`handleAnthropicBufferedResponse`
) |
`c.JSON`
改为
`json.Marshal + c.Data`
,填充
`ResponseBody`
|
|
`service/openai_gateway_messages.go`
(
`handleAnthropicStreamingResponse`
) | 新增
`textBuilder`
;在
`processDataLine`
中捕获
`content_block_delta + text_delta`
;
`resultWithUsage()`
加
`ResponseBody`
|
---
## 七、管理员 API(动态开关 + 缓存强制失效)
### 7.1 接口
**`PUT /api/v1/admin/api-keys/:id/capture-requests`**
```
bash
# 开启
curl
-X
PUT https://your-server/api/v1/admin/api-keys/35/capture-requests
\
-H
"Authorization: Bearer
$ADMIN_KEY
"
\
-H
"Content-Type: application/json"
\
-d
'{"enabled": true}'
# 关闭
curl
-X
PUT https://your-server/api/v1/admin/api-keys/35/capture-requests
\
-H
"Authorization: Bearer
$ADMIN_KEY
"
\
-H
"Content-Type: application/json"
\
-d
'{"enabled": false}'
```
**响应:**
```
json
{
"code"
:
0
,
"data"
:
{
"id"
:
35
,
"capture_requests"
:
true
}}
```
### 7.2 实现文件
| 文件 | 变更 |
|---|---|
|
`handler/admin/apikey_handler.go`
| 新增
`AdminSetCaptureRequestsRequest`
结构体 +
`SetCaptureRequests`
handler |
|
`service/admin_service.go`
| 接口新增
`AdminSetCaptureRequests`
;实现:
`GetByID → Update → InvalidateAuthCacheByKey`
|
|
`server/routes/admin.go`
|
`apiKeys.PUT("/:id/capture-requests", h.Admin.APIKey.SetCaptureRequests)`
|
|
`handler/admin/admin_service_stub_test.go`
| 新增 stub 实现 |
### 7.3 `AdminSetCaptureRequests` 执行流程
```
1. GetByID(keyID) ← 从 DB 读取完整 APIKey 对象
2. apiKey.CaptureRequests = enabled
3. apiKeyRepo.Update(apiKey) ← 持久化(包含 SetCaptureRequests builder 调用)
4. InvalidateAuthCacheByKey(apiKey.Key)
├─ 删除 L1 in-memory 缓存
└─ 删除 L2 Redis 缓存
```
步骤 4 确保下一条请求立即回源 DB,获取最新的
`capture_requests`
值。
### 7.4 bash 脚本(项目根目录)
**文件:`capture_requests.sh`**
```
bash
./capture_requests.sh <key_id> <on|off>
# 示例
BASE_URL
=
https://s2a-st.appbym.com
ADMIN_KEY
=
sk-xxx ./capture_requests.sh 35 on
BASE_URL
=
https://s2a-st.appbym.com
ADMIN_KEY
=
sk-xxx ./capture_requests.sh 35 off
```
支持
`on/true/1/yes`
和
`off/false/0/no`
,输出带颜色,自动用 jq 格式化 JSON。
---
## 八、端点覆盖总览
| 端点 | 协议 | 请求捕获 | 响应捕获 |
|---|---|:---:|:---:|
|
`POST /v1/messages`
→ Anthropic 账号(非流式) | Claude Direct | ✅ | ✅ |
|
`POST /v1/messages`
→ Anthropic 账号(流式) | Claude Direct | ✅ | ✅ |
|
`POST /v1/messages`
→ Bedrock 账号(非流式) | Claude via Bedrock | ✅ | ✅ |
|
`POST /v1/messages`
→ Bedrock 账号(流式) | Claude via Bedrock | ✅ | ✅ |
|
`POST /v1/messages`
→ CC 转发(非流式) | Claude → OpenAI CC | ✅ | ✅ |
|
`POST /v1/messages`
→ CC 转发(流式) | Claude → OpenAI CC | ✅ | ✅ |
|
`POST /v1/messages`
→ Antigravity 账号(非流式) | Claude → Gemini | ✅ | ✅ |
|
`POST /v1/messages`
→ Antigravity 账号(流式) | Claude → Gemini | ✅ | ✅ |
|
`POST /v1/messages`
→ GeminiCompat 账号(非流式)| Claude → Gemini | ✅ | ✅ |
|
`POST /v1/messages`
→ GeminiCompat 账号(流式) | Claude → Gemini | ✅ | ✅ |
|
`POST /openai/v1/chat/completions`
(非流式) | OpenAI CC | ✅ | ✅ |
|
`POST /openai/v1/chat/completions`
(流式) | OpenAI CC | ✅ | ✅ |
|
`POST /openai/v1/responses`
(Codex path,非流式)| OpenAI Responses | ✅ | ✅ |
|
`POST /openai/v1/responses`
(Codex path,流式) | OpenAI Responses | ✅ | ✅ |
|
`POST /openai/v1/responses`
(Messages path)| OpenAI → Anthropic | ✅ | ✅ |
---
## 九、依赖注入
**`backend/cmd/server/wire_gen.go`**
(已生成,确认包含)
```
go
requestCaptureLogRepository
:=
repository
.
NewRequestCaptureLogRepository
(
client
)
requestCaptureService
:=
service
.
NewRequestCaptureService
(
requestCaptureLogRepository
,
configConfig
)
gatewayHandler
:=
handler
.
NewGatewayHandler
(
...
,
requestCaptureService
,
...
)
openAIGatewayHandler
:=
handler
.
NewOpenAIGatewayHandler
(
...
,
requestCaptureService
,
...
)
```
---
## 十、部署检查清单
部署前确认以下事项:
-
[ ] 执行数据库迁移(
`108_request_capture_log.sql`
),确认
`api_keys.capture_requests`
列存在
-
[ ] 确认
`request_capture_logs`
分区表及当月分区已创建
-
[ ] 确认服务重启后日志中出现
`request_capture: NFS storage enabled/disabled`
-
[ ] 若需 NFS 落盘,确认环境变量
`REQUEST_CAPTURE_NFS_PATH`
已设置且目录可写
-
[ ] 部署完成后通过脚本测试管理 API:
`./capture_requests.sh <key_id> on`
---
## 十一、测试与验证
### 11.1 前置条件
```
bash
# 执行数据库迁移
psql
-U
sub2api
-d
sub2api
-f
backend/migrations/108_request_capture_log.sql
# 配置 NFS(可选,留空则只写 DB)
export
REQUEST_CAPTURE_NFS_PATH
=
/tmp/nfs_test/
# 开启测试用 Key 的采集(通过管理员 API,避免绕过缓存失效)
BASE_URL
=
http://localhost:8080
ADMIN_KEY
=
sk-admin
\
./capture_requests.sh <your_key_id> on
```
### 11.2 测试矩阵
```
bash
KEY
=
"your-capture-enabled-key"
BASE
=
"http://localhost:8080"
# Claude非流式调用
curl
-s
-X
POST
$BASE
/v1/messages
\
-H
"x-api-key:
$KEY
"
-H
"Content-Type: application/json"
\
-d
'{"model":"claude-sonnet-4-6","max_tokens":50,
"messages":[{"role":"user","content":"你到底是谁呀?"}]}'
# Claude流式调用
curl
-s
-X
POST
$BASE
/v1/messages
\
-H
"x-api-key:
$KEY
"
-H
"Content-Type: application/json"
\
-d
'{"model":"claude-sonnet-4-6","max_tokens":50,"stream":true,
"messages":[{"role":"user","content":"你用的什么模型"}]}'
# OpenAI非流式调用
curl
-X
POST
"
$BASE
/v1/chat/completions"
\
-H
"Authorization: Bearer
$KEY
"
\
-H
"Content-Type: application/json"
\
-d
'{
"model": "gpt-5.2",
"messages": [
{
"role": "user",
"content": "现在几点了"
}
],
"max_tokens": 1024
}'
# OpenAI流式调用
curl
-X
POST
"
$BASE
/v1/chat/completions"
\
-H
"Authorization: Bearer
$KEY
"
\
-H
"Content-Type: application/json"
\
-d
'{
"model": "gpt-5.2",
"messages": [
{
"role": "user",
"content": "你可以告诉我现在几点了吗"
}
],
"max_tokens": 1024,
"stream": true
}'
```
### 11.3 DB 验证
```
sql
-- 1. 请求后立即查(DB 写是同步的,应立即有记录)
SELECT
id
,
api_key_id
,
path
,
method
,
(
request_body
IS
NOT
NULL
)
AS
has_req
,
(
response_body
IS
NOT
NULL
)
AS
has_resp
,
nfs_file_path
,
created_at
FROM
request_capture_logs
ORDER
BY
created_at
DESC
LIMIT
10
;
-- 2. 约 1 秒后查响应体(CaptureResponse 是异步的)
SELECT
id
,
length
(
request_body
)
AS
req_len
,
length
(
response_body
)
AS
resp_len
,
left
(
response_body
,
100
)
AS
resp_preview
FROM
request_capture_logs
ORDER
BY
id
DESC
LIMIT
5
;
```
**预期结果:**
| 场景 | has_req | has_resp(~1s 后) | resp_preview |
|---|:---:|:---:|---|
| 非流式请求 |
`true`
|
`true`
| JSON,以
`{`
开头 |
| 流式请求 |
`true`
|
`true`
| 纯文本,如
`"Hi! How can I..."`
|
| 中文流式请求 |
`true`
|
`true`
| 中文字符(无乱码) |
| 未开启 capture_requests 的 Key | 无记录 | — | — |
### 11.4 NFS 验证(配置了 `nfs_path` 时)
```
bash
DATE
=
$(
date
+%Y-%m-%d
)
API_KEY_ID
=
<your_key_id>
NFS_DIR
=
"
${
REQUEST_CAPTURE_NFS_PATH
}
/
${
DATE
}
/
${
API_KEY_ID
}
"
# 查看文件列表(请求文件和响应文件应成对出现)
ls
-la
"
$NFS_DIR
/"
# 验证 JSON 格式
cat
"
$NFS_DIR
/"
*
.json | python3
-m
json.tool |
head
-30
# 验证中文无乱码
grep
-r
"你好"
"
$NFS_DIR
/"
&&
echo
"中文正常"
```
### 11.5 管理员 API 验证(关键:验证缓存失效是否生效)
```
bash
# 1. 开启
./capture_requests.sh 35 on
# 发一条请求,等 1 秒,查 DB 是否有记录
# 2. 关闭
./capture_requests.sh 35 off
# 再发一条请求,查 DB 新记录数不应增加
# 验证关闭生效(应无新记录)
psql
-c
"SELECT count(*) FROM request_capture_logs
WHERE api_key_id = 35 AND created_at > now() - interval '10 seconds';"
```
> **注意:** 若直接用 SQL `UPDATE api_keys SET capture_requests = false` 绕过服务层,
> 缓存不会失效,关闭最多需等 L2 Redis TTL(5 分钟)才生效。
> **必须通过管理员 API 或脚本操作,才能立即生效。**
### 11.6 负向验证
```
bash
NO_CAPTURE_KEY
=
"your-normal-key"
curl
-s
-X
POST
$BASE
/v1/messages
\
-H
"x-api-key:
$NO_CAPTURE_KEY
"
\
-H
"Content-Type: application/json"
\
-d
'{"model":"claude-3-5-haiku-20241022","max_tokens":10,
"messages":[{"role":"user","content":"hi"}]}'
```
```
sql
-- 该 key 对应的 api_key_id 不应有任何记录
SELECT
count
(
*
)
FROM
request_capture_logs
WHERE
api_key_id
=
<
no_capture_key_id
>
;
-- 预期:0
```
---
## 十二、已知限制与边界行为
| 场景 | 行为 |
|---|---|
| DB 写 request 失败 |
`captureID = 0`
,后续
`CaptureResponse`
自动跳过,请求正常返回 |
| DB 写 response 失败 | 记录 error 日志,请求已正常返回,不影响用户 |
| NFS 目录不存在 |
`MkdirAll`
自动创建;失败则 error 日志,不影响 DB 写入 |
| 流式请求客户端中途断开 | buffer 内已采集的文本会被写入,响应体为截断内容(属预期行为) |
|
`captureID`
对应
`CaptureResponse`
从未被调用 |
`sync.Map`
中的条目滞留,但量级等同于并发请求数,可忽略 |
| 直接 SQL 修改
`capture_requests`
字段 | 缓存不失效,最多等 5 分钟(Redis TTL)才生效;
**应通过管理 API 操作**
|
| 流式纯文本响应写入 NFS |
`json.Valid()`
判断后以 string 类型存入
`body`
字段,不会引起编码错误 |
| 中文字符 |
`json.Encoder`
设置
`SetEscapeHTML(false)`
,中文原样存储,不转义为
`\uXXXX`
|
backend/cmd/server/wire_gen.go
View file @
a7386882
...
...
@@ -234,10 +234,12 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
affiliateHandler
:=
admin
.
NewAffiliateHandler
(
affiliateService
,
adminService
)
adminHandlers
:=
handler
.
ProvideAdminHandlers
(
dashboardHandler
,
adminUserHandler
,
groupHandler
,
accountHandler
,
adminAnnouncementHandler
,
dataManagementHandler
,
backupHandler
,
oAuthHandler
,
openAIOAuthHandler
,
geminiOAuthHandler
,
antigravityOAuthHandler
,
proxyHandler
,
adminRedeemHandler
,
promoHandler
,
settingHandler
,
opsHandler
,
systemHandler
,
adminSubscriptionHandler
,
adminUsageHandler
,
userAttributeHandler
,
errorPassthroughHandler
,
tlsFingerprintProfileHandler
,
adminAPIKeyHandler
,
scheduledTestHandler
,
channelHandler
,
channelMonitorHandler
,
channelMonitorRequestTemplateHandler
,
paymentHandler
,
affiliateHandler
)
usageRecordWorkerPool
:=
service
.
NewUsageRecordWorkerPool
(
configConfig
)
requestCaptureLogRepository
:=
repository
.
NewRequestCaptureLogRepository
(
client
)
requestCaptureService
:=
service
.
NewRequestCaptureService
(
requestCaptureLogRepository
,
configConfig
)
userMsgQueueCache
:=
repository
.
NewUserMsgQueueCache
(
redisClient
)
userMessageQueueService
:=
service
.
ProvideUserMessageQueueService
(
userMsgQueueCache
,
rpmCache
,
configConfig
)
gatewayHandler
:=
handler
.
NewGatewayHandler
(
gatewayService
,
geminiMessagesCompatService
,
antigravityGatewayService
,
userService
,
concurrencyService
,
billingCacheService
,
usageService
,
apiKeyService
,
usageRecordWorkerPool
,
errorPassthroughService
,
userMessageQueueService
,
configConfig
,
settingService
)
openAIGatewayHandler
:=
handler
.
NewOpenAIGatewayHandler
(
openAIGatewayService
,
concurrencyService
,
billingCacheService
,
apiKeyService
,
usageRecordWorkerPool
,
errorPassthroughService
,
configConfig
)
gatewayHandler
:=
handler
.
NewGatewayHandler
(
gatewayService
,
geminiMessagesCompatService
,
antigravityGatewayService
,
userService
,
concurrencyService
,
billingCacheService
,
usageService
,
apiKeyService
,
usageRecordWorkerPool
,
errorPassthroughService
,
requestCaptureService
,
userMessageQueueService
,
configConfig
,
settingService
)
openAIGatewayHandler
:=
handler
.
NewOpenAIGatewayHandler
(
openAIGatewayService
,
concurrencyService
,
billingCacheService
,
apiKeyService
,
usageRecordWorkerPool
,
errorPassthroughService
,
requestCaptureService
,
configConfig
)
handlerSettingHandler
:=
handler
.
ProvideSettingHandler
(
settingService
,
buildInfo
)
totpHandler
:=
handler
.
NewTotpHandler
(
totpService
)
handlerPaymentHandler
:=
handler
.
NewPaymentHandler
(
paymentService
,
paymentConfigService
,
channelService
)
...
...
backend/ent/apikey.go
View file @
a7386882
...
...
@@ -66,6 +66,8 @@ type APIKey struct {
Window1dStart
*
time
.
Time
`json:"window_1d_start,omitempty"`
// Start time of the current 7d rate limit window
Window7dStart
*
time
.
Time
`json:"window_7d_start,omitempty"`
// 是否对该 API Key 的请求体进行存储捕获
CaptureRequests
bool
`json:"capture_requests,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the APIKeyQuery when eager-loading is set.
Edges
APIKeyEdges
`json:"edges"`
...
...
@@ -123,6 +125,8 @@ func (*APIKey) scanValues(columns []string) ([]any, error) {
switch
columns
[
i
]
{
case
apikey
.
FieldIPWhitelist
,
apikey
.
FieldIPBlacklist
:
values
[
i
]
=
new
([]
byte
)
case
apikey
.
FieldCaptureRequests
:
values
[
i
]
=
new
(
sql
.
NullBool
)
case
apikey
.
FieldQuota
,
apikey
.
FieldQuotaUsed
,
apikey
.
FieldRateLimit5h
,
apikey
.
FieldRateLimit1d
,
apikey
.
FieldRateLimit7d
,
apikey
.
FieldUsage5h
,
apikey
.
FieldUsage1d
,
apikey
.
FieldUsage7d
:
values
[
i
]
=
new
(
sql
.
NullFloat64
)
case
apikey
.
FieldID
,
apikey
.
FieldUserID
,
apikey
.
FieldGroupID
:
...
...
@@ -301,6 +305,12 @@ func (_m *APIKey) assignValues(columns []string, values []any) error {
_m
.
Window7dStart
=
new
(
time
.
Time
)
*
_m
.
Window7dStart
=
value
.
Time
}
case
apikey
.
FieldCaptureRequests
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullBool
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field capture_requests"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
CaptureRequests
=
value
.
Bool
}
default
:
_m
.
selectValues
.
Set
(
columns
[
i
],
values
[
i
])
}
...
...
@@ -434,6 +444,9 @@ func (_m *APIKey) String() string {
builder
.
WriteString
(
"window_7d_start="
)
builder
.
WriteString
(
v
.
Format
(
time
.
ANSIC
))
}
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"capture_requests="
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
_m
.
CaptureRequests
))
builder
.
WriteByte
(
')'
)
return
builder
.
String
()
}
...
...
backend/ent/apikey/apikey.go
View file @
a7386882
...
...
@@ -61,6 +61,8 @@ const (
FieldWindow1dStart
=
"window_1d_start"
// FieldWindow7dStart holds the string denoting the window_7d_start field in the database.
FieldWindow7dStart
=
"window_7d_start"
// FieldCaptureRequests holds the string denoting the capture_requests field in the database.
FieldCaptureRequests
=
"capture_requests"
// EdgeUser holds the string denoting the user edge name in mutations.
EdgeUser
=
"user"
// EdgeGroup holds the string denoting the group edge name in mutations.
...
...
@@ -118,6 +120,7 @@ var Columns = []string{
FieldWindow5hStart
,
FieldWindow1dStart
,
FieldWindow7dStart
,
FieldCaptureRequests
,
}
// ValidColumn reports if the column name is valid (part of the table columns).
...
...
@@ -168,6 +171,8 @@ var (
DefaultUsage1d
float64
// DefaultUsage7d holds the default value on creation for the "usage_7d" field.
DefaultUsage7d
float64
// DefaultCaptureRequests holds the default value on creation for the "capture_requests" field.
DefaultCaptureRequests
bool
)
// OrderOption defines the ordering options for the APIKey queries.
...
...
@@ -283,6 +288,11 @@ func ByWindow7dStart(opts ...sql.OrderTermOption) OrderOption {
return
sql
.
OrderByField
(
FieldWindow7dStart
,
opts
...
)
.
ToFunc
()
}
// ByCaptureRequests orders the results by the capture_requests field.
func
ByCaptureRequests
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldCaptureRequests
,
opts
...
)
.
ToFunc
()
}
// ByUserField orders the results by user field.
func
ByUserField
(
field
string
,
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
func
(
s
*
sql
.
Selector
)
{
...
...
backend/ent/apikey/where.go
View file @
a7386882
...
...
@@ -160,6 +160,11 @@ func Window7dStart(v time.Time) predicate.APIKey {
return
predicate
.
APIKey
(
sql
.
FieldEQ
(
FieldWindow7dStart
,
v
))
}
// CaptureRequests applies equality check predicate on the "capture_requests" field. It's identical to CaptureRequestsEQ.
func
CaptureRequests
(
v
bool
)
predicate
.
APIKey
{
return
predicate
.
APIKey
(
sql
.
FieldEQ
(
FieldCaptureRequests
,
v
))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func
CreatedAtEQ
(
v
time
.
Time
)
predicate
.
APIKey
{
return
predicate
.
APIKey
(
sql
.
FieldEQ
(
FieldCreatedAt
,
v
))
...
...
@@ -1125,6 +1130,16 @@ func Window7dStartNotNil() predicate.APIKey {
return
predicate
.
APIKey
(
sql
.
FieldNotNull
(
FieldWindow7dStart
))
}
// CaptureRequestsEQ applies the EQ predicate on the "capture_requests" field.
func
CaptureRequestsEQ
(
v
bool
)
predicate
.
APIKey
{
return
predicate
.
APIKey
(
sql
.
FieldEQ
(
FieldCaptureRequests
,
v
))
}
// CaptureRequestsNEQ applies the NEQ predicate on the "capture_requests" field.
func
CaptureRequestsNEQ
(
v
bool
)
predicate
.
APIKey
{
return
predicate
.
APIKey
(
sql
.
FieldNEQ
(
FieldCaptureRequests
,
v
))
}
// HasUser applies the HasEdge predicate on the "user" edge.
func
HasUser
()
predicate
.
APIKey
{
return
predicate
.
APIKey
(
func
(
s
*
sql
.
Selector
)
{
...
...
backend/ent/apikey_create.go
View file @
a7386882
...
...
@@ -307,6 +307,20 @@ func (_c *APIKeyCreate) SetNillableWindow7dStart(v *time.Time) *APIKeyCreate {
return
_c
}
// SetCaptureRequests sets the "capture_requests" field.
func
(
_c
*
APIKeyCreate
)
SetCaptureRequests
(
v
bool
)
*
APIKeyCreate
{
_c
.
mutation
.
SetCaptureRequests
(
v
)
return
_c
}
// SetNillableCaptureRequests sets the "capture_requests" field if the given value is not nil.
func
(
_c
*
APIKeyCreate
)
SetNillableCaptureRequests
(
v
*
bool
)
*
APIKeyCreate
{
if
v
!=
nil
{
_c
.
SetCaptureRequests
(
*
v
)
}
return
_c
}
// SetUser sets the "user" edge to the User entity.
func
(
_c
*
APIKeyCreate
)
SetUser
(
v
*
User
)
*
APIKeyCreate
{
return
_c
.
SetUserID
(
v
.
ID
)
...
...
@@ -419,6 +433,10 @@ func (_c *APIKeyCreate) defaults() error {
v
:=
apikey
.
DefaultUsage7d
_c
.
mutation
.
SetUsage7d
(
v
)
}
if
_
,
ok
:=
_c
.
mutation
.
CaptureRequests
();
!
ok
{
v
:=
apikey
.
DefaultCaptureRequests
_c
.
mutation
.
SetCaptureRequests
(
v
)
}
return
nil
}
...
...
@@ -481,6 +499,9 @@ func (_c *APIKeyCreate) check() error {
if
_
,
ok
:=
_c
.
mutation
.
Usage7d
();
!
ok
{
return
&
ValidationError
{
Name
:
"usage_7d"
,
err
:
errors
.
New
(
`ent: missing required field "APIKey.usage_7d"`
)}
}
if
_
,
ok
:=
_c
.
mutation
.
CaptureRequests
();
!
ok
{
return
&
ValidationError
{
Name
:
"capture_requests"
,
err
:
errors
.
New
(
`ent: missing required field "APIKey.capture_requests"`
)}
}
if
len
(
_c
.
mutation
.
UserIDs
())
==
0
{
return
&
ValidationError
{
Name
:
"user"
,
err
:
errors
.
New
(
`ent: missing required edge "APIKey.user"`
)}
}
...
...
@@ -595,6 +616,10 @@ func (_c *APIKeyCreate) createSpec() (*APIKey, *sqlgraph.CreateSpec) {
_spec
.
SetField
(
apikey
.
FieldWindow7dStart
,
field
.
TypeTime
,
value
)
_node
.
Window7dStart
=
&
value
}
if
value
,
ok
:=
_c
.
mutation
.
CaptureRequests
();
ok
{
_spec
.
SetField
(
apikey
.
FieldCaptureRequests
,
field
.
TypeBool
,
value
)
_node
.
CaptureRequests
=
value
}
if
nodes
:=
_c
.
mutation
.
UserIDs
();
len
(
nodes
)
>
0
{
edge
:=
&
sqlgraph
.
EdgeSpec
{
Rel
:
sqlgraph
.
M2O
,
...
...
@@ -1063,6 +1088,18 @@ func (u *APIKeyUpsert) ClearWindow7dStart() *APIKeyUpsert {
return
u
}
// SetCaptureRequests sets the "capture_requests" field.
func
(
u
*
APIKeyUpsert
)
SetCaptureRequests
(
v
bool
)
*
APIKeyUpsert
{
u
.
Set
(
apikey
.
FieldCaptureRequests
,
v
)
return
u
}
// UpdateCaptureRequests sets the "capture_requests" field to the value that was provided on create.
func
(
u
*
APIKeyUpsert
)
UpdateCaptureRequests
()
*
APIKeyUpsert
{
u
.
SetExcluded
(
apikey
.
FieldCaptureRequests
)
return
u
}
// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
...
...
@@ -1535,6 +1572,20 @@ func (u *APIKeyUpsertOne) ClearWindow7dStart() *APIKeyUpsertOne {
})
}
// SetCaptureRequests sets the "capture_requests" field.
func
(
u
*
APIKeyUpsertOne
)
SetCaptureRequests
(
v
bool
)
*
APIKeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
APIKeyUpsert
)
{
s
.
SetCaptureRequests
(
v
)
})
}
// UpdateCaptureRequests sets the "capture_requests" field to the value that was provided on create.
func
(
u
*
APIKeyUpsertOne
)
UpdateCaptureRequests
()
*
APIKeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
APIKeyUpsert
)
{
s
.
UpdateCaptureRequests
()
})
}
// Exec executes the query.
func
(
u
*
APIKeyUpsertOne
)
Exec
(
ctx
context
.
Context
)
error
{
if
len
(
u
.
create
.
conflict
)
==
0
{
...
...
@@ -2173,6 +2224,20 @@ func (u *APIKeyUpsertBulk) ClearWindow7dStart() *APIKeyUpsertBulk {
})
}
// SetCaptureRequests sets the "capture_requests" field.
func
(
u
*
APIKeyUpsertBulk
)
SetCaptureRequests
(
v
bool
)
*
APIKeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
APIKeyUpsert
)
{
s
.
SetCaptureRequests
(
v
)
})
}
// UpdateCaptureRequests sets the "capture_requests" field to the value that was provided on create.
func
(
u
*
APIKeyUpsertBulk
)
UpdateCaptureRequests
()
*
APIKeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
APIKeyUpsert
)
{
s
.
UpdateCaptureRequests
()
})
}
// Exec executes the query.
func
(
u
*
APIKeyUpsertBulk
)
Exec
(
ctx
context
.
Context
)
error
{
if
u
.
create
.
err
!=
nil
{
...
...
backend/ent/apikey_update.go
View file @
a7386882
...
...
@@ -438,6 +438,20 @@ func (_u *APIKeyUpdate) ClearWindow7dStart() *APIKeyUpdate {
return
_u
}
// SetCaptureRequests sets the "capture_requests" field.
func
(
_u
*
APIKeyUpdate
)
SetCaptureRequests
(
v
bool
)
*
APIKeyUpdate
{
_u
.
mutation
.
SetCaptureRequests
(
v
)
return
_u
}
// SetNillableCaptureRequests sets the "capture_requests" field if the given value is not nil.
func
(
_u
*
APIKeyUpdate
)
SetNillableCaptureRequests
(
v
*
bool
)
*
APIKeyUpdate
{
if
v
!=
nil
{
_u
.
SetCaptureRequests
(
*
v
)
}
return
_u
}
// SetUser sets the "user" edge to the User entity.
func
(
_u
*
APIKeyUpdate
)
SetUser
(
v
*
User
)
*
APIKeyUpdate
{
return
_u
.
SetUserID
(
v
.
ID
)
...
...
@@ -696,6 +710,9 @@ func (_u *APIKeyUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if
_u
.
mutation
.
Window7dStartCleared
()
{
_spec
.
ClearField
(
apikey
.
FieldWindow7dStart
,
field
.
TypeTime
)
}
if
value
,
ok
:=
_u
.
mutation
.
CaptureRequests
();
ok
{
_spec
.
SetField
(
apikey
.
FieldCaptureRequests
,
field
.
TypeBool
,
value
)
}
if
_u
.
mutation
.
UserCleared
()
{
edge
:=
&
sqlgraph
.
EdgeSpec
{
Rel
:
sqlgraph
.
M2O
,
...
...
@@ -1225,6 +1242,20 @@ func (_u *APIKeyUpdateOne) ClearWindow7dStart() *APIKeyUpdateOne {
return
_u
}
// SetCaptureRequests sets the "capture_requests" field.
func
(
_u
*
APIKeyUpdateOne
)
SetCaptureRequests
(
v
bool
)
*
APIKeyUpdateOne
{
_u
.
mutation
.
SetCaptureRequests
(
v
)
return
_u
}
// SetNillableCaptureRequests sets the "capture_requests" field if the given value is not nil.
func
(
_u
*
APIKeyUpdateOne
)
SetNillableCaptureRequests
(
v
*
bool
)
*
APIKeyUpdateOne
{
if
v
!=
nil
{
_u
.
SetCaptureRequests
(
*
v
)
}
return
_u
}
// SetUser sets the "user" edge to the User entity.
func
(
_u
*
APIKeyUpdateOne
)
SetUser
(
v
*
User
)
*
APIKeyUpdateOne
{
return
_u
.
SetUserID
(
v
.
ID
)
...
...
@@ -1513,6 +1544,9 @@ func (_u *APIKeyUpdateOne) sqlSave(ctx context.Context) (_node *APIKey, err erro
if
_u
.
mutation
.
Window7dStartCleared
()
{
_spec
.
ClearField
(
apikey
.
FieldWindow7dStart
,
field
.
TypeTime
)
}
if
value
,
ok
:=
_u
.
mutation
.
CaptureRequests
();
ok
{
_spec
.
SetField
(
apikey
.
FieldCaptureRequests
,
field
.
TypeBool
,
value
)
}
if
_u
.
mutation
.
UserCleared
()
{
edge
:=
&
sqlgraph
.
EdgeSpec
{
Rel
:
sqlgraph
.
M2O
,
...
...
backend/ent/client.go
View file @
a7386882
...
...
@@ -38,6 +38,7 @@ import (
"github.com/Wei-Shaw/sub2api/ent/promocodeusage"
"github.com/Wei-Shaw/sub2api/ent/proxy"
"github.com/Wei-Shaw/sub2api/ent/redeemcode"
"github.com/Wei-Shaw/sub2api/ent/requestcapturelog"
"github.com/Wei-Shaw/sub2api/ent/securitysecret"
"github.com/Wei-Shaw/sub2api/ent/setting"
"github.com/Wei-Shaw/sub2api/ent/subscriptionplan"
...
...
@@ -104,6 +105,8 @@ type Client struct {
Proxy *ProxyClient
// RedeemCode is the client for interacting with the RedeemCode builders.
RedeemCode *RedeemCodeClient
// RequestCaptureLog is the client for interacting with the RequestCaptureLog builders.
RequestCaptureLog *RequestCaptureLogClient
// SecuritySecret is the client for interacting with the SecuritySecret builders.
SecuritySecret *SecuritySecretClient
// Setting is the client for interacting with the Setting builders.
...
...
@@ -160,6 +163,7 @@ func (c *Client) init() {
c.PromoCodeUsage = NewPromoCodeUsageClient(c.config)
c.Proxy = NewProxyClient(c.config)
c.RedeemCode = NewRedeemCodeClient(c.config)
c.RequestCaptureLog = NewRequestCaptureLogClient(c.config)
c.SecuritySecret = NewSecuritySecretClient(c.config)
c.Setting = NewSettingClient(c.config)
c.SubscriptionPlan = NewSubscriptionPlanClient(c.config)
...
...
@@ -286,6 +290,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
PromoCodeUsage: NewPromoCodeUsageClient(cfg),
Proxy: NewProxyClient(cfg),
RedeemCode: NewRedeemCodeClient(cfg),
RequestCaptureLog: NewRequestCaptureLogClient(cfg),
SecuritySecret: NewSecuritySecretClient(cfg),
Setting: NewSettingClient(cfg),
SubscriptionPlan: NewSubscriptionPlanClient(cfg),
...
...
@@ -339,6 +344,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
PromoCodeUsage: NewPromoCodeUsageClient(cfg),
Proxy: NewProxyClient(cfg),
RedeemCode: NewRedeemCodeClient(cfg),
RequestCaptureLog: NewRequestCaptureLogClient(cfg),
SecuritySecret: NewSecuritySecretClient(cfg),
Setting: NewSettingClient(cfg),
SubscriptionPlan: NewSubscriptionPlanClient(cfg),
...
...
@@ -386,6 +392,7 @@ func (c *Client) Use(hooks ...Hook) {
c.IdempotencyRecord, c.IdentityAdoptionDecision, c.PaymentAuditLog,
c.PaymentOrder, c.PaymentProviderInstance, c.PendingAuthSession, c.PromoCode,
c.PromoCodeUsage, c.Proxy, c.RedeemCode, c.SecuritySecret, c.Setting,
c.Proxy, c.RedeemCode, c.RequestCaptureLog, c.SecuritySecret, c.Setting,
c.SubscriptionPlan, c.TLSFingerprintProfile, c.UsageCleanupTask, c.UsageLog,
c.User, c.UserAllowedGroup, c.UserAttributeDefinition, c.UserAttributeValue,
c.UserSubscription,
...
...
@@ -404,6 +411,7 @@ func (c *Client) Intercept(interceptors ...Interceptor) {
c.ChannelMonitorRequestTemplate, c.ErrorPassthroughRule, c.Group,
c.IdempotencyRecord, c.IdentityAdoptionDecision, c.PaymentAuditLog,
c.PaymentOrder, c.PaymentProviderInstance, c.PendingAuthSession, c.PromoCode,
c.Proxy, c.RedeemCode, c.RequestCaptureLog, c.SecuritySecret, c.Setting,
c.PromoCodeUsage, c.Proxy, c.RedeemCode, c.SecuritySecret, c.Setting,
c.SubscriptionPlan, c.TLSFingerprintProfile, c.UsageCleanupTask, c.UsageLog,
c.User, c.UserAllowedGroup, c.UserAttributeDefinition, c.UserAttributeValue,
...
...
@@ -462,6 +470,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
return c.Proxy.mutate(ctx, m)
case *RedeemCodeMutation:
return c.RedeemCode.mutate(ctx, m)
case *RequestCaptureLogMutation:
return c.RequestCaptureLog.mutate(ctx, m)
case *SecuritySecretMutation:
return c.SecuritySecret.mutate(ctx, m)
case *SettingMutation:
...
...
@@ -4163,6 +4173,139 @@ func (c *RedeemCodeClient) mutate(ctx context.Context, m *RedeemCodeMutation) (V
}
}
// RequestCaptureLogClient is a client for the RequestCaptureLog schema.
type RequestCaptureLogClient struct {
config
}
// NewRequestCaptureLogClient returns a client for the RequestCaptureLog from the given config.
func NewRequestCaptureLogClient(c config) *RequestCaptureLogClient {
return &RequestCaptureLogClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `requestcapturelog.Hooks(f(g(h())))`.
func (c *RequestCaptureLogClient) Use(hooks ...Hook) {
c.hooks.RequestCaptureLog = append(c.hooks.RequestCaptureLog, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `requestcapturelog.Intercept(f(g(h())))`.
func (c *RequestCaptureLogClient) Intercept(interceptors ...Interceptor) {
c.inters.RequestCaptureLog = append(c.inters.RequestCaptureLog, interceptors...)
}
// Create returns a builder for creating a RequestCaptureLog entity.
func (c *RequestCaptureLogClient) Create() *RequestCaptureLogCreate {
mutation := newRequestCaptureLogMutation(c.config, OpCreate)
return &RequestCaptureLogCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of RequestCaptureLog entities.
func (c *RequestCaptureLogClient) CreateBulk(builders ...*RequestCaptureLogCreate) *RequestCaptureLogCreateBulk {
return &RequestCaptureLogCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *RequestCaptureLogClient) MapCreateBulk(slice any, setFunc func(*RequestCaptureLogCreate, int)) *RequestCaptureLogCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &RequestCaptureLogCreateBulk{err: fmt.Errorf("calling to RequestCaptureLogClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*RequestCaptureLogCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &RequestCaptureLogCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for RequestCaptureLog.
func (c *RequestCaptureLogClient) Update() *RequestCaptureLogUpdate {
mutation := newRequestCaptureLogMutation(c.config, OpUpdate)
return &RequestCaptureLogUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *RequestCaptureLogClient) UpdateOne(_m *RequestCaptureLog) *RequestCaptureLogUpdateOne {
mutation := newRequestCaptureLogMutation(c.config, OpUpdateOne, withRequestCaptureLog(_m))
return &RequestCaptureLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *RequestCaptureLogClient) UpdateOneID(id int64) *RequestCaptureLogUpdateOne {
mutation := newRequestCaptureLogMutation(c.config, OpUpdateOne, withRequestCaptureLogID(id))
return &RequestCaptureLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for RequestCaptureLog.
func (c *RequestCaptureLogClient) Delete() *RequestCaptureLogDelete {
mutation := newRequestCaptureLogMutation(c.config, OpDelete)
return &RequestCaptureLogDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *RequestCaptureLogClient) DeleteOne(_m *RequestCaptureLog) *RequestCaptureLogDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *RequestCaptureLogClient) DeleteOneID(id int64) *RequestCaptureLogDeleteOne {
builder := c.Delete().Where(requestcapturelog.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &RequestCaptureLogDeleteOne{builder}
}
// Query returns a query builder for RequestCaptureLog.
func (c *RequestCaptureLogClient) Query() *RequestCaptureLogQuery {
return &RequestCaptureLogQuery{
config: c.config,
ctx: &QueryContext{Type: TypeRequestCaptureLog},
inters: c.Interceptors(),
}
}
// Get returns a RequestCaptureLog entity by its id.
func (c *RequestCaptureLogClient) Get(ctx context.Context, id int64) (*RequestCaptureLog, error) {
return c.Query().Where(requestcapturelog.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *RequestCaptureLogClient) GetX(ctx context.Context, id int64) *RequestCaptureLog {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *RequestCaptureLogClient) Hooks() []Hook {
return c.hooks.RequestCaptureLog
}
// Interceptors returns the client interceptors.
func (c *RequestCaptureLogClient) Interceptors() []Interceptor {
return c.inters.RequestCaptureLog
}
func (c *RequestCaptureLogClient) mutate(ctx context.Context, m *RequestCaptureLogMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&RequestCaptureLogCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&RequestCaptureLogUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&RequestCaptureLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&RequestCaptureLogDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown RequestCaptureLog mutation op: %q", m.Op())
}
}
// SecuritySecretClient is a client for the SecuritySecret schema.
type SecuritySecretClient struct {
config
...
...
@@ -6023,7 +6166,7 @@ type (
ChannelMonitorHistory, ChannelMonitorRequestTemplate, ErrorPassthroughRule,
Group, IdempotencyRecord, IdentityAdoptionDecision, PaymentAuditLog,
PaymentOrder, PaymentProviderInstance, PendingAuthSession, PromoCode,
PromoCodeUsage
,
Proxy
,
RedeemCode
,
SecuritySecret
,
Setting
,
SubscriptionPlan
,
PromoCodeUsage, Proxy, RedeemCode,
RequestCaptureLog,
SecuritySecret, Setting, SubscriptionPlan,
TLSFingerprintProfile, UsageCleanupTask, UsageLog, User, UserAllowedGroup,
UserAttributeDefinition, UserAttributeValue, UserSubscription []ent.Hook
}
...
...
@@ -6033,7 +6176,7 @@ type (
ChannelMonitorHistory, ChannelMonitorRequestTemplate, ErrorPassthroughRule,
Group, IdempotencyRecord, IdentityAdoptionDecision, PaymentAuditLog,
PaymentOrder, PaymentProviderInstance, PendingAuthSession, PromoCode,
PromoCodeUsage
,
Proxy
,
RedeemCode
,
SecuritySecret
,
Setting
,
SubscriptionPlan
,
PromoCodeUsage, Proxy, RedeemCode,
RequestCaptureLog,
SecuritySecret, Setting, SubscriptionPlan,
TLSFingerprintProfile, UsageCleanupTask, UsageLog, User, UserAllowedGroup,
UserAttributeDefinition, UserAttributeValue, UserSubscription []ent.Interceptor
}
...
...
backend/ent/ent.go
View file @
a7386882
...
...
@@ -35,6 +35,7 @@ import (
"github.com/Wei-Shaw/sub2api/ent/promocodeusage"
"github.com/Wei-Shaw/sub2api/ent/proxy"
"github.com/Wei-Shaw/sub2api/ent/redeemcode"
"github.com/Wei-Shaw/sub2api/ent/requestcapturelog"
"github.com/Wei-Shaw/sub2api/ent/securitysecret"
"github.com/Wei-Shaw/sub2api/ent/setting"
"github.com/Wei-Shaw/sub2api/ent/subscriptionplan"
...
...
@@ -129,6 +130,7 @@ func checkColumn(t, c string) error {
promocodeusage
.
Table
:
promocodeusage
.
ValidColumn
,
proxy
.
Table
:
proxy
.
ValidColumn
,
redeemcode
.
Table
:
redeemcode
.
ValidColumn
,
requestcapturelog
.
Table
:
requestcapturelog
.
ValidColumn
,
securitysecret
.
Table
:
securitysecret
.
ValidColumn
,
setting
.
Table
:
setting
.
ValidColumn
,
subscriptionplan
.
Table
:
subscriptionplan
.
ValidColumn
,
...
...
backend/ent/hook/hook.go
View file @
a7386882
...
...
@@ -285,6 +285,18 @@ func (f RedeemCodeFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value,
return
nil
,
fmt
.
Errorf
(
"unexpected mutation type %T. expect *ent.RedeemCodeMutation"
,
m
)
}
// The RequestCaptureLogFunc type is an adapter to allow the use of ordinary
// function as RequestCaptureLog mutator.
type
RequestCaptureLogFunc
func
(
context
.
Context
,
*
ent
.
RequestCaptureLogMutation
)
(
ent
.
Value
,
error
)
// Mutate calls f(ctx, m).
func
(
f
RequestCaptureLogFunc
)
Mutate
(
ctx
context
.
Context
,
m
ent
.
Mutation
)
(
ent
.
Value
,
error
)
{
if
mv
,
ok
:=
m
.
(
*
ent
.
RequestCaptureLogMutation
);
ok
{
return
f
(
ctx
,
mv
)
}
return
nil
,
fmt
.
Errorf
(
"unexpected mutation type %T. expect *ent.RequestCaptureLogMutation"
,
m
)
}
// The SecuritySecretFunc type is an adapter to allow the use of ordinary
// function as SecuritySecret mutator.
type
SecuritySecretFunc
func
(
context
.
Context
,
*
ent
.
SecuritySecretMutation
)
(
ent
.
Value
,
error
)
...
...
backend/ent/intercept/intercept.go
View file @
a7386882
...
...
@@ -32,6 +32,7 @@ import (
"github.com/Wei-Shaw/sub2api/ent/promocodeusage"
"github.com/Wei-Shaw/sub2api/ent/proxy"
"github.com/Wei-Shaw/sub2api/ent/redeemcode"
"github.com/Wei-Shaw/sub2api/ent/requestcapturelog"
"github.com/Wei-Shaw/sub2api/ent/securitysecret"
"github.com/Wei-Shaw/sub2api/ent/setting"
"github.com/Wei-Shaw/sub2api/ent/subscriptionplan"
...
...
@@ -722,6 +723,33 @@ func (f TraverseRedeemCode) Traverse(ctx context.Context, q ent.Query) error {
return
fmt
.
Errorf
(
"unexpected query type %T. expect *ent.RedeemCodeQuery"
,
q
)
}
// The RequestCaptureLogFunc type is an adapter to allow the use of ordinary function as a Querier.
type
RequestCaptureLogFunc
func
(
context
.
Context
,
*
ent
.
RequestCaptureLogQuery
)
(
ent
.
Value
,
error
)
// Query calls f(ctx, q).
func
(
f
RequestCaptureLogFunc
)
Query
(
ctx
context
.
Context
,
q
ent
.
Query
)
(
ent
.
Value
,
error
)
{
if
q
,
ok
:=
q
.
(
*
ent
.
RequestCaptureLogQuery
);
ok
{
return
f
(
ctx
,
q
)
}
return
nil
,
fmt
.
Errorf
(
"unexpected query type %T. expect *ent.RequestCaptureLogQuery"
,
q
)
}
// The TraverseRequestCaptureLog type is an adapter to allow the use of ordinary function as Traverser.
type
TraverseRequestCaptureLog
func
(
context
.
Context
,
*
ent
.
RequestCaptureLogQuery
)
error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func
(
f
TraverseRequestCaptureLog
)
Intercept
(
next
ent
.
Querier
)
ent
.
Querier
{
return
next
}
// Traverse calls f(ctx, q).
func
(
f
TraverseRequestCaptureLog
)
Traverse
(
ctx
context
.
Context
,
q
ent
.
Query
)
error
{
if
q
,
ok
:=
q
.
(
*
ent
.
RequestCaptureLogQuery
);
ok
{
return
f
(
ctx
,
q
)
}
return
fmt
.
Errorf
(
"unexpected query type %T. expect *ent.RequestCaptureLogQuery"
,
q
)
}
// The SecuritySecretFunc type is an adapter to allow the use of ordinary function as a Querier.
type
SecuritySecretFunc
func
(
context
.
Context
,
*
ent
.
SecuritySecretQuery
)
(
ent
.
Value
,
error
)
...
...
@@ -1068,6 +1096,8 @@ func NewQuery(q ent.Query) (Query, error) {
return
&
query
[
*
ent
.
ProxyQuery
,
predicate
.
Proxy
,
proxy
.
OrderOption
]{
typ
:
ent
.
TypeProxy
,
tq
:
q
},
nil
case
*
ent
.
RedeemCodeQuery
:
return
&
query
[
*
ent
.
RedeemCodeQuery
,
predicate
.
RedeemCode
,
redeemcode
.
OrderOption
]{
typ
:
ent
.
TypeRedeemCode
,
tq
:
q
},
nil
case
*
ent
.
RequestCaptureLogQuery
:
return
&
query
[
*
ent
.
RequestCaptureLogQuery
,
predicate
.
RequestCaptureLog
,
requestcapturelog
.
OrderOption
]{
typ
:
ent
.
TypeRequestCaptureLog
,
tq
:
q
},
nil
case
*
ent
.
SecuritySecretQuery
:
return
&
query
[
*
ent
.
SecuritySecretQuery
,
predicate
.
SecuritySecret
,
securitysecret
.
OrderOption
]{
typ
:
ent
.
TypeSecuritySecret
,
tq
:
q
},
nil
case
*
ent
.
SettingQuery
:
...
...
backend/ent/migrate/schema.go
View file @
a7386882
...
...
@@ -33,6 +33,7 @@ var (
{
Name
:
"window_5h_start"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
},
{
Name
:
"window_1d_start"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
},
{
Name
:
"window_7d_start"
,
Type
:
field
.
TypeTime
,
Nullable
:
true
},
{
Name
:
"capture_requests"
,
Type
:
field
.
TypeBool
,
Default
:
false
},
{
Name
:
"group_id"
,
Type
:
field
.
TypeInt64
,
Nullable
:
true
},
{
Name
:
"user_id"
,
Type
:
field
.
TypeInt64
},
}
...
...
@@ -44,13 +45,13 @@ var (
ForeignKeys
:
[]
*
schema
.
ForeignKey
{
{
Symbol
:
"api_keys_groups_api_keys"
,
Columns
:
[]
*
schema
.
Column
{
APIKeysColumns
[
2
2
]},
Columns
:
[]
*
schema
.
Column
{
APIKeysColumns
[
2
3
]},
RefColumns
:
[]
*
schema
.
Column
{
GroupsColumns
[
0
]},
OnDelete
:
schema
.
SetNull
,
},
{
Symbol
:
"api_keys_users_api_keys"
,
Columns
:
[]
*
schema
.
Column
{
APIKeysColumns
[
2
3
]},
Columns
:
[]
*
schema
.
Column
{
APIKeysColumns
[
2
4
]},
RefColumns
:
[]
*
schema
.
Column
{
UsersColumns
[
0
]},
OnDelete
:
schema
.
NoAction
,
},
...
...
@@ -59,12 +60,12 @@ var (
{
Name
:
"apikey_user_id"
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
APIKeysColumns
[
2
3
]},
Columns
:
[]
*
schema
.
Column
{
APIKeysColumns
[
2
4
]},
},
{
Name
:
"apikey_group_id"
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
APIKeysColumns
[
2
2
]},
Columns
:
[]
*
schema
.
Column
{
APIKeysColumns
[
2
3
]},
},
{
Name
:
"apikey_status"
,
...
...
@@ -1158,6 +1159,38 @@ var (
},
},
}
// RequestCaptureLogsColumns holds the columns for the "request_capture_logs" table.
RequestCaptureLogsColumns
=
[]
*
schema
.
Column
{
{
Name
:
"id"
,
Type
:
field
.
TypeInt64
,
Increment
:
true
},
{
Name
:
"api_key_id"
,
Type
:
field
.
TypeInt64
},
{
Name
:
"user_id"
,
Type
:
field
.
TypeInt64
},
{
Name
:
"request_id"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
Size
:
64
},
{
Name
:
"path"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
Size
:
100
},
{
Name
:
"method"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
Size
:
10
},
{
Name
:
"ip_address"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
Size
:
45
},
{
Name
:
"request_body"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
Size
:
2147483647
},
{
Name
:
"response_body"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
Size
:
2147483647
},
{
Name
:
"nfs_file_path"
,
Type
:
field
.
TypeString
,
Nullable
:
true
,
Size
:
500
},
{
Name
:
"created_at"
,
Type
:
field
.
TypeTime
,
SchemaType
:
map
[
string
]
string
{
"postgres"
:
"timestamptz"
}},
}
// RequestCaptureLogsTable holds the schema information for the "request_capture_logs" table.
RequestCaptureLogsTable
=
&
schema
.
Table
{
Name
:
"request_capture_logs"
,
Columns
:
RequestCaptureLogsColumns
,
PrimaryKey
:
[]
*
schema
.
Column
{
RequestCaptureLogsColumns
[
0
]},
Indexes
:
[]
*
schema
.
Index
{
{
Name
:
"requestcapturelog_api_key_id_created_at"
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
RequestCaptureLogsColumns
[
1
],
RequestCaptureLogsColumns
[
10
]},
},
{
Name
:
"requestcapturelog_user_id"
,
Unique
:
false
,
Columns
:
[]
*
schema
.
Column
{
RequestCaptureLogsColumns
[
2
]},
},
},
}
// SecuritySecretsColumns holds the columns for the "security_secrets" table.
SecuritySecretsColumns
=
[]
*
schema
.
Column
{
{
Name
:
"id"
,
Type
:
field
.
TypeInt64
,
Increment
:
true
},
...
...
@@ -1701,6 +1734,7 @@ var (
PromoCodeUsagesTable
,
ProxiesTable
,
RedeemCodesTable
,
RequestCaptureLogsTable
,
SecuritySecretsTable
,
SettingsTable
,
SubscriptionPlansTable
,
...
...
@@ -1805,6 +1839,9 @@ func init() {
RedeemCodesTable
.
Annotation
=
&
entsql
.
Annotation
{
Table
:
"redeem_codes"
,
}
RequestCaptureLogsTable
.
Annotation
=
&
entsql
.
Annotation
{
Table
:
"request_capture_logs"
,
}
SecuritySecretsTable
.
Annotation
=
&
entsql
.
Annotation
{
Table
:
"security_secrets"
,
}
...
...
backend/ent/mutation.go
View file @
a7386882
...
...
@@ -36,6 +36,7 @@ import (
"github.com/Wei-Shaw/sub2api/ent/promocodeusage"
"github.com/Wei-Shaw/sub2api/ent/proxy"
"github.com/Wei-Shaw/sub2api/ent/redeemcode"
"github.com/Wei-Shaw/sub2api/ent/requestcapturelog"
"github.com/Wei-Shaw/sub2api/ent/securitysecret"
"github.com/Wei-Shaw/sub2api/ent/setting"
"github.com/Wei-Shaw/sub2api/ent/subscriptionplan"
...
...
@@ -82,6 +83,7 @@ const (
TypePromoCodeUsage = "PromoCodeUsage"
TypeProxy = "Proxy"
TypeRedeemCode = "RedeemCode"
TypeRequestCaptureLog = "RequestCaptureLog"
TypeSecuritySecret = "SecuritySecret"
TypeSetting = "Setting"
TypeSubscriptionPlan = "SubscriptionPlan"
...
...
@@ -132,6 +134,7 @@ type APIKeyMutation struct {
window_5h_start *time.Time
window_1d_start *time.Time
window_7d_start *time.Time
capture_requests *bool
clearedFields map[string]struct{}
user *int64
cleareduser bool
...
...
@@ -1380,6 +1383,42 @@ func (m *APIKeyMutation) ResetWindow7dStart() {
delete(m.clearedFields, apikey.FieldWindow7dStart)
}
// SetCaptureRequests sets the "capture_requests" field.
func (m *APIKeyMutation) SetCaptureRequests(b bool) {
m.capture_requests = &b
}
// CaptureRequests returns the value of the "capture_requests" field in the mutation.
func (m *APIKeyMutation) CaptureRequests() (r bool, exists bool) {
v := m.capture_requests
if v == nil {
return
}
return *v, true
}
// OldCaptureRequests returns the old "capture_requests" field's value of the APIKey entity.
// If the APIKey object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *APIKeyMutation) OldCaptureRequests(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldCaptureRequests is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldCaptureRequests requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldCaptureRequests: %w", err)
}
return oldValue.CaptureRequests, nil
}
// ResetCaptureRequests resets all changes to the "capture_requests" field.
func (m *APIKeyMutation) ResetCaptureRequests() {
m.capture_requests = nil
}
// ClearUser clears the "user" edge to the User entity.
func (m *APIKeyMutation) ClearUser() {
m.cleareduser = true
...
...
@@ -1522,7 +1561,7 @@ func (m *APIKeyMutation) Type() string {
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *APIKeyMutation) Fields() []string {
fields := make([]string, 0, 2
3
)
fields := make([]string, 0, 2
4
)
if m.created_at != nil {
fields = append(fields, apikey.FieldCreatedAt)
}
...
...
@@ -1592,6 +1631,9 @@ func (m *APIKeyMutation) Fields() []string {
if m.window_7d_start != nil {
fields = append(fields, apikey.FieldWindow7dStart)
}
if m.capture_requests != nil {
fields = append(fields, apikey.FieldCaptureRequests)
}
return fields
}
...
...
@@ -1646,6 +1688,8 @@ func (m *APIKeyMutation) Field(name string) (ent.Value, bool) {
return m.Window1dStart()
case apikey.FieldWindow7dStart:
return m.Window7dStart()
case apikey.FieldCaptureRequests:
return m.CaptureRequests()
}
return nil, false
}
...
...
@@ -1701,6 +1745,8 @@ func (m *APIKeyMutation) OldField(ctx context.Context, name string) (ent.Value,
return m.OldWindow1dStart(ctx)
case apikey.FieldWindow7dStart:
return m.OldWindow7dStart(ctx)
case apikey.FieldCaptureRequests:
return m.OldCaptureRequests(ctx)
}
return nil, fmt.Errorf("unknown APIKey field %s", name)
}
...
...
@@ -1871,6 +1917,13 @@ func (m *APIKeyMutation) SetField(name string, value ent.Value) error {
}
m.SetWindow7dStart(v)
return nil
case apikey.FieldCaptureRequests:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCaptureRequests(v)
return nil
}
return fmt.Errorf("unknown APIKey field %s", name)
}
...
...
@@ -2145,6 +2198,9 @@ func (m *APIKeyMutation) ResetField(name string) error {
case apikey.FieldWindow7dStart:
m.ResetWindow7dStart()
return nil
case apikey.FieldCaptureRequests:
m.ResetCaptureRequests()
return nil
}
return fmt.Errorf("unknown APIKey field %s", name)
}
...
...
@@ -29466,6 +29522,1023 @@ func (m *RedeemCodeMutation) ResetEdge(name string) error {
return fmt.Errorf("unknown RedeemCode edge %s", name)
}
// RequestCaptureLogMutation represents an operation that mutates the RequestCaptureLog nodes in the graph.
type RequestCaptureLogMutation struct {
config
op Op
typ string
id *int64
api_key_id *int64
addapi_key_id *int64
user_id *int64
adduser_id *int64
request_id *string
_path *string
method *string
ip_address *string
request_body *string
response_body *string
nfs_file_path *string
created_at *time.Time
clearedFields map[string]struct{}
done bool
oldValue func(context.Context) (*RequestCaptureLog, error)
predicates []predicate.RequestCaptureLog
}
var _ ent.Mutation = (*RequestCaptureLogMutation)(nil)
// requestcapturelogOption allows management of the mutation configuration using functional options.
type requestcapturelogOption func(*RequestCaptureLogMutation)
// newRequestCaptureLogMutation creates new mutation for the RequestCaptureLog entity.
func newRequestCaptureLogMutation(c config, op Op, opts ...requestcapturelogOption) *RequestCaptureLogMutation {
m := &RequestCaptureLogMutation{
config: c,
op: op,
typ: TypeRequestCaptureLog,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withRequestCaptureLogID sets the ID field of the mutation.
func withRequestCaptureLogID(id int64) requestcapturelogOption {
return func(m *RequestCaptureLogMutation) {
var (
err error
once sync.Once
value *RequestCaptureLog
)
m.oldValue = func(ctx context.Context) (*RequestCaptureLog, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().RequestCaptureLog.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withRequestCaptureLog sets the old RequestCaptureLog of the mutation.
func withRequestCaptureLog(node *RequestCaptureLog) requestcapturelogOption {
return func(m *RequestCaptureLogMutation) {
m.oldValue = func(context.Context) (*RequestCaptureLog, error) {
return node, nil
}
m.id = &node.ID
}
}
// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m RequestCaptureLogMutation) Client() *Client {
client := &Client{config: m.config}
client.init()
return client
}
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m RequestCaptureLogMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("ent: mutation is not running in a transaction")
}
tx := &Tx{config: m.config}
tx.init()
return tx, nil
}
// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *RequestCaptureLogMutation) ID() (id int64, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// IDs queries the database and returns the entity ids that match the mutation's predicate.
// That means, if the mutation is applied within a transaction with an isolation level such
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
// or updated by the mutation.
func (m *RequestCaptureLogMutation) IDs(ctx context.Context) ([]int64, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []int64{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().RequestCaptureLog.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetAPIKeyID sets the "api_key_id" field.
func (m *RequestCaptureLogMutation) SetAPIKeyID(i int64) {
m.api_key_id = &i
m.addapi_key_id = nil
}
// APIKeyID returns the value of the "api_key_id" field in the mutation.
func (m *RequestCaptureLogMutation) APIKeyID() (r int64, exists bool) {
v := m.api_key_id
if v == nil {
return
}
return *v, true
}
// OldAPIKeyID returns the old "api_key_id" field's value of the RequestCaptureLog entity.
// If the RequestCaptureLog object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *RequestCaptureLogMutation) OldAPIKeyID(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldAPIKeyID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldAPIKeyID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAPIKeyID: %w", err)
}
return oldValue.APIKeyID, nil
}
// AddAPIKeyID adds i to the "api_key_id" field.
func (m *RequestCaptureLogMutation) AddAPIKeyID(i int64) {
if m.addapi_key_id != nil {
*m.addapi_key_id += i
} else {
m.addapi_key_id = &i
}
}
// AddedAPIKeyID returns the value that was added to the "api_key_id" field in this mutation.
func (m *RequestCaptureLogMutation) AddedAPIKeyID() (r int64, exists bool) {
v := m.addapi_key_id
if v == nil {
return
}
return *v, true
}
// ResetAPIKeyID resets all changes to the "api_key_id" field.
func (m *RequestCaptureLogMutation) ResetAPIKeyID() {
m.api_key_id = nil
m.addapi_key_id = nil
}
// SetUserID sets the "user_id" field.
func (m *RequestCaptureLogMutation) SetUserID(i int64) {
m.user_id = &i
m.adduser_id = nil
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *RequestCaptureLogMutation) UserID() (r int64, exists bool) {
v := m.user_id
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the RequestCaptureLog entity.
// If the RequestCaptureLog object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *RequestCaptureLogMutation) OldUserID(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// AddUserID adds i to the "user_id" field.
func (m *RequestCaptureLogMutation) AddUserID(i int64) {
if m.adduser_id != nil {
*m.adduser_id += i
} else {
m.adduser_id = &i
}
}
// AddedUserID returns the value that was added to the "user_id" field in this mutation.
func (m *RequestCaptureLogMutation) AddedUserID() (r int64, exists bool) {
v := m.adduser_id
if v == nil {
return
}
return *v, true
}
// ResetUserID resets all changes to the "user_id" field.
func (m *RequestCaptureLogMutation) ResetUserID() {
m.user_id = nil
m.adduser_id = nil
}
// SetRequestID sets the "request_id" field.
func (m *RequestCaptureLogMutation) SetRequestID(s string) {
m.request_id = &s
}
// RequestID returns the value of the "request_id" field in the mutation.
func (m *RequestCaptureLogMutation) RequestID() (r string, exists bool) {
v := m.request_id
if v == nil {
return
}
return *v, true
}
// OldRequestID returns the old "request_id" field's value of the RequestCaptureLog entity.
// If the RequestCaptureLog object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *RequestCaptureLogMutation) OldRequestID(ctx context.Context) (v *string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRequestID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRequestID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRequestID: %w", err)
}
return oldValue.RequestID, nil
}
// ClearRequestID clears the value of the "request_id" field.
func (m *RequestCaptureLogMutation) ClearRequestID() {
m.request_id = nil
m.clearedFields[requestcapturelog.FieldRequestID] = struct{}{}
}
// RequestIDCleared returns if the "request_id" field was cleared in this mutation.
func (m *RequestCaptureLogMutation) RequestIDCleared() bool {
_, ok := m.clearedFields[requestcapturelog.FieldRequestID]
return ok
}
// ResetRequestID resets all changes to the "request_id" field.
func (m *RequestCaptureLogMutation) ResetRequestID() {
m.request_id = nil
delete(m.clearedFields, requestcapturelog.FieldRequestID)
}
// SetPath sets the "path" field.
func (m *RequestCaptureLogMutation) SetPath(s string) {
m._path = &s
}
// Path returns the value of the "path" field in the mutation.
func (m *RequestCaptureLogMutation) Path() (r string, exists bool) {
v := m._path
if v == nil {
return
}
return *v, true
}
// OldPath returns the old "path" field's value of the RequestCaptureLog entity.
// If the RequestCaptureLog object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *RequestCaptureLogMutation) OldPath(ctx context.Context) (v *string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldPath is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldPath requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPath: %w", err)
}
return oldValue.Path, nil
}
// ClearPath clears the value of the "path" field.
func (m *RequestCaptureLogMutation) ClearPath() {
m._path = nil
m.clearedFields[requestcapturelog.FieldPath] = struct{}{}
}
// PathCleared returns if the "path" field was cleared in this mutation.
func (m *RequestCaptureLogMutation) PathCleared() bool {
_, ok := m.clearedFields[requestcapturelog.FieldPath]
return ok
}
// ResetPath resets all changes to the "path" field.
func (m *RequestCaptureLogMutation) ResetPath() {
m._path = nil
delete(m.clearedFields, requestcapturelog.FieldPath)
}
// SetMethod sets the "method" field.
func (m *RequestCaptureLogMutation) SetMethod(s string) {
m.method = &s
}
// Method returns the value of the "method" field in the mutation.
func (m *RequestCaptureLogMutation) Method() (r string, exists bool) {
v := m.method
if v == nil {
return
}
return *v, true
}
// OldMethod returns the old "method" field's value of the RequestCaptureLog entity.
// If the RequestCaptureLog object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *RequestCaptureLogMutation) OldMethod(ctx context.Context) (v *string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldMethod is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldMethod requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMethod: %w", err)
}
return oldValue.Method, nil
}
// ClearMethod clears the value of the "method" field.
func (m *RequestCaptureLogMutation) ClearMethod() {
m.method = nil
m.clearedFields[requestcapturelog.FieldMethod] = struct{}{}
}
// MethodCleared returns if the "method" field was cleared in this mutation.
func (m *RequestCaptureLogMutation) MethodCleared() bool {
_, ok := m.clearedFields[requestcapturelog.FieldMethod]
return ok
}
// ResetMethod resets all changes to the "method" field.
func (m *RequestCaptureLogMutation) ResetMethod() {
m.method = nil
delete(m.clearedFields, requestcapturelog.FieldMethod)
}
// SetIPAddress sets the "ip_address" field.
func (m *RequestCaptureLogMutation) SetIPAddress(s string) {
m.ip_address = &s
}
// IPAddress returns the value of the "ip_address" field in the mutation.
func (m *RequestCaptureLogMutation) IPAddress() (r string, exists bool) {
v := m.ip_address
if v == nil {
return
}
return *v, true
}
// OldIPAddress returns the old "ip_address" field's value of the RequestCaptureLog entity.
// If the RequestCaptureLog object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *RequestCaptureLogMutation) OldIPAddress(ctx context.Context) (v *string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldIPAddress is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldIPAddress requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldIPAddress: %w", err)
}
return oldValue.IPAddress, nil
}
// ClearIPAddress clears the value of the "ip_address" field.
func (m *RequestCaptureLogMutation) ClearIPAddress() {
m.ip_address = nil
m.clearedFields[requestcapturelog.FieldIPAddress] = struct{}{}
}
// IPAddressCleared returns if the "ip_address" field was cleared in this mutation.
func (m *RequestCaptureLogMutation) IPAddressCleared() bool {
_, ok := m.clearedFields[requestcapturelog.FieldIPAddress]
return ok
}
// ResetIPAddress resets all changes to the "ip_address" field.
func (m *RequestCaptureLogMutation) ResetIPAddress() {
m.ip_address = nil
delete(m.clearedFields, requestcapturelog.FieldIPAddress)
}
// SetRequestBody sets the "request_body" field.
func (m *RequestCaptureLogMutation) SetRequestBody(s string) {
m.request_body = &s
}
// RequestBody returns the value of the "request_body" field in the mutation.
func (m *RequestCaptureLogMutation) RequestBody() (r string, exists bool) {
v := m.request_body
if v == nil {
return
}
return *v, true
}
// OldRequestBody returns the old "request_body" field's value of the RequestCaptureLog entity.
// If the RequestCaptureLog object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *RequestCaptureLogMutation) OldRequestBody(ctx context.Context) (v *string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRequestBody is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRequestBody requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRequestBody: %w", err)
}
return oldValue.RequestBody, nil
}
// ClearRequestBody clears the value of the "request_body" field.
func (m *RequestCaptureLogMutation) ClearRequestBody() {
m.request_body = nil
m.clearedFields[requestcapturelog.FieldRequestBody] = struct{}{}
}
// RequestBodyCleared returns if the "request_body" field was cleared in this mutation.
func (m *RequestCaptureLogMutation) RequestBodyCleared() bool {
_, ok := m.clearedFields[requestcapturelog.FieldRequestBody]
return ok
}
// ResetRequestBody resets all changes to the "request_body" field.
func (m *RequestCaptureLogMutation) ResetRequestBody() {
m.request_body = nil
delete(m.clearedFields, requestcapturelog.FieldRequestBody)
}
// SetResponseBody sets the "response_body" field.
func (m *RequestCaptureLogMutation) SetResponseBody(s string) {
m.response_body = &s
}
// ResponseBody returns the value of the "response_body" field in the mutation.
func (m *RequestCaptureLogMutation) ResponseBody() (r string, exists bool) {
v := m.response_body
if v == nil {
return
}
return *v, true
}
// OldResponseBody returns the old "response_body" field's value of the RequestCaptureLog entity.
// If the RequestCaptureLog object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *RequestCaptureLogMutation) OldResponseBody(ctx context.Context) (v *string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldResponseBody is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldResponseBody requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldResponseBody: %w", err)
}
return oldValue.ResponseBody, nil
}
// ClearResponseBody clears the value of the "response_body" field.
func (m *RequestCaptureLogMutation) ClearResponseBody() {
m.response_body = nil
m.clearedFields[requestcapturelog.FieldResponseBody] = struct{}{}
}
// ResponseBodyCleared returns if the "response_body" field was cleared in this mutation.
func (m *RequestCaptureLogMutation) ResponseBodyCleared() bool {
_, ok := m.clearedFields[requestcapturelog.FieldResponseBody]
return ok
}
// ResetResponseBody resets all changes to the "response_body" field.
func (m *RequestCaptureLogMutation) ResetResponseBody() {
m.response_body = nil
delete(m.clearedFields, requestcapturelog.FieldResponseBody)
}
// SetNfsFilePath sets the "nfs_file_path" field.
func (m *RequestCaptureLogMutation) SetNfsFilePath(s string) {
m.nfs_file_path = &s
}
// NfsFilePath returns the value of the "nfs_file_path" field in the mutation.
func (m *RequestCaptureLogMutation) NfsFilePath() (r string, exists bool) {
v := m.nfs_file_path
if v == nil {
return
}
return *v, true
}
// OldNfsFilePath returns the old "nfs_file_path" field's value of the RequestCaptureLog entity.
// If the RequestCaptureLog object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *RequestCaptureLogMutation) OldNfsFilePath(ctx context.Context) (v *string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldNfsFilePath is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldNfsFilePath requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldNfsFilePath: %w", err)
}
return oldValue.NfsFilePath, nil
}
// ClearNfsFilePath clears the value of the "nfs_file_path" field.
func (m *RequestCaptureLogMutation) ClearNfsFilePath() {
m.nfs_file_path = nil
m.clearedFields[requestcapturelog.FieldNfsFilePath] = struct{}{}
}
// NfsFilePathCleared returns if the "nfs_file_path" field was cleared in this mutation.
func (m *RequestCaptureLogMutation) NfsFilePathCleared() bool {
_, ok := m.clearedFields[requestcapturelog.FieldNfsFilePath]
return ok
}
// ResetNfsFilePath resets all changes to the "nfs_file_path" field.
func (m *RequestCaptureLogMutation) ResetNfsFilePath() {
m.nfs_file_path = nil
delete(m.clearedFields, requestcapturelog.FieldNfsFilePath)
}
// SetCreatedAt sets the "created_at" field.
func (m *RequestCaptureLogMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *RequestCaptureLogMutation) CreatedAt() (r time.Time, exists bool) {
v := m.created_at
if v == nil {
return
}
return *v, true
}
// OldCreatedAt returns the old "created_at" field's value of the RequestCaptureLog entity.
// If the RequestCaptureLog object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *RequestCaptureLogMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldCreatedAt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
}
return oldValue.CreatedAt, nil
}
// ResetCreatedAt resets all changes to the "created_at" field.
func (m *RequestCaptureLogMutation) ResetCreatedAt() {
m.created_at = nil
}
// Where appends a list predicates to the RequestCaptureLogMutation builder.
func (m *RequestCaptureLogMutation) Where(ps ...predicate.RequestCaptureLog) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the RequestCaptureLogMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *RequestCaptureLogMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.RequestCaptureLog, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *RequestCaptureLogMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *RequestCaptureLogMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (RequestCaptureLog).
func (m *RequestCaptureLogMutation) Type() string {
return m.typ
}
// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *RequestCaptureLogMutation) Fields() []string {
fields := make([]string, 0, 10)
if m.api_key_id != nil {
fields = append(fields, requestcapturelog.FieldAPIKeyID)
}
if m.user_id != nil {
fields = append(fields, requestcapturelog.FieldUserID)
}
if m.request_id != nil {
fields = append(fields, requestcapturelog.FieldRequestID)
}
if m._path != nil {
fields = append(fields, requestcapturelog.FieldPath)
}
if m.method != nil {
fields = append(fields, requestcapturelog.FieldMethod)
}
if m.ip_address != nil {
fields = append(fields, requestcapturelog.FieldIPAddress)
}
if m.request_body != nil {
fields = append(fields, requestcapturelog.FieldRequestBody)
}
if m.response_body != nil {
fields = append(fields, requestcapturelog.FieldResponseBody)
}
if m.nfs_file_path != nil {
fields = append(fields, requestcapturelog.FieldNfsFilePath)
}
if m.created_at != nil {
fields = append(fields, requestcapturelog.FieldCreatedAt)
}
return fields
}
// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *RequestCaptureLogMutation) Field(name string) (ent.Value, bool) {
switch name {
case requestcapturelog.FieldAPIKeyID:
return m.APIKeyID()
case requestcapturelog.FieldUserID:
return m.UserID()
case requestcapturelog.FieldRequestID:
return m.RequestID()
case requestcapturelog.FieldPath:
return m.Path()
case requestcapturelog.FieldMethod:
return m.Method()
case requestcapturelog.FieldIPAddress:
return m.IPAddress()
case requestcapturelog.FieldRequestBody:
return m.RequestBody()
case requestcapturelog.FieldResponseBody:
return m.ResponseBody()
case requestcapturelog.FieldNfsFilePath:
return m.NfsFilePath()
case requestcapturelog.FieldCreatedAt:
return m.CreatedAt()
}
return nil, false
}
// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *RequestCaptureLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case requestcapturelog.FieldAPIKeyID:
return m.OldAPIKeyID(ctx)
case requestcapturelog.FieldUserID:
return m.OldUserID(ctx)
case requestcapturelog.FieldRequestID:
return m.OldRequestID(ctx)
case requestcapturelog.FieldPath:
return m.OldPath(ctx)
case requestcapturelog.FieldMethod:
return m.OldMethod(ctx)
case requestcapturelog.FieldIPAddress:
return m.OldIPAddress(ctx)
case requestcapturelog.FieldRequestBody:
return m.OldRequestBody(ctx)
case requestcapturelog.FieldResponseBody:
return m.OldResponseBody(ctx)
case requestcapturelog.FieldNfsFilePath:
return m.OldNfsFilePath(ctx)
case requestcapturelog.FieldCreatedAt:
return m.OldCreatedAt(ctx)
}
return nil, fmt.Errorf("unknown RequestCaptureLog field %s", name)
}
// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *RequestCaptureLogMutation) SetField(name string, value ent.Value) error {
switch name {
case requestcapturelog.FieldAPIKeyID:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAPIKeyID(v)
return nil
case requestcapturelog.FieldUserID:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case requestcapturelog.FieldRequestID:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRequestID(v)
return nil
case requestcapturelog.FieldPath:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetPath(v)
return nil
case requestcapturelog.FieldMethod:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetMethod(v)
return nil
case requestcapturelog.FieldIPAddress:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetIPAddress(v)
return nil
case requestcapturelog.FieldRequestBody:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRequestBody(v)
return nil
case requestcapturelog.FieldResponseBody:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetResponseBody(v)
return nil
case requestcapturelog.FieldNfsFilePath:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetNfsFilePath(v)
return nil
case requestcapturelog.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
}
return fmt.Errorf("unknown RequestCaptureLog field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *RequestCaptureLogMutation) AddedFields() []string {
var fields []string
if m.addapi_key_id != nil {
fields = append(fields, requestcapturelog.FieldAPIKeyID)
}
if m.adduser_id != nil {
fields = append(fields, requestcapturelog.FieldUserID)
}
return fields
}
// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *RequestCaptureLogMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case requestcapturelog.FieldAPIKeyID:
return m.AddedAPIKeyID()
case requestcapturelog.FieldUserID:
return m.AddedUserID()
}
return nil, false
}
// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *RequestCaptureLogMutation) AddField(name string, value ent.Value) error {
switch name {
case requestcapturelog.FieldAPIKeyID:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddAPIKeyID(v)
return nil
case requestcapturelog.FieldUserID:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddUserID(v)
return nil
}
return fmt.Errorf("unknown RequestCaptureLog numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *RequestCaptureLogMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(requestcapturelog.FieldRequestID) {
fields = append(fields, requestcapturelog.FieldRequestID)
}
if m.FieldCleared(requestcapturelog.FieldPath) {
fields = append(fields, requestcapturelog.FieldPath)
}
if m.FieldCleared(requestcapturelog.FieldMethod) {
fields = append(fields, requestcapturelog.FieldMethod)
}
if m.FieldCleared(requestcapturelog.FieldIPAddress) {
fields = append(fields, requestcapturelog.FieldIPAddress)
}
if m.FieldCleared(requestcapturelog.FieldRequestBody) {
fields = append(fields, requestcapturelog.FieldRequestBody)
}
if m.FieldCleared(requestcapturelog.FieldResponseBody) {
fields = append(fields, requestcapturelog.FieldResponseBody)
}
if m.FieldCleared(requestcapturelog.FieldNfsFilePath) {
fields = append(fields, requestcapturelog.FieldNfsFilePath)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *RequestCaptureLogMutation) FieldCleared(name string) bool {
_, ok := m.clearedFields[name]
return ok
}
// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *RequestCaptureLogMutation) ClearField(name string) error {
switch name {
case requestcapturelog.FieldRequestID:
m.ClearRequestID()
return nil
case requestcapturelog.FieldPath:
m.ClearPath()
return nil
case requestcapturelog.FieldMethod:
m.ClearMethod()
return nil
case requestcapturelog.FieldIPAddress:
m.ClearIPAddress()
return nil
case requestcapturelog.FieldRequestBody:
m.ClearRequestBody()
return nil
case requestcapturelog.FieldResponseBody:
m.ClearResponseBody()
return nil
case requestcapturelog.FieldNfsFilePath:
m.ClearNfsFilePath()
return nil
}
return fmt.Errorf("unknown RequestCaptureLog nullable field %s", name)
}
// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *RequestCaptureLogMutation) ResetField(name string) error {
switch name {
case requestcapturelog.FieldAPIKeyID:
m.ResetAPIKeyID()
return nil
case requestcapturelog.FieldUserID:
m.ResetUserID()
return nil
case requestcapturelog.FieldRequestID:
m.ResetRequestID()
return nil
case requestcapturelog.FieldPath:
m.ResetPath()
return nil
case requestcapturelog.FieldMethod:
m.ResetMethod()
return nil
case requestcapturelog.FieldIPAddress:
m.ResetIPAddress()
return nil
case requestcapturelog.FieldRequestBody:
m.ResetRequestBody()
return nil
case requestcapturelog.FieldResponseBody:
m.ResetResponseBody()
return nil
case requestcapturelog.FieldNfsFilePath:
m.ResetNfsFilePath()
return nil
case requestcapturelog.FieldCreatedAt:
m.ResetCreatedAt()
return nil
}
return fmt.Errorf("unknown RequestCaptureLog field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *RequestCaptureLogMutation) AddedEdges() []string {
edges := make([]string, 0, 0)
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *RequestCaptureLogMutation) AddedIDs(name string) []ent.Value {
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *RequestCaptureLogMutation) RemovedEdges() []string {
edges := make([]string, 0, 0)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *RequestCaptureLogMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *RequestCaptureLogMutation) ClearedEdges() []string {
edges := make([]string, 0, 0)
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *RequestCaptureLogMutation) EdgeCleared(name string) bool {
return false
}
// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *RequestCaptureLogMutation) ClearEdge(name string) error {
return fmt.Errorf("unknown RequestCaptureLog unique edge %s", name)
}
// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *RequestCaptureLogMutation) ResetEdge(name string) error {
return fmt.Errorf("unknown RequestCaptureLog edge %s", name)
}
// SecuritySecretMutation represents an operation that mutates the SecuritySecret nodes in the graph.
type SecuritySecretMutation struct {
config
backend/ent/predicate/predicate.go
View file @
a7386882
...
...
@@ -75,6 +75,9 @@ type Proxy func(*sql.Selector)
// RedeemCode is the predicate function for redeemcode builders.
type
RedeemCode
func
(
*
sql
.
Selector
)
// RequestCaptureLog is the predicate function for requestcapturelog builders.
type
RequestCaptureLog
func
(
*
sql
.
Selector
)
// SecuritySecret is the predicate function for securitysecret builders.
type
SecuritySecret
func
(
*
sql
.
Selector
)
...
...
backend/ent/requestcapturelog.go
0 → 100644
View file @
a7386882
// Code generated by ent, DO NOT EDIT.
package
ent
import
(
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/requestcapturelog"
)
// RequestCaptureLog is the model entity for the RequestCaptureLog schema.
type
RequestCaptureLog
struct
{
config
`json:"-"`
// ID of the ent.
ID
int64
`json:"id,omitempty"`
// APIKeyID holds the value of the "api_key_id" field.
APIKeyID
int64
`json:"api_key_id,omitempty"`
// UserID holds the value of the "user_id" field.
UserID
int64
`json:"user_id,omitempty"`
// RequestID holds the value of the "request_id" field.
RequestID
*
string
`json:"request_id,omitempty"`
// Path holds the value of the "path" field.
Path
*
string
`json:"path,omitempty"`
// Method holds the value of the "method" field.
Method
*
string
`json:"method,omitempty"`
// IPAddress holds the value of the "ip_address" field.
IPAddress
*
string
`json:"ip_address,omitempty"`
// RequestBody holds the value of the "request_body" field.
RequestBody
*
string
`json:"request_body,omitempty"`
// ResponseBody holds the value of the "response_body" field.
ResponseBody
*
string
`json:"response_body,omitempty"`
// NfsFilePath holds the value of the "nfs_file_path" field.
NfsFilePath
*
string
`json:"nfs_file_path,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt
time
.
Time
`json:"created_at,omitempty"`
selectValues
sql
.
SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func
(
*
RequestCaptureLog
)
scanValues
(
columns
[]
string
)
([]
any
,
error
)
{
values
:=
make
([]
any
,
len
(
columns
))
for
i
:=
range
columns
{
switch
columns
[
i
]
{
case
requestcapturelog
.
FieldID
,
requestcapturelog
.
FieldAPIKeyID
,
requestcapturelog
.
FieldUserID
:
values
[
i
]
=
new
(
sql
.
NullInt64
)
case
requestcapturelog
.
FieldRequestID
,
requestcapturelog
.
FieldPath
,
requestcapturelog
.
FieldMethod
,
requestcapturelog
.
FieldIPAddress
,
requestcapturelog
.
FieldRequestBody
,
requestcapturelog
.
FieldResponseBody
,
requestcapturelog
.
FieldNfsFilePath
:
values
[
i
]
=
new
(
sql
.
NullString
)
case
requestcapturelog
.
FieldCreatedAt
:
values
[
i
]
=
new
(
sql
.
NullTime
)
default
:
values
[
i
]
=
new
(
sql
.
UnknownType
)
}
}
return
values
,
nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the RequestCaptureLog fields.
func
(
_m
*
RequestCaptureLog
)
assignValues
(
columns
[]
string
,
values
[]
any
)
error
{
if
m
,
n
:=
len
(
values
),
len
(
columns
);
m
<
n
{
return
fmt
.
Errorf
(
"mismatch number of scan values: %d != %d"
,
m
,
n
)
}
for
i
:=
range
columns
{
switch
columns
[
i
]
{
case
requestcapturelog
.
FieldID
:
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullInt64
)
if
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field id"
,
value
)
}
_m
.
ID
=
int64
(
value
.
Int64
)
case
requestcapturelog
.
FieldAPIKeyID
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullInt64
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field api_key_id"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
APIKeyID
=
value
.
Int64
}
case
requestcapturelog
.
FieldUserID
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullInt64
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field user_id"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
UserID
=
value
.
Int64
}
case
requestcapturelog
.
FieldRequestID
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field request_id"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
RequestID
=
new
(
string
)
*
_m
.
RequestID
=
value
.
String
}
case
requestcapturelog
.
FieldPath
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field path"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
Path
=
new
(
string
)
*
_m
.
Path
=
value
.
String
}
case
requestcapturelog
.
FieldMethod
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field method"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
Method
=
new
(
string
)
*
_m
.
Method
=
value
.
String
}
case
requestcapturelog
.
FieldIPAddress
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field ip_address"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
IPAddress
=
new
(
string
)
*
_m
.
IPAddress
=
value
.
String
}
case
requestcapturelog
.
FieldRequestBody
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field request_body"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
RequestBody
=
new
(
string
)
*
_m
.
RequestBody
=
value
.
String
}
case
requestcapturelog
.
FieldResponseBody
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field response_body"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
ResponseBody
=
new
(
string
)
*
_m
.
ResponseBody
=
value
.
String
}
case
requestcapturelog
.
FieldNfsFilePath
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field nfs_file_path"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
NfsFilePath
=
new
(
string
)
*
_m
.
NfsFilePath
=
value
.
String
}
case
requestcapturelog
.
FieldCreatedAt
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullTime
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field created_at"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
CreatedAt
=
value
.
Time
}
default
:
_m
.
selectValues
.
Set
(
columns
[
i
],
values
[
i
])
}
}
return
nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the RequestCaptureLog.
// This includes values selected through modifiers, order, etc.
func
(
_m
*
RequestCaptureLog
)
Value
(
name
string
)
(
ent
.
Value
,
error
)
{
return
_m
.
selectValues
.
Get
(
name
)
}
// Update returns a builder for updating this RequestCaptureLog.
// Note that you need to call RequestCaptureLog.Unwrap() before calling this method if this RequestCaptureLog
// was returned from a transaction, and the transaction was committed or rolled back.
func
(
_m
*
RequestCaptureLog
)
Update
()
*
RequestCaptureLogUpdateOne
{
return
NewRequestCaptureLogClient
(
_m
.
config
)
.
UpdateOne
(
_m
)
}
// Unwrap unwraps the RequestCaptureLog entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func
(
_m
*
RequestCaptureLog
)
Unwrap
()
*
RequestCaptureLog
{
_tx
,
ok
:=
_m
.
config
.
driver
.
(
*
txDriver
)
if
!
ok
{
panic
(
"ent: RequestCaptureLog is not a transactional entity"
)
}
_m
.
config
.
driver
=
_tx
.
drv
return
_m
}
// String implements the fmt.Stringer.
func
(
_m
*
RequestCaptureLog
)
String
()
string
{
var
builder
strings
.
Builder
builder
.
WriteString
(
"RequestCaptureLog("
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"id=%v, "
,
_m
.
ID
))
builder
.
WriteString
(
"api_key_id="
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
_m
.
APIKeyID
))
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"user_id="
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
_m
.
UserID
))
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
RequestID
;
v
!=
nil
{
builder
.
WriteString
(
"request_id="
)
builder
.
WriteString
(
*
v
)
}
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
Path
;
v
!=
nil
{
builder
.
WriteString
(
"path="
)
builder
.
WriteString
(
*
v
)
}
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
Method
;
v
!=
nil
{
builder
.
WriteString
(
"method="
)
builder
.
WriteString
(
*
v
)
}
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
IPAddress
;
v
!=
nil
{
builder
.
WriteString
(
"ip_address="
)
builder
.
WriteString
(
*
v
)
}
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
RequestBody
;
v
!=
nil
{
builder
.
WriteString
(
"request_body="
)
builder
.
WriteString
(
*
v
)
}
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
ResponseBody
;
v
!=
nil
{
builder
.
WriteString
(
"response_body="
)
builder
.
WriteString
(
*
v
)
}
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
NfsFilePath
;
v
!=
nil
{
builder
.
WriteString
(
"nfs_file_path="
)
builder
.
WriteString
(
*
v
)
}
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"created_at="
)
builder
.
WriteString
(
_m
.
CreatedAt
.
Format
(
time
.
ANSIC
))
builder
.
WriteByte
(
')'
)
return
builder
.
String
()
}
// RequestCaptureLogs is a parsable slice of RequestCaptureLog.
type
RequestCaptureLogs
[]
*
RequestCaptureLog
backend/ent/requestcapturelog/requestcapturelog.go
0 → 100644
View file @
a7386882
// Code generated by ent, DO NOT EDIT.
package
requestcapturelog
import
(
"time"
"entgo.io/ent/dialect/sql"
)
const
(
// Label holds the string label denoting the requestcapturelog type in the database.
Label
=
"request_capture_log"
// FieldID holds the string denoting the id field in the database.
FieldID
=
"id"
// FieldAPIKeyID holds the string denoting the api_key_id field in the database.
FieldAPIKeyID
=
"api_key_id"
// FieldUserID holds the string denoting the user_id field in the database.
FieldUserID
=
"user_id"
// FieldRequestID holds the string denoting the request_id field in the database.
FieldRequestID
=
"request_id"
// FieldPath holds the string denoting the path field in the database.
FieldPath
=
"path"
// FieldMethod holds the string denoting the method field in the database.
FieldMethod
=
"method"
// FieldIPAddress holds the string denoting the ip_address field in the database.
FieldIPAddress
=
"ip_address"
// FieldRequestBody holds the string denoting the request_body field in the database.
FieldRequestBody
=
"request_body"
// FieldResponseBody holds the string denoting the response_body field in the database.
FieldResponseBody
=
"response_body"
// FieldNfsFilePath holds the string denoting the nfs_file_path field in the database.
FieldNfsFilePath
=
"nfs_file_path"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt
=
"created_at"
// Table holds the table name of the requestcapturelog in the database.
Table
=
"request_capture_logs"
)
// Columns holds all SQL columns for requestcapturelog fields.
var
Columns
=
[]
string
{
FieldID
,
FieldAPIKeyID
,
FieldUserID
,
FieldRequestID
,
FieldPath
,
FieldMethod
,
FieldIPAddress
,
FieldRequestBody
,
FieldResponseBody
,
FieldNfsFilePath
,
FieldCreatedAt
,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func
ValidColumn
(
column
string
)
bool
{
for
i
:=
range
Columns
{
if
column
==
Columns
[
i
]
{
return
true
}
}
return
false
}
var
(
// RequestIDValidator is a validator for the "request_id" field. It is called by the builders before save.
RequestIDValidator
func
(
string
)
error
// PathValidator is a validator for the "path" field. It is called by the builders before save.
PathValidator
func
(
string
)
error
// MethodValidator is a validator for the "method" field. It is called by the builders before save.
MethodValidator
func
(
string
)
error
// IPAddressValidator is a validator for the "ip_address" field. It is called by the builders before save.
IPAddressValidator
func
(
string
)
error
// NfsFilePathValidator is a validator for the "nfs_file_path" field. It is called by the builders before save.
NfsFilePathValidator
func
(
string
)
error
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt
func
()
time
.
Time
)
// OrderOption defines the ordering options for the RequestCaptureLog queries.
type
OrderOption
func
(
*
sql
.
Selector
)
// ByID orders the results by the id field.
func
ByID
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldID
,
opts
...
)
.
ToFunc
()
}
// ByAPIKeyID orders the results by the api_key_id field.
func
ByAPIKeyID
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldAPIKeyID
,
opts
...
)
.
ToFunc
()
}
// ByUserID orders the results by the user_id field.
func
ByUserID
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldUserID
,
opts
...
)
.
ToFunc
()
}
// ByRequestID orders the results by the request_id field.
func
ByRequestID
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldRequestID
,
opts
...
)
.
ToFunc
()
}
// ByPath orders the results by the path field.
func
ByPath
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldPath
,
opts
...
)
.
ToFunc
()
}
// ByMethod orders the results by the method field.
func
ByMethod
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldMethod
,
opts
...
)
.
ToFunc
()
}
// ByIPAddress orders the results by the ip_address field.
func
ByIPAddress
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldIPAddress
,
opts
...
)
.
ToFunc
()
}
// ByRequestBody orders the results by the request_body field.
func
ByRequestBody
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldRequestBody
,
opts
...
)
.
ToFunc
()
}
// ByResponseBody orders the results by the response_body field.
func
ByResponseBody
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldResponseBody
,
opts
...
)
.
ToFunc
()
}
// ByNfsFilePath orders the results by the nfs_file_path field.
func
ByNfsFilePath
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldNfsFilePath
,
opts
...
)
.
ToFunc
()
}
// ByCreatedAt orders the results by the created_at field.
func
ByCreatedAt
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldCreatedAt
,
opts
...
)
.
ToFunc
()
}
backend/ent/requestcapturelog/where.go
0 → 100644
View file @
a7386882
// Code generated by ent, DO NOT EDIT.
package
requestcapturelog
import
(
"time"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// ID filters vertices based on their ID field.
func
ID
(
id
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldID
,
id
))
}
// IDEQ applies the EQ predicate on the ID field.
func
IDEQ
(
id
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldID
,
id
))
}
// IDNEQ applies the NEQ predicate on the ID field.
func
IDNEQ
(
id
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNEQ
(
FieldID
,
id
))
}
// IDIn applies the In predicate on the ID field.
func
IDIn
(
ids
...
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldIn
(
FieldID
,
ids
...
))
}
// IDNotIn applies the NotIn predicate on the ID field.
func
IDNotIn
(
ids
...
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNotIn
(
FieldID
,
ids
...
))
}
// IDGT applies the GT predicate on the ID field.
func
IDGT
(
id
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGT
(
FieldID
,
id
))
}
// IDGTE applies the GTE predicate on the ID field.
func
IDGTE
(
id
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGTE
(
FieldID
,
id
))
}
// IDLT applies the LT predicate on the ID field.
func
IDLT
(
id
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLT
(
FieldID
,
id
))
}
// IDLTE applies the LTE predicate on the ID field.
func
IDLTE
(
id
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLTE
(
FieldID
,
id
))
}
// APIKeyID applies equality check predicate on the "api_key_id" field. It's identical to APIKeyIDEQ.
func
APIKeyID
(
v
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldAPIKeyID
,
v
))
}
// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ.
func
UserID
(
v
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldUserID
,
v
))
}
// RequestID applies equality check predicate on the "request_id" field. It's identical to RequestIDEQ.
func
RequestID
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldRequestID
,
v
))
}
// Path applies equality check predicate on the "path" field. It's identical to PathEQ.
func
Path
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldPath
,
v
))
}
// Method applies equality check predicate on the "method" field. It's identical to MethodEQ.
func
Method
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldMethod
,
v
))
}
// IPAddress applies equality check predicate on the "ip_address" field. It's identical to IPAddressEQ.
func
IPAddress
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldIPAddress
,
v
))
}
// RequestBody applies equality check predicate on the "request_body" field. It's identical to RequestBodyEQ.
func
RequestBody
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldRequestBody
,
v
))
}
// ResponseBody applies equality check predicate on the "response_body" field. It's identical to ResponseBodyEQ.
func
ResponseBody
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldResponseBody
,
v
))
}
// NfsFilePath applies equality check predicate on the "nfs_file_path" field. It's identical to NfsFilePathEQ.
func
NfsFilePath
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldNfsFilePath
,
v
))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func
CreatedAt
(
v
time
.
Time
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldCreatedAt
,
v
))
}
// APIKeyIDEQ applies the EQ predicate on the "api_key_id" field.
func
APIKeyIDEQ
(
v
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldAPIKeyID
,
v
))
}
// APIKeyIDNEQ applies the NEQ predicate on the "api_key_id" field.
func
APIKeyIDNEQ
(
v
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNEQ
(
FieldAPIKeyID
,
v
))
}
// APIKeyIDIn applies the In predicate on the "api_key_id" field.
func
APIKeyIDIn
(
vs
...
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldIn
(
FieldAPIKeyID
,
vs
...
))
}
// APIKeyIDNotIn applies the NotIn predicate on the "api_key_id" field.
func
APIKeyIDNotIn
(
vs
...
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNotIn
(
FieldAPIKeyID
,
vs
...
))
}
// APIKeyIDGT applies the GT predicate on the "api_key_id" field.
func
APIKeyIDGT
(
v
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGT
(
FieldAPIKeyID
,
v
))
}
// APIKeyIDGTE applies the GTE predicate on the "api_key_id" field.
func
APIKeyIDGTE
(
v
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGTE
(
FieldAPIKeyID
,
v
))
}
// APIKeyIDLT applies the LT predicate on the "api_key_id" field.
func
APIKeyIDLT
(
v
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLT
(
FieldAPIKeyID
,
v
))
}
// APIKeyIDLTE applies the LTE predicate on the "api_key_id" field.
func
APIKeyIDLTE
(
v
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLTE
(
FieldAPIKeyID
,
v
))
}
// UserIDEQ applies the EQ predicate on the "user_id" field.
func
UserIDEQ
(
v
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldUserID
,
v
))
}
// UserIDNEQ applies the NEQ predicate on the "user_id" field.
func
UserIDNEQ
(
v
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNEQ
(
FieldUserID
,
v
))
}
// UserIDIn applies the In predicate on the "user_id" field.
func
UserIDIn
(
vs
...
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldIn
(
FieldUserID
,
vs
...
))
}
// UserIDNotIn applies the NotIn predicate on the "user_id" field.
func
UserIDNotIn
(
vs
...
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNotIn
(
FieldUserID
,
vs
...
))
}
// UserIDGT applies the GT predicate on the "user_id" field.
func
UserIDGT
(
v
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGT
(
FieldUserID
,
v
))
}
// UserIDGTE applies the GTE predicate on the "user_id" field.
func
UserIDGTE
(
v
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGTE
(
FieldUserID
,
v
))
}
// UserIDLT applies the LT predicate on the "user_id" field.
func
UserIDLT
(
v
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLT
(
FieldUserID
,
v
))
}
// UserIDLTE applies the LTE predicate on the "user_id" field.
func
UserIDLTE
(
v
int64
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLTE
(
FieldUserID
,
v
))
}
// RequestIDEQ applies the EQ predicate on the "request_id" field.
func
RequestIDEQ
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldRequestID
,
v
))
}
// RequestIDNEQ applies the NEQ predicate on the "request_id" field.
func
RequestIDNEQ
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNEQ
(
FieldRequestID
,
v
))
}
// RequestIDIn applies the In predicate on the "request_id" field.
func
RequestIDIn
(
vs
...
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldIn
(
FieldRequestID
,
vs
...
))
}
// RequestIDNotIn applies the NotIn predicate on the "request_id" field.
func
RequestIDNotIn
(
vs
...
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNotIn
(
FieldRequestID
,
vs
...
))
}
// RequestIDGT applies the GT predicate on the "request_id" field.
func
RequestIDGT
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGT
(
FieldRequestID
,
v
))
}
// RequestIDGTE applies the GTE predicate on the "request_id" field.
func
RequestIDGTE
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGTE
(
FieldRequestID
,
v
))
}
// RequestIDLT applies the LT predicate on the "request_id" field.
func
RequestIDLT
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLT
(
FieldRequestID
,
v
))
}
// RequestIDLTE applies the LTE predicate on the "request_id" field.
func
RequestIDLTE
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLTE
(
FieldRequestID
,
v
))
}
// RequestIDContains applies the Contains predicate on the "request_id" field.
func
RequestIDContains
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldContains
(
FieldRequestID
,
v
))
}
// RequestIDHasPrefix applies the HasPrefix predicate on the "request_id" field.
func
RequestIDHasPrefix
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldHasPrefix
(
FieldRequestID
,
v
))
}
// RequestIDHasSuffix applies the HasSuffix predicate on the "request_id" field.
func
RequestIDHasSuffix
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldHasSuffix
(
FieldRequestID
,
v
))
}
// RequestIDIsNil applies the IsNil predicate on the "request_id" field.
func
RequestIDIsNil
()
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldIsNull
(
FieldRequestID
))
}
// RequestIDNotNil applies the NotNil predicate on the "request_id" field.
func
RequestIDNotNil
()
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNotNull
(
FieldRequestID
))
}
// RequestIDEqualFold applies the EqualFold predicate on the "request_id" field.
func
RequestIDEqualFold
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEqualFold
(
FieldRequestID
,
v
))
}
// RequestIDContainsFold applies the ContainsFold predicate on the "request_id" field.
func
RequestIDContainsFold
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldContainsFold
(
FieldRequestID
,
v
))
}
// PathEQ applies the EQ predicate on the "path" field.
func
PathEQ
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldPath
,
v
))
}
// PathNEQ applies the NEQ predicate on the "path" field.
func
PathNEQ
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNEQ
(
FieldPath
,
v
))
}
// PathIn applies the In predicate on the "path" field.
func
PathIn
(
vs
...
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldIn
(
FieldPath
,
vs
...
))
}
// PathNotIn applies the NotIn predicate on the "path" field.
func
PathNotIn
(
vs
...
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNotIn
(
FieldPath
,
vs
...
))
}
// PathGT applies the GT predicate on the "path" field.
func
PathGT
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGT
(
FieldPath
,
v
))
}
// PathGTE applies the GTE predicate on the "path" field.
func
PathGTE
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGTE
(
FieldPath
,
v
))
}
// PathLT applies the LT predicate on the "path" field.
func
PathLT
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLT
(
FieldPath
,
v
))
}
// PathLTE applies the LTE predicate on the "path" field.
func
PathLTE
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLTE
(
FieldPath
,
v
))
}
// PathContains applies the Contains predicate on the "path" field.
func
PathContains
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldContains
(
FieldPath
,
v
))
}
// PathHasPrefix applies the HasPrefix predicate on the "path" field.
func
PathHasPrefix
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldHasPrefix
(
FieldPath
,
v
))
}
// PathHasSuffix applies the HasSuffix predicate on the "path" field.
func
PathHasSuffix
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldHasSuffix
(
FieldPath
,
v
))
}
// PathIsNil applies the IsNil predicate on the "path" field.
func
PathIsNil
()
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldIsNull
(
FieldPath
))
}
// PathNotNil applies the NotNil predicate on the "path" field.
func
PathNotNil
()
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNotNull
(
FieldPath
))
}
// PathEqualFold applies the EqualFold predicate on the "path" field.
func
PathEqualFold
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEqualFold
(
FieldPath
,
v
))
}
// PathContainsFold applies the ContainsFold predicate on the "path" field.
func
PathContainsFold
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldContainsFold
(
FieldPath
,
v
))
}
// MethodEQ applies the EQ predicate on the "method" field.
func
MethodEQ
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldMethod
,
v
))
}
// MethodNEQ applies the NEQ predicate on the "method" field.
func
MethodNEQ
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNEQ
(
FieldMethod
,
v
))
}
// MethodIn applies the In predicate on the "method" field.
func
MethodIn
(
vs
...
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldIn
(
FieldMethod
,
vs
...
))
}
// MethodNotIn applies the NotIn predicate on the "method" field.
func
MethodNotIn
(
vs
...
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNotIn
(
FieldMethod
,
vs
...
))
}
// MethodGT applies the GT predicate on the "method" field.
func
MethodGT
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGT
(
FieldMethod
,
v
))
}
// MethodGTE applies the GTE predicate on the "method" field.
func
MethodGTE
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGTE
(
FieldMethod
,
v
))
}
// MethodLT applies the LT predicate on the "method" field.
func
MethodLT
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLT
(
FieldMethod
,
v
))
}
// MethodLTE applies the LTE predicate on the "method" field.
func
MethodLTE
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLTE
(
FieldMethod
,
v
))
}
// MethodContains applies the Contains predicate on the "method" field.
func
MethodContains
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldContains
(
FieldMethod
,
v
))
}
// MethodHasPrefix applies the HasPrefix predicate on the "method" field.
func
MethodHasPrefix
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldHasPrefix
(
FieldMethod
,
v
))
}
// MethodHasSuffix applies the HasSuffix predicate on the "method" field.
func
MethodHasSuffix
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldHasSuffix
(
FieldMethod
,
v
))
}
// MethodIsNil applies the IsNil predicate on the "method" field.
func
MethodIsNil
()
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldIsNull
(
FieldMethod
))
}
// MethodNotNil applies the NotNil predicate on the "method" field.
func
MethodNotNil
()
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNotNull
(
FieldMethod
))
}
// MethodEqualFold applies the EqualFold predicate on the "method" field.
func
MethodEqualFold
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEqualFold
(
FieldMethod
,
v
))
}
// MethodContainsFold applies the ContainsFold predicate on the "method" field.
func
MethodContainsFold
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldContainsFold
(
FieldMethod
,
v
))
}
// IPAddressEQ applies the EQ predicate on the "ip_address" field.
func
IPAddressEQ
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldIPAddress
,
v
))
}
// IPAddressNEQ applies the NEQ predicate on the "ip_address" field.
func
IPAddressNEQ
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNEQ
(
FieldIPAddress
,
v
))
}
// IPAddressIn applies the In predicate on the "ip_address" field.
func
IPAddressIn
(
vs
...
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldIn
(
FieldIPAddress
,
vs
...
))
}
// IPAddressNotIn applies the NotIn predicate on the "ip_address" field.
func
IPAddressNotIn
(
vs
...
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNotIn
(
FieldIPAddress
,
vs
...
))
}
// IPAddressGT applies the GT predicate on the "ip_address" field.
func
IPAddressGT
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGT
(
FieldIPAddress
,
v
))
}
// IPAddressGTE applies the GTE predicate on the "ip_address" field.
func
IPAddressGTE
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGTE
(
FieldIPAddress
,
v
))
}
// IPAddressLT applies the LT predicate on the "ip_address" field.
func
IPAddressLT
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLT
(
FieldIPAddress
,
v
))
}
// IPAddressLTE applies the LTE predicate on the "ip_address" field.
func
IPAddressLTE
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLTE
(
FieldIPAddress
,
v
))
}
// IPAddressContains applies the Contains predicate on the "ip_address" field.
func
IPAddressContains
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldContains
(
FieldIPAddress
,
v
))
}
// IPAddressHasPrefix applies the HasPrefix predicate on the "ip_address" field.
func
IPAddressHasPrefix
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldHasPrefix
(
FieldIPAddress
,
v
))
}
// IPAddressHasSuffix applies the HasSuffix predicate on the "ip_address" field.
func
IPAddressHasSuffix
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldHasSuffix
(
FieldIPAddress
,
v
))
}
// IPAddressIsNil applies the IsNil predicate on the "ip_address" field.
func
IPAddressIsNil
()
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldIsNull
(
FieldIPAddress
))
}
// IPAddressNotNil applies the NotNil predicate on the "ip_address" field.
func
IPAddressNotNil
()
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNotNull
(
FieldIPAddress
))
}
// IPAddressEqualFold applies the EqualFold predicate on the "ip_address" field.
func
IPAddressEqualFold
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEqualFold
(
FieldIPAddress
,
v
))
}
// IPAddressContainsFold applies the ContainsFold predicate on the "ip_address" field.
func
IPAddressContainsFold
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldContainsFold
(
FieldIPAddress
,
v
))
}
// RequestBodyEQ applies the EQ predicate on the "request_body" field.
func
RequestBodyEQ
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldRequestBody
,
v
))
}
// RequestBodyNEQ applies the NEQ predicate on the "request_body" field.
func
RequestBodyNEQ
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNEQ
(
FieldRequestBody
,
v
))
}
// RequestBodyIn applies the In predicate on the "request_body" field.
func
RequestBodyIn
(
vs
...
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldIn
(
FieldRequestBody
,
vs
...
))
}
// RequestBodyNotIn applies the NotIn predicate on the "request_body" field.
func
RequestBodyNotIn
(
vs
...
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNotIn
(
FieldRequestBody
,
vs
...
))
}
// RequestBodyGT applies the GT predicate on the "request_body" field.
func
RequestBodyGT
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGT
(
FieldRequestBody
,
v
))
}
// RequestBodyGTE applies the GTE predicate on the "request_body" field.
func
RequestBodyGTE
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGTE
(
FieldRequestBody
,
v
))
}
// RequestBodyLT applies the LT predicate on the "request_body" field.
func
RequestBodyLT
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLT
(
FieldRequestBody
,
v
))
}
// RequestBodyLTE applies the LTE predicate on the "request_body" field.
func
RequestBodyLTE
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLTE
(
FieldRequestBody
,
v
))
}
// RequestBodyContains applies the Contains predicate on the "request_body" field.
func
RequestBodyContains
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldContains
(
FieldRequestBody
,
v
))
}
// RequestBodyHasPrefix applies the HasPrefix predicate on the "request_body" field.
func
RequestBodyHasPrefix
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldHasPrefix
(
FieldRequestBody
,
v
))
}
// RequestBodyHasSuffix applies the HasSuffix predicate on the "request_body" field.
func
RequestBodyHasSuffix
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldHasSuffix
(
FieldRequestBody
,
v
))
}
// RequestBodyIsNil applies the IsNil predicate on the "request_body" field.
func
RequestBodyIsNil
()
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldIsNull
(
FieldRequestBody
))
}
// RequestBodyNotNil applies the NotNil predicate on the "request_body" field.
func
RequestBodyNotNil
()
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNotNull
(
FieldRequestBody
))
}
// RequestBodyEqualFold applies the EqualFold predicate on the "request_body" field.
func
RequestBodyEqualFold
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEqualFold
(
FieldRequestBody
,
v
))
}
// RequestBodyContainsFold applies the ContainsFold predicate on the "request_body" field.
func
RequestBodyContainsFold
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldContainsFold
(
FieldRequestBody
,
v
))
}
// ResponseBodyEQ applies the EQ predicate on the "response_body" field.
func
ResponseBodyEQ
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldResponseBody
,
v
))
}
// ResponseBodyNEQ applies the NEQ predicate on the "response_body" field.
func
ResponseBodyNEQ
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNEQ
(
FieldResponseBody
,
v
))
}
// ResponseBodyIn applies the In predicate on the "response_body" field.
func
ResponseBodyIn
(
vs
...
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldIn
(
FieldResponseBody
,
vs
...
))
}
// ResponseBodyNotIn applies the NotIn predicate on the "response_body" field.
func
ResponseBodyNotIn
(
vs
...
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNotIn
(
FieldResponseBody
,
vs
...
))
}
// ResponseBodyGT applies the GT predicate on the "response_body" field.
func
ResponseBodyGT
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGT
(
FieldResponseBody
,
v
))
}
// ResponseBodyGTE applies the GTE predicate on the "response_body" field.
func
ResponseBodyGTE
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGTE
(
FieldResponseBody
,
v
))
}
// ResponseBodyLT applies the LT predicate on the "response_body" field.
func
ResponseBodyLT
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLT
(
FieldResponseBody
,
v
))
}
// ResponseBodyLTE applies the LTE predicate on the "response_body" field.
func
ResponseBodyLTE
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLTE
(
FieldResponseBody
,
v
))
}
// ResponseBodyContains applies the Contains predicate on the "response_body" field.
func
ResponseBodyContains
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldContains
(
FieldResponseBody
,
v
))
}
// ResponseBodyHasPrefix applies the HasPrefix predicate on the "response_body" field.
func
ResponseBodyHasPrefix
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldHasPrefix
(
FieldResponseBody
,
v
))
}
// ResponseBodyHasSuffix applies the HasSuffix predicate on the "response_body" field.
func
ResponseBodyHasSuffix
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldHasSuffix
(
FieldResponseBody
,
v
))
}
// ResponseBodyIsNil applies the IsNil predicate on the "response_body" field.
func
ResponseBodyIsNil
()
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldIsNull
(
FieldResponseBody
))
}
// ResponseBodyNotNil applies the NotNil predicate on the "response_body" field.
func
ResponseBodyNotNil
()
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNotNull
(
FieldResponseBody
))
}
// ResponseBodyEqualFold applies the EqualFold predicate on the "response_body" field.
func
ResponseBodyEqualFold
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEqualFold
(
FieldResponseBody
,
v
))
}
// ResponseBodyContainsFold applies the ContainsFold predicate on the "response_body" field.
func
ResponseBodyContainsFold
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldContainsFold
(
FieldResponseBody
,
v
))
}
// NfsFilePathEQ applies the EQ predicate on the "nfs_file_path" field.
func
NfsFilePathEQ
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldNfsFilePath
,
v
))
}
// NfsFilePathNEQ applies the NEQ predicate on the "nfs_file_path" field.
func
NfsFilePathNEQ
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNEQ
(
FieldNfsFilePath
,
v
))
}
// NfsFilePathIn applies the In predicate on the "nfs_file_path" field.
func
NfsFilePathIn
(
vs
...
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldIn
(
FieldNfsFilePath
,
vs
...
))
}
// NfsFilePathNotIn applies the NotIn predicate on the "nfs_file_path" field.
func
NfsFilePathNotIn
(
vs
...
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNotIn
(
FieldNfsFilePath
,
vs
...
))
}
// NfsFilePathGT applies the GT predicate on the "nfs_file_path" field.
func
NfsFilePathGT
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGT
(
FieldNfsFilePath
,
v
))
}
// NfsFilePathGTE applies the GTE predicate on the "nfs_file_path" field.
func
NfsFilePathGTE
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGTE
(
FieldNfsFilePath
,
v
))
}
// NfsFilePathLT applies the LT predicate on the "nfs_file_path" field.
func
NfsFilePathLT
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLT
(
FieldNfsFilePath
,
v
))
}
// NfsFilePathLTE applies the LTE predicate on the "nfs_file_path" field.
func
NfsFilePathLTE
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLTE
(
FieldNfsFilePath
,
v
))
}
// NfsFilePathContains applies the Contains predicate on the "nfs_file_path" field.
func
NfsFilePathContains
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldContains
(
FieldNfsFilePath
,
v
))
}
// NfsFilePathHasPrefix applies the HasPrefix predicate on the "nfs_file_path" field.
func
NfsFilePathHasPrefix
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldHasPrefix
(
FieldNfsFilePath
,
v
))
}
// NfsFilePathHasSuffix applies the HasSuffix predicate on the "nfs_file_path" field.
func
NfsFilePathHasSuffix
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldHasSuffix
(
FieldNfsFilePath
,
v
))
}
// NfsFilePathIsNil applies the IsNil predicate on the "nfs_file_path" field.
func
NfsFilePathIsNil
()
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldIsNull
(
FieldNfsFilePath
))
}
// NfsFilePathNotNil applies the NotNil predicate on the "nfs_file_path" field.
func
NfsFilePathNotNil
()
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNotNull
(
FieldNfsFilePath
))
}
// NfsFilePathEqualFold applies the EqualFold predicate on the "nfs_file_path" field.
func
NfsFilePathEqualFold
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEqualFold
(
FieldNfsFilePath
,
v
))
}
// NfsFilePathContainsFold applies the ContainsFold predicate on the "nfs_file_path" field.
func
NfsFilePathContainsFold
(
v
string
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldContainsFold
(
FieldNfsFilePath
,
v
))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func
CreatedAtEQ
(
v
time
.
Time
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldEQ
(
FieldCreatedAt
,
v
))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func
CreatedAtNEQ
(
v
time
.
Time
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNEQ
(
FieldCreatedAt
,
v
))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func
CreatedAtIn
(
vs
...
time
.
Time
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldIn
(
FieldCreatedAt
,
vs
...
))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func
CreatedAtNotIn
(
vs
...
time
.
Time
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldNotIn
(
FieldCreatedAt
,
vs
...
))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func
CreatedAtGT
(
v
time
.
Time
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGT
(
FieldCreatedAt
,
v
))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func
CreatedAtGTE
(
v
time
.
Time
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldGTE
(
FieldCreatedAt
,
v
))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func
CreatedAtLT
(
v
time
.
Time
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLT
(
FieldCreatedAt
,
v
))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func
CreatedAtLTE
(
v
time
.
Time
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
FieldLTE
(
FieldCreatedAt
,
v
))
}
// And groups predicates with the AND operator between them.
func
And
(
predicates
...
predicate
.
RequestCaptureLog
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
AndPredicates
(
predicates
...
))
}
// Or groups predicates with the OR operator between them.
func
Or
(
predicates
...
predicate
.
RequestCaptureLog
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
OrPredicates
(
predicates
...
))
}
// Not applies the not operator on the given predicate.
func
Not
(
p
predicate
.
RequestCaptureLog
)
predicate
.
RequestCaptureLog
{
return
predicate
.
RequestCaptureLog
(
sql
.
NotPredicates
(
p
))
}
backend/ent/requestcapturelog_create.go
0 → 100644
View file @
a7386882
// Code generated by ent, DO NOT EDIT.
package
ent
import
(
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/requestcapturelog"
)
// RequestCaptureLogCreate is the builder for creating a RequestCaptureLog entity.
type
RequestCaptureLogCreate
struct
{
config
mutation
*
RequestCaptureLogMutation
hooks
[]
Hook
conflict
[]
sql
.
ConflictOption
}
// SetAPIKeyID sets the "api_key_id" field.
func
(
_c
*
RequestCaptureLogCreate
)
SetAPIKeyID
(
v
int64
)
*
RequestCaptureLogCreate
{
_c
.
mutation
.
SetAPIKeyID
(
v
)
return
_c
}
// SetUserID sets the "user_id" field.
func
(
_c
*
RequestCaptureLogCreate
)
SetUserID
(
v
int64
)
*
RequestCaptureLogCreate
{
_c
.
mutation
.
SetUserID
(
v
)
return
_c
}
// SetRequestID sets the "request_id" field.
func
(
_c
*
RequestCaptureLogCreate
)
SetRequestID
(
v
string
)
*
RequestCaptureLogCreate
{
_c
.
mutation
.
SetRequestID
(
v
)
return
_c
}
// SetNillableRequestID sets the "request_id" field if the given value is not nil.
func
(
_c
*
RequestCaptureLogCreate
)
SetNillableRequestID
(
v
*
string
)
*
RequestCaptureLogCreate
{
if
v
!=
nil
{
_c
.
SetRequestID
(
*
v
)
}
return
_c
}
// SetPath sets the "path" field.
func
(
_c
*
RequestCaptureLogCreate
)
SetPath
(
v
string
)
*
RequestCaptureLogCreate
{
_c
.
mutation
.
SetPath
(
v
)
return
_c
}
// SetNillablePath sets the "path" field if the given value is not nil.
func
(
_c
*
RequestCaptureLogCreate
)
SetNillablePath
(
v
*
string
)
*
RequestCaptureLogCreate
{
if
v
!=
nil
{
_c
.
SetPath
(
*
v
)
}
return
_c
}
// SetMethod sets the "method" field.
func
(
_c
*
RequestCaptureLogCreate
)
SetMethod
(
v
string
)
*
RequestCaptureLogCreate
{
_c
.
mutation
.
SetMethod
(
v
)
return
_c
}
// SetNillableMethod sets the "method" field if the given value is not nil.
func
(
_c
*
RequestCaptureLogCreate
)
SetNillableMethod
(
v
*
string
)
*
RequestCaptureLogCreate
{
if
v
!=
nil
{
_c
.
SetMethod
(
*
v
)
}
return
_c
}
// SetIPAddress sets the "ip_address" field.
func
(
_c
*
RequestCaptureLogCreate
)
SetIPAddress
(
v
string
)
*
RequestCaptureLogCreate
{
_c
.
mutation
.
SetIPAddress
(
v
)
return
_c
}
// SetNillableIPAddress sets the "ip_address" field if the given value is not nil.
func
(
_c
*
RequestCaptureLogCreate
)
SetNillableIPAddress
(
v
*
string
)
*
RequestCaptureLogCreate
{
if
v
!=
nil
{
_c
.
SetIPAddress
(
*
v
)
}
return
_c
}
// SetRequestBody sets the "request_body" field.
func
(
_c
*
RequestCaptureLogCreate
)
SetRequestBody
(
v
string
)
*
RequestCaptureLogCreate
{
_c
.
mutation
.
SetRequestBody
(
v
)
return
_c
}
// SetNillableRequestBody sets the "request_body" field if the given value is not nil.
func
(
_c
*
RequestCaptureLogCreate
)
SetNillableRequestBody
(
v
*
string
)
*
RequestCaptureLogCreate
{
if
v
!=
nil
{
_c
.
SetRequestBody
(
*
v
)
}
return
_c
}
// SetResponseBody sets the "response_body" field.
func
(
_c
*
RequestCaptureLogCreate
)
SetResponseBody
(
v
string
)
*
RequestCaptureLogCreate
{
_c
.
mutation
.
SetResponseBody
(
v
)
return
_c
}
// SetNillableResponseBody sets the "response_body" field if the given value is not nil.
func
(
_c
*
RequestCaptureLogCreate
)
SetNillableResponseBody
(
v
*
string
)
*
RequestCaptureLogCreate
{
if
v
!=
nil
{
_c
.
SetResponseBody
(
*
v
)
}
return
_c
}
// SetNfsFilePath sets the "nfs_file_path" field.
func
(
_c
*
RequestCaptureLogCreate
)
SetNfsFilePath
(
v
string
)
*
RequestCaptureLogCreate
{
_c
.
mutation
.
SetNfsFilePath
(
v
)
return
_c
}
// SetNillableNfsFilePath sets the "nfs_file_path" field if the given value is not nil.
func
(
_c
*
RequestCaptureLogCreate
)
SetNillableNfsFilePath
(
v
*
string
)
*
RequestCaptureLogCreate
{
if
v
!=
nil
{
_c
.
SetNfsFilePath
(
*
v
)
}
return
_c
}
// SetCreatedAt sets the "created_at" field.
func
(
_c
*
RequestCaptureLogCreate
)
SetCreatedAt
(
v
time
.
Time
)
*
RequestCaptureLogCreate
{
_c
.
mutation
.
SetCreatedAt
(
v
)
return
_c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func
(
_c
*
RequestCaptureLogCreate
)
SetNillableCreatedAt
(
v
*
time
.
Time
)
*
RequestCaptureLogCreate
{
if
v
!=
nil
{
_c
.
SetCreatedAt
(
*
v
)
}
return
_c
}
// Mutation returns the RequestCaptureLogMutation object of the builder.
func
(
_c
*
RequestCaptureLogCreate
)
Mutation
()
*
RequestCaptureLogMutation
{
return
_c
.
mutation
}
// Save creates the RequestCaptureLog in the database.
func
(
_c
*
RequestCaptureLogCreate
)
Save
(
ctx
context
.
Context
)
(
*
RequestCaptureLog
,
error
)
{
_c
.
defaults
()
return
withHooks
(
ctx
,
_c
.
sqlSave
,
_c
.
mutation
,
_c
.
hooks
)
}
// SaveX calls Save and panics if Save returns an error.
func
(
_c
*
RequestCaptureLogCreate
)
SaveX
(
ctx
context
.
Context
)
*
RequestCaptureLog
{
v
,
err
:=
_c
.
Save
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
v
}
// Exec executes the query.
func
(
_c
*
RequestCaptureLogCreate
)
Exec
(
ctx
context
.
Context
)
error
{
_
,
err
:=
_c
.
Save
(
ctx
)
return
err
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_c
*
RequestCaptureLogCreate
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
_c
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
// defaults sets the default values of the builder before save.
func
(
_c
*
RequestCaptureLogCreate
)
defaults
()
{
if
_
,
ok
:=
_c
.
mutation
.
CreatedAt
();
!
ok
{
v
:=
requestcapturelog
.
DefaultCreatedAt
()
_c
.
mutation
.
SetCreatedAt
(
v
)
}
}
// check runs all checks and user-defined validators on the builder.
func
(
_c
*
RequestCaptureLogCreate
)
check
()
error
{
if
_
,
ok
:=
_c
.
mutation
.
APIKeyID
();
!
ok
{
return
&
ValidationError
{
Name
:
"api_key_id"
,
err
:
errors
.
New
(
`ent: missing required field "RequestCaptureLog.api_key_id"`
)}
}
if
_
,
ok
:=
_c
.
mutation
.
UserID
();
!
ok
{
return
&
ValidationError
{
Name
:
"user_id"
,
err
:
errors
.
New
(
`ent: missing required field "RequestCaptureLog.user_id"`
)}
}
if
v
,
ok
:=
_c
.
mutation
.
RequestID
();
ok
{
if
err
:=
requestcapturelog
.
RequestIDValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"request_id"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "RequestCaptureLog.request_id": %w`
,
err
)}
}
}
if
v
,
ok
:=
_c
.
mutation
.
Path
();
ok
{
if
err
:=
requestcapturelog
.
PathValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"path"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "RequestCaptureLog.path": %w`
,
err
)}
}
}
if
v
,
ok
:=
_c
.
mutation
.
Method
();
ok
{
if
err
:=
requestcapturelog
.
MethodValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"method"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "RequestCaptureLog.method": %w`
,
err
)}
}
}
if
v
,
ok
:=
_c
.
mutation
.
IPAddress
();
ok
{
if
err
:=
requestcapturelog
.
IPAddressValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"ip_address"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "RequestCaptureLog.ip_address": %w`
,
err
)}
}
}
if
v
,
ok
:=
_c
.
mutation
.
NfsFilePath
();
ok
{
if
err
:=
requestcapturelog
.
NfsFilePathValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"nfs_file_path"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "RequestCaptureLog.nfs_file_path": %w`
,
err
)}
}
}
if
_
,
ok
:=
_c
.
mutation
.
CreatedAt
();
!
ok
{
return
&
ValidationError
{
Name
:
"created_at"
,
err
:
errors
.
New
(
`ent: missing required field "RequestCaptureLog.created_at"`
)}
}
return
nil
}
func
(
_c
*
RequestCaptureLogCreate
)
sqlSave
(
ctx
context
.
Context
)
(
*
RequestCaptureLog
,
error
)
{
if
err
:=
_c
.
check
();
err
!=
nil
{
return
nil
,
err
}
_node
,
_spec
:=
_c
.
createSpec
()
if
err
:=
sqlgraph
.
CreateNode
(
ctx
,
_c
.
driver
,
_spec
);
err
!=
nil
{
if
sqlgraph
.
IsConstraintError
(
err
)
{
err
=
&
ConstraintError
{
msg
:
err
.
Error
(),
wrap
:
err
}
}
return
nil
,
err
}
id
:=
_spec
.
ID
.
Value
.
(
int64
)
_node
.
ID
=
int64
(
id
)
_c
.
mutation
.
id
=
&
_node
.
ID
_c
.
mutation
.
done
=
true
return
_node
,
nil
}
func
(
_c
*
RequestCaptureLogCreate
)
createSpec
()
(
*
RequestCaptureLog
,
*
sqlgraph
.
CreateSpec
)
{
var
(
_node
=
&
RequestCaptureLog
{
config
:
_c
.
config
}
_spec
=
sqlgraph
.
NewCreateSpec
(
requestcapturelog
.
Table
,
sqlgraph
.
NewFieldSpec
(
requestcapturelog
.
FieldID
,
field
.
TypeInt64
))
)
_spec
.
OnConflict
=
_c
.
conflict
if
value
,
ok
:=
_c
.
mutation
.
APIKeyID
();
ok
{
_spec
.
SetField
(
requestcapturelog
.
FieldAPIKeyID
,
field
.
TypeInt64
,
value
)
_node
.
APIKeyID
=
value
}
if
value
,
ok
:=
_c
.
mutation
.
UserID
();
ok
{
_spec
.
SetField
(
requestcapturelog
.
FieldUserID
,
field
.
TypeInt64
,
value
)
_node
.
UserID
=
value
}
if
value
,
ok
:=
_c
.
mutation
.
RequestID
();
ok
{
_spec
.
SetField
(
requestcapturelog
.
FieldRequestID
,
field
.
TypeString
,
value
)
_node
.
RequestID
=
&
value
}
if
value
,
ok
:=
_c
.
mutation
.
Path
();
ok
{
_spec
.
SetField
(
requestcapturelog
.
FieldPath
,
field
.
TypeString
,
value
)
_node
.
Path
=
&
value
}
if
value
,
ok
:=
_c
.
mutation
.
Method
();
ok
{
_spec
.
SetField
(
requestcapturelog
.
FieldMethod
,
field
.
TypeString
,
value
)
_node
.
Method
=
&
value
}
if
value
,
ok
:=
_c
.
mutation
.
IPAddress
();
ok
{
_spec
.
SetField
(
requestcapturelog
.
FieldIPAddress
,
field
.
TypeString
,
value
)
_node
.
IPAddress
=
&
value
}
if
value
,
ok
:=
_c
.
mutation
.
RequestBody
();
ok
{
_spec
.
SetField
(
requestcapturelog
.
FieldRequestBody
,
field
.
TypeString
,
value
)
_node
.
RequestBody
=
&
value
}
if
value
,
ok
:=
_c
.
mutation
.
ResponseBody
();
ok
{
_spec
.
SetField
(
requestcapturelog
.
FieldResponseBody
,
field
.
TypeString
,
value
)
_node
.
ResponseBody
=
&
value
}
if
value
,
ok
:=
_c
.
mutation
.
NfsFilePath
();
ok
{
_spec
.
SetField
(
requestcapturelog
.
FieldNfsFilePath
,
field
.
TypeString
,
value
)
_node
.
NfsFilePath
=
&
value
}
if
value
,
ok
:=
_c
.
mutation
.
CreatedAt
();
ok
{
_spec
.
SetField
(
requestcapturelog
.
FieldCreatedAt
,
field
.
TypeTime
,
value
)
_node
.
CreatedAt
=
value
}
return
_node
,
_spec
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.RequestCaptureLog.Create().
// SetAPIKeyID(v).
// OnConflict(
// // Update the row with the new values
// // the was proposed for insertion.
// sql.ResolveWithNewValues(),
// ).
// // Override some of the fields with custom
// // update values.
// Update(func(u *ent.RequestCaptureLogUpsert) {
// SetAPIKeyID(v+v).
// }).
// Exec(ctx)
func
(
_c
*
RequestCaptureLogCreate
)
OnConflict
(
opts
...
sql
.
ConflictOption
)
*
RequestCaptureLogUpsertOne
{
_c
.
conflict
=
opts
return
&
RequestCaptureLogUpsertOne
{
create
:
_c
,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.RequestCaptureLog.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func
(
_c
*
RequestCaptureLogCreate
)
OnConflictColumns
(
columns
...
string
)
*
RequestCaptureLogUpsertOne
{
_c
.
conflict
=
append
(
_c
.
conflict
,
sql
.
ConflictColumns
(
columns
...
))
return
&
RequestCaptureLogUpsertOne
{
create
:
_c
,
}
}
type
(
// RequestCaptureLogUpsertOne is the builder for "upsert"-ing
// one RequestCaptureLog node.
RequestCaptureLogUpsertOne
struct
{
create
*
RequestCaptureLogCreate
}
// RequestCaptureLogUpsert is the "OnConflict" setter.
RequestCaptureLogUpsert
struct
{
*
sql
.
UpdateSet
}
)
// SetAPIKeyID sets the "api_key_id" field.
func
(
u
*
RequestCaptureLogUpsert
)
SetAPIKeyID
(
v
int64
)
*
RequestCaptureLogUpsert
{
u
.
Set
(
requestcapturelog
.
FieldAPIKeyID
,
v
)
return
u
}
// UpdateAPIKeyID sets the "api_key_id" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsert
)
UpdateAPIKeyID
()
*
RequestCaptureLogUpsert
{
u
.
SetExcluded
(
requestcapturelog
.
FieldAPIKeyID
)
return
u
}
// AddAPIKeyID adds v to the "api_key_id" field.
func
(
u
*
RequestCaptureLogUpsert
)
AddAPIKeyID
(
v
int64
)
*
RequestCaptureLogUpsert
{
u
.
Add
(
requestcapturelog
.
FieldAPIKeyID
,
v
)
return
u
}
// SetUserID sets the "user_id" field.
func
(
u
*
RequestCaptureLogUpsert
)
SetUserID
(
v
int64
)
*
RequestCaptureLogUpsert
{
u
.
Set
(
requestcapturelog
.
FieldUserID
,
v
)
return
u
}
// UpdateUserID sets the "user_id" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsert
)
UpdateUserID
()
*
RequestCaptureLogUpsert
{
u
.
SetExcluded
(
requestcapturelog
.
FieldUserID
)
return
u
}
// AddUserID adds v to the "user_id" field.
func
(
u
*
RequestCaptureLogUpsert
)
AddUserID
(
v
int64
)
*
RequestCaptureLogUpsert
{
u
.
Add
(
requestcapturelog
.
FieldUserID
,
v
)
return
u
}
// SetRequestID sets the "request_id" field.
func
(
u
*
RequestCaptureLogUpsert
)
SetRequestID
(
v
string
)
*
RequestCaptureLogUpsert
{
u
.
Set
(
requestcapturelog
.
FieldRequestID
,
v
)
return
u
}
// UpdateRequestID sets the "request_id" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsert
)
UpdateRequestID
()
*
RequestCaptureLogUpsert
{
u
.
SetExcluded
(
requestcapturelog
.
FieldRequestID
)
return
u
}
// ClearRequestID clears the value of the "request_id" field.
func
(
u
*
RequestCaptureLogUpsert
)
ClearRequestID
()
*
RequestCaptureLogUpsert
{
u
.
SetNull
(
requestcapturelog
.
FieldRequestID
)
return
u
}
// SetPath sets the "path" field.
func
(
u
*
RequestCaptureLogUpsert
)
SetPath
(
v
string
)
*
RequestCaptureLogUpsert
{
u
.
Set
(
requestcapturelog
.
FieldPath
,
v
)
return
u
}
// UpdatePath sets the "path" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsert
)
UpdatePath
()
*
RequestCaptureLogUpsert
{
u
.
SetExcluded
(
requestcapturelog
.
FieldPath
)
return
u
}
// ClearPath clears the value of the "path" field.
func
(
u
*
RequestCaptureLogUpsert
)
ClearPath
()
*
RequestCaptureLogUpsert
{
u
.
SetNull
(
requestcapturelog
.
FieldPath
)
return
u
}
// SetMethod sets the "method" field.
func
(
u
*
RequestCaptureLogUpsert
)
SetMethod
(
v
string
)
*
RequestCaptureLogUpsert
{
u
.
Set
(
requestcapturelog
.
FieldMethod
,
v
)
return
u
}
// UpdateMethod sets the "method" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsert
)
UpdateMethod
()
*
RequestCaptureLogUpsert
{
u
.
SetExcluded
(
requestcapturelog
.
FieldMethod
)
return
u
}
// ClearMethod clears the value of the "method" field.
func
(
u
*
RequestCaptureLogUpsert
)
ClearMethod
()
*
RequestCaptureLogUpsert
{
u
.
SetNull
(
requestcapturelog
.
FieldMethod
)
return
u
}
// SetIPAddress sets the "ip_address" field.
func
(
u
*
RequestCaptureLogUpsert
)
SetIPAddress
(
v
string
)
*
RequestCaptureLogUpsert
{
u
.
Set
(
requestcapturelog
.
FieldIPAddress
,
v
)
return
u
}
// UpdateIPAddress sets the "ip_address" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsert
)
UpdateIPAddress
()
*
RequestCaptureLogUpsert
{
u
.
SetExcluded
(
requestcapturelog
.
FieldIPAddress
)
return
u
}
// ClearIPAddress clears the value of the "ip_address" field.
func
(
u
*
RequestCaptureLogUpsert
)
ClearIPAddress
()
*
RequestCaptureLogUpsert
{
u
.
SetNull
(
requestcapturelog
.
FieldIPAddress
)
return
u
}
// SetRequestBody sets the "request_body" field.
func
(
u
*
RequestCaptureLogUpsert
)
SetRequestBody
(
v
string
)
*
RequestCaptureLogUpsert
{
u
.
Set
(
requestcapturelog
.
FieldRequestBody
,
v
)
return
u
}
// UpdateRequestBody sets the "request_body" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsert
)
UpdateRequestBody
()
*
RequestCaptureLogUpsert
{
u
.
SetExcluded
(
requestcapturelog
.
FieldRequestBody
)
return
u
}
// ClearRequestBody clears the value of the "request_body" field.
func
(
u
*
RequestCaptureLogUpsert
)
ClearRequestBody
()
*
RequestCaptureLogUpsert
{
u
.
SetNull
(
requestcapturelog
.
FieldRequestBody
)
return
u
}
// SetResponseBody sets the "response_body" field.
func
(
u
*
RequestCaptureLogUpsert
)
SetResponseBody
(
v
string
)
*
RequestCaptureLogUpsert
{
u
.
Set
(
requestcapturelog
.
FieldResponseBody
,
v
)
return
u
}
// UpdateResponseBody sets the "response_body" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsert
)
UpdateResponseBody
()
*
RequestCaptureLogUpsert
{
u
.
SetExcluded
(
requestcapturelog
.
FieldResponseBody
)
return
u
}
// ClearResponseBody clears the value of the "response_body" field.
func
(
u
*
RequestCaptureLogUpsert
)
ClearResponseBody
()
*
RequestCaptureLogUpsert
{
u
.
SetNull
(
requestcapturelog
.
FieldResponseBody
)
return
u
}
// SetNfsFilePath sets the "nfs_file_path" field.
func
(
u
*
RequestCaptureLogUpsert
)
SetNfsFilePath
(
v
string
)
*
RequestCaptureLogUpsert
{
u
.
Set
(
requestcapturelog
.
FieldNfsFilePath
,
v
)
return
u
}
// UpdateNfsFilePath sets the "nfs_file_path" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsert
)
UpdateNfsFilePath
()
*
RequestCaptureLogUpsert
{
u
.
SetExcluded
(
requestcapturelog
.
FieldNfsFilePath
)
return
u
}
// ClearNfsFilePath clears the value of the "nfs_file_path" field.
func
(
u
*
RequestCaptureLogUpsert
)
ClearNfsFilePath
()
*
RequestCaptureLogUpsert
{
u
.
SetNull
(
requestcapturelog
.
FieldNfsFilePath
)
return
u
}
// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
// client.RequestCaptureLog.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func
(
u
*
RequestCaptureLogUpsertOne
)
UpdateNewValues
()
*
RequestCaptureLogUpsertOne
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWithNewValues
())
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWith
(
func
(
s
*
sql
.
UpdateSet
)
{
if
_
,
exists
:=
u
.
create
.
mutation
.
CreatedAt
();
exists
{
s
.
SetIgnore
(
requestcapturelog
.
FieldCreatedAt
)
}
}))
return
u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.RequestCaptureLog.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func
(
u
*
RequestCaptureLogUpsertOne
)
Ignore
()
*
RequestCaptureLogUpsertOne
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWithIgnore
())
return
u
}
// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func
(
u
*
RequestCaptureLogUpsertOne
)
DoNothing
()
*
RequestCaptureLogUpsertOne
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
DoNothing
())
return
u
}
// Update allows overriding fields `UPDATE` values. See the RequestCaptureLogCreate.OnConflict
// documentation for more info.
func
(
u
*
RequestCaptureLogUpsertOne
)
Update
(
set
func
(
*
RequestCaptureLogUpsert
))
*
RequestCaptureLogUpsertOne
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWith
(
func
(
update
*
sql
.
UpdateSet
)
{
set
(
&
RequestCaptureLogUpsert
{
UpdateSet
:
update
})
}))
return
u
}
// SetAPIKeyID sets the "api_key_id" field.
func
(
u
*
RequestCaptureLogUpsertOne
)
SetAPIKeyID
(
v
int64
)
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
SetAPIKeyID
(
v
)
})
}
// AddAPIKeyID adds v to the "api_key_id" field.
func
(
u
*
RequestCaptureLogUpsertOne
)
AddAPIKeyID
(
v
int64
)
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
AddAPIKeyID
(
v
)
})
}
// UpdateAPIKeyID sets the "api_key_id" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsertOne
)
UpdateAPIKeyID
()
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
UpdateAPIKeyID
()
})
}
// SetUserID sets the "user_id" field.
func
(
u
*
RequestCaptureLogUpsertOne
)
SetUserID
(
v
int64
)
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
SetUserID
(
v
)
})
}
// AddUserID adds v to the "user_id" field.
func
(
u
*
RequestCaptureLogUpsertOne
)
AddUserID
(
v
int64
)
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
AddUserID
(
v
)
})
}
// UpdateUserID sets the "user_id" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsertOne
)
UpdateUserID
()
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
UpdateUserID
()
})
}
// SetRequestID sets the "request_id" field.
func
(
u
*
RequestCaptureLogUpsertOne
)
SetRequestID
(
v
string
)
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
SetRequestID
(
v
)
})
}
// UpdateRequestID sets the "request_id" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsertOne
)
UpdateRequestID
()
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
UpdateRequestID
()
})
}
// ClearRequestID clears the value of the "request_id" field.
func
(
u
*
RequestCaptureLogUpsertOne
)
ClearRequestID
()
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
ClearRequestID
()
})
}
// SetPath sets the "path" field.
func
(
u
*
RequestCaptureLogUpsertOne
)
SetPath
(
v
string
)
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
SetPath
(
v
)
})
}
// UpdatePath sets the "path" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsertOne
)
UpdatePath
()
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
UpdatePath
()
})
}
// ClearPath clears the value of the "path" field.
func
(
u
*
RequestCaptureLogUpsertOne
)
ClearPath
()
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
ClearPath
()
})
}
// SetMethod sets the "method" field.
func
(
u
*
RequestCaptureLogUpsertOne
)
SetMethod
(
v
string
)
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
SetMethod
(
v
)
})
}
// UpdateMethod sets the "method" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsertOne
)
UpdateMethod
()
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
UpdateMethod
()
})
}
// ClearMethod clears the value of the "method" field.
func
(
u
*
RequestCaptureLogUpsertOne
)
ClearMethod
()
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
ClearMethod
()
})
}
// SetIPAddress sets the "ip_address" field.
func
(
u
*
RequestCaptureLogUpsertOne
)
SetIPAddress
(
v
string
)
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
SetIPAddress
(
v
)
})
}
// UpdateIPAddress sets the "ip_address" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsertOne
)
UpdateIPAddress
()
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
UpdateIPAddress
()
})
}
// ClearIPAddress clears the value of the "ip_address" field.
func
(
u
*
RequestCaptureLogUpsertOne
)
ClearIPAddress
()
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
ClearIPAddress
()
})
}
// SetRequestBody sets the "request_body" field.
func
(
u
*
RequestCaptureLogUpsertOne
)
SetRequestBody
(
v
string
)
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
SetRequestBody
(
v
)
})
}
// UpdateRequestBody sets the "request_body" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsertOne
)
UpdateRequestBody
()
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
UpdateRequestBody
()
})
}
// ClearRequestBody clears the value of the "request_body" field.
func
(
u
*
RequestCaptureLogUpsertOne
)
ClearRequestBody
()
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
ClearRequestBody
()
})
}
// SetResponseBody sets the "response_body" field.
func
(
u
*
RequestCaptureLogUpsertOne
)
SetResponseBody
(
v
string
)
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
SetResponseBody
(
v
)
})
}
// UpdateResponseBody sets the "response_body" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsertOne
)
UpdateResponseBody
()
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
UpdateResponseBody
()
})
}
// ClearResponseBody clears the value of the "response_body" field.
func
(
u
*
RequestCaptureLogUpsertOne
)
ClearResponseBody
()
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
ClearResponseBody
()
})
}
// SetNfsFilePath sets the "nfs_file_path" field.
func
(
u
*
RequestCaptureLogUpsertOne
)
SetNfsFilePath
(
v
string
)
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
SetNfsFilePath
(
v
)
})
}
// UpdateNfsFilePath sets the "nfs_file_path" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsertOne
)
UpdateNfsFilePath
()
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
UpdateNfsFilePath
()
})
}
// ClearNfsFilePath clears the value of the "nfs_file_path" field.
func
(
u
*
RequestCaptureLogUpsertOne
)
ClearNfsFilePath
()
*
RequestCaptureLogUpsertOne
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
ClearNfsFilePath
()
})
}
// Exec executes the query.
func
(
u
*
RequestCaptureLogUpsertOne
)
Exec
(
ctx
context
.
Context
)
error
{
if
len
(
u
.
create
.
conflict
)
==
0
{
return
errors
.
New
(
"ent: missing options for RequestCaptureLogCreate.OnConflict"
)
}
return
u
.
create
.
Exec
(
ctx
)
}
// ExecX is like Exec, but panics if an error occurs.
func
(
u
*
RequestCaptureLogUpsertOne
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
u
.
create
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
// Exec executes the UPSERT query and returns the inserted/updated ID.
func
(
u
*
RequestCaptureLogUpsertOne
)
ID
(
ctx
context
.
Context
)
(
id
int64
,
err
error
)
{
node
,
err
:=
u
.
create
.
Save
(
ctx
)
if
err
!=
nil
{
return
id
,
err
}
return
node
.
ID
,
nil
}
// IDX is like ID, but panics if an error occurs.
func
(
u
*
RequestCaptureLogUpsertOne
)
IDX
(
ctx
context
.
Context
)
int64
{
id
,
err
:=
u
.
ID
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
id
}
// RequestCaptureLogCreateBulk is the builder for creating many RequestCaptureLog entities in bulk.
type
RequestCaptureLogCreateBulk
struct
{
config
err
error
builders
[]
*
RequestCaptureLogCreate
conflict
[]
sql
.
ConflictOption
}
// Save creates the RequestCaptureLog entities in the database.
func
(
_c
*
RequestCaptureLogCreateBulk
)
Save
(
ctx
context
.
Context
)
([]
*
RequestCaptureLog
,
error
)
{
if
_c
.
err
!=
nil
{
return
nil
,
_c
.
err
}
specs
:=
make
([]
*
sqlgraph
.
CreateSpec
,
len
(
_c
.
builders
))
nodes
:=
make
([]
*
RequestCaptureLog
,
len
(
_c
.
builders
))
mutators
:=
make
([]
Mutator
,
len
(
_c
.
builders
))
for
i
:=
range
_c
.
builders
{
func
(
i
int
,
root
context
.
Context
)
{
builder
:=
_c
.
builders
[
i
]
builder
.
defaults
()
var
mut
Mutator
=
MutateFunc
(
func
(
ctx
context
.
Context
,
m
Mutation
)
(
Value
,
error
)
{
mutation
,
ok
:=
m
.
(
*
RequestCaptureLogMutation
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"unexpected mutation type %T"
,
m
)
}
if
err
:=
builder
.
check
();
err
!=
nil
{
return
nil
,
err
}
builder
.
mutation
=
mutation
var
err
error
nodes
[
i
],
specs
[
i
]
=
builder
.
createSpec
()
if
i
<
len
(
mutators
)
-
1
{
_
,
err
=
mutators
[
i
+
1
]
.
Mutate
(
root
,
_c
.
builders
[
i
+
1
]
.
mutation
)
}
else
{
spec
:=
&
sqlgraph
.
BatchCreateSpec
{
Nodes
:
specs
}
spec
.
OnConflict
=
_c
.
conflict
// Invoke the actual operation on the latest mutation in the chain.
if
err
=
sqlgraph
.
BatchCreate
(
ctx
,
_c
.
driver
,
spec
);
err
!=
nil
{
if
sqlgraph
.
IsConstraintError
(
err
)
{
err
=
&
ConstraintError
{
msg
:
err
.
Error
(),
wrap
:
err
}
}
}
}
if
err
!=
nil
{
return
nil
,
err
}
mutation
.
id
=
&
nodes
[
i
]
.
ID
if
specs
[
i
]
.
ID
.
Value
!=
nil
{
id
:=
specs
[
i
]
.
ID
.
Value
.
(
int64
)
nodes
[
i
]
.
ID
=
int64
(
id
)
}
mutation
.
done
=
true
return
nodes
[
i
],
nil
})
for
i
:=
len
(
builder
.
hooks
)
-
1
;
i
>=
0
;
i
--
{
mut
=
builder
.
hooks
[
i
](
mut
)
}
mutators
[
i
]
=
mut
}(
i
,
ctx
)
}
if
len
(
mutators
)
>
0
{
if
_
,
err
:=
mutators
[
0
]
.
Mutate
(
ctx
,
_c
.
builders
[
0
]
.
mutation
);
err
!=
nil
{
return
nil
,
err
}
}
return
nodes
,
nil
}
// SaveX is like Save, but panics if an error occurs.
func
(
_c
*
RequestCaptureLogCreateBulk
)
SaveX
(
ctx
context
.
Context
)
[]
*
RequestCaptureLog
{
v
,
err
:=
_c
.
Save
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
v
}
// Exec executes the query.
func
(
_c
*
RequestCaptureLogCreateBulk
)
Exec
(
ctx
context
.
Context
)
error
{
_
,
err
:=
_c
.
Save
(
ctx
)
return
err
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_c
*
RequestCaptureLogCreateBulk
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
_c
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.RequestCaptureLog.CreateBulk(builders...).
// OnConflict(
// // Update the row with the new values
// // the was proposed for insertion.
// sql.ResolveWithNewValues(),
// ).
// // Override some of the fields with custom
// // update values.
// Update(func(u *ent.RequestCaptureLogUpsert) {
// SetAPIKeyID(v+v).
// }).
// Exec(ctx)
func
(
_c
*
RequestCaptureLogCreateBulk
)
OnConflict
(
opts
...
sql
.
ConflictOption
)
*
RequestCaptureLogUpsertBulk
{
_c
.
conflict
=
opts
return
&
RequestCaptureLogUpsertBulk
{
create
:
_c
,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.RequestCaptureLog.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func
(
_c
*
RequestCaptureLogCreateBulk
)
OnConflictColumns
(
columns
...
string
)
*
RequestCaptureLogUpsertBulk
{
_c
.
conflict
=
append
(
_c
.
conflict
,
sql
.
ConflictColumns
(
columns
...
))
return
&
RequestCaptureLogUpsertBulk
{
create
:
_c
,
}
}
// RequestCaptureLogUpsertBulk is the builder for "upsert"-ing
// a bulk of RequestCaptureLog nodes.
type
RequestCaptureLogUpsertBulk
struct
{
create
*
RequestCaptureLogCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.RequestCaptureLog.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func
(
u
*
RequestCaptureLogUpsertBulk
)
UpdateNewValues
()
*
RequestCaptureLogUpsertBulk
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWithNewValues
())
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWith
(
func
(
s
*
sql
.
UpdateSet
)
{
for
_
,
b
:=
range
u
.
create
.
builders
{
if
_
,
exists
:=
b
.
mutation
.
CreatedAt
();
exists
{
s
.
SetIgnore
(
requestcapturelog
.
FieldCreatedAt
)
}
}
}))
return
u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.RequestCaptureLog.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func
(
u
*
RequestCaptureLogUpsertBulk
)
Ignore
()
*
RequestCaptureLogUpsertBulk
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWithIgnore
())
return
u
}
// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func
(
u
*
RequestCaptureLogUpsertBulk
)
DoNothing
()
*
RequestCaptureLogUpsertBulk
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
DoNothing
())
return
u
}
// Update allows overriding fields `UPDATE` values. See the RequestCaptureLogCreateBulk.OnConflict
// documentation for more info.
func
(
u
*
RequestCaptureLogUpsertBulk
)
Update
(
set
func
(
*
RequestCaptureLogUpsert
))
*
RequestCaptureLogUpsertBulk
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWith
(
func
(
update
*
sql
.
UpdateSet
)
{
set
(
&
RequestCaptureLogUpsert
{
UpdateSet
:
update
})
}))
return
u
}
// SetAPIKeyID sets the "api_key_id" field.
func
(
u
*
RequestCaptureLogUpsertBulk
)
SetAPIKeyID
(
v
int64
)
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
SetAPIKeyID
(
v
)
})
}
// AddAPIKeyID adds v to the "api_key_id" field.
func
(
u
*
RequestCaptureLogUpsertBulk
)
AddAPIKeyID
(
v
int64
)
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
AddAPIKeyID
(
v
)
})
}
// UpdateAPIKeyID sets the "api_key_id" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsertBulk
)
UpdateAPIKeyID
()
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
UpdateAPIKeyID
()
})
}
// SetUserID sets the "user_id" field.
func
(
u
*
RequestCaptureLogUpsertBulk
)
SetUserID
(
v
int64
)
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
SetUserID
(
v
)
})
}
// AddUserID adds v to the "user_id" field.
func
(
u
*
RequestCaptureLogUpsertBulk
)
AddUserID
(
v
int64
)
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
AddUserID
(
v
)
})
}
// UpdateUserID sets the "user_id" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsertBulk
)
UpdateUserID
()
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
UpdateUserID
()
})
}
// SetRequestID sets the "request_id" field.
func
(
u
*
RequestCaptureLogUpsertBulk
)
SetRequestID
(
v
string
)
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
SetRequestID
(
v
)
})
}
// UpdateRequestID sets the "request_id" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsertBulk
)
UpdateRequestID
()
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
UpdateRequestID
()
})
}
// ClearRequestID clears the value of the "request_id" field.
func
(
u
*
RequestCaptureLogUpsertBulk
)
ClearRequestID
()
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
ClearRequestID
()
})
}
// SetPath sets the "path" field.
func
(
u
*
RequestCaptureLogUpsertBulk
)
SetPath
(
v
string
)
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
SetPath
(
v
)
})
}
// UpdatePath sets the "path" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsertBulk
)
UpdatePath
()
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
UpdatePath
()
})
}
// ClearPath clears the value of the "path" field.
func
(
u
*
RequestCaptureLogUpsertBulk
)
ClearPath
()
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
ClearPath
()
})
}
// SetMethod sets the "method" field.
func
(
u
*
RequestCaptureLogUpsertBulk
)
SetMethod
(
v
string
)
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
SetMethod
(
v
)
})
}
// UpdateMethod sets the "method" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsertBulk
)
UpdateMethod
()
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
UpdateMethod
()
})
}
// ClearMethod clears the value of the "method" field.
func
(
u
*
RequestCaptureLogUpsertBulk
)
ClearMethod
()
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
ClearMethod
()
})
}
// SetIPAddress sets the "ip_address" field.
func
(
u
*
RequestCaptureLogUpsertBulk
)
SetIPAddress
(
v
string
)
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
SetIPAddress
(
v
)
})
}
// UpdateIPAddress sets the "ip_address" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsertBulk
)
UpdateIPAddress
()
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
UpdateIPAddress
()
})
}
// ClearIPAddress clears the value of the "ip_address" field.
func
(
u
*
RequestCaptureLogUpsertBulk
)
ClearIPAddress
()
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
ClearIPAddress
()
})
}
// SetRequestBody sets the "request_body" field.
func
(
u
*
RequestCaptureLogUpsertBulk
)
SetRequestBody
(
v
string
)
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
SetRequestBody
(
v
)
})
}
// UpdateRequestBody sets the "request_body" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsertBulk
)
UpdateRequestBody
()
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
UpdateRequestBody
()
})
}
// ClearRequestBody clears the value of the "request_body" field.
func
(
u
*
RequestCaptureLogUpsertBulk
)
ClearRequestBody
()
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
ClearRequestBody
()
})
}
// SetResponseBody sets the "response_body" field.
func
(
u
*
RequestCaptureLogUpsertBulk
)
SetResponseBody
(
v
string
)
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
SetResponseBody
(
v
)
})
}
// UpdateResponseBody sets the "response_body" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsertBulk
)
UpdateResponseBody
()
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
UpdateResponseBody
()
})
}
// ClearResponseBody clears the value of the "response_body" field.
func
(
u
*
RequestCaptureLogUpsertBulk
)
ClearResponseBody
()
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
ClearResponseBody
()
})
}
// SetNfsFilePath sets the "nfs_file_path" field.
func
(
u
*
RequestCaptureLogUpsertBulk
)
SetNfsFilePath
(
v
string
)
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
SetNfsFilePath
(
v
)
})
}
// UpdateNfsFilePath sets the "nfs_file_path" field to the value that was provided on create.
func
(
u
*
RequestCaptureLogUpsertBulk
)
UpdateNfsFilePath
()
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
UpdateNfsFilePath
()
})
}
// ClearNfsFilePath clears the value of the "nfs_file_path" field.
func
(
u
*
RequestCaptureLogUpsertBulk
)
ClearNfsFilePath
()
*
RequestCaptureLogUpsertBulk
{
return
u
.
Update
(
func
(
s
*
RequestCaptureLogUpsert
)
{
s
.
ClearNfsFilePath
()
})
}
// Exec executes the query.
func
(
u
*
RequestCaptureLogUpsertBulk
)
Exec
(
ctx
context
.
Context
)
error
{
if
u
.
create
.
err
!=
nil
{
return
u
.
create
.
err
}
for
i
,
b
:=
range
u
.
create
.
builders
{
if
len
(
b
.
conflict
)
!=
0
{
return
fmt
.
Errorf
(
"ent: OnConflict was set for builder %d. Set it on the RequestCaptureLogCreateBulk instead"
,
i
)
}
}
if
len
(
u
.
create
.
conflict
)
==
0
{
return
errors
.
New
(
"ent: missing options for RequestCaptureLogCreateBulk.OnConflict"
)
}
return
u
.
create
.
Exec
(
ctx
)
}
// ExecX is like Exec, but panics if an error occurs.
func
(
u
*
RequestCaptureLogUpsertBulk
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
u
.
create
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
backend/ent/requestcapturelog_delete.go
0 → 100644
View file @
a7386882
// Code generated by ent, DO NOT EDIT.
package
ent
import
(
"context"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/predicate"
"github.com/Wei-Shaw/sub2api/ent/requestcapturelog"
)
// RequestCaptureLogDelete is the builder for deleting a RequestCaptureLog entity.
type
RequestCaptureLogDelete
struct
{
config
hooks
[]
Hook
mutation
*
RequestCaptureLogMutation
}
// Where appends a list predicates to the RequestCaptureLogDelete builder.
func
(
_d
*
RequestCaptureLogDelete
)
Where
(
ps
...
predicate
.
RequestCaptureLog
)
*
RequestCaptureLogDelete
{
_d
.
mutation
.
Where
(
ps
...
)
return
_d
}
// Exec executes the deletion query and returns how many vertices were deleted.
func
(
_d
*
RequestCaptureLogDelete
)
Exec
(
ctx
context
.
Context
)
(
int
,
error
)
{
return
withHooks
(
ctx
,
_d
.
sqlExec
,
_d
.
mutation
,
_d
.
hooks
)
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_d
*
RequestCaptureLogDelete
)
ExecX
(
ctx
context
.
Context
)
int
{
n
,
err
:=
_d
.
Exec
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
n
}
func
(
_d
*
RequestCaptureLogDelete
)
sqlExec
(
ctx
context
.
Context
)
(
int
,
error
)
{
_spec
:=
sqlgraph
.
NewDeleteSpec
(
requestcapturelog
.
Table
,
sqlgraph
.
NewFieldSpec
(
requestcapturelog
.
FieldID
,
field
.
TypeInt64
))
if
ps
:=
_d
.
mutation
.
predicates
;
len
(
ps
)
>
0
{
_spec
.
Predicate
=
func
(
selector
*
sql
.
Selector
)
{
for
i
:=
range
ps
{
ps
[
i
](
selector
)
}
}
}
affected
,
err
:=
sqlgraph
.
DeleteNodes
(
ctx
,
_d
.
driver
,
_spec
)
if
err
!=
nil
&&
sqlgraph
.
IsConstraintError
(
err
)
{
err
=
&
ConstraintError
{
msg
:
err
.
Error
(),
wrap
:
err
}
}
_d
.
mutation
.
done
=
true
return
affected
,
err
}
// RequestCaptureLogDeleteOne is the builder for deleting a single RequestCaptureLog entity.
type
RequestCaptureLogDeleteOne
struct
{
_d
*
RequestCaptureLogDelete
}
// Where appends a list predicates to the RequestCaptureLogDelete builder.
func
(
_d
*
RequestCaptureLogDeleteOne
)
Where
(
ps
...
predicate
.
RequestCaptureLog
)
*
RequestCaptureLogDeleteOne
{
_d
.
_d
.
mutation
.
Where
(
ps
...
)
return
_d
}
// Exec executes the deletion query.
func
(
_d
*
RequestCaptureLogDeleteOne
)
Exec
(
ctx
context
.
Context
)
error
{
n
,
err
:=
_d
.
_d
.
Exec
(
ctx
)
switch
{
case
err
!=
nil
:
return
err
case
n
==
0
:
return
&
NotFoundError
{
requestcapturelog
.
Label
}
default
:
return
nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_d
*
RequestCaptureLogDeleteOne
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
_d
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
backend/ent/requestcapturelog_query.go
0 → 100644
View file @
a7386882
// Code generated by ent, DO NOT EDIT.
package
ent
import
(
"context"
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/predicate"
"github.com/Wei-Shaw/sub2api/ent/requestcapturelog"
)
// RequestCaptureLogQuery is the builder for querying RequestCaptureLog entities.
type
RequestCaptureLogQuery
struct
{
config
ctx
*
QueryContext
order
[]
requestcapturelog
.
OrderOption
inters
[]
Interceptor
predicates
[]
predicate
.
RequestCaptureLog
modifiers
[]
func
(
*
sql
.
Selector
)
// intermediate query (i.e. traversal path).
sql
*
sql
.
Selector
path
func
(
context
.
Context
)
(
*
sql
.
Selector
,
error
)
}
// Where adds a new predicate for the RequestCaptureLogQuery builder.
func
(
_q
*
RequestCaptureLogQuery
)
Where
(
ps
...
predicate
.
RequestCaptureLog
)
*
RequestCaptureLogQuery
{
_q
.
predicates
=
append
(
_q
.
predicates
,
ps
...
)
return
_q
}
// Limit the number of records to be returned by this query.
func
(
_q
*
RequestCaptureLogQuery
)
Limit
(
limit
int
)
*
RequestCaptureLogQuery
{
_q
.
ctx
.
Limit
=
&
limit
return
_q
}
// Offset to start from.
func
(
_q
*
RequestCaptureLogQuery
)
Offset
(
offset
int
)
*
RequestCaptureLogQuery
{
_q
.
ctx
.
Offset
=
&
offset
return
_q
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func
(
_q
*
RequestCaptureLogQuery
)
Unique
(
unique
bool
)
*
RequestCaptureLogQuery
{
_q
.
ctx
.
Unique
=
&
unique
return
_q
}
// Order specifies how the records should be ordered.
func
(
_q
*
RequestCaptureLogQuery
)
Order
(
o
...
requestcapturelog
.
OrderOption
)
*
RequestCaptureLogQuery
{
_q
.
order
=
append
(
_q
.
order
,
o
...
)
return
_q
}
// First returns the first RequestCaptureLog entity from the query.
// Returns a *NotFoundError when no RequestCaptureLog was found.
func
(
_q
*
RequestCaptureLogQuery
)
First
(
ctx
context
.
Context
)
(
*
RequestCaptureLog
,
error
)
{
nodes
,
err
:=
_q
.
Limit
(
1
)
.
All
(
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryFirst
))
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
nodes
)
==
0
{
return
nil
,
&
NotFoundError
{
requestcapturelog
.
Label
}
}
return
nodes
[
0
],
nil
}
// FirstX is like First, but panics if an error occurs.
func
(
_q
*
RequestCaptureLogQuery
)
FirstX
(
ctx
context
.
Context
)
*
RequestCaptureLog
{
node
,
err
:=
_q
.
First
(
ctx
)
if
err
!=
nil
&&
!
IsNotFound
(
err
)
{
panic
(
err
)
}
return
node
}
// FirstID returns the first RequestCaptureLog ID from the query.
// Returns a *NotFoundError when no RequestCaptureLog ID was found.
func
(
_q
*
RequestCaptureLogQuery
)
FirstID
(
ctx
context
.
Context
)
(
id
int64
,
err
error
)
{
var
ids
[]
int64
if
ids
,
err
=
_q
.
Limit
(
1
)
.
IDs
(
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryFirstID
));
err
!=
nil
{
return
}
if
len
(
ids
)
==
0
{
err
=
&
NotFoundError
{
requestcapturelog
.
Label
}
return
}
return
ids
[
0
],
nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func
(
_q
*
RequestCaptureLogQuery
)
FirstIDX
(
ctx
context
.
Context
)
int64
{
id
,
err
:=
_q
.
FirstID
(
ctx
)
if
err
!=
nil
&&
!
IsNotFound
(
err
)
{
panic
(
err
)
}
return
id
}
// Only returns a single RequestCaptureLog entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one RequestCaptureLog entity is found.
// Returns a *NotFoundError when no RequestCaptureLog entities are found.
func
(
_q
*
RequestCaptureLogQuery
)
Only
(
ctx
context
.
Context
)
(
*
RequestCaptureLog
,
error
)
{
nodes
,
err
:=
_q
.
Limit
(
2
)
.
All
(
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryOnly
))
if
err
!=
nil
{
return
nil
,
err
}
switch
len
(
nodes
)
{
case
1
:
return
nodes
[
0
],
nil
case
0
:
return
nil
,
&
NotFoundError
{
requestcapturelog
.
Label
}
default
:
return
nil
,
&
NotSingularError
{
requestcapturelog
.
Label
}
}
}
// OnlyX is like Only, but panics if an error occurs.
func
(
_q
*
RequestCaptureLogQuery
)
OnlyX
(
ctx
context
.
Context
)
*
RequestCaptureLog
{
node
,
err
:=
_q
.
Only
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
node
}
// OnlyID is like Only, but returns the only RequestCaptureLog ID in the query.
// Returns a *NotSingularError when more than one RequestCaptureLog ID is found.
// Returns a *NotFoundError when no entities are found.
func
(
_q
*
RequestCaptureLogQuery
)
OnlyID
(
ctx
context
.
Context
)
(
id
int64
,
err
error
)
{
var
ids
[]
int64
if
ids
,
err
=
_q
.
Limit
(
2
)
.
IDs
(
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryOnlyID
));
err
!=
nil
{
return
}
switch
len
(
ids
)
{
case
1
:
id
=
ids
[
0
]
case
0
:
err
=
&
NotFoundError
{
requestcapturelog
.
Label
}
default
:
err
=
&
NotSingularError
{
requestcapturelog
.
Label
}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func
(
_q
*
RequestCaptureLogQuery
)
OnlyIDX
(
ctx
context
.
Context
)
int64
{
id
,
err
:=
_q
.
OnlyID
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
id
}
// All executes the query and returns a list of RequestCaptureLogs.
func
(
_q
*
RequestCaptureLogQuery
)
All
(
ctx
context
.
Context
)
([]
*
RequestCaptureLog
,
error
)
{
ctx
=
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryAll
)
if
err
:=
_q
.
prepareQuery
(
ctx
);
err
!=
nil
{
return
nil
,
err
}
qr
:=
querierAll
[[]
*
RequestCaptureLog
,
*
RequestCaptureLogQuery
]()
return
withInterceptors
[[]
*
RequestCaptureLog
](
ctx
,
_q
,
qr
,
_q
.
inters
)
}
// AllX is like All, but panics if an error occurs.
func
(
_q
*
RequestCaptureLogQuery
)
AllX
(
ctx
context
.
Context
)
[]
*
RequestCaptureLog
{
nodes
,
err
:=
_q
.
All
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
nodes
}
// IDs executes the query and returns a list of RequestCaptureLog IDs.
func
(
_q
*
RequestCaptureLogQuery
)
IDs
(
ctx
context
.
Context
)
(
ids
[]
int64
,
err
error
)
{
if
_q
.
ctx
.
Unique
==
nil
&&
_q
.
path
!=
nil
{
_q
.
Unique
(
true
)
}
ctx
=
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryIDs
)
if
err
=
_q
.
Select
(
requestcapturelog
.
FieldID
)
.
Scan
(
ctx
,
&
ids
);
err
!=
nil
{
return
nil
,
err
}
return
ids
,
nil
}
// IDsX is like IDs, but panics if an error occurs.
func
(
_q
*
RequestCaptureLogQuery
)
IDsX
(
ctx
context
.
Context
)
[]
int64
{
ids
,
err
:=
_q
.
IDs
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
ids
}
// Count returns the count of the given query.
func
(
_q
*
RequestCaptureLogQuery
)
Count
(
ctx
context
.
Context
)
(
int
,
error
)
{
ctx
=
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryCount
)
if
err
:=
_q
.
prepareQuery
(
ctx
);
err
!=
nil
{
return
0
,
err
}
return
withInterceptors
[
int
](
ctx
,
_q
,
querierCount
[
*
RequestCaptureLogQuery
](),
_q
.
inters
)
}
// CountX is like Count, but panics if an error occurs.
func
(
_q
*
RequestCaptureLogQuery
)
CountX
(
ctx
context
.
Context
)
int
{
count
,
err
:=
_q
.
Count
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
count
}
// Exist returns true if the query has elements in the graph.
func
(
_q
*
RequestCaptureLogQuery
)
Exist
(
ctx
context
.
Context
)
(
bool
,
error
)
{
ctx
=
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryExist
)
switch
_
,
err
:=
_q
.
FirstID
(
ctx
);
{
case
IsNotFound
(
err
)
:
return
false
,
nil
case
err
!=
nil
:
return
false
,
fmt
.
Errorf
(
"ent: check existence: %w"
,
err
)
default
:
return
true
,
nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func
(
_q
*
RequestCaptureLogQuery
)
ExistX
(
ctx
context
.
Context
)
bool
{
exist
,
err
:=
_q
.
Exist
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
exist
}
// Clone returns a duplicate of the RequestCaptureLogQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func
(
_q
*
RequestCaptureLogQuery
)
Clone
()
*
RequestCaptureLogQuery
{
if
_q
==
nil
{
return
nil
}
return
&
RequestCaptureLogQuery
{
config
:
_q
.
config
,
ctx
:
_q
.
ctx
.
Clone
(),
order
:
append
([]
requestcapturelog
.
OrderOption
{},
_q
.
order
...
),
inters
:
append
([]
Interceptor
{},
_q
.
inters
...
),
predicates
:
append
([]
predicate
.
RequestCaptureLog
{},
_q
.
predicates
...
),
// clone intermediate query.
sql
:
_q
.
sql
.
Clone
(),
path
:
_q
.
path
,
}
}
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
// Example:
//
// var v []struct {
// APIKeyID int64 `json:"api_key_id,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.RequestCaptureLog.Query().
// GroupBy(requestcapturelog.FieldAPIKeyID).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func
(
_q
*
RequestCaptureLogQuery
)
GroupBy
(
field
string
,
fields
...
string
)
*
RequestCaptureLogGroupBy
{
_q
.
ctx
.
Fields
=
append
([]
string
{
field
},
fields
...
)
grbuild
:=
&
RequestCaptureLogGroupBy
{
build
:
_q
}
grbuild
.
flds
=
&
_q
.
ctx
.
Fields
grbuild
.
label
=
requestcapturelog
.
Label
grbuild
.
scan
=
grbuild
.
Scan
return
grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// APIKeyID int64 `json:"api_key_id,omitempty"`
// }
//
// client.RequestCaptureLog.Query().
// Select(requestcapturelog.FieldAPIKeyID).
// Scan(ctx, &v)
func
(
_q
*
RequestCaptureLogQuery
)
Select
(
fields
...
string
)
*
RequestCaptureLogSelect
{
_q
.
ctx
.
Fields
=
append
(
_q
.
ctx
.
Fields
,
fields
...
)
sbuild
:=
&
RequestCaptureLogSelect
{
RequestCaptureLogQuery
:
_q
}
sbuild
.
label
=
requestcapturelog
.
Label
sbuild
.
flds
,
sbuild
.
scan
=
&
_q
.
ctx
.
Fields
,
sbuild
.
Scan
return
sbuild
}
// Aggregate returns a RequestCaptureLogSelect configured with the given aggregations.
func
(
_q
*
RequestCaptureLogQuery
)
Aggregate
(
fns
...
AggregateFunc
)
*
RequestCaptureLogSelect
{
return
_q
.
Select
()
.
Aggregate
(
fns
...
)
}
func
(
_q
*
RequestCaptureLogQuery
)
prepareQuery
(
ctx
context
.
Context
)
error
{
for
_
,
inter
:=
range
_q
.
inters
{
if
inter
==
nil
{
return
fmt
.
Errorf
(
"ent: uninitialized interceptor (forgotten import ent/runtime?)"
)
}
if
trv
,
ok
:=
inter
.
(
Traverser
);
ok
{
if
err
:=
trv
.
Traverse
(
ctx
,
_q
);
err
!=
nil
{
return
err
}
}
}
for
_
,
f
:=
range
_q
.
ctx
.
Fields
{
if
!
requestcapturelog
.
ValidColumn
(
f
)
{
return
&
ValidationError
{
Name
:
f
,
err
:
fmt
.
Errorf
(
"ent: invalid field %q for query"
,
f
)}
}
}
if
_q
.
path
!=
nil
{
prev
,
err
:=
_q
.
path
(
ctx
)
if
err
!=
nil
{
return
err
}
_q
.
sql
=
prev
}
return
nil
}
func
(
_q
*
RequestCaptureLogQuery
)
sqlAll
(
ctx
context
.
Context
,
hooks
...
queryHook
)
([]
*
RequestCaptureLog
,
error
)
{
var
(
nodes
=
[]
*
RequestCaptureLog
{}
_spec
=
_q
.
querySpec
()
)
_spec
.
ScanValues
=
func
(
columns
[]
string
)
([]
any
,
error
)
{
return
(
*
RequestCaptureLog
)
.
scanValues
(
nil
,
columns
)
}
_spec
.
Assign
=
func
(
columns
[]
string
,
values
[]
any
)
error
{
node
:=
&
RequestCaptureLog
{
config
:
_q
.
config
}
nodes
=
append
(
nodes
,
node
)
return
node
.
assignValues
(
columns
,
values
)
}
if
len
(
_q
.
modifiers
)
>
0
{
_spec
.
Modifiers
=
_q
.
modifiers
}
for
i
:=
range
hooks
{
hooks
[
i
](
ctx
,
_spec
)
}
if
err
:=
sqlgraph
.
QueryNodes
(
ctx
,
_q
.
driver
,
_spec
);
err
!=
nil
{
return
nil
,
err
}
if
len
(
nodes
)
==
0
{
return
nodes
,
nil
}
return
nodes
,
nil
}
func
(
_q
*
RequestCaptureLogQuery
)
sqlCount
(
ctx
context
.
Context
)
(
int
,
error
)
{
_spec
:=
_q
.
querySpec
()
if
len
(
_q
.
modifiers
)
>
0
{
_spec
.
Modifiers
=
_q
.
modifiers
}
_spec
.
Node
.
Columns
=
_q
.
ctx
.
Fields
if
len
(
_q
.
ctx
.
Fields
)
>
0
{
_spec
.
Unique
=
_q
.
ctx
.
Unique
!=
nil
&&
*
_q
.
ctx
.
Unique
}
return
sqlgraph
.
CountNodes
(
ctx
,
_q
.
driver
,
_spec
)
}
func
(
_q
*
RequestCaptureLogQuery
)
querySpec
()
*
sqlgraph
.
QuerySpec
{
_spec
:=
sqlgraph
.
NewQuerySpec
(
requestcapturelog
.
Table
,
requestcapturelog
.
Columns
,
sqlgraph
.
NewFieldSpec
(
requestcapturelog
.
FieldID
,
field
.
TypeInt64
))
_spec
.
From
=
_q
.
sql
if
unique
:=
_q
.
ctx
.
Unique
;
unique
!=
nil
{
_spec
.
Unique
=
*
unique
}
else
if
_q
.
path
!=
nil
{
_spec
.
Unique
=
true
}
if
fields
:=
_q
.
ctx
.
Fields
;
len
(
fields
)
>
0
{
_spec
.
Node
.
Columns
=
make
([]
string
,
0
,
len
(
fields
))
_spec
.
Node
.
Columns
=
append
(
_spec
.
Node
.
Columns
,
requestcapturelog
.
FieldID
)
for
i
:=
range
fields
{
if
fields
[
i
]
!=
requestcapturelog
.
FieldID
{
_spec
.
Node
.
Columns
=
append
(
_spec
.
Node
.
Columns
,
fields
[
i
])
}
}
}
if
ps
:=
_q
.
predicates
;
len
(
ps
)
>
0
{
_spec
.
Predicate
=
func
(
selector
*
sql
.
Selector
)
{
for
i
:=
range
ps
{
ps
[
i
](
selector
)
}
}
}
if
limit
:=
_q
.
ctx
.
Limit
;
limit
!=
nil
{
_spec
.
Limit
=
*
limit
}
if
offset
:=
_q
.
ctx
.
Offset
;
offset
!=
nil
{
_spec
.
Offset
=
*
offset
}
if
ps
:=
_q
.
order
;
len
(
ps
)
>
0
{
_spec
.
Order
=
func
(
selector
*
sql
.
Selector
)
{
for
i
:=
range
ps
{
ps
[
i
](
selector
)
}
}
}
return
_spec
}
func
(
_q
*
RequestCaptureLogQuery
)
sqlQuery
(
ctx
context
.
Context
)
*
sql
.
Selector
{
builder
:=
sql
.
Dialect
(
_q
.
driver
.
Dialect
())
t1
:=
builder
.
Table
(
requestcapturelog
.
Table
)
columns
:=
_q
.
ctx
.
Fields
if
len
(
columns
)
==
0
{
columns
=
requestcapturelog
.
Columns
}
selector
:=
builder
.
Select
(
t1
.
Columns
(
columns
...
)
...
)
.
From
(
t1
)
if
_q
.
sql
!=
nil
{
selector
=
_q
.
sql
selector
.
Select
(
selector
.
Columns
(
columns
...
)
...
)
}
if
_q
.
ctx
.
Unique
!=
nil
&&
*
_q
.
ctx
.
Unique
{
selector
.
Distinct
()
}
for
_
,
m
:=
range
_q
.
modifiers
{
m
(
selector
)
}
for
_
,
p
:=
range
_q
.
predicates
{
p
(
selector
)
}
for
_
,
p
:=
range
_q
.
order
{
p
(
selector
)
}
if
offset
:=
_q
.
ctx
.
Offset
;
offset
!=
nil
{
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector
.
Offset
(
*
offset
)
.
Limit
(
math
.
MaxInt32
)
}
if
limit
:=
_q
.
ctx
.
Limit
;
limit
!=
nil
{
selector
.
Limit
(
*
limit
)
}
return
selector
}
// ForUpdate locks the selected rows against concurrent updates, and prevent them from being
// updated, deleted or "selected ... for update" by other sessions, until the transaction is
// either committed or rolled-back.
func
(
_q
*
RequestCaptureLogQuery
)
ForUpdate
(
opts
...
sql
.
LockOption
)
*
RequestCaptureLogQuery
{
if
_q
.
driver
.
Dialect
()
==
dialect
.
Postgres
{
_q
.
Unique
(
false
)
}
_q
.
modifiers
=
append
(
_q
.
modifiers
,
func
(
s
*
sql
.
Selector
)
{
s
.
ForUpdate
(
opts
...
)
})
return
_q
}
// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock
// on any rows that are read. Other sessions can read the rows, but cannot modify them
// until your transaction commits.
func
(
_q
*
RequestCaptureLogQuery
)
ForShare
(
opts
...
sql
.
LockOption
)
*
RequestCaptureLogQuery
{
if
_q
.
driver
.
Dialect
()
==
dialect
.
Postgres
{
_q
.
Unique
(
false
)
}
_q
.
modifiers
=
append
(
_q
.
modifiers
,
func
(
s
*
sql
.
Selector
)
{
s
.
ForShare
(
opts
...
)
})
return
_q
}
// RequestCaptureLogGroupBy is the group-by builder for RequestCaptureLog entities.
type
RequestCaptureLogGroupBy
struct
{
selector
build
*
RequestCaptureLogQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func
(
_g
*
RequestCaptureLogGroupBy
)
Aggregate
(
fns
...
AggregateFunc
)
*
RequestCaptureLogGroupBy
{
_g
.
fns
=
append
(
_g
.
fns
,
fns
...
)
return
_g
}
// Scan applies the selector query and scans the result into the given value.
func
(
_g
*
RequestCaptureLogGroupBy
)
Scan
(
ctx
context
.
Context
,
v
any
)
error
{
ctx
=
setContextOp
(
ctx
,
_g
.
build
.
ctx
,
ent
.
OpQueryGroupBy
)
if
err
:=
_g
.
build
.
prepareQuery
(
ctx
);
err
!=
nil
{
return
err
}
return
scanWithInterceptors
[
*
RequestCaptureLogQuery
,
*
RequestCaptureLogGroupBy
](
ctx
,
_g
.
build
,
_g
,
_g
.
build
.
inters
,
v
)
}
func
(
_g
*
RequestCaptureLogGroupBy
)
sqlScan
(
ctx
context
.
Context
,
root
*
RequestCaptureLogQuery
,
v
any
)
error
{
selector
:=
root
.
sqlQuery
(
ctx
)
.
Select
()
aggregation
:=
make
([]
string
,
0
,
len
(
_g
.
fns
))
for
_
,
fn
:=
range
_g
.
fns
{
aggregation
=
append
(
aggregation
,
fn
(
selector
))
}
if
len
(
selector
.
SelectedColumns
())
==
0
{
columns
:=
make
([]
string
,
0
,
len
(
*
_g
.
flds
)
+
len
(
_g
.
fns
))
for
_
,
f
:=
range
*
_g
.
flds
{
columns
=
append
(
columns
,
selector
.
C
(
f
))
}
columns
=
append
(
columns
,
aggregation
...
)
selector
.
Select
(
columns
...
)
}
selector
.
GroupBy
(
selector
.
Columns
(
*
_g
.
flds
...
)
...
)
if
err
:=
selector
.
Err
();
err
!=
nil
{
return
err
}
rows
:=
&
sql
.
Rows
{}
query
,
args
:=
selector
.
Query
()
if
err
:=
_g
.
build
.
driver
.
Query
(
ctx
,
query
,
args
,
rows
);
err
!=
nil
{
return
err
}
defer
rows
.
Close
()
return
sql
.
ScanSlice
(
rows
,
v
)
}
// RequestCaptureLogSelect is the builder for selecting fields of RequestCaptureLog entities.
type
RequestCaptureLogSelect
struct
{
*
RequestCaptureLogQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func
(
_s
*
RequestCaptureLogSelect
)
Aggregate
(
fns
...
AggregateFunc
)
*
RequestCaptureLogSelect
{
_s
.
fns
=
append
(
_s
.
fns
,
fns
...
)
return
_s
}
// Scan applies the selector query and scans the result into the given value.
func
(
_s
*
RequestCaptureLogSelect
)
Scan
(
ctx
context
.
Context
,
v
any
)
error
{
ctx
=
setContextOp
(
ctx
,
_s
.
ctx
,
ent
.
OpQuerySelect
)
if
err
:=
_s
.
prepareQuery
(
ctx
);
err
!=
nil
{
return
err
}
return
scanWithInterceptors
[
*
RequestCaptureLogQuery
,
*
RequestCaptureLogSelect
](
ctx
,
_s
.
RequestCaptureLogQuery
,
_s
,
_s
.
inters
,
v
)
}
func
(
_s
*
RequestCaptureLogSelect
)
sqlScan
(
ctx
context
.
Context
,
root
*
RequestCaptureLogQuery
,
v
any
)
error
{
selector
:=
root
.
sqlQuery
(
ctx
)
aggregation
:=
make
([]
string
,
0
,
len
(
_s
.
fns
))
for
_
,
fn
:=
range
_s
.
fns
{
aggregation
=
append
(
aggregation
,
fn
(
selector
))
}
switch
n
:=
len
(
*
_s
.
selector
.
flds
);
{
case
n
==
0
&&
len
(
aggregation
)
>
0
:
selector
.
Select
(
aggregation
...
)
case
n
!=
0
&&
len
(
aggregation
)
>
0
:
selector
.
AppendSelect
(
aggregation
...
)
}
rows
:=
&
sql
.
Rows
{}
query
,
args
:=
selector
.
Query
()
if
err
:=
_s
.
driver
.
Query
(
ctx
,
query
,
args
,
rows
);
err
!=
nil
{
return
err
}
defer
rows
.
Close
()
return
sql
.
ScanSlice
(
rows
,
v
)
}
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment