Compare commits
391 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0954632b65 | ||
|
|
03105a1989 | ||
|
|
e169172c68 | ||
|
|
937b035634 | ||
|
|
c639e11b90 | ||
|
|
f2ac688ed8 | ||
|
|
369263a55c | ||
|
|
9d4848129f | ||
|
|
f7e82fa464 | ||
|
|
d2354ab33c | ||
|
|
67014cfb16 | ||
|
|
60edeacd0d | ||
|
|
4c77cf5798 | ||
|
|
3cf48d1f8e | ||
|
|
6d127c6d00 | ||
|
|
22f76e3f57 | ||
|
|
e947396c04 | ||
|
|
1020190c01 | ||
|
|
7c05acd1cf | ||
|
|
76a9183b52 | ||
|
|
6698d368c3 | ||
|
|
acb627d011 | ||
|
|
7c64d964e8 | ||
|
|
bec3b04705 | ||
|
|
990da92b75 | ||
|
|
ee14cc63b8 | ||
|
|
8df7b8665b | ||
|
|
ea90e014b1 | ||
|
|
6372c5c6e6 | ||
|
|
7b6dba1afe | ||
|
|
c833f6fab6 | ||
|
|
b4c2002ad1 | ||
|
|
b2a9f1f83b | ||
|
|
b69881d26b | ||
|
|
be07e457d0 | ||
|
|
2cdd6e3740 | ||
|
|
fa2968f01a | ||
|
|
36f24a7e04 | ||
|
|
ecc7465028 | ||
|
|
3af4ac795e | ||
|
|
af2a30405c | ||
|
|
ba3f6de852 | ||
|
|
7d5ce8ba97 | ||
|
|
b136b9167f | ||
|
|
f0f3281428 | ||
|
|
196ba6635f | ||
|
|
b61b7f082e | ||
|
|
105b296ba2 | ||
|
|
c4d153f15b | ||
|
|
d2619120da | ||
|
|
fbfee65a50 | ||
|
|
c433ccaa0e | ||
|
|
58428405b0 | ||
|
|
45cd94f65b | ||
|
|
53cbca3101 | ||
|
|
576956e271 | ||
|
|
31d20b4f36 | ||
|
|
d026dc4eec | ||
|
|
e472d67c79 | ||
|
|
2165a8c533 | ||
|
|
0c3b5a6907 | ||
|
|
aaa006a322 | ||
|
|
a83f860624 | ||
|
|
b0c325bc4b | ||
|
|
a0431df1ee | ||
|
|
7b02eeac51 | ||
|
|
66a307f202 | ||
|
|
ae611943c3 | ||
|
|
4fd11540cd | ||
|
|
587a28127b | ||
|
|
05ae58030c | ||
|
|
f1c4e306f4 | ||
|
|
949b6e5188 | ||
|
|
0d4b453d0a | ||
|
|
bce4d93ab1 | ||
|
|
36b72e6461 | ||
|
|
62417727f9 | ||
|
|
03f72b9d86 | ||
|
|
c17cf750e5 | ||
|
|
b176253fc4 | ||
|
|
1e2d8b8520 | ||
|
|
3739f2c960 | ||
|
|
bb6da47efb | ||
|
|
c28373bde1 | ||
|
|
8ce7045466 | ||
|
|
0b1bd8226d | ||
|
|
e67413cec2 | ||
|
|
2da02fa706 | ||
|
|
bc50dd888a | ||
|
|
0305c0709d | ||
|
|
5e9e85206e | ||
|
|
3babb9f5c7 | ||
|
|
c9928f10ce | ||
|
|
a2da1e7479 | ||
|
|
038f643ce3 | ||
|
|
cf2fa90d5d | ||
|
|
677923ea8a | ||
|
|
1192d00fe0 | ||
|
|
b317636a8a | ||
|
|
0e6465593b | ||
|
|
2cb8a5b6fb | ||
|
|
8b7bd1f6c6 | ||
|
|
1a9ba8a599 | ||
|
|
709d9ea4eb | ||
|
|
ed692b5aae | ||
|
|
f80ee71018 | ||
|
|
98fae05e16 | ||
|
|
f2faefa837 | ||
|
|
b281c6febb | ||
|
|
09862a2844 | ||
|
|
f77f565146 | ||
|
|
befd5c6a8a | ||
|
|
8376fef376 | ||
|
|
9b641fb593 | ||
|
|
9b0fb42043 | ||
|
|
bf2aeaa2d0 | ||
|
|
c52204619d | ||
|
|
485a580661 | ||
|
|
a22100b2fc | ||
|
|
1728690860 | ||
|
|
e0d0ab80b6 | ||
|
|
19f21ddd6e | ||
|
|
37ad1391db | ||
|
|
5daeca0bd9 | ||
|
|
7e4d907ef6 | ||
|
|
6527f843d8 | ||
|
|
f5ca53f7d7 | ||
|
|
7461918a6c | ||
|
|
3af5f96cb0 | ||
|
|
7dfa4eafc4 | ||
|
|
579b010d13 | ||
|
|
c42cbb5e5d | ||
|
|
6a5c105f8c | ||
|
|
e8067f96f1 | ||
|
|
84a0197776 | ||
|
|
f9556ec2d2 | ||
|
|
98d14befa9 | ||
|
|
6fcc569bf2 | ||
|
|
672e7f914d | ||
|
|
20bdcdbcde | ||
|
|
577a6cee1e | ||
|
|
4186d7d97f | ||
|
|
5d726dbcf1 | ||
|
|
ce25c090f5 | ||
|
|
2683c5dbf2 | ||
|
|
b717885270 | ||
|
|
4e457e99b9 | ||
|
|
ecfe31ea45 | ||
|
|
89104785d7 | ||
|
|
f4ccc69b50 | ||
|
|
40c6e2df5c | ||
|
|
37dfb0fe94 | ||
|
|
9968f9f225 | ||
|
|
f5c977224b | ||
|
|
8af3ffccd3 | ||
|
|
c535dfd714 | ||
|
|
f696b78260 | ||
|
|
4f3e3e399d | ||
|
|
e4e3c9a851 | ||
|
|
bf608f933d | ||
|
|
5923fc73e1 | ||
|
|
c2d9ccfd4c | ||
|
|
5d4429bf7c | ||
|
|
e4c111ac2a | ||
|
|
3e5e20e933 | ||
|
|
ba1be8f279 | ||
|
|
361556228b | ||
|
|
ca414a73ff | ||
|
|
32b595e116 | ||
|
|
b12bbd2ad9 | ||
|
|
60110f4ca6 | ||
|
|
b7ca02429c | ||
|
|
ff63084014 | ||
|
|
821d6859ff | ||
|
|
10e6e99990 | ||
|
|
23a5997814 | ||
|
|
b487c81865 | ||
|
|
32914344d1 | ||
|
|
644c9ed228 | ||
|
|
d3ad80380f | ||
|
|
19c6308a81 | ||
|
|
7017f32fe3 | ||
|
|
02a23f13f9 | ||
|
|
cc211a89a4 | ||
|
|
4800e6c79d | ||
|
|
b5f0b28c61 | ||
|
|
081338df24 | ||
|
|
9632ca45b3 | ||
|
|
b948bff497 | ||
|
|
29383cf75c | ||
|
|
57ec0b9eb9 | ||
|
|
0cce4ffee0 | ||
|
|
5c01c45068 | ||
|
|
712bf84c90 | ||
|
|
fdb63a8459 | ||
|
|
990d9dab08 | ||
|
|
da863588e4 | ||
|
|
09ff67fef7 | ||
|
|
3c37948798 | ||
|
|
6fd39d818c | ||
|
|
a0e211c328 | ||
|
|
27d8b1672a | ||
|
|
349e394e8e | ||
|
|
620f085ca5 | ||
|
|
5b70badb50 | ||
|
|
5c6ac2c430 | ||
|
|
365cfddf8f | ||
|
|
6c26812b92 | ||
|
|
0057a75a95 | ||
|
|
f110f257d4 | ||
|
|
93e8e78591 | ||
|
|
9ff12cd86b | ||
|
|
fd2f4b140f | ||
|
|
4607af6982 | ||
|
|
984bebcfe0 | ||
|
|
d31abd59ad | ||
|
|
e0ad71291c | ||
|
|
8ecc9393cf | ||
|
|
b62e0e9bfd | ||
|
|
1391f55f44 | ||
|
|
0c709ee517 | ||
|
|
806d821388 | ||
|
|
829043bf28 | ||
|
|
66ab418054 | ||
|
|
5fe40cc64b | ||
|
|
8f6f26f00e | ||
|
|
ee0bee2b06 | ||
|
|
1bb16a8a66 | ||
|
|
d746032114 | ||
|
|
b34e39889c | ||
|
|
64e98647a8 | ||
|
|
f91c91e0b1 | ||
|
|
f1aaa06d05 | ||
|
|
e8a38aa6f8 | ||
|
|
7e88533ea2 | ||
|
|
05698f4047 | ||
|
|
1daad0c236 | ||
|
|
86c8163f9c | ||
|
|
78ab8cc8e6 | ||
|
|
1390277b43 | ||
|
|
1aa3dca2c6 | ||
|
|
f48b3c657e | ||
|
|
d8d570f1b2 | ||
|
|
bd385d4f85 | ||
|
|
466596345d | ||
|
|
8ab33f3d54 | ||
|
|
4d3b26135c | ||
|
|
56d5cdb2bf | ||
|
|
6f80da779b | ||
|
|
5fef156052 | ||
|
|
eab3a6ca2b | ||
|
|
ffa5c37c4c | ||
|
|
241e30152b | ||
|
|
16216fcc4f | ||
|
|
578b6a9d78 | ||
|
|
f4da80c845 | ||
|
|
5a9acd3e6e | ||
|
|
8bfa8f84b9 | ||
|
|
5b0b2ce5b0 | ||
|
|
b24c1a1501 | ||
|
|
aa320c6dcb | ||
|
|
5132714247 | ||
|
|
3aeecac4fb | ||
|
|
7f8c613a65 | ||
|
|
c787d71fbd | ||
|
|
c28e16805e | ||
|
|
fc3d3878bc | ||
|
|
e26e86a63f | ||
|
|
408ff163ef | ||
|
|
35d299b60c | ||
|
|
6e002b1198 | ||
|
|
7508a264a6 | ||
|
|
0022c9dad5 | ||
|
|
654d8b50b4 | ||
|
|
97ede5d9c9 | ||
|
|
4803567818 | ||
|
|
4e0014cb3f | ||
|
|
c256d46d5c | ||
|
|
b765f16ea6 | ||
|
|
9350e376f4 | ||
|
|
06f935871a | ||
|
|
001b850d8f | ||
|
|
1340305f2d | ||
|
|
b337e40fcc | ||
|
|
e94386e455 | ||
|
|
2b4fb99c89 | ||
|
|
faa603d5df | ||
|
|
9ba59a7d5a | ||
|
|
0ea1c040a2 | ||
|
|
eba646f5db | ||
|
|
ebcc0c32da | ||
|
|
769f217506 | ||
|
|
3525d1bb83 | ||
|
|
2c3fd89f2a | ||
|
|
19ab8c65de | ||
|
|
979218f615 | ||
|
|
d4dd2da335 | ||
|
|
000717fcd9 | ||
|
|
300f9a478b | ||
|
|
88a554b186 | ||
|
|
6ef4bedebe | ||
|
|
233970ef39 | ||
|
|
e2bba8ec71 | ||
|
|
b7aeb9c3c6 | ||
|
|
4a93d51fdc | ||
|
|
f158b74be6 | ||
|
|
2c8c715540 | ||
|
|
ba532d406a | ||
|
|
cff093ca98 | ||
|
|
8f677b29a7 | ||
|
|
e08c126af2 | ||
|
|
eed72c5eb9 | ||
|
|
fcff47041a | ||
|
|
f9d4f851eb | ||
|
|
262baf769f | ||
|
|
6ef2e5b347 | ||
|
|
e0e11b70bb | ||
|
|
3de2f89107 | ||
|
|
b024b5f6dc | ||
|
|
961d762f35 | ||
|
|
7f025a6246 | ||
|
|
fc86a441f4 | ||
|
|
34fa05e7dd | ||
|
|
9c3757a1bf | ||
|
|
e63a899df5 | ||
|
|
3a4e303d9d | ||
|
|
ef9e4487c6 | ||
|
|
02f6cfb5b7 | ||
|
|
e73ae86801 | ||
|
|
b19938f2df | ||
|
|
bb3c4551af | ||
|
|
eae35ce862 | ||
|
|
feecc9f983 | ||
|
|
5175e651ee | ||
|
|
f065abfbf9 | ||
|
|
cd4d600f5e | ||
|
|
741a4024fd | ||
|
|
0433cc7b0a | ||
|
|
accc02c74c | ||
|
|
87b6c99f1f | ||
|
|
b2a092c64e | ||
|
|
51fc5c3c74 | ||
|
|
5e6a17f86c | ||
|
|
2fedfd6c76 | ||
|
|
61bc9b72bd | ||
|
|
a997726a5f | ||
|
|
7a2c67af04 | ||
|
|
3698170d0b | ||
|
|
6c38db5248 | ||
|
|
b597edab8a | ||
|
|
2e3b67dfce | ||
|
|
1dd61ccbca | ||
|
|
f5f8434832 | ||
|
|
2cb6a15c0b | ||
|
|
317f5655b8 | ||
|
|
00506df5a1 | ||
|
|
57de442eb9 | ||
|
|
690ce272c2 | ||
|
|
6a9f63fff6 | ||
|
|
7b9b619de6 | ||
|
|
8bc9076d90 | ||
|
|
891be34504 | ||
|
|
04df9adfdf | ||
|
|
3c47eba618 | ||
|
|
e85bd231c9 | ||
|
|
58e65b21fb | ||
|
|
520933085d | ||
|
|
5cc88986d2 | ||
|
|
d63a923589 | ||
|
|
bca68befb1 | ||
|
|
1be44bff9e | ||
|
|
3998270cbd | ||
|
|
73e76c2185 | ||
|
|
c72a460509 | ||
|
|
912293d8e8 | ||
|
|
7f2e84ad52 | ||
|
|
e52ad612c1 | ||
|
|
45a212fec5 | ||
|
|
39bfda4cda | ||
|
|
24a4d3152d | ||
|
|
6c6670a8c0 | ||
|
|
63fc4f277b | ||
|
|
45d2a4fb79 | ||
|
|
5e337871c9 | ||
|
|
803dcfeacd | ||
|
|
c26e61bbee | ||
|
|
e334acba32 | ||
|
|
1359df599b | ||
|
|
16ca00d19c | ||
|
|
f4b8d03cfc | ||
|
|
8811b89889 |
26
.github/workflows/go.yml
vendored
@@ -17,14 +17,11 @@ jobs:
|
||||
|
||||
build-and-push-image:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
attestations: write
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Login to image repository
|
||||
uses: docker/login-action@v2
|
||||
@@ -32,6 +29,19 @@ jobs:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GHCR_TOKEN }}
|
||||
|
||||
- name: Set up Flutter
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: stable
|
||||
flutter-version: 3
|
||||
|
||||
- name: Build Web
|
||||
run: |
|
||||
cd ui
|
||||
flutter pub get
|
||||
flutter build web --no-web-resources-cdn
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
@@ -49,9 +59,3 @@ jobs:
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
- name: Generate artifact attestation
|
||||
uses: actions/attest-build-provenance@v1
|
||||
with:
|
||||
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
|
||||
subject-digest: ${{ steps.push.outputs.digest }}
|
||||
push-to-registry: true
|
||||
|
||||
50
.github/workflows/goreleaser.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
name: goreleaser
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
|
||||
jobs:
|
||||
goreleaser:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up Flutter
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: stable
|
||||
flutter-version: 3
|
||||
- name: Build Web
|
||||
run: |
|
||||
cd ui
|
||||
flutter pub get
|
||||
flutter build web --no-web-resources-cdn --web-renderer html
|
||||
-
|
||||
name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '>=1.23.0'
|
||||
check-latest: true
|
||||
-
|
||||
name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v6
|
||||
with:
|
||||
# either 'goreleaser' (default) or 'goreleaser-pro'
|
||||
distribution: goreleaser
|
||||
# 'latest', 'nightly', or a semver
|
||||
version: '~> v2'
|
||||
args: release --clean --skip=validate
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
|
||||
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
|
||||
21
.github/workflows/release.yml
vendored
@@ -22,6 +22,8 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set Up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
@@ -35,12 +37,25 @@ jobs:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GHCR_TOKEN }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
|
||||
- name: Set up Flutter
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: stable
|
||||
flutter-version: 3
|
||||
|
||||
- name: Build Web
|
||||
run: |
|
||||
cd ui
|
||||
flutter pub get
|
||||
flutter build web --no-web-resources-cdn
|
||||
|
||||
- name: Build and push
|
||||
id: push
|
||||
uses: docker/build-push-action@v6
|
||||
@@ -48,9 +63,7 @@ jobs:
|
||||
context: .
|
||||
file: Dockerfile
|
||||
push: true
|
||||
platforms: |
|
||||
linux/amd64
|
||||
linux/arm64
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/s390x,linux/ppc64le
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
@@ -59,4 +72,4 @@ jobs:
|
||||
with:
|
||||
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
|
||||
subject-digest: ${{ steps.push.outputs.digest }}
|
||||
push-to-registry: true
|
||||
push-to-registry: false
|
||||
|
||||
2
.gitignore
vendored
@@ -30,3 +30,5 @@ ui/dist/
|
||||
# Go workspace file
|
||||
go.work
|
||||
go.work.sum
|
||||
|
||||
dist/
|
||||
|
||||
51
.goreleaser.yaml
Normal file
@@ -0,0 +1,51 @@
|
||||
# This is an example .goreleaser.yml file with some sensible defaults.
|
||||
# Make sure to check the documentation at https://goreleaser.com
|
||||
|
||||
# The lines below are called `modelines`. See `:help modeline`
|
||||
# Feel free to remove those if you don't want/need to use them.
|
||||
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
|
||||
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
|
||||
|
||||
version: 2
|
||||
|
||||
before:
|
||||
hooks:
|
||||
# You may remove this if you don't use go modules.
|
||||
- go mod tidy
|
||||
# you may remove this if you don't need go generate
|
||||
#- go generate ./...
|
||||
|
||||
builds:
|
||||
- env:
|
||||
- CGO_ENABLED=0
|
||||
goos:
|
||||
- linux
|
||||
- windows
|
||||
- darwin
|
||||
- freebsd
|
||||
main: ./cmd
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
|
||||
archives:
|
||||
- format: tar.gz
|
||||
# this name template makes the OS and Arch compatible with the results of `uname`.
|
||||
name_template: >-
|
||||
{{ .ProjectName }}_
|
||||
{{- title .Os }}_
|
||||
{{- if eq .Arch "amd64" }}x86_64
|
||||
{{- else if eq .Arch "386" }}i386
|
||||
{{- else }}{{ .Arch }}{{ end }}
|
||||
{{- if .Arm }}v{{ .Arm }}{{ end }}
|
||||
# use zip for windows archives
|
||||
format_overrides:
|
||||
- goos: windows
|
||||
format: zip
|
||||
|
||||
changelog:
|
||||
sort: asc
|
||||
filters:
|
||||
exclude:
|
||||
- "^docs:"
|
||||
- "^test:"
|
||||
26
Dockerfile
@@ -1,12 +1,4 @@
|
||||
FROM instrumentisto/flutter:3 AS flutter
|
||||
WORKDIR /app
|
||||
COPY ./ui/pubspec.yaml ./ui/pubspec.lock ./
|
||||
RUN flutter pub get
|
||||
COPY ./ui/ ./
|
||||
RUN flutter build web
|
||||
|
||||
# 打包依赖阶段使用golang作为基础镜像
|
||||
FROM golang:1.22 as builder
|
||||
FROM golang:1.23 as builder
|
||||
|
||||
# 启用go module
|
||||
ENV GO111MODULE=on \
|
||||
@@ -20,18 +12,24 @@ RUN go mod download
|
||||
|
||||
COPY . .
|
||||
|
||||
COPY --from=flutter /app/build/web ./ui/build/web/
|
||||
# 指定OS等,并go build
|
||||
RUN CGO_ENABLED=1 go build -o polaris ./cmd/
|
||||
RUN CGO_ENABLED=0 go build -o polaris -ldflags="-X polaris/db.Version=$(git describe --tags --long)" ./cmd/
|
||||
|
||||
FROM debian:12
|
||||
FROM debian:stable-slim
|
||||
|
||||
WORKDIR /app
|
||||
RUN apt-get update && apt-get -y install ca-certificates
|
||||
RUN apt-get update && apt-get -y install ca-certificates tzdata gosu tini locales && ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \
|
||||
&& echo "${TZ}" > /etc/timezone && apt-get clean && sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
|
||||
|
||||
ENV TZ="Asia/Shanghai" GIN_MODE=release PUID=0 PGID=0 UMASK=0
|
||||
ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
|
||||
|
||||
# 将上一个阶段publish文件夹下的所有文件复制进来
|
||||
COPY --from=builder /app/polaris .
|
||||
COPY --from=builder /app/entrypoint.sh .
|
||||
RUN chmod +x /app/entrypoint.sh
|
||||
|
||||
VOLUME /app/data
|
||||
EXPOSE 8080
|
||||
|
||||
ENTRYPOINT ["./polaris"]
|
||||
ENTRYPOINT ["tini","./entrypoint.sh"]
|
||||
136
README.md
@@ -1,87 +1,89 @@
|
||||
# polaris
|
||||
|
||||
Polaris 是一个电视剧和电影的追踪软件。配置好了之后,当剧集或者电影播出后,会第一时间下载对应的资源。支持本地存储或者webdav。
|
||||

|
||||
|
||||
|
||||
<h1 align="center">Polaris</h1>
|
||||
|
||||
<div align="center">
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
|
||||
**Polaris 是一个电视剧和电影的追踪下载软件。对美剧动漫日剧都有良好的匹配,支持多种存储方式(webdav、alist、本地存储)。**
|
||||
|
||||
</div>
|
||||
|
||||

|
||||

|
||||
|
||||
交流群: https://t.me/+8R2nzrlSs2JhMDgx
|
||||
|
||||
## 功能
|
||||
## 快速开始
|
||||
|
||||
使用此程序参考 [【快速开始】](./doc/quick_start.md)
|
||||
|
||||
## Features
|
||||
|
||||
- [x] 电视剧自动追踪下载
|
||||
- [x] 电影自动追踪下载
|
||||
- [x] webdav 存储支持,配合 [alist](https://github.com/alist-org/alist) 或阿里云等实现更多功能
|
||||
- [x] 本地、webdav、 [alist](https://github.com/alist-org/alist) 存储支持,使用 alist 存储支持秒传功能
|
||||
- [x] 事件通知推送,目前支持 Pushover和 Bark,还在扩充中
|
||||
- [x] TMDB 代理支持
|
||||
- [x] 用户认证
|
||||
- [x] plex 刮削支持
|
||||
- [x] NFO 刮削文件支持
|
||||
- [x] BT/PT 支持
|
||||
- [x] qbittorrent/transmission客户端支持
|
||||
- [x] 支持导入plex watchlist,plex里标记,自动导入polaris
|
||||
- [x] and more...
|
||||
|
||||
## 对比 sonarr/radarr
|
||||
## 支持的平台
|
||||
|
||||
- linux/amd64
|
||||
- linux/arm64
|
||||
- linux/arm/v7
|
||||
- linux/386
|
||||
- linux/s390x
|
||||
- linux/ppc64le
|
||||
|
||||
## Todos
|
||||
|
||||
|
||||
- [ ] 更多通知客户端支持
|
||||
- [ ] 更多第三方watchlist导入支持
|
||||
- [ ] 手机客户端
|
||||
|
||||
|
||||
## 截图
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
|
||||
## 运行原理
|
||||
|
||||
Polaris本身不提供任何资源,要使其能正常工作,需要同时安装一个下载客户端(transmission)和一个索引客户端(jackett)。
|
||||
|
||||
Polaris通过索引客户端查询相关的BT/PT站点,然后把查到的资源送到下载器,等待下载器下载完成对应资源。下载完成后,根据下载的对应资源,整理到对应的文件夹里去
|
||||
|
||||

|
||||
|
||||
<!-- ## 对比 sonarr/radarr
|
||||
* 更好的中文支持
|
||||
* 对于动漫、日剧的良好支持,配合国内站点基本能匹配上对应资源
|
||||
* 支持 webdav 后端存储,可以配合 alist 或者阿里云来实现下载后实时传到云上的功能。这样外出就可以不依靠家里的宽带来看电影了,或者实现个轻 NAS 功能,下载功能放在本地,数据放在云盘
|
||||
* golang 实现后端,相比于 .NET 更节省资源
|
||||
* 一个程序同时实现了电影、电视剧功能,不需要装两个程序
|
||||
* 当然 sonarr/radarr 也是非常优秀的开源项目,目前 Polaris 功能还没有 sonarr/radarr 丰富
|
||||
|
||||
## 快速开始
|
||||
|
||||
最简单部署 Polaris 的方式是使用 docker compose
|
||||
|
||||
```yaml
|
||||
services:
|
||||
polaris:
|
||||
image: ghcr.io/simon-ding/polaris:latest
|
||||
restart: always
|
||||
volumes:
|
||||
- ./config/polaris:/app/data #程序配置文件路径
|
||||
- /downloads:/downloads #下载路径,需要和下载客户端配置一致
|
||||
- /data:/data #媒体数据存储路径,也可以启动自己配置webdav存储
|
||||
ports:
|
||||
- 8080:8080
|
||||
transmission: #下载客户端,也可以不安装使用已有的
|
||||
image: lscr.io/linuxserver/transmission:latest
|
||||
container_name: transmission
|
||||
environment:
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
- TZ=Asia/Shanghai
|
||||
volumes:
|
||||
- ./config/transmission:/config
|
||||
- /downloads:/downloads #此路径要与polaris下载路径保持一致
|
||||
ports:
|
||||
- 9091:9091
|
||||
- 51413:51413
|
||||
- 51413:51413/udp
|
||||
```
|
||||
|
||||
拉起之后访问 http://< ip >:8080 的形式访问
|
||||
|
||||
## 配置
|
||||
|
||||
要正确使用此程序,需要配置好以下设置:
|
||||
|
||||
### TMDB设置
|
||||
因为此程序需要使用到 TMDB 的数据,使用此程序首先要申请一个 TMDB 的 Api Key
|
||||
|
||||
### 索引器
|
||||
|
||||
索引器是资源提供者,目前支持 torznab 协议,意味着 polarr 或者 jackett 都可以支持。请自行部署相关程序。
|
||||
|
||||
推荐使用 linuxserver 的镜像:https://docs.linuxserver.io/images/docker-jackett/
|
||||
|
||||
### 下载器
|
||||
|
||||
资源由谁下载,目前可支持 tansmission,需要配置好对应下载器
|
||||
|
||||
### 存储设置
|
||||
|
||||
程序默认所有剧集和电影存储在 /data 路径下,如果想修改路径或者webdav存储,需要在存储配置下修改
|
||||
|
||||
## 开始使用
|
||||
|
||||
配置完了这些,开始享受使用此程序吧!可以搜索几部自己想看的电影或者电视机,加入想看列表。当剧集有更新或者电影有资源是就会自动下载对应资源了。
|
||||
* 当然 sonarr/radarr 也是非常优秀的开源项目,目前 Polaris 功能还没有 sonarr/radarr 丰富 -->
|
||||
|
||||
|
||||
## Stargazers over time
|
||||
[](https://starchart.cc/simon-ding/polaris)
|
||||
|
||||
-------------
|
||||
|
||||
## 请我喝杯咖啡
|
||||
|
||||
<img src="assets/wechat.JPG" width=40% height=40%>
|
||||
<img src="./doc/assets/wechat.JPG" width=40% height=40%>
|
||||
|
||||
|
Before Width: | Height: | Size: 2.1 MiB |
|
Before Width: | Height: | Size: 2.7 MiB |
|
Before Width: | Height: | Size: 111 KiB |
11
cmd/main.go
@@ -7,11 +7,22 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.Infof("------------------- Starting Polaris ---------------------")
|
||||
|
||||
//utils.MaxPermission()
|
||||
|
||||
dbClient, err := db.Open()
|
||||
if err != nil {
|
||||
log.Panicf("init db error: %v", err)
|
||||
}
|
||||
|
||||
// go func() {
|
||||
// time.Sleep(2 * time.Second)
|
||||
// if err := utils.OpenURL("http://127.0.0.1:8080"); err != nil {
|
||||
// log.Errorf("open url error: %v", err)
|
||||
// }
|
||||
|
||||
// }()
|
||||
s := server.NewServer(dbClient)
|
||||
if err := s.Serve(); err != nil {
|
||||
log.Errorf("server start error: %v", err)
|
||||
|
||||
105
db/const.go
@@ -1,23 +1,44 @@
|
||||
package db
|
||||
|
||||
import "polaris/ent/media"
|
||||
|
||||
var Version = "undefined"
|
||||
|
||||
const (
|
||||
SettingTmdbApiKey = "tmdb_api_key"
|
||||
SettingLanguage = "language"
|
||||
SettingJacketUrl = "jacket_url"
|
||||
SettingJacketApiKey = "jacket_api_key"
|
||||
SettingDownloadDir = "download_dir"
|
||||
SettingTmdbApiKey = "tmdb_api_key"
|
||||
SettingLanguage = "language"
|
||||
SettingJacketUrl = "jacket_url"
|
||||
SettingJacketApiKey = "jacket_api_key"
|
||||
SettingDownloadDir = "download_dir"
|
||||
SettingLogLevel = "log_level"
|
||||
SettingProxy = "proxy"
|
||||
SettingPlexMatchEnabled = "plexmatch_enabled"
|
||||
SettingNfoSupportEnabled = "nfo_support_enabled"
|
||||
SettingAllowQiangban = "filter_qiangban"
|
||||
SettingEnableTmdbAdultContent = "tmdb_adult_content"
|
||||
SettingTvNamingFormat = "tv_naming_format"
|
||||
SettingMovieNamingFormat = "movie_naming_format"
|
||||
SettingProwlarrInfo = "prowlarr_info"
|
||||
|
||||
SettingTvSizeLimiter = "tv_size_limiter"
|
||||
SettingMovieSizeLimiter = "movie_size_limiter"
|
||||
SettingAcceptedVideoFormats = "accepted_video_formats"
|
||||
SettingAcceptedSubtitleFormats = "accepted_subtitle_formats"
|
||||
|
||||
SettingAIConfig = "ai_config"
|
||||
)
|
||||
|
||||
const (
|
||||
SettingAuthEnabled = "auth_enbled"
|
||||
SettingUsername = "auth_username"
|
||||
SettingPassword = "auth_password"
|
||||
SettingUsername = "auth_username"
|
||||
SettingPassword = "auth_password"
|
||||
)
|
||||
|
||||
const (
|
||||
IndexerTorznabImpl = "torznab"
|
||||
DataPath = "./data"
|
||||
ImgPath = DataPath + "/img"
|
||||
DataPath = "./data"
|
||||
ImgPath = DataPath + "/img"
|
||||
LogPath = DataPath + "/logs"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -25,18 +46,62 @@ const (
|
||||
LanguageCN = "zh-CN"
|
||||
)
|
||||
|
||||
type ResolutionType string
|
||||
const DefaultNamingFormat = "{{.NameCN}} {{.NameEN}} {{if .Year}} ({{.Year}}) {{end}}"
|
||||
|
||||
const (
|
||||
Any ResolutionType = "any"
|
||||
R720p ResolutionType = "720p"
|
||||
R1080p ResolutionType = "1080p"
|
||||
R4k ResolutionType = "4k"
|
||||
)
|
||||
|
||||
func (r ResolutionType) String() string {
|
||||
return string(r)
|
||||
// https://en.wikipedia.org/wiki/Video_file_format
|
||||
var defaultAcceptedVideoFormats = []string{
|
||||
".webm", ".mkv", ".flv", ".vob", ".ogv", ".ogg", ".drc", ".mng", ".avi", ".mts", ".m2ts", ".ts",
|
||||
".mov", ".qt", ".wmv", ".yuv", ".rm", ".rmvb", ".viv", ".amv", ".mp4", ".m4p", ".m4v",
|
||||
".mpg", ".mp2", ".mpeg", ".mpe", ".mpv", ".m2v", ".m4v",
|
||||
".svi", ".3gp", ".3g2", ".nsv",
|
||||
}
|
||||
|
||||
var defaultAcceptedSubtitleFormats = []string{
|
||||
".ass", ".srt", ".vtt", ".webvtt", ".sub", ".idx",
|
||||
}
|
||||
|
||||
const JwtSerectKey = "jwt_secrect_key"
|
||||
type NamingInfo struct {
|
||||
NameCN string
|
||||
NameEN string
|
||||
Year string
|
||||
TmdbID int
|
||||
}
|
||||
|
||||
type ResolutionType string
|
||||
|
||||
const JwtSerectKey = "jwt_secrect_key"
|
||||
|
||||
type MediaSizeLimiter struct {
|
||||
P720p SizeLimiter `json:"720p"`
|
||||
P1080 SizeLimiter `json:"1080p"`
|
||||
P2160 SizeLimiter `json:"2160p"`
|
||||
}
|
||||
|
||||
func (m *MediaSizeLimiter) GetLimiter(r media.Resolution) SizeLimiter {
|
||||
if r == media.Resolution1080p {
|
||||
return m.P1080
|
||||
} else if r == media.Resolution720p {
|
||||
return m.P720p
|
||||
} else if r == media.Resolution2160p {
|
||||
return m.P2160
|
||||
}
|
||||
return SizeLimiter{}
|
||||
}
|
||||
|
||||
type SizeLimiter struct {
|
||||
MaxSIze int64 `json:"max_size"`
|
||||
MinSize int64 `json:"min_size"`
|
||||
PreferSIze int64 `json:"prefer_size"`
|
||||
}
|
||||
|
||||
type ProwlarrSetting struct {
|
||||
Disabled bool `json:"disabled"`
|
||||
ApiKey string `json:"api_key"`
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
type AIConfig struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
GeminiApiKey string `json:"gemini_api_key"`
|
||||
GeminiModelName string `json:"gemini_model_name"`
|
||||
}
|
||||
|
||||
437
db/db.go
@@ -9,8 +9,10 @@ import (
|
||||
"polaris/ent/downloadclients"
|
||||
"polaris/ent/episode"
|
||||
"polaris/ent/history"
|
||||
"polaris/ent/importlist"
|
||||
"polaris/ent/indexers"
|
||||
"polaris/ent/media"
|
||||
"polaris/ent/schema"
|
||||
"polaris/ent/settings"
|
||||
"polaris/ent/storage"
|
||||
"polaris/log"
|
||||
@@ -20,7 +22,8 @@ import (
|
||||
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
_ "github.com/ncruces/go-sqlite3/driver"
|
||||
_ "github.com/ncruces/go-sqlite3/embed"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@@ -42,6 +45,7 @@ func Open() (*Client, error) {
|
||||
c := &Client{
|
||||
ent: client,
|
||||
}
|
||||
c.init()
|
||||
|
||||
return c, nil
|
||||
}
|
||||
@@ -55,7 +59,20 @@ func (c *Client) init() {
|
||||
downloadDir := c.GetSetting(SettingDownloadDir)
|
||||
if downloadDir == "" {
|
||||
log.Infof("set default download dir")
|
||||
c.SetSetting(downloadDir, "/downloads")
|
||||
c.SetSetting(SettingDownloadDir, "/downloads")
|
||||
}
|
||||
logLevel := c.GetSetting(SettingLogLevel)
|
||||
if logLevel == "" {
|
||||
log.Infof("set default log level")
|
||||
c.SetSetting(SettingLogLevel, "info")
|
||||
}
|
||||
if tr := c.GetAllDonloadClients(); len(tr) == 0 {
|
||||
log.Warnf("no download client, set default download client")
|
||||
c.SaveDownloader(&ent.DownloadClients{
|
||||
Name: "transmission",
|
||||
Implementation: downloadclients.ImplementationTransmission,
|
||||
URL: "http://transmission:9091",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,18 +94,16 @@ func (c *Client) generateDefaultLocalStorage() error {
|
||||
return c.AddStorage(&StorageInfo{
|
||||
Name: "local",
|
||||
Implementation: "local",
|
||||
TvPath: "/data/tv/",
|
||||
MoviePath: "/data/movies/",
|
||||
Default: true,
|
||||
Settings: map[string]string{
|
||||
"tv_path": "/data/tv/",
|
||||
"movie_path": "/data/movies/",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Client) GetSetting(key string) string {
|
||||
v, err := c.ent.Settings.Query().Where(settings.Key(key)).Only(context.TODO())
|
||||
if err != nil {
|
||||
log.Errorf("get setting by key: %s error: %v", key, err)
|
||||
log.Debugf("get setting by key: %s error: %v", key, err)
|
||||
return ""
|
||||
}
|
||||
return v.Value
|
||||
@@ -109,7 +124,7 @@ func (c *Client) GetLanguage() string {
|
||||
lang := c.GetSetting(SettingLanguage)
|
||||
log.Infof("get application language: %s", lang)
|
||||
if lang == "" {
|
||||
return "zh-CN"
|
||||
return LanguageCN
|
||||
}
|
||||
return lang
|
||||
}
|
||||
@@ -129,6 +144,7 @@ func (c *Client) AddMediaWatchlist(m *ent.Media, episodes []int) (*ent.Media, er
|
||||
}
|
||||
r, err := c.ent.Media.Create().
|
||||
SetTmdbID(m.TmdbID).
|
||||
SetImdbID(m.ImdbID).
|
||||
SetStorageID(m.StorageID).
|
||||
SetOverview(m.Overview).
|
||||
SetNameCn(m.NameCn).
|
||||
@@ -138,6 +154,10 @@ func (c *Client) AddMediaWatchlist(m *ent.Media, episodes []int) (*ent.Media, er
|
||||
SetAirDate(m.AirDate).
|
||||
SetResolution(m.Resolution).
|
||||
SetTargetDir(m.TargetDir).
|
||||
SetDownloadHistoryEpisodes(m.DownloadHistoryEpisodes).
|
||||
SetLimiter(m.Limiter).
|
||||
SetExtras(m.Extras).
|
||||
SetAlternativeTitles(m.AlternativeTitles).
|
||||
AddEpisodeIDs(episodes...).
|
||||
Save(context.TODO())
|
||||
return r, err
|
||||
@@ -145,7 +165,7 @@ func (c *Client) AddMediaWatchlist(m *ent.Media, episodes []int) (*ent.Media, er
|
||||
}
|
||||
|
||||
func (c *Client) GetMediaWatchlist(mediaType media.MediaType) []*ent.Media {
|
||||
list, err := c.ent.Media.Query().Where(media.MediaTypeEQ(mediaType)).All(context.TODO())
|
||||
list, err := c.ent.Media.Query().Where(media.MediaTypeEQ(mediaType)).Order(ent.Desc(media.FieldID)).All(context.TODO())
|
||||
if err != nil {
|
||||
log.Infof("query wtach list error: %v", err)
|
||||
return nil
|
||||
@@ -157,11 +177,18 @@ func (c *Client) GetEpisode(seriesId, seasonNum, episodeNum int) (*ent.Episode,
|
||||
return c.ent.Episode.Query().Where(episode.MediaID(seriesId), episode.SeasonNumber(seasonNum),
|
||||
episode.EpisodeNumber(episodeNum)).First(context.TODO())
|
||||
}
|
||||
func (c *Client) GetEpisodeByID(epID int) (*ent.Episode, error) {
|
||||
return c.ent.Episode.Query().Where(episode.ID(epID)).First(context.TODO())
|
||||
}
|
||||
|
||||
func (c *Client) UpdateEpiode(episodeId int, name, overview string) error {
|
||||
return c.ent.Episode.Update().Where(episode.ID(episodeId)).SetTitle(name).SetOverview(overview).Exec(context.TODO())
|
||||
}
|
||||
|
||||
func (c *Client) UpdateEpiode2(episodeId int, name, overview, airdate string) error {
|
||||
return c.ent.Episode.Update().Where(episode.ID(episodeId)).SetTitle(name).SetOverview(overview).SetAirDate(airdate).Exec(context.TODO())
|
||||
}
|
||||
|
||||
type MediaDetails struct {
|
||||
*ent.Media
|
||||
Episodes []*ent.Episode `json:"episodes"`
|
||||
@@ -187,13 +214,20 @@ func (c *Client) GetMediaDetails(id int) *MediaDetails {
|
||||
return md
|
||||
}
|
||||
|
||||
func (c *Client) GetMedia(id int) (*ent.Media, error) {
|
||||
return c.ent.Media.Query().Where(media.ID(id)).First(context.TODO())
|
||||
}
|
||||
|
||||
func (c *Client) DeleteMedia(id int) error {
|
||||
_, err := c.ent.Episode.Delete().Where(episode.MediaID(id)).Exec(context.TODO())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = c.ent.Media.Delete().Where(media.ID(id)).Exec(context.TODO())
|
||||
return err
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return c.CleanAllDanglingEpisodes()
|
||||
}
|
||||
|
||||
func (c *Client) SaveEposideDetail(d *ent.Episode) (int, error) {
|
||||
@@ -202,6 +236,23 @@ func (c *Client) SaveEposideDetail(d *ent.Episode) (int, error) {
|
||||
SetSeasonNumber(d.SeasonNumber).
|
||||
SetEpisodeNumber(d.EpisodeNumber).
|
||||
SetOverview(d.Overview).
|
||||
SetMonitored(d.Monitored).
|
||||
SetTitle(d.Title).Save(context.TODO())
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, "save episode")
|
||||
}
|
||||
return ep.ID, nil
|
||||
}
|
||||
|
||||
func (c *Client) SaveEposideDetail2(d *ent.Episode) (int, error) {
|
||||
ep, err := c.ent.Episode.Create().
|
||||
SetAirDate(d.AirDate).
|
||||
SetSeasonNumber(d.SeasonNumber).
|
||||
SetEpisodeNumber(d.EpisodeNumber).
|
||||
SetMediaID(d.MediaID).
|
||||
SetStatus(d.Status).
|
||||
SetOverview(d.Overview).
|
||||
SetMonitored(d.Monitored).
|
||||
SetTitle(d.Title).Save(context.TODO())
|
||||
|
||||
return ep.ID, err
|
||||
@@ -212,19 +263,22 @@ type TorznabSetting struct {
|
||||
ApiKey string `json:"api_key"`
|
||||
}
|
||||
|
||||
func (c *Client) SaveTorznabInfo(name string, setting TorznabSetting) error {
|
||||
data, err := json.Marshal(setting)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "marshal json")
|
||||
func (c *Client) SaveIndexer(in *ent.Indexers) error {
|
||||
|
||||
if in.ID != 0 {
|
||||
//update setting
|
||||
return c.ent.Indexers.Update().Where(indexers.ID(in.ID)).SetName(in.Name).SetImplementation(in.Implementation).
|
||||
SetPriority(in.Priority).SetSettings(in.Settings).SetSeedRatio(in.SeedRatio).SetDisabled(in.Disabled).Exec(context.Background())
|
||||
}
|
||||
count := c.ent.Indexers.Query().Where(indexers.Name(name)).CountX(context.TODO())
|
||||
//create new one
|
||||
count := c.ent.Indexers.Query().Where(indexers.Name(in.Name)).CountX(context.TODO())
|
||||
if count > 0 {
|
||||
c.ent.Indexers.Update().Where(indexers.Name(name)).SetSettings(string(data)).Save(context.TODO())
|
||||
return err
|
||||
return fmt.Errorf("name already esxits: %v", in.Name)
|
||||
}
|
||||
|
||||
_, err = c.ent.Indexers.Create().
|
||||
SetName(name).SetImplementation(IndexerTorznabImpl).SetPriority(1).SetSettings(string(data)).Save(context.TODO())
|
||||
_, err := c.ent.Indexers.Create().
|
||||
SetName(in.Name).SetImplementation(in.Implementation).SetPriority(in.Priority).SetSettings(in.Settings).SetSeedRatio(in.SeedRatio).
|
||||
SetDisabled(in.Disabled).Save(context.TODO())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "save db")
|
||||
}
|
||||
@@ -236,9 +290,22 @@ func (c *Client) DeleteTorznab(id int) {
|
||||
c.ent.Indexers.Delete().Where(indexers.ID(id)).Exec(context.TODO())
|
||||
}
|
||||
|
||||
func (c *Client) GetIndexer(id int) (*TorznabInfo, error) {
|
||||
res, err := c.ent.Indexers.Query().Where(indexers.ID(id)).First(context.TODO())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var ss TorznabSetting
|
||||
err = json.Unmarshal([]byte(res.Settings), &ss)
|
||||
if err != nil {
|
||||
|
||||
return nil, fmt.Errorf("unmarshal torznab %s error: %v", res.Name, err)
|
||||
}
|
||||
return &TorznabInfo{Indexers: res, TorznabSetting: ss}, nil
|
||||
}
|
||||
|
||||
type TorznabInfo struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
*ent.Indexers
|
||||
TorznabSetting
|
||||
}
|
||||
|
||||
@@ -254,38 +321,28 @@ func (c *Client) GetAllTorznabInfo() []*TorznabInfo {
|
||||
continue
|
||||
}
|
||||
l = append(l, &TorznabInfo{
|
||||
ID: r.ID,
|
||||
Name: r.Name,
|
||||
Indexers: r,
|
||||
TorznabSetting: ss,
|
||||
})
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
func (c *Client) SaveTransmission(name, url, user, password string) error {
|
||||
count := c.ent.DownloadClients.Query().Where(downloadclients.Name(name)).CountX(context.TODO())
|
||||
func (c *Client) SaveDownloader(downloader *ent.DownloadClients) error {
|
||||
count := c.ent.DownloadClients.Query().Where(downloadclients.Name(downloader.Name)).CountX(context.TODO())
|
||||
if count != 0 {
|
||||
err := c.ent.DownloadClients.Update().Where(downloadclients.Name(name)).
|
||||
SetURL(url).SetUser(user).SetPassword(password).Exec(context.TODO())
|
||||
err := c.ent.DownloadClients.Update().Where(downloadclients.Name(downloader.Name)).SetImplementation(downloader.Implementation).
|
||||
SetURL(downloader.URL).SetUser(downloader.User).SetPassword(downloader.Password).SetPriority1(downloader.Priority1).Exec(context.TODO())
|
||||
return err
|
||||
}
|
||||
|
||||
_, err := c.ent.DownloadClients.Create().SetEnable(true).SetImplementation("transmission").
|
||||
SetName(name).SetURL(url).SetUser(user).SetPassword(password).Save(context.TODO())
|
||||
_, err := c.ent.DownloadClients.Create().SetEnable(true).SetImplementation(downloader.Implementation).
|
||||
SetName(downloader.Name).SetURL(downloader.URL).SetUser(downloader.User).SetPriority1(downloader.Priority1).SetPassword(downloader.Password).Save(context.TODO())
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) GetTransmission() *ent.DownloadClients {
|
||||
dc, err := c.ent.DownloadClients.Query().Where(downloadclients.Implementation("transmission")).First(context.TODO())
|
||||
if err != nil {
|
||||
log.Errorf("no transmission client found: %v", err)
|
||||
return nil
|
||||
}
|
||||
return dc
|
||||
}
|
||||
|
||||
func (c *Client) GetAllDonloadClients() []*ent.DownloadClients {
|
||||
cc, err := c.ent.DownloadClients.Query().All(context.TODO())
|
||||
cc, err := c.ent.DownloadClients.Query().Order(ent.Asc(downloadclients.FieldPriority1)).All(context.TODO())
|
||||
if err != nil {
|
||||
log.Errorf("no download client")
|
||||
return nil
|
||||
@@ -299,9 +356,11 @@ func (c *Client) DeleteDownloadCLient(id int) {
|
||||
|
||||
// Storage is the model entity for the Storage schema.
|
||||
type StorageInfo struct {
|
||||
Name string `json:"name"`
|
||||
Implementation string `json:"implementation"`
|
||||
Settings map[string]string `json:"settings"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
Implementation string `json:"implementation" binding:"required"`
|
||||
Settings map[string]string `json:"settings" binding:"required"`
|
||||
TvPath string `json:"tv_path" binding:"required"`
|
||||
MoviePath string `json:"movie_path" binding:"required"`
|
||||
Default bool `json:"default"`
|
||||
}
|
||||
|
||||
@@ -310,36 +369,38 @@ func (s *StorageInfo) ToWebDavSetting() WebdavSetting {
|
||||
panic("not webdav storage")
|
||||
}
|
||||
return WebdavSetting{
|
||||
URL: s.Settings["url"],
|
||||
TvPath: s.Settings["tv_path"],
|
||||
MoviePath: s.Settings["movie_path"],
|
||||
User: s.Settings["user"],
|
||||
Password: s.Settings["password"],
|
||||
URL: s.Settings["url"],
|
||||
User: s.Settings["user"],
|
||||
Password: s.Settings["password"],
|
||||
ChangeFileHash: s.Settings["change_file_hash"],
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
type LocalDirSetting struct {
|
||||
TvPath string `json:"tv_path"`
|
||||
MoviePath string `json:"movie_path"`
|
||||
func (s *StorageInfo) ToAlistSetting() WebdavSetting {
|
||||
return WebdavSetting{
|
||||
URL: s.Settings["url"],
|
||||
User: s.Settings["user"],
|
||||
Password: s.Settings["password"],
|
||||
ChangeFileHash: s.Settings["change_file_hash"],
|
||||
}
|
||||
}
|
||||
|
||||
type WebdavSetting struct {
|
||||
URL string `json:"url"`
|
||||
TvPath string `json:"tv_path"`
|
||||
MoviePath string `json:"movie_path"`
|
||||
User string `json:"user"`
|
||||
Password string `json:"password"`
|
||||
ChangeFileHash string `json:"change_file_hash"`
|
||||
}
|
||||
|
||||
func (c *Client) AddStorage(st *StorageInfo) error {
|
||||
if !strings.HasSuffix(st.Settings["tv_path"], "/") {
|
||||
st.Settings["tv_path"] += "/"
|
||||
if !strings.HasSuffix(st.TvPath, "/") {
|
||||
st.TvPath += "/"
|
||||
}
|
||||
if !strings.HasSuffix(st.Settings["movie_path"], "/") {
|
||||
st.Settings["movie_path"] += "/"
|
||||
if !strings.HasSuffix(st.MoviePath, "/") {
|
||||
st.MoviePath += "/"
|
||||
}
|
||||
if st.Settings == nil {
|
||||
st.Settings = map[string]string{}
|
||||
}
|
||||
|
||||
data, err := json.Marshal(st.Settings)
|
||||
@@ -351,7 +412,7 @@ func (c *Client) AddStorage(st *StorageInfo) error {
|
||||
if count > 0 {
|
||||
//storage already exist, edit exist one
|
||||
return c.ent.Storage.Update().Where(storage.Name(st.Name)).
|
||||
SetImplementation(storage.Implementation(st.Implementation)).
|
||||
SetImplementation(storage.Implementation(st.Implementation)).SetTvPath(st.TvPath).SetMoviePath(st.MoviePath).
|
||||
SetSettings(string(data)).Exec(context.TODO())
|
||||
}
|
||||
countAll := c.ent.Storage.Query().Where(storage.Deleted(false)).CountX(context.TODO())
|
||||
@@ -360,7 +421,7 @@ func (c *Client) AddStorage(st *StorageInfo) error {
|
||||
st.Default = true
|
||||
}
|
||||
_, err = c.ent.Storage.Create().SetName(st.Name).
|
||||
SetImplementation(storage.Implementation(st.Implementation)).
|
||||
SetImplementation(storage.Implementation(st.Implementation)).SetTvPath(st.TvPath).SetMoviePath(st.MoviePath).
|
||||
SetSettings(string(data)).SetDefault(st.Default).Save(context.TODO())
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -381,17 +442,8 @@ type Storage struct {
|
||||
ent.Storage
|
||||
}
|
||||
|
||||
func (s *Storage) ToLocalSetting() LocalDirSetting {
|
||||
if s.Implementation != storage.ImplementationLocal {
|
||||
panic("not local storage")
|
||||
}
|
||||
var localSetting LocalDirSetting
|
||||
json.Unmarshal([]byte(s.Settings), &localSetting)
|
||||
return localSetting
|
||||
}
|
||||
|
||||
func (s *Storage) ToWebDavSetting() WebdavSetting {
|
||||
if s.Implementation != storage.ImplementationWebdav {
|
||||
if s.Implementation != storage.ImplementationWebdav && s.Implementation != storage.ImplementationAlist {
|
||||
panic("not webdav storage")
|
||||
}
|
||||
var webdavSetting WebdavSetting
|
||||
@@ -399,12 +451,6 @@ func (s *Storage) ToWebDavSetting() WebdavSetting {
|
||||
return webdavSetting
|
||||
}
|
||||
|
||||
func (s *Storage) GetPath() (tvPath string, moviePath string) {
|
||||
var m map[string]string
|
||||
json.Unmarshal([]byte(s.Settings), &m)
|
||||
return m["tv_path"], m["movie_path"]
|
||||
}
|
||||
|
||||
func (c *Client) GetStorage(id int) *Storage {
|
||||
r, err := c.ent.Storage.Query().Where(storage.ID(id)).First(context.TODO())
|
||||
if err != nil {
|
||||
@@ -438,8 +484,18 @@ func (c *Client) SetDefaultStorageByName(name string) error {
|
||||
}
|
||||
|
||||
func (c *Client) SaveHistoryRecord(h ent.History) (*ent.History, error) {
|
||||
if h.Link != "" {
|
||||
r, err := utils.Link2Magnet(h.Link)
|
||||
if err != nil {
|
||||
log.Warnf("convert link to magnet error, link %v, error: %v", h.Link, err)
|
||||
} else {
|
||||
h.Link = r
|
||||
}
|
||||
}
|
||||
return c.ent.History.Create().SetMediaID(h.MediaID).SetEpisodeID(h.EpisodeID).SetDate(time.Now()).
|
||||
SetStatus(h.Status).SetTargetDir(h.TargetDir).SetSourceTitle(h.SourceTitle).SetSaved(h.Saved).Save(context.TODO())
|
||||
SetStatus(h.Status).SetTargetDir(h.TargetDir).SetSourceTitle(h.SourceTitle).SetIndexerID(h.IndexerID).
|
||||
SetDownloadClientID(h.DownloadClientID).SetSize(h.Size).SetSaved(h.Saved).SetSeasonNum(h.SeasonNum).
|
||||
SetEpisodeNums(h.EpisodeNums).SetLink(h.Link).Save(context.TODO())
|
||||
}
|
||||
|
||||
func (c *Client) SetHistoryStatus(id int, status history.Status) error {
|
||||
@@ -456,7 +512,7 @@ func (c *Client) GetHistories() ent.Histories {
|
||||
|
||||
func (c *Client) GetRunningHistories() ent.Histories {
|
||||
h, err := c.ent.History.Query().Where(history.Or(history.StatusEQ(history.StatusRunning),
|
||||
history.StatusEQ(history.StatusUploading))).All(context.TODO())
|
||||
history.StatusEQ(history.StatusUploading), history.StatusEQ(history.StatusSeeding))).All(context.TODO())
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
@@ -480,19 +536,29 @@ func (c *Client) GetDownloadDir() string {
|
||||
return r.Value
|
||||
}
|
||||
|
||||
func (c *Client) UpdateEpisodeFile(mediaID int, seasonNum, episodeNum int, file string) error {
|
||||
func (c *Client) UpdateEpisodeStatus(mediaID int, seasonNum, episodeNum int) error {
|
||||
ep, err := c.ent.Episode.Query().Where(episode.MediaID(mediaID)).Where(episode.EpisodeNumber(episodeNum)).
|
||||
Where(episode.SeasonNumber(seasonNum)).First(context.TODO())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "finding episode")
|
||||
}
|
||||
return ep.Update().SetFileInStorage(file).SetStatus(episode.StatusDownloaded).Exec(context.TODO())
|
||||
return ep.Update().SetStatus(episode.StatusDownloaded).Exec(context.TODO())
|
||||
}
|
||||
|
||||
func (c *Client) SetEpisodeStatus(id int, status episode.Status) error {
|
||||
return c.ent.Episode.Update().Where(episode.ID(id)).SetStatus(status).Exec(context.TODO())
|
||||
}
|
||||
|
||||
func (c *Client) IsEpisodeDownloadingOrDownloaded(id int) bool {
|
||||
his := c.ent.History.Query().Where(history.EpisodeID(id)).AllX(context.Background())
|
||||
for _, h := range his {
|
||||
if h.Status != history.StatusFail {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (c *Client) SetSeasonAllEpisodeStatus(mediaID, seasonNum int, status episode.Status) error {
|
||||
return c.ent.Episode.Update().Where(episode.MediaID(mediaID), episode.SeasonNumber(seasonNum)).SetStatus(status).Exec(context.TODO())
|
||||
}
|
||||
@@ -501,7 +567,218 @@ func (c *Client) TmdbIdInWatchlist(tmdb_id int) bool {
|
||||
return c.ent.Media.Query().Where(media.TmdbID(tmdb_id)).CountX(context.TODO()) > 0
|
||||
}
|
||||
|
||||
|
||||
func (c *Client) GetDownloadHistory(mediaID int) ([]*ent.History, error) {
|
||||
return c.ent.History.Query().Where(history.MediaID(mediaID)).All(context.TODO())
|
||||
}
|
||||
|
||||
func (c *Client) GetMovieDummyEpisode(movieId int) (*ent.Episode, error) {
|
||||
_, err := c.ent.Media.Query().Where(media.ID(movieId), media.MediaTypeEQ(media.MediaTypeMovie)).First(context.TODO())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get movie")
|
||||
}
|
||||
ep, err := c.ent.Episode.Query().Where(episode.MediaID(movieId)).First(context.TODO())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "query episode")
|
||||
}
|
||||
return ep, nil
|
||||
}
|
||||
|
||||
func (c *Client) GetDownloadClient(id int) (*ent.DownloadClients, error) {
|
||||
return c.ent.DownloadClients.Query().Where(downloadclients.ID(id)).First(context.Background())
|
||||
}
|
||||
|
||||
func (c *Client) SetEpisodeMonitoring(id int, b bool) error {
|
||||
return c.ent.Episode.Update().Where(episode.ID(id)).SetMonitored(b).Exec(context.Background())
|
||||
}
|
||||
|
||||
type EditMediaData struct {
|
||||
ID int `json:"id"`
|
||||
Resolution media.Resolution `json:"resolution"`
|
||||
TargetDir string `json:"target_dir"`
|
||||
Limiter schema.MediaLimiter `json:"limiter"`
|
||||
}
|
||||
|
||||
func (c *Client) EditMediaMetadata(in EditMediaData) error {
|
||||
return c.ent.Media.Update().Where(media.ID(in.ID)).SetResolution(in.Resolution).SetTargetDir(in.TargetDir).SetLimiter(in.Limiter).
|
||||
Exec(context.Background())
|
||||
}
|
||||
|
||||
func (c *Client) UpdateEpisodeTargetFile(id int, filename string) error {
|
||||
return c.ent.Episode.Update().Where(episode.ID(id)).SetTargetFile(filename).Exec(context.Background())
|
||||
}
|
||||
|
||||
func (c *Client) GetSeasonEpisodes(mediaId, seasonNum int) ([]*ent.Episode, error) {
|
||||
return c.ent.Episode.Query().Where(episode.MediaID(mediaId), episode.SeasonNumber(seasonNum)).All(context.Background())
|
||||
}
|
||||
|
||||
func (c *Client) GetAllImportLists() ([]*ent.ImportList, error) {
|
||||
return c.ent.ImportList.Query().All(context.Background())
|
||||
}
|
||||
|
||||
func (c *Client) AddImportlist(il *ent.ImportList) error {
|
||||
count, err := c.ent.ImportList.Query().Where(importlist.Name(il.Name)).Count(context.Background())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if count > 0 {
|
||||
//edit exist record
|
||||
return c.ent.ImportList.Update().Where(importlist.Name(il.Name)).
|
||||
SetURL(il.URL).SetQulity(il.Qulity).SetType(il.Type).SetStorageID(il.StorageID).Exec(context.Background())
|
||||
}
|
||||
return c.ent.ImportList.Create().SetName(il.Name).SetURL(il.URL).SetQulity(il.Qulity).SetStorageID(il.StorageID).
|
||||
SetType(il.Type).Exec(context.Background())
|
||||
}
|
||||
|
||||
func (c *Client) DeleteImportlist(id int) error {
|
||||
return c.ent.ImportList.DeleteOneID(id).Exec(context.TODO())
|
||||
}
|
||||
|
||||
func (c *Client) GetSizeLimiter(mediaType string) (*MediaSizeLimiter, error) {
|
||||
var v string
|
||||
if mediaType == "tv" {
|
||||
v = c.GetSetting(SettingTvSizeLimiter)
|
||||
} else if mediaType == "movie" {
|
||||
v = c.GetSetting(SettingMovieSizeLimiter)
|
||||
} else {
|
||||
return nil, errors.Errorf("media type not supported: %v", mediaType)
|
||||
}
|
||||
|
||||
var limiter MediaSizeLimiter
|
||||
if v == "" {
|
||||
return &limiter, nil
|
||||
}
|
||||
|
||||
err := json.Unmarshal([]byte(v), &limiter)
|
||||
return &limiter, err
|
||||
}
|
||||
|
||||
func (c *Client) SetSizeLimiter(mediaType string, limiter *MediaSizeLimiter) error {
|
||||
data, err := json.Marshal(limiter)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if mediaType == "tv" {
|
||||
return c.SetSetting(SettingTvSizeLimiter, string(data))
|
||||
} else if mediaType == "movie" {
|
||||
return c.SetSetting(SettingMovieSizeLimiter, string(data))
|
||||
} else {
|
||||
return errors.Errorf("media type not supported: %v", mediaType)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (c *Client) GetTvNamingFormat() string {
|
||||
s := c.GetSetting(SettingTvNamingFormat)
|
||||
if s == "" {
|
||||
return DefaultNamingFormat
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func (c *Client) GetMovingNamingFormat() string {
|
||||
s := c.GetSetting(SettingMovieNamingFormat)
|
||||
if s == "" {
|
||||
return DefaultNamingFormat
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func (c *Client) CleanAllDanglingEpisodes() error {
|
||||
_, err := c.ent.Episode.Delete().Where(episode.Not(episode.HasMedia())).Exec(context.Background())
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) AddBlacklistItem(item *ent.Blacklist) error {
|
||||
return c.ent.Blacklist.Create().SetType(item.Type).SetValue(item.Value).SetNotes(item.Notes).Exec(context.Background())
|
||||
}
|
||||
|
||||
func (c *Client) GetProwlarrSetting() (*ProwlarrSetting, error) {
|
||||
s := c.GetSetting(SettingProwlarrInfo)
|
||||
if s == "" {
|
||||
return nil, errors.New("prowlarr setting not set")
|
||||
}
|
||||
var se ProwlarrSetting
|
||||
if err := json.Unmarshal([]byte(s), &se); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &se, nil
|
||||
}
|
||||
|
||||
func (c *Client) SaveProwlarrSetting(se *ProwlarrSetting) error {
|
||||
data, err := json.Marshal(se)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return c.SetSetting(SettingProwlarrInfo, string(data))
|
||||
}
|
||||
|
||||
|
||||
func (c *Client) getAcceptedFormats(key string) ([]string, error) {
|
||||
v := c.GetSetting(key)
|
||||
if v == "" {
|
||||
return nil, nil
|
||||
}
|
||||
var res []string
|
||||
|
||||
err := json.Unmarshal([]byte(v), &res)
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (c *Client) setAcceptedFormats(key string, v []string) error {
|
||||
data, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return c.SetSetting(key, string(data))
|
||||
}
|
||||
|
||||
func (c *Client) GetAcceptedVideoFormats() ([]string, error) {
|
||||
res, err := c.getAcceptedFormats(SettingAcceptedVideoFormats)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if res == nil {
|
||||
return defaultAcceptedVideoFormats, nil
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (c *Client) SetAcceptedVideoFormats(key string, v []string) error {
|
||||
return c.setAcceptedFormats(SettingAcceptedVideoFormats, v)
|
||||
}
|
||||
|
||||
func (c *Client) GetAcceptedSubtitleFormats() ([]string, error) {
|
||||
res, err := c.getAcceptedFormats(SettingAcceptedSubtitleFormats)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if res== nil {
|
||||
return defaultAcceptedSubtitleFormats, nil
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (c *Client) SetAcceptedSubtitleFormats(key string, v []string) error {
|
||||
return c.setAcceptedFormats(SettingAcceptedSubtitleFormats, v)
|
||||
}
|
||||
|
||||
func (c *Client) GetAIConfig() (AIConfig, error) {
|
||||
cfg := c.GetSetting(SettingAIConfig)
|
||||
var ai AIConfig
|
||||
if cfg == "" {
|
||||
return ai, nil
|
||||
}
|
||||
err := json.Unmarshal([]byte(cfg), &ai)
|
||||
if err != nil {
|
||||
return AIConfig{}, err
|
||||
}
|
||||
return ai, nil
|
||||
}
|
||||
|
||||
func (c *Client) SetAIConfig(cfg *AIConfig) error {
|
||||
if data, err := json.Marshal(cfg); err != nil {
|
||||
return err
|
||||
} else {
|
||||
return c.SetSetting(SettingAIConfig, string(data))
|
||||
}
|
||||
}
|
||||
97
db/notification.go
Normal file
@@ -0,0 +1,97 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"polaris/ent"
|
||||
"polaris/ent/notificationclient"
|
||||
"polaris/pkg/notifier"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func (c *Client) GetAllNotificationClients2() ([]*ent.NotificationClient, error) {
|
||||
return c.ent.NotificationClient.Query().All(context.TODO())
|
||||
}
|
||||
|
||||
func (c *Client) GetAllNotificationClients() ([]*NotificationClient, error) {
|
||||
all, err := c.ent.NotificationClient.Query().All(context.TODO())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "query db")
|
||||
}
|
||||
var all1 []*NotificationClient
|
||||
for _, item := range all {
|
||||
cl, err := toNotificationClient(item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "convert")
|
||||
}
|
||||
all1 = append(all1, cl)
|
||||
}
|
||||
return all1, nil
|
||||
}
|
||||
|
||||
func (c *Client) AddNotificationClient(name, service string, setting string, enabled bool) error {
|
||||
// data, err := json.Marshal(setting)
|
||||
// if err != nil {
|
||||
// return errors.Wrap(err, "json")
|
||||
// }
|
||||
service = strings.ToLower(service)
|
||||
count, err := c.ent.NotificationClient.Query().Where(notificationclient.Name(name)).Count(context.Background())
|
||||
if err == nil && count > 0 {
|
||||
//update exist one
|
||||
return c.ent.NotificationClient.Update().Where(notificationclient.Name(name)).SetService(service).
|
||||
SetSettings(setting).SetEnabled(enabled).Exec(context.Background())
|
||||
}
|
||||
|
||||
return c.ent.NotificationClient.Create().SetName(name).SetService(service).
|
||||
SetSettings(setting).SetEnabled(enabled).Exec(context.Background())
|
||||
}
|
||||
|
||||
func (c *Client) DeleteNotificationClient(id int) error {
|
||||
_, err := c.ent.NotificationClient.Delete().Where(notificationclient.ID(id)).Exec(context.Background())
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) GetNotificationClient(id int) (*NotificationClient, error) {
|
||||
noti, err := c.ent.NotificationClient.Query().Where(notificationclient.ID(id)).First(context.Background())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "query")
|
||||
}
|
||||
|
||||
return toNotificationClient(noti)
|
||||
}
|
||||
|
||||
func toNotificationClient(cl *ent.NotificationClient) (*NotificationClient, error) {
|
||||
var settings interface{}
|
||||
switch cl.Service {
|
||||
case "pushover":
|
||||
settings = notifier.PushoverConfig{}
|
||||
case "dingtalk":
|
||||
settings = notifier.DingTalkConfig{}
|
||||
case "telegram":
|
||||
settings = notifier.TelegramConfig{}
|
||||
case "bark":
|
||||
settings = notifier.BarkConfig{}
|
||||
}
|
||||
err := json.Unmarshal([]byte(cl.Settings), &settings)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "json")
|
||||
}
|
||||
return &NotificationClient{
|
||||
ID: cl.ID,
|
||||
Name: cl.Name,
|
||||
Service: cl.Service,
|
||||
Enabled: cl.Enabled,
|
||||
Settings: settings,
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
type NotificationClient struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Service string `json:"service"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Settings interface{} `json:"settings"`
|
||||
}
|
||||
13
doc/alist.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# alist 对接
|
||||
|
||||
> 本程序可以把alist作为一个存储后台使用,下载完成的电影电视剧上传到alist对应的文件夹。配合阿里云、夸克云盘等实现云盘NAS功能。目前支持两种对接方式,webdav和直接对接
|
||||
|
||||
## webdav
|
||||
|
||||
使用webdav形式对接本程序,支持程序所有功能,但是不支持秒传,上传会比较慢
|
||||
|
||||
## alist 直接对接
|
||||
|
||||
存储设置里选择 alist,填入对应的信息即可。
|
||||
|
||||
优点:支持秒传,上传速度快。缺点:部分功能无法使用(plex和nfo文件刮削)
|
||||
BIN
doc/assets/add_indexer.png
Normal file
|
After Width: | Height: | Size: 92 KiB |
BIN
doc/assets/add_series.png
Normal file
|
After Width: | Height: | Size: 804 KiB |
BIN
doc/assets/anime_match.png
Normal file
|
After Width: | Height: | Size: 774 KiB |
BIN
doc/assets/copy_feed.png
Normal file
|
After Width: | Height: | Size: 106 KiB |
BIN
doc/assets/detail_page.png
Normal file
|
After Width: | Height: | Size: 2.6 MiB |
BIN
doc/assets/downloader.png
Normal file
|
After Width: | Height: | Size: 60 KiB |
BIN
doc/assets/jackett_api_key.png
Normal file
|
After Width: | Height: | Size: 115 KiB |
BIN
doc/assets/local_storage.png
Normal file
|
After Width: | Height: | Size: 63 KiB |
BIN
doc/assets/main_page.png
Normal file
|
After Width: | Height: | Size: 843 KiB |
BIN
doc/assets/polaris_add_indexer.png
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
doc/assets/search_add.png
Normal file
|
After Width: | Height: | Size: 80 KiB |
BIN
doc/assets/search_series.png
Normal file
|
After Width: | Height: | Size: 1.2 MiB |
BIN
doc/assets/unraid.png
Normal file
|
After Width: | Height: | Size: 206 KiB |
BIN
doc/assets/webdav_storage.png
Normal file
|
After Width: | Height: | Size: 80 KiB |
BIN
doc/assets/wechat.JPG
Normal file
|
After Width: | Height: | Size: 74 KiB |
BIN
doc/assets/yuanli.png
Normal file
|
After Width: | Height: | Size: 170 KiB |
38
doc/configuration.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# 配置
|
||||
|
||||
要正确使用此程序,需要配置好以下设置:
|
||||
|
||||
### 1. TMDB设置
|
||||
|
||||
1. 因为此程序需要使用到 TMDB 的数据,使用此程序首先要申请一个 TMDB 的 Api Key. 申请教程请 google [tmdb api key申请](https://www.google.com/search?q=tmdb+api+key%E7%94%B3%E8%AF%B7)
|
||||
|
||||
2. 拿到 TMDB Api Key之后,请填到 *设置 -> 常规设置 -> TMDB Api Key里*
|
||||
|
||||
**注意:** TMDB可能需要翻墙才能使用,参考 [TMDB 访问问题](./tmdb.md)
|
||||
|
||||
### 2. 索引器
|
||||
|
||||
使用配置页面索引器配置或者prowlarr设置,其中一个即可。
|
||||
|
||||
#### jackett配置参考 [jackett](./jackett.md)
|
||||
|
||||
#### prowlarr设置
|
||||
|
||||
1) 取得prowlarr的url和api key, api key在 *Prowlarr 设置 -> 通用 -> API 密钥* 处取得
|
||||
2) 对应参数填到 polaris程序,*设置->prowlarr设置*当中
|
||||
|
||||
### 下载器
|
||||
|
||||
资源下载器,目前可支持 tansmission/qbittorrent,请配置好对应配置
|
||||
|
||||

|
||||
|
||||
### 存储设置
|
||||
|
||||
默认配置了名为 local 的本地存储,如果你不知道怎么配置。请使用默认配置
|
||||
|
||||

|
||||
|
||||
类型里选择 webdav 可以使用 webdav 存储,配合 alist/clouddrive 等,可以实现存储到云盘里的功能。
|
||||
|
||||

|
||||
21
doc/jackett.md
Normal file
@@ -0,0 +1,21 @@
|
||||
## jackett 索引器配置
|
||||
|
||||
1. 打开 jackett 主页后,点击页面上面的 Add indexer,会出现 BT/PT 站点列表,选择你需要的站点点击+号添加。如果是PT,请自行配置好相关配置
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
|
||||
2. 添加后主页即会显示相应的BT/PT站点,点击 *Copy Torznab Feed* 即得到了我们需要的地址
|
||||
|
||||

|
||||
|
||||
3. 回到我们的主程序 Polaris 当中,点击 *设置 -> 索引器设置* -> 点击+号增加新的索引器,输入一个名称,拷贝我们第2步得到的地址到地址栏
|
||||
|
||||

|
||||
|
||||
4. 选相框中我们可以看到,还需要一个 API Key,我们回到 Jackett 中,在页面右上角,复制我们需要的 API Key:
|
||||

|
||||
|
||||
5. 恭喜!你已经成功完成了索引器配置。如需要更多的站点,请重复相同的操作完成配置
|
||||
137
doc/quick_start.md
Normal file
@@ -0,0 +1,137 @@
|
||||
# 快速开始
|
||||
|
||||
## 1. 安装 Polaris
|
||||
|
||||
### 1.1 Docker Compose 方式安装
|
||||
|
||||
最简单使用本程序的方式是通过docker compose,下面内容保存成 docker-compose.yml,然后执行 docker compose up -d, 即可拉起程序。
|
||||
|
||||
```yaml
|
||||
services:
|
||||
polaris:
|
||||
image: ghcr.io/simon-ding/polaris:latest
|
||||
restart: always
|
||||
environment:
|
||||
- PUID=99 #程序运行的用户UID
|
||||
- PGID=100 #程序运行的用户GID
|
||||
- TZ=Asia/Shanghai #时区
|
||||
volumes:
|
||||
- <配置文件路径>:/app/data #程序配置文件路径
|
||||
- <下载路径>:/downloads #下载路径,需要和下载客户端配置一致
|
||||
- <媒体文件路径>:/data #媒体数据存储路径,也可以启动自己配置webdav存储
|
||||
ports:
|
||||
- 8080:8080 #端口映射,冒号前的端口可自行改为需要的
|
||||
```
|
||||
|
||||
> latest为发布版本,如果你追求新功能,且能接受bug,可以使用main tag
|
||||
|
||||
### 1.2 Docker 方式安装
|
||||
|
||||
也可以通过原始 docker 命令的方式安装 Polaris:
|
||||
|
||||
```bash
|
||||
docker run -d \
|
||||
-v <配置文件路径>:/app/data \
|
||||
-v <下载路径>:/downloads \
|
||||
-v <媒体文件路径>:/data \
|
||||
-e PUID=99 \
|
||||
-e PGID=100 \
|
||||
-e TZ=Asia/Shanghai \
|
||||
-p 8080:8080 \
|
||||
--restart always \
|
||||
ghcr.io/simon-ding/polaris:latest
|
||||
```
|
||||
|
||||
### 1.3 Unraid 安装
|
||||
|
||||
参考下图进行配置
|
||||
|
||||

|
||||
|
||||
### 1.4 访问
|
||||
拉起之后访问 http://< ip >:8080 即可访问 Polaris 的主页:
|
||||
|
||||

|
||||
|
||||
|
||||
## 2. 安装下载客户端
|
||||
|
||||
Polaris 需要下载客户端的配合使用,目前支持 Transmission 和 Qbittorrent。推荐使用linuxserver镜像进行安装
|
||||
|
||||
* [linuxserver/transmission](https://docs.linuxserver.io/images/docker-transmission)
|
||||
|
||||
* [linuxserver/qbittorrent](https://docs.linuxserver.io/images/docker-qbittorrent/)
|
||||
|
||||
需要注意的是下载客户端内 /downloads 路径的映射地址要和 Polaris的/downloads路径映射保持一致。也就是说他俩都要映射到同一路径。
|
||||
|
||||
## 3. 安装 Jackett/Prowlarr
|
||||
|
||||
Polaris 如果要正常工作,还需要一个索引客户端的支持,目前支持jackett/prowlarr索引客户端。推荐使用prowlarr,设置更简单
|
||||
|
||||
安装方式见:
|
||||
|
||||
* [linuxserver/jackett](https://docs.linuxserver.io/images/docker-jackett/)
|
||||
* [linuxserver/prowlarr](https://docs.linuxserver.io/images/docker-prowlarr/)
|
||||
|
||||
|
||||
|
||||
## 4. 联合安装
|
||||
|
||||
如果觉得一个个安装麻烦,也可以使用下面docker compose文件,一键拉起所有组件
|
||||
|
||||
**注意:** transmission 的下载路径映射要和 polaris 保持一致,如果您不知道怎么做,请保持默认设置。
|
||||
|
||||
```yaml
|
||||
services:
|
||||
polaris:
|
||||
image: ghcr.io/simon-ding/polaris:latest
|
||||
restart: always
|
||||
environment:
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
- TZ=Asia/Shanghai
|
||||
volumes:
|
||||
- ./config/polaris:/app/data #程序配置文件路径
|
||||
- /downloads:/downloads #下载路径,需要和下载客户端配置一致
|
||||
- /data:/data #媒体数据存储路径,也可以启动自己配置webdav存储
|
||||
ports:
|
||||
- 8080:8080
|
||||
transmission: #下载客户端,也可以不安装使用已有的
|
||||
image: lscr.io/linuxserver/transmission:latest
|
||||
environment:
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
- TZ=Asia/Shanghai
|
||||
volumes:
|
||||
- ./config/transmission:/config
|
||||
- /downloads:/downloads #此路径要与polaris下载路径保持一致
|
||||
ports:
|
||||
- 9091:9091
|
||||
- 51413:51413
|
||||
- 51413:51413/udp
|
||||
jackett: #索引客户端,也可以不安装使用已有的
|
||||
image: lscr.io/linuxserver/jackett:latest
|
||||
environment:
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
- TZ=Asia/Shanghai
|
||||
volumes:
|
||||
- ./config/jackett:/config
|
||||
ports:
|
||||
- 9117:9117
|
||||
restart: unless-stopped
|
||||
```
|
||||
|
||||
复制上面文件保存成 docker-compose.yml 文件,然后执行下面命令
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
|
||||
## 5. 配置
|
||||
|
||||
详细配置请看 [配置篇](./configuration.md)
|
||||
|
||||
|
||||
|
||||
6
doc/tmdb.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# TMDB 访问问题
|
||||
|
||||
由于国内特殊的网络环境,访问 tmdb 可能需要翻墙代理,有两种解决方案
|
||||
|
||||
1. 设置路由器全局代理,openwrt等第三方路由固件可以实现这个功能
|
||||
2. 使用程序代理功能,*常规->代理地址* 中设置,格式如 http://192.168.0.10:1080
|
||||
131
ent/blacklist.go
Normal file
@@ -0,0 +1,131 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"polaris/ent/blacklist"
|
||||
"polaris/ent/schema"
|
||||
"strings"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// Blacklist is the model entity for the Blacklist schema.
|
||||
type Blacklist struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// Type holds the value of the "type" field.
|
||||
Type blacklist.Type `json:"type,omitempty"`
|
||||
// Value holds the value of the "value" field.
|
||||
Value schema.BlacklistValue `json:"value,omitempty"`
|
||||
// Notes holds the value of the "notes" field.
|
||||
Notes string `json:"notes,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Blacklist) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case blacklist.FieldValue:
|
||||
values[i] = new([]byte)
|
||||
case blacklist.FieldID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case blacklist.FieldType, blacklist.FieldNotes:
|
||||
values[i] = new(sql.NullString)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Blacklist fields.
|
||||
func (b *Blacklist) 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 blacklist.FieldID:
|
||||
value, ok := values[i].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
b.ID = int(value.Int64)
|
||||
case blacklist.FieldType:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field type", values[i])
|
||||
} else if value.Valid {
|
||||
b.Type = blacklist.Type(value.String)
|
||||
}
|
||||
case blacklist.FieldValue:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field value", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
if err := json.Unmarshal(*value, &b.Value); err != nil {
|
||||
return fmt.Errorf("unmarshal field value: %w", err)
|
||||
}
|
||||
}
|
||||
case blacklist.FieldNotes:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field notes", values[i])
|
||||
} else if value.Valid {
|
||||
b.Notes = value.String
|
||||
}
|
||||
default:
|
||||
b.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetValue returns the ent.Value that was dynamically selected and assigned to the Blacklist.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (b *Blacklist) GetValue(name string) (ent.Value, error) {
|
||||
return b.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Blacklist.
|
||||
// Note that you need to call Blacklist.Unwrap() before calling this method if this Blacklist
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (b *Blacklist) Update() *BlacklistUpdateOne {
|
||||
return NewBlacklistClient(b.config).UpdateOne(b)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Blacklist 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 (b *Blacklist) Unwrap() *Blacklist {
|
||||
_tx, ok := b.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Blacklist is not a transactional entity")
|
||||
}
|
||||
b.config.driver = _tx.drv
|
||||
return b
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (b *Blacklist) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Blacklist(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", b.ID))
|
||||
builder.WriteString("type=")
|
||||
builder.WriteString(fmt.Sprintf("%v", b.Type))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("value=")
|
||||
builder.WriteString(fmt.Sprintf("%v", b.Value))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("notes=")
|
||||
builder.WriteString(b.Notes)
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// Blacklists is a parsable slice of Blacklist.
|
||||
type Blacklists []*Blacklist
|
||||
89
ent/blacklist/blacklist.go
Normal file
@@ -0,0 +1,89 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package blacklist
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"polaris/ent/schema"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the blacklist type in the database.
|
||||
Label = "blacklist"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldType holds the string denoting the type field in the database.
|
||||
FieldType = "type"
|
||||
// FieldValue holds the string denoting the value field in the database.
|
||||
FieldValue = "value"
|
||||
// FieldNotes holds the string denoting the notes field in the database.
|
||||
FieldNotes = "notes"
|
||||
// Table holds the table name of the blacklist in the database.
|
||||
Table = "blacklists"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for blacklist fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldType,
|
||||
FieldValue,
|
||||
FieldNotes,
|
||||
}
|
||||
|
||||
// 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 (
|
||||
// DefaultValue holds the default value on creation for the "value" field.
|
||||
DefaultValue schema.BlacklistValue
|
||||
)
|
||||
|
||||
// Type defines the type for the "type" enum field.
|
||||
type Type string
|
||||
|
||||
// Type values.
|
||||
const (
|
||||
TypeMedia Type = "media"
|
||||
TypeTorrent Type = "torrent"
|
||||
)
|
||||
|
||||
func (_type Type) String() string {
|
||||
return string(_type)
|
||||
}
|
||||
|
||||
// TypeValidator is a validator for the "type" field enum values. It is called by the builders before save.
|
||||
func TypeValidator(_type Type) error {
|
||||
switch _type {
|
||||
case TypeMedia, TypeTorrent:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("blacklist: invalid enum value for type field: %q", _type)
|
||||
}
|
||||
}
|
||||
|
||||
// OrderOption defines the ordering options for the Blacklist 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()
|
||||
}
|
||||
|
||||
// ByType orders the results by the type field.
|
||||
func ByType(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldType, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByNotes orders the results by the notes field.
|
||||
func ByNotes(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldNotes, opts...).ToFunc()
|
||||
}
|
||||
169
ent/blacklist/where.go
Normal file
@@ -0,0 +1,169 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package blacklist
|
||||
|
||||
import (
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id int) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// Notes applies equality check predicate on the "notes" field. It's identical to NotesEQ.
|
||||
func Notes(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldEQ(FieldNotes, v))
|
||||
}
|
||||
|
||||
// TypeEQ applies the EQ predicate on the "type" field.
|
||||
func TypeEQ(v Type) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldEQ(FieldType, v))
|
||||
}
|
||||
|
||||
// TypeNEQ applies the NEQ predicate on the "type" field.
|
||||
func TypeNEQ(v Type) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldNEQ(FieldType, v))
|
||||
}
|
||||
|
||||
// TypeIn applies the In predicate on the "type" field.
|
||||
func TypeIn(vs ...Type) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldIn(FieldType, vs...))
|
||||
}
|
||||
|
||||
// TypeNotIn applies the NotIn predicate on the "type" field.
|
||||
func TypeNotIn(vs ...Type) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldNotIn(FieldType, vs...))
|
||||
}
|
||||
|
||||
// NotesEQ applies the EQ predicate on the "notes" field.
|
||||
func NotesEQ(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldEQ(FieldNotes, v))
|
||||
}
|
||||
|
||||
// NotesNEQ applies the NEQ predicate on the "notes" field.
|
||||
func NotesNEQ(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldNEQ(FieldNotes, v))
|
||||
}
|
||||
|
||||
// NotesIn applies the In predicate on the "notes" field.
|
||||
func NotesIn(vs ...string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldIn(FieldNotes, vs...))
|
||||
}
|
||||
|
||||
// NotesNotIn applies the NotIn predicate on the "notes" field.
|
||||
func NotesNotIn(vs ...string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldNotIn(FieldNotes, vs...))
|
||||
}
|
||||
|
||||
// NotesGT applies the GT predicate on the "notes" field.
|
||||
func NotesGT(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldGT(FieldNotes, v))
|
||||
}
|
||||
|
||||
// NotesGTE applies the GTE predicate on the "notes" field.
|
||||
func NotesGTE(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldGTE(FieldNotes, v))
|
||||
}
|
||||
|
||||
// NotesLT applies the LT predicate on the "notes" field.
|
||||
func NotesLT(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldLT(FieldNotes, v))
|
||||
}
|
||||
|
||||
// NotesLTE applies the LTE predicate on the "notes" field.
|
||||
func NotesLTE(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldLTE(FieldNotes, v))
|
||||
}
|
||||
|
||||
// NotesContains applies the Contains predicate on the "notes" field.
|
||||
func NotesContains(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldContains(FieldNotes, v))
|
||||
}
|
||||
|
||||
// NotesHasPrefix applies the HasPrefix predicate on the "notes" field.
|
||||
func NotesHasPrefix(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldHasPrefix(FieldNotes, v))
|
||||
}
|
||||
|
||||
// NotesHasSuffix applies the HasSuffix predicate on the "notes" field.
|
||||
func NotesHasSuffix(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldHasSuffix(FieldNotes, v))
|
||||
}
|
||||
|
||||
// NotesIsNil applies the IsNil predicate on the "notes" field.
|
||||
func NotesIsNil() predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldIsNull(FieldNotes))
|
||||
}
|
||||
|
||||
// NotesNotNil applies the NotNil predicate on the "notes" field.
|
||||
func NotesNotNil() predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldNotNull(FieldNotes))
|
||||
}
|
||||
|
||||
// NotesEqualFold applies the EqualFold predicate on the "notes" field.
|
||||
func NotesEqualFold(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldEqualFold(FieldNotes, v))
|
||||
}
|
||||
|
||||
// NotesContainsFold applies the ContainsFold predicate on the "notes" field.
|
||||
func NotesContainsFold(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldContainsFold(FieldNotes, v))
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Blacklist) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.Blacklist) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.Blacklist) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.NotPredicates(p))
|
||||
}
|
||||
238
ent/blacklist_create.go
Normal file
@@ -0,0 +1,238 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/blacklist"
|
||||
"polaris/ent/schema"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// BlacklistCreate is the builder for creating a Blacklist entity.
|
||||
type BlacklistCreate struct {
|
||||
config
|
||||
mutation *BlacklistMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetType sets the "type" field.
|
||||
func (bc *BlacklistCreate) SetType(b blacklist.Type) *BlacklistCreate {
|
||||
bc.mutation.SetType(b)
|
||||
return bc
|
||||
}
|
||||
|
||||
// SetValue sets the "value" field.
|
||||
func (bc *BlacklistCreate) SetValue(sv schema.BlacklistValue) *BlacklistCreate {
|
||||
bc.mutation.SetValue(sv)
|
||||
return bc
|
||||
}
|
||||
|
||||
// SetNillableValue sets the "value" field if the given value is not nil.
|
||||
func (bc *BlacklistCreate) SetNillableValue(sv *schema.BlacklistValue) *BlacklistCreate {
|
||||
if sv != nil {
|
||||
bc.SetValue(*sv)
|
||||
}
|
||||
return bc
|
||||
}
|
||||
|
||||
// SetNotes sets the "notes" field.
|
||||
func (bc *BlacklistCreate) SetNotes(s string) *BlacklistCreate {
|
||||
bc.mutation.SetNotes(s)
|
||||
return bc
|
||||
}
|
||||
|
||||
// SetNillableNotes sets the "notes" field if the given value is not nil.
|
||||
func (bc *BlacklistCreate) SetNillableNotes(s *string) *BlacklistCreate {
|
||||
if s != nil {
|
||||
bc.SetNotes(*s)
|
||||
}
|
||||
return bc
|
||||
}
|
||||
|
||||
// Mutation returns the BlacklistMutation object of the builder.
|
||||
func (bc *BlacklistCreate) Mutation() *BlacklistMutation {
|
||||
return bc.mutation
|
||||
}
|
||||
|
||||
// Save creates the Blacklist in the database.
|
||||
func (bc *BlacklistCreate) Save(ctx context.Context) (*Blacklist, error) {
|
||||
bc.defaults()
|
||||
return withHooks(ctx, bc.sqlSave, bc.mutation, bc.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (bc *BlacklistCreate) SaveX(ctx context.Context) *Blacklist {
|
||||
v, err := bc.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (bc *BlacklistCreate) Exec(ctx context.Context) error {
|
||||
_, err := bc.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (bc *BlacklistCreate) ExecX(ctx context.Context) {
|
||||
if err := bc.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (bc *BlacklistCreate) defaults() {
|
||||
if _, ok := bc.mutation.Value(); !ok {
|
||||
v := blacklist.DefaultValue
|
||||
bc.mutation.SetValue(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (bc *BlacklistCreate) check() error {
|
||||
if _, ok := bc.mutation.GetType(); !ok {
|
||||
return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Blacklist.type"`)}
|
||||
}
|
||||
if v, ok := bc.mutation.GetType(); ok {
|
||||
if err := blacklist.TypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Blacklist.type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := bc.mutation.Value(); !ok {
|
||||
return &ValidationError{Name: "value", err: errors.New(`ent: missing required field "Blacklist.value"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bc *BlacklistCreate) sqlSave(ctx context.Context) (*Blacklist, error) {
|
||||
if err := bc.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := bc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, bc.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 = int(id)
|
||||
bc.mutation.id = &_node.ID
|
||||
bc.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (bc *BlacklistCreate) createSpec() (*Blacklist, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Blacklist{config: bc.config}
|
||||
_spec = sqlgraph.NewCreateSpec(blacklist.Table, sqlgraph.NewFieldSpec(blacklist.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := bc.mutation.GetType(); ok {
|
||||
_spec.SetField(blacklist.FieldType, field.TypeEnum, value)
|
||||
_node.Type = value
|
||||
}
|
||||
if value, ok := bc.mutation.Value(); ok {
|
||||
_spec.SetField(blacklist.FieldValue, field.TypeJSON, value)
|
||||
_node.Value = value
|
||||
}
|
||||
if value, ok := bc.mutation.Notes(); ok {
|
||||
_spec.SetField(blacklist.FieldNotes, field.TypeString, value)
|
||||
_node.Notes = value
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// BlacklistCreateBulk is the builder for creating many Blacklist entities in bulk.
|
||||
type BlacklistCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*BlacklistCreate
|
||||
}
|
||||
|
||||
// Save creates the Blacklist entities in the database.
|
||||
func (bcb *BlacklistCreateBulk) Save(ctx context.Context) ([]*Blacklist, error) {
|
||||
if bcb.err != nil {
|
||||
return nil, bcb.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(bcb.builders))
|
||||
nodes := make([]*Blacklist, len(bcb.builders))
|
||||
mutators := make([]Mutator, len(bcb.builders))
|
||||
for i := range bcb.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := bcb.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*BlacklistMutation)
|
||||
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, bcb.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, bcb.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 = int(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, bcb.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (bcb *BlacklistCreateBulk) SaveX(ctx context.Context) []*Blacklist {
|
||||
v, err := bcb.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (bcb *BlacklistCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := bcb.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (bcb *BlacklistCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := bcb.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
88
ent/blacklist_delete.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"polaris/ent/blacklist"
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// BlacklistDelete is the builder for deleting a Blacklist entity.
|
||||
type BlacklistDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *BlacklistMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the BlacklistDelete builder.
|
||||
func (bd *BlacklistDelete) Where(ps ...predicate.Blacklist) *BlacklistDelete {
|
||||
bd.mutation.Where(ps...)
|
||||
return bd
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (bd *BlacklistDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, bd.sqlExec, bd.mutation, bd.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (bd *BlacklistDelete) ExecX(ctx context.Context) int {
|
||||
n, err := bd.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (bd *BlacklistDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(blacklist.Table, sqlgraph.NewFieldSpec(blacklist.FieldID, field.TypeInt))
|
||||
if ps := bd.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, bd.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
bd.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// BlacklistDeleteOne is the builder for deleting a single Blacklist entity.
|
||||
type BlacklistDeleteOne struct {
|
||||
bd *BlacklistDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the BlacklistDelete builder.
|
||||
func (bdo *BlacklistDeleteOne) Where(ps ...predicate.Blacklist) *BlacklistDeleteOne {
|
||||
bdo.bd.mutation.Where(ps...)
|
||||
return bdo
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (bdo *BlacklistDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := bdo.bd.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{blacklist.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (bdo *BlacklistDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := bdo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
526
ent/blacklist_query.go
Normal file
@@ -0,0 +1,526 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"polaris/ent/blacklist"
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// BlacklistQuery is the builder for querying Blacklist entities.
|
||||
type BlacklistQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []blacklist.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.Blacklist
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the BlacklistQuery builder.
|
||||
func (bq *BlacklistQuery) Where(ps ...predicate.Blacklist) *BlacklistQuery {
|
||||
bq.predicates = append(bq.predicates, ps...)
|
||||
return bq
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (bq *BlacklistQuery) Limit(limit int) *BlacklistQuery {
|
||||
bq.ctx.Limit = &limit
|
||||
return bq
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (bq *BlacklistQuery) Offset(offset int) *BlacklistQuery {
|
||||
bq.ctx.Offset = &offset
|
||||
return bq
|
||||
}
|
||||
|
||||
// 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 (bq *BlacklistQuery) Unique(unique bool) *BlacklistQuery {
|
||||
bq.ctx.Unique = &unique
|
||||
return bq
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (bq *BlacklistQuery) Order(o ...blacklist.OrderOption) *BlacklistQuery {
|
||||
bq.order = append(bq.order, o...)
|
||||
return bq
|
||||
}
|
||||
|
||||
// First returns the first Blacklist entity from the query.
|
||||
// Returns a *NotFoundError when no Blacklist was found.
|
||||
func (bq *BlacklistQuery) First(ctx context.Context) (*Blacklist, error) {
|
||||
nodes, err := bq.Limit(1).All(setContextOp(ctx, bq.ctx, "First"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{blacklist.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (bq *BlacklistQuery) FirstX(ctx context.Context) *Blacklist {
|
||||
node, err := bq.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first Blacklist ID from the query.
|
||||
// Returns a *NotFoundError when no Blacklist ID was found.
|
||||
func (bq *BlacklistQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = bq.Limit(1).IDs(setContextOp(ctx, bq.ctx, "FirstID")); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{blacklist.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (bq *BlacklistQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := bq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single Blacklist entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Blacklist entity is found.
|
||||
// Returns a *NotFoundError when no Blacklist entities are found.
|
||||
func (bq *BlacklistQuery) Only(ctx context.Context) (*Blacklist, error) {
|
||||
nodes, err := bq.Limit(2).All(setContextOp(ctx, bq.ctx, "Only"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{blacklist.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{blacklist.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (bq *BlacklistQuery) OnlyX(ctx context.Context) *Blacklist {
|
||||
node, err := bq.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only Blacklist ID in the query.
|
||||
// Returns a *NotSingularError when more than one Blacklist ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (bq *BlacklistQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = bq.Limit(2).IDs(setContextOp(ctx, bq.ctx, "OnlyID")); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{blacklist.Label}
|
||||
default:
|
||||
err = &NotSingularError{blacklist.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (bq *BlacklistQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := bq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of Blacklists.
|
||||
func (bq *BlacklistQuery) All(ctx context.Context) ([]*Blacklist, error) {
|
||||
ctx = setContextOp(ctx, bq.ctx, "All")
|
||||
if err := bq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Blacklist, *BlacklistQuery]()
|
||||
return withInterceptors[[]*Blacklist](ctx, bq, qr, bq.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (bq *BlacklistQuery) AllX(ctx context.Context) []*Blacklist {
|
||||
nodes, err := bq.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Blacklist IDs.
|
||||
func (bq *BlacklistQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if bq.ctx.Unique == nil && bq.path != nil {
|
||||
bq.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, bq.ctx, "IDs")
|
||||
if err = bq.Select(blacklist.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (bq *BlacklistQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := bq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (bq *BlacklistQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, bq.ctx, "Count")
|
||||
if err := bq.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, bq, querierCount[*BlacklistQuery](), bq.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (bq *BlacklistQuery) CountX(ctx context.Context) int {
|
||||
count, err := bq.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (bq *BlacklistQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, bq.ctx, "Exist")
|
||||
switch _, err := bq.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 (bq *BlacklistQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := bq.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the BlacklistQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (bq *BlacklistQuery) Clone() *BlacklistQuery {
|
||||
if bq == nil {
|
||||
return nil
|
||||
}
|
||||
return &BlacklistQuery{
|
||||
config: bq.config,
|
||||
ctx: bq.ctx.Clone(),
|
||||
order: append([]blacklist.OrderOption{}, bq.order...),
|
||||
inters: append([]Interceptor{}, bq.inters...),
|
||||
predicates: append([]predicate.Blacklist{}, bq.predicates...),
|
||||
// clone intermediate query.
|
||||
sql: bq.sql.Clone(),
|
||||
path: bq.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 {
|
||||
// Type blacklist.Type `json:"type,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Blacklist.Query().
|
||||
// GroupBy(blacklist.FieldType).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (bq *BlacklistQuery) GroupBy(field string, fields ...string) *BlacklistGroupBy {
|
||||
bq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &BlacklistGroupBy{build: bq}
|
||||
grbuild.flds = &bq.ctx.Fields
|
||||
grbuild.label = blacklist.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 {
|
||||
// Type blacklist.Type `json:"type,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Blacklist.Query().
|
||||
// Select(blacklist.FieldType).
|
||||
// Scan(ctx, &v)
|
||||
func (bq *BlacklistQuery) Select(fields ...string) *BlacklistSelect {
|
||||
bq.ctx.Fields = append(bq.ctx.Fields, fields...)
|
||||
sbuild := &BlacklistSelect{BlacklistQuery: bq}
|
||||
sbuild.label = blacklist.Label
|
||||
sbuild.flds, sbuild.scan = &bq.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a BlacklistSelect configured with the given aggregations.
|
||||
func (bq *BlacklistQuery) Aggregate(fns ...AggregateFunc) *BlacklistSelect {
|
||||
return bq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (bq *BlacklistQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range bq.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, bq); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range bq.ctx.Fields {
|
||||
if !blacklist.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if bq.path != nil {
|
||||
prev, err := bq.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
bq.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bq *BlacklistQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Blacklist, error) {
|
||||
var (
|
||||
nodes = []*Blacklist{}
|
||||
_spec = bq.querySpec()
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*Blacklist).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Blacklist{config: bq.config}
|
||||
nodes = append(nodes, node)
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, bq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (bq *BlacklistQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := bq.querySpec()
|
||||
_spec.Node.Columns = bq.ctx.Fields
|
||||
if len(bq.ctx.Fields) > 0 {
|
||||
_spec.Unique = bq.ctx.Unique != nil && *bq.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, bq.driver, _spec)
|
||||
}
|
||||
|
||||
func (bq *BlacklistQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(blacklist.Table, blacklist.Columns, sqlgraph.NewFieldSpec(blacklist.FieldID, field.TypeInt))
|
||||
_spec.From = bq.sql
|
||||
if unique := bq.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if bq.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := bq.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, blacklist.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != blacklist.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := bq.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := bq.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := bq.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := bq.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (bq *BlacklistQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(bq.driver.Dialect())
|
||||
t1 := builder.Table(blacklist.Table)
|
||||
columns := bq.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = blacklist.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if bq.sql != nil {
|
||||
selector = bq.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if bq.ctx.Unique != nil && *bq.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range bq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range bq.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := bq.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 := bq.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// BlacklistGroupBy is the group-by builder for Blacklist entities.
|
||||
type BlacklistGroupBy struct {
|
||||
selector
|
||||
build *BlacklistQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (bgb *BlacklistGroupBy) Aggregate(fns ...AggregateFunc) *BlacklistGroupBy {
|
||||
bgb.fns = append(bgb.fns, fns...)
|
||||
return bgb
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (bgb *BlacklistGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, bgb.build.ctx, "GroupBy")
|
||||
if err := bgb.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*BlacklistQuery, *BlacklistGroupBy](ctx, bgb.build, bgb, bgb.build.inters, v)
|
||||
}
|
||||
|
||||
func (bgb *BlacklistGroupBy) sqlScan(ctx context.Context, root *BlacklistQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(bgb.fns))
|
||||
for _, fn := range bgb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*bgb.flds)+len(bgb.fns))
|
||||
for _, f := range *bgb.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*bgb.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := bgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// BlacklistSelect is the builder for selecting fields of Blacklist entities.
|
||||
type BlacklistSelect struct {
|
||||
*BlacklistQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (bs *BlacklistSelect) Aggregate(fns ...AggregateFunc) *BlacklistSelect {
|
||||
bs.fns = append(bs.fns, fns...)
|
||||
return bs
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (bs *BlacklistSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, bs.ctx, "Select")
|
||||
if err := bs.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*BlacklistQuery, *BlacklistSelect](ctx, bs.BlacklistQuery, bs, bs.inters, v)
|
||||
}
|
||||
|
||||
func (bs *BlacklistSelect) sqlScan(ctx context.Context, root *BlacklistQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(bs.fns))
|
||||
for _, fn := range bs.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*bs.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 := bs.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
322
ent/blacklist_update.go
Normal file
@@ -0,0 +1,322 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/blacklist"
|
||||
"polaris/ent/predicate"
|
||||
"polaris/ent/schema"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// BlacklistUpdate is the builder for updating Blacklist entities.
|
||||
type BlacklistUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *BlacklistMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the BlacklistUpdate builder.
|
||||
func (bu *BlacklistUpdate) Where(ps ...predicate.Blacklist) *BlacklistUpdate {
|
||||
bu.mutation.Where(ps...)
|
||||
return bu
|
||||
}
|
||||
|
||||
// SetType sets the "type" field.
|
||||
func (bu *BlacklistUpdate) SetType(b blacklist.Type) *BlacklistUpdate {
|
||||
bu.mutation.SetType(b)
|
||||
return bu
|
||||
}
|
||||
|
||||
// SetNillableType sets the "type" field if the given value is not nil.
|
||||
func (bu *BlacklistUpdate) SetNillableType(b *blacklist.Type) *BlacklistUpdate {
|
||||
if b != nil {
|
||||
bu.SetType(*b)
|
||||
}
|
||||
return bu
|
||||
}
|
||||
|
||||
// SetValue sets the "value" field.
|
||||
func (bu *BlacklistUpdate) SetValue(sv schema.BlacklistValue) *BlacklistUpdate {
|
||||
bu.mutation.SetValue(sv)
|
||||
return bu
|
||||
}
|
||||
|
||||
// SetNillableValue sets the "value" field if the given value is not nil.
|
||||
func (bu *BlacklistUpdate) SetNillableValue(sv *schema.BlacklistValue) *BlacklistUpdate {
|
||||
if sv != nil {
|
||||
bu.SetValue(*sv)
|
||||
}
|
||||
return bu
|
||||
}
|
||||
|
||||
// SetNotes sets the "notes" field.
|
||||
func (bu *BlacklistUpdate) SetNotes(s string) *BlacklistUpdate {
|
||||
bu.mutation.SetNotes(s)
|
||||
return bu
|
||||
}
|
||||
|
||||
// SetNillableNotes sets the "notes" field if the given value is not nil.
|
||||
func (bu *BlacklistUpdate) SetNillableNotes(s *string) *BlacklistUpdate {
|
||||
if s != nil {
|
||||
bu.SetNotes(*s)
|
||||
}
|
||||
return bu
|
||||
}
|
||||
|
||||
// ClearNotes clears the value of the "notes" field.
|
||||
func (bu *BlacklistUpdate) ClearNotes() *BlacklistUpdate {
|
||||
bu.mutation.ClearNotes()
|
||||
return bu
|
||||
}
|
||||
|
||||
// Mutation returns the BlacklistMutation object of the builder.
|
||||
func (bu *BlacklistUpdate) Mutation() *BlacklistMutation {
|
||||
return bu.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (bu *BlacklistUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, bu.sqlSave, bu.mutation, bu.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (bu *BlacklistUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := bu.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (bu *BlacklistUpdate) Exec(ctx context.Context) error {
|
||||
_, err := bu.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (bu *BlacklistUpdate) ExecX(ctx context.Context) {
|
||||
if err := bu.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (bu *BlacklistUpdate) check() error {
|
||||
if v, ok := bu.mutation.GetType(); ok {
|
||||
if err := blacklist.TypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Blacklist.type": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bu *BlacklistUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if err := bu.check(); err != nil {
|
||||
return n, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(blacklist.Table, blacklist.Columns, sqlgraph.NewFieldSpec(blacklist.FieldID, field.TypeInt))
|
||||
if ps := bu.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := bu.mutation.GetType(); ok {
|
||||
_spec.SetField(blacklist.FieldType, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := bu.mutation.Value(); ok {
|
||||
_spec.SetField(blacklist.FieldValue, field.TypeJSON, value)
|
||||
}
|
||||
if value, ok := bu.mutation.Notes(); ok {
|
||||
_spec.SetField(blacklist.FieldNotes, field.TypeString, value)
|
||||
}
|
||||
if bu.mutation.NotesCleared() {
|
||||
_spec.ClearField(blacklist.FieldNotes, field.TypeString)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, bu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{blacklist.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
bu.mutation.done = true
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// BlacklistUpdateOne is the builder for updating a single Blacklist entity.
|
||||
type BlacklistUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *BlacklistMutation
|
||||
}
|
||||
|
||||
// SetType sets the "type" field.
|
||||
func (buo *BlacklistUpdateOne) SetType(b blacklist.Type) *BlacklistUpdateOne {
|
||||
buo.mutation.SetType(b)
|
||||
return buo
|
||||
}
|
||||
|
||||
// SetNillableType sets the "type" field if the given value is not nil.
|
||||
func (buo *BlacklistUpdateOne) SetNillableType(b *blacklist.Type) *BlacklistUpdateOne {
|
||||
if b != nil {
|
||||
buo.SetType(*b)
|
||||
}
|
||||
return buo
|
||||
}
|
||||
|
||||
// SetValue sets the "value" field.
|
||||
func (buo *BlacklistUpdateOne) SetValue(sv schema.BlacklistValue) *BlacklistUpdateOne {
|
||||
buo.mutation.SetValue(sv)
|
||||
return buo
|
||||
}
|
||||
|
||||
// SetNillableValue sets the "value" field if the given value is not nil.
|
||||
func (buo *BlacklistUpdateOne) SetNillableValue(sv *schema.BlacklistValue) *BlacklistUpdateOne {
|
||||
if sv != nil {
|
||||
buo.SetValue(*sv)
|
||||
}
|
||||
return buo
|
||||
}
|
||||
|
||||
// SetNotes sets the "notes" field.
|
||||
func (buo *BlacklistUpdateOne) SetNotes(s string) *BlacklistUpdateOne {
|
||||
buo.mutation.SetNotes(s)
|
||||
return buo
|
||||
}
|
||||
|
||||
// SetNillableNotes sets the "notes" field if the given value is not nil.
|
||||
func (buo *BlacklistUpdateOne) SetNillableNotes(s *string) *BlacklistUpdateOne {
|
||||
if s != nil {
|
||||
buo.SetNotes(*s)
|
||||
}
|
||||
return buo
|
||||
}
|
||||
|
||||
// ClearNotes clears the value of the "notes" field.
|
||||
func (buo *BlacklistUpdateOne) ClearNotes() *BlacklistUpdateOne {
|
||||
buo.mutation.ClearNotes()
|
||||
return buo
|
||||
}
|
||||
|
||||
// Mutation returns the BlacklistMutation object of the builder.
|
||||
func (buo *BlacklistUpdateOne) Mutation() *BlacklistMutation {
|
||||
return buo.mutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the BlacklistUpdate builder.
|
||||
func (buo *BlacklistUpdateOne) Where(ps ...predicate.Blacklist) *BlacklistUpdateOne {
|
||||
buo.mutation.Where(ps...)
|
||||
return buo
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (buo *BlacklistUpdateOne) Select(field string, fields ...string) *BlacklistUpdateOne {
|
||||
buo.fields = append([]string{field}, fields...)
|
||||
return buo
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated Blacklist entity.
|
||||
func (buo *BlacklistUpdateOne) Save(ctx context.Context) (*Blacklist, error) {
|
||||
return withHooks(ctx, buo.sqlSave, buo.mutation, buo.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (buo *BlacklistUpdateOne) SaveX(ctx context.Context) *Blacklist {
|
||||
node, err := buo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (buo *BlacklistUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := buo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (buo *BlacklistUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := buo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (buo *BlacklistUpdateOne) check() error {
|
||||
if v, ok := buo.mutation.GetType(); ok {
|
||||
if err := blacklist.TypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Blacklist.type": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (buo *BlacklistUpdateOne) sqlSave(ctx context.Context) (_node *Blacklist, err error) {
|
||||
if err := buo.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(blacklist.Table, blacklist.Columns, sqlgraph.NewFieldSpec(blacklist.FieldID, field.TypeInt))
|
||||
id, ok := buo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Blacklist.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := buo.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, blacklist.FieldID)
|
||||
for _, f := range fields {
|
||||
if !blacklist.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != blacklist.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := buo.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := buo.mutation.GetType(); ok {
|
||||
_spec.SetField(blacklist.FieldType, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := buo.mutation.Value(); ok {
|
||||
_spec.SetField(blacklist.FieldValue, field.TypeJSON, value)
|
||||
}
|
||||
if value, ok := buo.mutation.Notes(); ok {
|
||||
_spec.SetField(blacklist.FieldNotes, field.TypeString, value)
|
||||
}
|
||||
if buo.mutation.NotesCleared() {
|
||||
_spec.ClearField(blacklist.FieldNotes, field.TypeString)
|
||||
}
|
||||
_node = &Blacklist{config: buo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, buo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{blacklist.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
buo.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
476
ent/client.go
@@ -11,11 +11,14 @@ import (
|
||||
|
||||
"polaris/ent/migrate"
|
||||
|
||||
"polaris/ent/blacklist"
|
||||
"polaris/ent/downloadclients"
|
||||
"polaris/ent/episode"
|
||||
"polaris/ent/history"
|
||||
"polaris/ent/importlist"
|
||||
"polaris/ent/indexers"
|
||||
"polaris/ent/media"
|
||||
"polaris/ent/notificationclient"
|
||||
"polaris/ent/settings"
|
||||
"polaris/ent/storage"
|
||||
|
||||
@@ -30,16 +33,22 @@ type Client struct {
|
||||
config
|
||||
// Schema is the client for creating, migrating and dropping schema.
|
||||
Schema *migrate.Schema
|
||||
// Blacklist is the client for interacting with the Blacklist builders.
|
||||
Blacklist *BlacklistClient
|
||||
// DownloadClients is the client for interacting with the DownloadClients builders.
|
||||
DownloadClients *DownloadClientsClient
|
||||
// Episode is the client for interacting with the Episode builders.
|
||||
Episode *EpisodeClient
|
||||
// History is the client for interacting with the History builders.
|
||||
History *HistoryClient
|
||||
// ImportList is the client for interacting with the ImportList builders.
|
||||
ImportList *ImportListClient
|
||||
// Indexers is the client for interacting with the Indexers builders.
|
||||
Indexers *IndexersClient
|
||||
// Media is the client for interacting with the Media builders.
|
||||
Media *MediaClient
|
||||
// NotificationClient is the client for interacting with the NotificationClient builders.
|
||||
NotificationClient *NotificationClientClient
|
||||
// Settings is the client for interacting with the Settings builders.
|
||||
Settings *SettingsClient
|
||||
// Storage is the client for interacting with the Storage builders.
|
||||
@@ -55,11 +64,14 @@ func NewClient(opts ...Option) *Client {
|
||||
|
||||
func (c *Client) init() {
|
||||
c.Schema = migrate.NewSchema(c.driver)
|
||||
c.Blacklist = NewBlacklistClient(c.config)
|
||||
c.DownloadClients = NewDownloadClientsClient(c.config)
|
||||
c.Episode = NewEpisodeClient(c.config)
|
||||
c.History = NewHistoryClient(c.config)
|
||||
c.ImportList = NewImportListClient(c.config)
|
||||
c.Indexers = NewIndexersClient(c.config)
|
||||
c.Media = NewMediaClient(c.config)
|
||||
c.NotificationClient = NewNotificationClientClient(c.config)
|
||||
c.Settings = NewSettingsClient(c.config)
|
||||
c.Storage = NewStorageClient(c.config)
|
||||
}
|
||||
@@ -152,15 +164,18 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
||||
cfg := c.config
|
||||
cfg.driver = tx
|
||||
return &Tx{
|
||||
ctx: ctx,
|
||||
config: cfg,
|
||||
DownloadClients: NewDownloadClientsClient(cfg),
|
||||
Episode: NewEpisodeClient(cfg),
|
||||
History: NewHistoryClient(cfg),
|
||||
Indexers: NewIndexersClient(cfg),
|
||||
Media: NewMediaClient(cfg),
|
||||
Settings: NewSettingsClient(cfg),
|
||||
Storage: NewStorageClient(cfg),
|
||||
ctx: ctx,
|
||||
config: cfg,
|
||||
Blacklist: NewBlacklistClient(cfg),
|
||||
DownloadClients: NewDownloadClientsClient(cfg),
|
||||
Episode: NewEpisodeClient(cfg),
|
||||
History: NewHistoryClient(cfg),
|
||||
ImportList: NewImportListClient(cfg),
|
||||
Indexers: NewIndexersClient(cfg),
|
||||
Media: NewMediaClient(cfg),
|
||||
NotificationClient: NewNotificationClientClient(cfg),
|
||||
Settings: NewSettingsClient(cfg),
|
||||
Storage: NewStorageClient(cfg),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -178,22 +193,25 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
|
||||
cfg := c.config
|
||||
cfg.driver = &txDriver{tx: tx, drv: c.driver}
|
||||
return &Tx{
|
||||
ctx: ctx,
|
||||
config: cfg,
|
||||
DownloadClients: NewDownloadClientsClient(cfg),
|
||||
Episode: NewEpisodeClient(cfg),
|
||||
History: NewHistoryClient(cfg),
|
||||
Indexers: NewIndexersClient(cfg),
|
||||
Media: NewMediaClient(cfg),
|
||||
Settings: NewSettingsClient(cfg),
|
||||
Storage: NewStorageClient(cfg),
|
||||
ctx: ctx,
|
||||
config: cfg,
|
||||
Blacklist: NewBlacklistClient(cfg),
|
||||
DownloadClients: NewDownloadClientsClient(cfg),
|
||||
Episode: NewEpisodeClient(cfg),
|
||||
History: NewHistoryClient(cfg),
|
||||
ImportList: NewImportListClient(cfg),
|
||||
Indexers: NewIndexersClient(cfg),
|
||||
Media: NewMediaClient(cfg),
|
||||
NotificationClient: NewNotificationClientClient(cfg),
|
||||
Settings: NewSettingsClient(cfg),
|
||||
Storage: NewStorageClient(cfg),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Debug returns a new debug-client. It's used to get verbose logging on specific operations.
|
||||
//
|
||||
// client.Debug().
|
||||
// DownloadClients.
|
||||
// Blacklist.
|
||||
// Query().
|
||||
// Count(ctx)
|
||||
func (c *Client) Debug() *Client {
|
||||
@@ -216,8 +234,8 @@ func (c *Client) Close() error {
|
||||
// In order to add hooks to a specific client, call: `client.Node.Use(...)`.
|
||||
func (c *Client) Use(hooks ...Hook) {
|
||||
for _, n := range []interface{ Use(...Hook) }{
|
||||
c.DownloadClients, c.Episode, c.History, c.Indexers, c.Media, c.Settings,
|
||||
c.Storage,
|
||||
c.Blacklist, c.DownloadClients, c.Episode, c.History, c.ImportList, c.Indexers,
|
||||
c.Media, c.NotificationClient, c.Settings, c.Storage,
|
||||
} {
|
||||
n.Use(hooks...)
|
||||
}
|
||||
@@ -227,8 +245,8 @@ func (c *Client) Use(hooks ...Hook) {
|
||||
// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
|
||||
func (c *Client) Intercept(interceptors ...Interceptor) {
|
||||
for _, n := range []interface{ Intercept(...Interceptor) }{
|
||||
c.DownloadClients, c.Episode, c.History, c.Indexers, c.Media, c.Settings,
|
||||
c.Storage,
|
||||
c.Blacklist, c.DownloadClients, c.Episode, c.History, c.ImportList, c.Indexers,
|
||||
c.Media, c.NotificationClient, c.Settings, c.Storage,
|
||||
} {
|
||||
n.Intercept(interceptors...)
|
||||
}
|
||||
@@ -237,16 +255,22 @@ func (c *Client) Intercept(interceptors ...Interceptor) {
|
||||
// Mutate implements the ent.Mutator interface.
|
||||
func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
|
||||
switch m := m.(type) {
|
||||
case *BlacklistMutation:
|
||||
return c.Blacklist.mutate(ctx, m)
|
||||
case *DownloadClientsMutation:
|
||||
return c.DownloadClients.mutate(ctx, m)
|
||||
case *EpisodeMutation:
|
||||
return c.Episode.mutate(ctx, m)
|
||||
case *HistoryMutation:
|
||||
return c.History.mutate(ctx, m)
|
||||
case *ImportListMutation:
|
||||
return c.ImportList.mutate(ctx, m)
|
||||
case *IndexersMutation:
|
||||
return c.Indexers.mutate(ctx, m)
|
||||
case *MediaMutation:
|
||||
return c.Media.mutate(ctx, m)
|
||||
case *NotificationClientMutation:
|
||||
return c.NotificationClient.mutate(ctx, m)
|
||||
case *SettingsMutation:
|
||||
return c.Settings.mutate(ctx, m)
|
||||
case *StorageMutation:
|
||||
@@ -256,6 +280,139 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// BlacklistClient is a client for the Blacklist schema.
|
||||
type BlacklistClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewBlacklistClient returns a client for the Blacklist from the given config.
|
||||
func NewBlacklistClient(c config) *BlacklistClient {
|
||||
return &BlacklistClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `blacklist.Hooks(f(g(h())))`.
|
||||
func (c *BlacklistClient) Use(hooks ...Hook) {
|
||||
c.hooks.Blacklist = append(c.hooks.Blacklist, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `blacklist.Intercept(f(g(h())))`.
|
||||
func (c *BlacklistClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.Blacklist = append(c.inters.Blacklist, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a Blacklist entity.
|
||||
func (c *BlacklistClient) Create() *BlacklistCreate {
|
||||
mutation := newBlacklistMutation(c.config, OpCreate)
|
||||
return &BlacklistCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of Blacklist entities.
|
||||
func (c *BlacklistClient) CreateBulk(builders ...*BlacklistCreate) *BlacklistCreateBulk {
|
||||
return &BlacklistCreateBulk{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 *BlacklistClient) MapCreateBulk(slice any, setFunc func(*BlacklistCreate, int)) *BlacklistCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &BlacklistCreateBulk{err: fmt.Errorf("calling to BlacklistClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*BlacklistCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &BlacklistCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Blacklist.
|
||||
func (c *BlacklistClient) Update() *BlacklistUpdate {
|
||||
mutation := newBlacklistMutation(c.config, OpUpdate)
|
||||
return &BlacklistUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *BlacklistClient) UpdateOne(b *Blacklist) *BlacklistUpdateOne {
|
||||
mutation := newBlacklistMutation(c.config, OpUpdateOne, withBlacklist(b))
|
||||
return &BlacklistUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *BlacklistClient) UpdateOneID(id int) *BlacklistUpdateOne {
|
||||
mutation := newBlacklistMutation(c.config, OpUpdateOne, withBlacklistID(id))
|
||||
return &BlacklistUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for Blacklist.
|
||||
func (c *BlacklistClient) Delete() *BlacklistDelete {
|
||||
mutation := newBlacklistMutation(c.config, OpDelete)
|
||||
return &BlacklistDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *BlacklistClient) DeleteOne(b *Blacklist) *BlacklistDeleteOne {
|
||||
return c.DeleteOneID(b.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *BlacklistClient) DeleteOneID(id int) *BlacklistDeleteOne {
|
||||
builder := c.Delete().Where(blacklist.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &BlacklistDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for Blacklist.
|
||||
func (c *BlacklistClient) Query() *BlacklistQuery {
|
||||
return &BlacklistQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeBlacklist},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a Blacklist entity by its id.
|
||||
func (c *BlacklistClient) Get(ctx context.Context, id int) (*Blacklist, error) {
|
||||
return c.Query().Where(blacklist.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *BlacklistClient) GetX(ctx context.Context, id int) *Blacklist {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *BlacklistClient) Hooks() []Hook {
|
||||
return c.hooks.Blacklist
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *BlacklistClient) Interceptors() []Interceptor {
|
||||
return c.inters.Blacklist
|
||||
}
|
||||
|
||||
func (c *BlacklistClient) mutate(ctx context.Context, m *BlacklistMutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&BlacklistCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&BlacklistUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&BlacklistUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&BlacklistDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown Blacklist mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// DownloadClientsClient is a client for the DownloadClients schema.
|
||||
type DownloadClientsClient struct {
|
||||
config
|
||||
@@ -671,6 +828,139 @@ func (c *HistoryClient) mutate(ctx context.Context, m *HistoryMutation) (Value,
|
||||
}
|
||||
}
|
||||
|
||||
// ImportListClient is a client for the ImportList schema.
|
||||
type ImportListClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewImportListClient returns a client for the ImportList from the given config.
|
||||
func NewImportListClient(c config) *ImportListClient {
|
||||
return &ImportListClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `importlist.Hooks(f(g(h())))`.
|
||||
func (c *ImportListClient) Use(hooks ...Hook) {
|
||||
c.hooks.ImportList = append(c.hooks.ImportList, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `importlist.Intercept(f(g(h())))`.
|
||||
func (c *ImportListClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.ImportList = append(c.inters.ImportList, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a ImportList entity.
|
||||
func (c *ImportListClient) Create() *ImportListCreate {
|
||||
mutation := newImportListMutation(c.config, OpCreate)
|
||||
return &ImportListCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of ImportList entities.
|
||||
func (c *ImportListClient) CreateBulk(builders ...*ImportListCreate) *ImportListCreateBulk {
|
||||
return &ImportListCreateBulk{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 *ImportListClient) MapCreateBulk(slice any, setFunc func(*ImportListCreate, int)) *ImportListCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &ImportListCreateBulk{err: fmt.Errorf("calling to ImportListClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*ImportListCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &ImportListCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for ImportList.
|
||||
func (c *ImportListClient) Update() *ImportListUpdate {
|
||||
mutation := newImportListMutation(c.config, OpUpdate)
|
||||
return &ImportListUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *ImportListClient) UpdateOne(il *ImportList) *ImportListUpdateOne {
|
||||
mutation := newImportListMutation(c.config, OpUpdateOne, withImportList(il))
|
||||
return &ImportListUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *ImportListClient) UpdateOneID(id int) *ImportListUpdateOne {
|
||||
mutation := newImportListMutation(c.config, OpUpdateOne, withImportListID(id))
|
||||
return &ImportListUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for ImportList.
|
||||
func (c *ImportListClient) Delete() *ImportListDelete {
|
||||
mutation := newImportListMutation(c.config, OpDelete)
|
||||
return &ImportListDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *ImportListClient) DeleteOne(il *ImportList) *ImportListDeleteOne {
|
||||
return c.DeleteOneID(il.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *ImportListClient) DeleteOneID(id int) *ImportListDeleteOne {
|
||||
builder := c.Delete().Where(importlist.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &ImportListDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for ImportList.
|
||||
func (c *ImportListClient) Query() *ImportListQuery {
|
||||
return &ImportListQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeImportList},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a ImportList entity by its id.
|
||||
func (c *ImportListClient) Get(ctx context.Context, id int) (*ImportList, error) {
|
||||
return c.Query().Where(importlist.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *ImportListClient) GetX(ctx context.Context, id int) *ImportList {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *ImportListClient) Hooks() []Hook {
|
||||
return c.hooks.ImportList
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *ImportListClient) Interceptors() []Interceptor {
|
||||
return c.inters.ImportList
|
||||
}
|
||||
|
||||
func (c *ImportListClient) mutate(ctx context.Context, m *ImportListMutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&ImportListCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&ImportListUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&ImportListUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&ImportListDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown ImportList mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// IndexersClient is a client for the Indexers schema.
|
||||
type IndexersClient struct {
|
||||
config
|
||||
@@ -953,6 +1243,139 @@ func (c *MediaClient) mutate(ctx context.Context, m *MediaMutation) (Value, erro
|
||||
}
|
||||
}
|
||||
|
||||
// NotificationClientClient is a client for the NotificationClient schema.
|
||||
type NotificationClientClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewNotificationClientClient returns a client for the NotificationClient from the given config.
|
||||
func NewNotificationClientClient(c config) *NotificationClientClient {
|
||||
return &NotificationClientClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `notificationclient.Hooks(f(g(h())))`.
|
||||
func (c *NotificationClientClient) Use(hooks ...Hook) {
|
||||
c.hooks.NotificationClient = append(c.hooks.NotificationClient, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `notificationclient.Intercept(f(g(h())))`.
|
||||
func (c *NotificationClientClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.NotificationClient = append(c.inters.NotificationClient, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a NotificationClient entity.
|
||||
func (c *NotificationClientClient) Create() *NotificationClientCreate {
|
||||
mutation := newNotificationClientMutation(c.config, OpCreate)
|
||||
return &NotificationClientCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of NotificationClient entities.
|
||||
func (c *NotificationClientClient) CreateBulk(builders ...*NotificationClientCreate) *NotificationClientCreateBulk {
|
||||
return &NotificationClientCreateBulk{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 *NotificationClientClient) MapCreateBulk(slice any, setFunc func(*NotificationClientCreate, int)) *NotificationClientCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &NotificationClientCreateBulk{err: fmt.Errorf("calling to NotificationClientClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*NotificationClientCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &NotificationClientCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for NotificationClient.
|
||||
func (c *NotificationClientClient) Update() *NotificationClientUpdate {
|
||||
mutation := newNotificationClientMutation(c.config, OpUpdate)
|
||||
return &NotificationClientUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *NotificationClientClient) UpdateOne(nc *NotificationClient) *NotificationClientUpdateOne {
|
||||
mutation := newNotificationClientMutation(c.config, OpUpdateOne, withNotificationClient(nc))
|
||||
return &NotificationClientUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *NotificationClientClient) UpdateOneID(id int) *NotificationClientUpdateOne {
|
||||
mutation := newNotificationClientMutation(c.config, OpUpdateOne, withNotificationClientID(id))
|
||||
return &NotificationClientUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for NotificationClient.
|
||||
func (c *NotificationClientClient) Delete() *NotificationClientDelete {
|
||||
mutation := newNotificationClientMutation(c.config, OpDelete)
|
||||
return &NotificationClientDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *NotificationClientClient) DeleteOne(nc *NotificationClient) *NotificationClientDeleteOne {
|
||||
return c.DeleteOneID(nc.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *NotificationClientClient) DeleteOneID(id int) *NotificationClientDeleteOne {
|
||||
builder := c.Delete().Where(notificationclient.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &NotificationClientDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for NotificationClient.
|
||||
func (c *NotificationClientClient) Query() *NotificationClientQuery {
|
||||
return &NotificationClientQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeNotificationClient},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a NotificationClient entity by its id.
|
||||
func (c *NotificationClientClient) Get(ctx context.Context, id int) (*NotificationClient, error) {
|
||||
return c.Query().Where(notificationclient.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *NotificationClientClient) GetX(ctx context.Context, id int) *NotificationClient {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *NotificationClientClient) Hooks() []Hook {
|
||||
return c.hooks.NotificationClient
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *NotificationClientClient) Interceptors() []Interceptor {
|
||||
return c.inters.NotificationClient
|
||||
}
|
||||
|
||||
func (c *NotificationClientClient) mutate(ctx context.Context, m *NotificationClientMutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&NotificationClientCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&NotificationClientUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&NotificationClientUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&NotificationClientDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown NotificationClient mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// SettingsClient is a client for the Settings schema.
|
||||
type SettingsClient struct {
|
||||
config
|
||||
@@ -1222,10 +1645,11 @@ func (c *StorageClient) mutate(ctx context.Context, m *StorageMutation) (Value,
|
||||
// hooks and interceptors per client, for fast access.
|
||||
type (
|
||||
hooks struct {
|
||||
DownloadClients, Episode, History, Indexers, Media, Settings, Storage []ent.Hook
|
||||
Blacklist, DownloadClients, Episode, History, ImportList, Indexers, Media,
|
||||
NotificationClient, Settings, Storage []ent.Hook
|
||||
}
|
||||
inters struct {
|
||||
DownloadClients, Episode, History, Indexers, Media, Settings,
|
||||
Storage []ent.Interceptor
|
||||
Blacklist, DownloadClients, Episode, History, ImportList, Indexers, Media,
|
||||
NotificationClient, Settings, Storage []ent.Interceptor
|
||||
}
|
||||
)
|
||||
|
||||
@@ -21,7 +21,7 @@ type DownloadClients struct {
|
||||
// Name holds the value of the "name" field.
|
||||
Name string `json:"name,omitempty"`
|
||||
// Implementation holds the value of the "implementation" field.
|
||||
Implementation string `json:"implementation,omitempty"`
|
||||
Implementation downloadclients.Implementation `json:"implementation,omitempty"`
|
||||
// URL holds the value of the "url" field.
|
||||
URL string `json:"url,omitempty"`
|
||||
// User holds the value of the "user" field.
|
||||
@@ -30,8 +30,8 @@ type DownloadClients struct {
|
||||
Password string `json:"password,omitempty"`
|
||||
// Settings holds the value of the "settings" field.
|
||||
Settings string `json:"settings,omitempty"`
|
||||
// Priority holds the value of the "priority" field.
|
||||
Priority string `json:"priority,omitempty"`
|
||||
// Priority1 holds the value of the "priority1" field.
|
||||
Priority1 int `json:"priority1,omitempty"`
|
||||
// RemoveCompletedDownloads holds the value of the "remove_completed_downloads" field.
|
||||
RemoveCompletedDownloads bool `json:"remove_completed_downloads,omitempty"`
|
||||
// RemoveFailedDownloads holds the value of the "remove_failed_downloads" field.
|
||||
@@ -48,9 +48,9 @@ func (*DownloadClients) scanValues(columns []string) ([]any, error) {
|
||||
switch columns[i] {
|
||||
case downloadclients.FieldEnable, downloadclients.FieldRemoveCompletedDownloads, downloadclients.FieldRemoveFailedDownloads:
|
||||
values[i] = new(sql.NullBool)
|
||||
case downloadclients.FieldID:
|
||||
case downloadclients.FieldID, downloadclients.FieldPriority1:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case downloadclients.FieldName, downloadclients.FieldImplementation, downloadclients.FieldURL, downloadclients.FieldUser, downloadclients.FieldPassword, downloadclients.FieldSettings, downloadclients.FieldPriority, downloadclients.FieldTags:
|
||||
case downloadclients.FieldName, downloadclients.FieldImplementation, downloadclients.FieldURL, downloadclients.FieldUser, downloadclients.FieldPassword, downloadclients.FieldSettings, downloadclients.FieldTags:
|
||||
values[i] = new(sql.NullString)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
@@ -89,7 +89,7 @@ func (dc *DownloadClients) assignValues(columns []string, values []any) error {
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field implementation", values[i])
|
||||
} else if value.Valid {
|
||||
dc.Implementation = value.String
|
||||
dc.Implementation = downloadclients.Implementation(value.String)
|
||||
}
|
||||
case downloadclients.FieldURL:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
@@ -115,11 +115,11 @@ func (dc *DownloadClients) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
dc.Settings = value.String
|
||||
}
|
||||
case downloadclients.FieldPriority:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field priority", values[i])
|
||||
case downloadclients.FieldPriority1:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field priority1", values[i])
|
||||
} else if value.Valid {
|
||||
dc.Priority = value.String
|
||||
dc.Priority1 = int(value.Int64)
|
||||
}
|
||||
case downloadclients.FieldRemoveCompletedDownloads:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
@@ -182,7 +182,7 @@ func (dc *DownloadClients) String() string {
|
||||
builder.WriteString(dc.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("implementation=")
|
||||
builder.WriteString(dc.Implementation)
|
||||
builder.WriteString(fmt.Sprintf("%v", dc.Implementation))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("url=")
|
||||
builder.WriteString(dc.URL)
|
||||
@@ -196,8 +196,8 @@ func (dc *DownloadClients) String() string {
|
||||
builder.WriteString("settings=")
|
||||
builder.WriteString(dc.Settings)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("priority=")
|
||||
builder.WriteString(dc.Priority)
|
||||
builder.WriteString("priority1=")
|
||||
builder.WriteString(fmt.Sprintf("%v", dc.Priority1))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("remove_completed_downloads=")
|
||||
builder.WriteString(fmt.Sprintf("%v", dc.RemoveCompletedDownloads))
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
package downloadclients
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
@@ -25,8 +27,8 @@ const (
|
||||
FieldPassword = "password"
|
||||
// FieldSettings holds the string denoting the settings field in the database.
|
||||
FieldSettings = "settings"
|
||||
// FieldPriority holds the string denoting the priority field in the database.
|
||||
FieldPriority = "priority"
|
||||
// FieldPriority1 holds the string denoting the priority1 field in the database.
|
||||
FieldPriority1 = "priority1"
|
||||
// FieldRemoveCompletedDownloads holds the string denoting the remove_completed_downloads field in the database.
|
||||
FieldRemoveCompletedDownloads = "remove_completed_downloads"
|
||||
// FieldRemoveFailedDownloads holds the string denoting the remove_failed_downloads field in the database.
|
||||
@@ -47,7 +49,7 @@ var Columns = []string{
|
||||
FieldUser,
|
||||
FieldPassword,
|
||||
FieldSettings,
|
||||
FieldPriority,
|
||||
FieldPriority1,
|
||||
FieldRemoveCompletedDownloads,
|
||||
FieldRemoveFailedDownloads,
|
||||
FieldTags,
|
||||
@@ -70,8 +72,10 @@ var (
|
||||
DefaultPassword string
|
||||
// DefaultSettings holds the default value on creation for the "settings" field.
|
||||
DefaultSettings string
|
||||
// DefaultPriority holds the default value on creation for the "priority" field.
|
||||
DefaultPriority string
|
||||
// DefaultPriority1 holds the default value on creation for the "priority1" field.
|
||||
DefaultPriority1 int
|
||||
// Priority1Validator is a validator for the "priority1" field. It is called by the builders before save.
|
||||
Priority1Validator func(int) error
|
||||
// DefaultRemoveCompletedDownloads holds the default value on creation for the "remove_completed_downloads" field.
|
||||
DefaultRemoveCompletedDownloads bool
|
||||
// DefaultRemoveFailedDownloads holds the default value on creation for the "remove_failed_downloads" field.
|
||||
@@ -80,6 +84,29 @@ var (
|
||||
DefaultTags string
|
||||
)
|
||||
|
||||
// Implementation defines the type for the "implementation" enum field.
|
||||
type Implementation string
|
||||
|
||||
// Implementation values.
|
||||
const (
|
||||
ImplementationTransmission Implementation = "transmission"
|
||||
ImplementationQbittorrent Implementation = "qbittorrent"
|
||||
)
|
||||
|
||||
func (i Implementation) String() string {
|
||||
return string(i)
|
||||
}
|
||||
|
||||
// ImplementationValidator is a validator for the "implementation" field enum values. It is called by the builders before save.
|
||||
func ImplementationValidator(i Implementation) error {
|
||||
switch i {
|
||||
case ImplementationTransmission, ImplementationQbittorrent:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("downloadclients: invalid enum value for implementation field: %q", i)
|
||||
}
|
||||
}
|
||||
|
||||
// OrderOption defines the ordering options for the DownloadClients queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
@@ -123,9 +150,9 @@ func BySettings(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSettings, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPriority orders the results by the priority field.
|
||||
func ByPriority(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPriority, opts...).ToFunc()
|
||||
// ByPriority1 orders the results by the priority1 field.
|
||||
func ByPriority1(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPriority1, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByRemoveCompletedDownloads orders the results by the remove_completed_downloads field.
|
||||
|
||||
@@ -63,11 +63,6 @@ func Name(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// Implementation applies equality check predicate on the "implementation" field. It's identical to ImplementationEQ.
|
||||
func Implementation(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// URL applies equality check predicate on the "url" field. It's identical to URLEQ.
|
||||
func URL(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldURL, v))
|
||||
@@ -88,9 +83,9 @@ func Settings(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldSettings, v))
|
||||
}
|
||||
|
||||
// Priority applies equality check predicate on the "priority" field. It's identical to PriorityEQ.
|
||||
func Priority(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldPriority, v))
|
||||
// Priority1 applies equality check predicate on the "priority1" field. It's identical to Priority1EQ.
|
||||
func Priority1(v int) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldPriority1, v))
|
||||
}
|
||||
|
||||
// RemoveCompletedDownloads applies equality check predicate on the "remove_completed_downloads" field. It's identical to RemoveCompletedDownloadsEQ.
|
||||
@@ -184,70 +179,25 @@ func NameContainsFold(v string) predicate.DownloadClients {
|
||||
}
|
||||
|
||||
// ImplementationEQ applies the EQ predicate on the "implementation" field.
|
||||
func ImplementationEQ(v string) predicate.DownloadClients {
|
||||
func ImplementationEQ(v Implementation) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationNEQ applies the NEQ predicate on the "implementation" field.
|
||||
func ImplementationNEQ(v string) predicate.DownloadClients {
|
||||
func ImplementationNEQ(v Implementation) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNEQ(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationIn applies the In predicate on the "implementation" field.
|
||||
func ImplementationIn(vs ...string) predicate.DownloadClients {
|
||||
func ImplementationIn(vs ...Implementation) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldIn(FieldImplementation, vs...))
|
||||
}
|
||||
|
||||
// ImplementationNotIn applies the NotIn predicate on the "implementation" field.
|
||||
func ImplementationNotIn(vs ...string) predicate.DownloadClients {
|
||||
func ImplementationNotIn(vs ...Implementation) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNotIn(FieldImplementation, vs...))
|
||||
}
|
||||
|
||||
// ImplementationGT applies the GT predicate on the "implementation" field.
|
||||
func ImplementationGT(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldGT(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationGTE applies the GTE predicate on the "implementation" field.
|
||||
func ImplementationGTE(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldGTE(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationLT applies the LT predicate on the "implementation" field.
|
||||
func ImplementationLT(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldLT(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationLTE applies the LTE predicate on the "implementation" field.
|
||||
func ImplementationLTE(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldLTE(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationContains applies the Contains predicate on the "implementation" field.
|
||||
func ImplementationContains(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldContains(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationHasPrefix applies the HasPrefix predicate on the "implementation" field.
|
||||
func ImplementationHasPrefix(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldHasPrefix(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationHasSuffix applies the HasSuffix predicate on the "implementation" field.
|
||||
func ImplementationHasSuffix(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldHasSuffix(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationEqualFold applies the EqualFold predicate on the "implementation" field.
|
||||
func ImplementationEqualFold(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEqualFold(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationContainsFold applies the ContainsFold predicate on the "implementation" field.
|
||||
func ImplementationContainsFold(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldContainsFold(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// URLEQ applies the EQ predicate on the "url" field.
|
||||
func URLEQ(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldURL, v))
|
||||
@@ -508,69 +458,44 @@ func SettingsContainsFold(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldContainsFold(FieldSettings, v))
|
||||
}
|
||||
|
||||
// PriorityEQ applies the EQ predicate on the "priority" field.
|
||||
func PriorityEQ(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldPriority, v))
|
||||
// Priority1EQ applies the EQ predicate on the "priority1" field.
|
||||
func Priority1EQ(v int) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldPriority1, v))
|
||||
}
|
||||
|
||||
// PriorityNEQ applies the NEQ predicate on the "priority" field.
|
||||
func PriorityNEQ(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNEQ(FieldPriority, v))
|
||||
// Priority1NEQ applies the NEQ predicate on the "priority1" field.
|
||||
func Priority1NEQ(v int) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNEQ(FieldPriority1, v))
|
||||
}
|
||||
|
||||
// PriorityIn applies the In predicate on the "priority" field.
|
||||
func PriorityIn(vs ...string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldIn(FieldPriority, vs...))
|
||||
// Priority1In applies the In predicate on the "priority1" field.
|
||||
func Priority1In(vs ...int) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldIn(FieldPriority1, vs...))
|
||||
}
|
||||
|
||||
// PriorityNotIn applies the NotIn predicate on the "priority" field.
|
||||
func PriorityNotIn(vs ...string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNotIn(FieldPriority, vs...))
|
||||
// Priority1NotIn applies the NotIn predicate on the "priority1" field.
|
||||
func Priority1NotIn(vs ...int) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNotIn(FieldPriority1, vs...))
|
||||
}
|
||||
|
||||
// PriorityGT applies the GT predicate on the "priority" field.
|
||||
func PriorityGT(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldGT(FieldPriority, v))
|
||||
// Priority1GT applies the GT predicate on the "priority1" field.
|
||||
func Priority1GT(v int) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldGT(FieldPriority1, v))
|
||||
}
|
||||
|
||||
// PriorityGTE applies the GTE predicate on the "priority" field.
|
||||
func PriorityGTE(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldGTE(FieldPriority, v))
|
||||
// Priority1GTE applies the GTE predicate on the "priority1" field.
|
||||
func Priority1GTE(v int) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldGTE(FieldPriority1, v))
|
||||
}
|
||||
|
||||
// PriorityLT applies the LT predicate on the "priority" field.
|
||||
func PriorityLT(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldLT(FieldPriority, v))
|
||||
// Priority1LT applies the LT predicate on the "priority1" field.
|
||||
func Priority1LT(v int) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldLT(FieldPriority1, v))
|
||||
}
|
||||
|
||||
// PriorityLTE applies the LTE predicate on the "priority" field.
|
||||
func PriorityLTE(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldLTE(FieldPriority, v))
|
||||
}
|
||||
|
||||
// PriorityContains applies the Contains predicate on the "priority" field.
|
||||
func PriorityContains(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldContains(FieldPriority, v))
|
||||
}
|
||||
|
||||
// PriorityHasPrefix applies the HasPrefix predicate on the "priority" field.
|
||||
func PriorityHasPrefix(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldHasPrefix(FieldPriority, v))
|
||||
}
|
||||
|
||||
// PriorityHasSuffix applies the HasSuffix predicate on the "priority" field.
|
||||
func PriorityHasSuffix(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldHasSuffix(FieldPriority, v))
|
||||
}
|
||||
|
||||
// PriorityEqualFold applies the EqualFold predicate on the "priority" field.
|
||||
func PriorityEqualFold(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEqualFold(FieldPriority, v))
|
||||
}
|
||||
|
||||
// PriorityContainsFold applies the ContainsFold predicate on the "priority" field.
|
||||
func PriorityContainsFold(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldContainsFold(FieldPriority, v))
|
||||
// Priority1LTE applies the LTE predicate on the "priority1" field.
|
||||
func Priority1LTE(v int) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldLTE(FieldPriority1, v))
|
||||
}
|
||||
|
||||
// RemoveCompletedDownloadsEQ applies the EQ predicate on the "remove_completed_downloads" field.
|
||||
|
||||
@@ -32,8 +32,8 @@ func (dcc *DownloadClientsCreate) SetName(s string) *DownloadClientsCreate {
|
||||
}
|
||||
|
||||
// SetImplementation sets the "implementation" field.
|
||||
func (dcc *DownloadClientsCreate) SetImplementation(s string) *DownloadClientsCreate {
|
||||
dcc.mutation.SetImplementation(s)
|
||||
func (dcc *DownloadClientsCreate) SetImplementation(d downloadclients.Implementation) *DownloadClientsCreate {
|
||||
dcc.mutation.SetImplementation(d)
|
||||
return dcc
|
||||
}
|
||||
|
||||
@@ -85,16 +85,16 @@ func (dcc *DownloadClientsCreate) SetNillableSettings(s *string) *DownloadClient
|
||||
return dcc
|
||||
}
|
||||
|
||||
// SetPriority sets the "priority" field.
|
||||
func (dcc *DownloadClientsCreate) SetPriority(s string) *DownloadClientsCreate {
|
||||
dcc.mutation.SetPriority(s)
|
||||
// SetPriority1 sets the "priority1" field.
|
||||
func (dcc *DownloadClientsCreate) SetPriority1(i int) *DownloadClientsCreate {
|
||||
dcc.mutation.SetPriority1(i)
|
||||
return dcc
|
||||
}
|
||||
|
||||
// SetNillablePriority sets the "priority" field if the given value is not nil.
|
||||
func (dcc *DownloadClientsCreate) SetNillablePriority(s *string) *DownloadClientsCreate {
|
||||
if s != nil {
|
||||
dcc.SetPriority(*s)
|
||||
// SetNillablePriority1 sets the "priority1" field if the given value is not nil.
|
||||
func (dcc *DownloadClientsCreate) SetNillablePriority1(i *int) *DownloadClientsCreate {
|
||||
if i != nil {
|
||||
dcc.SetPriority1(*i)
|
||||
}
|
||||
return dcc
|
||||
}
|
||||
@@ -188,9 +188,9 @@ func (dcc *DownloadClientsCreate) defaults() {
|
||||
v := downloadclients.DefaultSettings
|
||||
dcc.mutation.SetSettings(v)
|
||||
}
|
||||
if _, ok := dcc.mutation.Priority(); !ok {
|
||||
v := downloadclients.DefaultPriority
|
||||
dcc.mutation.SetPriority(v)
|
||||
if _, ok := dcc.mutation.Priority1(); !ok {
|
||||
v := downloadclients.DefaultPriority1
|
||||
dcc.mutation.SetPriority1(v)
|
||||
}
|
||||
if _, ok := dcc.mutation.RemoveCompletedDownloads(); !ok {
|
||||
v := downloadclients.DefaultRemoveCompletedDownloads
|
||||
@@ -217,6 +217,11 @@ func (dcc *DownloadClientsCreate) check() error {
|
||||
if _, ok := dcc.mutation.Implementation(); !ok {
|
||||
return &ValidationError{Name: "implementation", err: errors.New(`ent: missing required field "DownloadClients.implementation"`)}
|
||||
}
|
||||
if v, ok := dcc.mutation.Implementation(); ok {
|
||||
if err := downloadclients.ImplementationValidator(v); err != nil {
|
||||
return &ValidationError{Name: "implementation", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.implementation": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := dcc.mutation.URL(); !ok {
|
||||
return &ValidationError{Name: "url", err: errors.New(`ent: missing required field "DownloadClients.url"`)}
|
||||
}
|
||||
@@ -229,8 +234,13 @@ func (dcc *DownloadClientsCreate) check() error {
|
||||
if _, ok := dcc.mutation.Settings(); !ok {
|
||||
return &ValidationError{Name: "settings", err: errors.New(`ent: missing required field "DownloadClients.settings"`)}
|
||||
}
|
||||
if _, ok := dcc.mutation.Priority(); !ok {
|
||||
return &ValidationError{Name: "priority", err: errors.New(`ent: missing required field "DownloadClients.priority"`)}
|
||||
if _, ok := dcc.mutation.Priority1(); !ok {
|
||||
return &ValidationError{Name: "priority1", err: errors.New(`ent: missing required field "DownloadClients.priority1"`)}
|
||||
}
|
||||
if v, ok := dcc.mutation.Priority1(); ok {
|
||||
if err := downloadclients.Priority1Validator(v); err != nil {
|
||||
return &ValidationError{Name: "priority1", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.priority1": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := dcc.mutation.RemoveCompletedDownloads(); !ok {
|
||||
return &ValidationError{Name: "remove_completed_downloads", err: errors.New(`ent: missing required field "DownloadClients.remove_completed_downloads"`)}
|
||||
@@ -276,7 +286,7 @@ func (dcc *DownloadClientsCreate) createSpec() (*DownloadClients, *sqlgraph.Crea
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := dcc.mutation.Implementation(); ok {
|
||||
_spec.SetField(downloadclients.FieldImplementation, field.TypeString, value)
|
||||
_spec.SetField(downloadclients.FieldImplementation, field.TypeEnum, value)
|
||||
_node.Implementation = value
|
||||
}
|
||||
if value, ok := dcc.mutation.URL(); ok {
|
||||
@@ -295,9 +305,9 @@ func (dcc *DownloadClientsCreate) createSpec() (*DownloadClients, *sqlgraph.Crea
|
||||
_spec.SetField(downloadclients.FieldSettings, field.TypeString, value)
|
||||
_node.Settings = value
|
||||
}
|
||||
if value, ok := dcc.mutation.Priority(); ok {
|
||||
_spec.SetField(downloadclients.FieldPriority, field.TypeString, value)
|
||||
_node.Priority = value
|
||||
if value, ok := dcc.mutation.Priority1(); ok {
|
||||
_spec.SetField(downloadclients.FieldPriority1, field.TypeInt, value)
|
||||
_node.Priority1 = value
|
||||
}
|
||||
if value, ok := dcc.mutation.RemoveCompletedDownloads(); ok {
|
||||
_spec.SetField(downloadclients.FieldRemoveCompletedDownloads, field.TypeBool, value)
|
||||
|
||||
@@ -56,15 +56,15 @@ func (dcu *DownloadClientsUpdate) SetNillableName(s *string) *DownloadClientsUpd
|
||||
}
|
||||
|
||||
// SetImplementation sets the "implementation" field.
|
||||
func (dcu *DownloadClientsUpdate) SetImplementation(s string) *DownloadClientsUpdate {
|
||||
dcu.mutation.SetImplementation(s)
|
||||
func (dcu *DownloadClientsUpdate) SetImplementation(d downloadclients.Implementation) *DownloadClientsUpdate {
|
||||
dcu.mutation.SetImplementation(d)
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetNillableImplementation sets the "implementation" field if the given value is not nil.
|
||||
func (dcu *DownloadClientsUpdate) SetNillableImplementation(s *string) *DownloadClientsUpdate {
|
||||
if s != nil {
|
||||
dcu.SetImplementation(*s)
|
||||
func (dcu *DownloadClientsUpdate) SetNillableImplementation(d *downloadclients.Implementation) *DownloadClientsUpdate {
|
||||
if d != nil {
|
||||
dcu.SetImplementation(*d)
|
||||
}
|
||||
return dcu
|
||||
}
|
||||
@@ -125,20 +125,27 @@ func (dcu *DownloadClientsUpdate) SetNillableSettings(s *string) *DownloadClient
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetPriority sets the "priority" field.
|
||||
func (dcu *DownloadClientsUpdate) SetPriority(s string) *DownloadClientsUpdate {
|
||||
dcu.mutation.SetPriority(s)
|
||||
// SetPriority1 sets the "priority1" field.
|
||||
func (dcu *DownloadClientsUpdate) SetPriority1(i int) *DownloadClientsUpdate {
|
||||
dcu.mutation.ResetPriority1()
|
||||
dcu.mutation.SetPriority1(i)
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetNillablePriority sets the "priority" field if the given value is not nil.
|
||||
func (dcu *DownloadClientsUpdate) SetNillablePriority(s *string) *DownloadClientsUpdate {
|
||||
if s != nil {
|
||||
dcu.SetPriority(*s)
|
||||
// SetNillablePriority1 sets the "priority1" field if the given value is not nil.
|
||||
func (dcu *DownloadClientsUpdate) SetNillablePriority1(i *int) *DownloadClientsUpdate {
|
||||
if i != nil {
|
||||
dcu.SetPriority1(*i)
|
||||
}
|
||||
return dcu
|
||||
}
|
||||
|
||||
// AddPriority1 adds i to the "priority1" field.
|
||||
func (dcu *DownloadClientsUpdate) AddPriority1(i int) *DownloadClientsUpdate {
|
||||
dcu.mutation.AddPriority1(i)
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetRemoveCompletedDownloads sets the "remove_completed_downloads" field.
|
||||
func (dcu *DownloadClientsUpdate) SetRemoveCompletedDownloads(b bool) *DownloadClientsUpdate {
|
||||
dcu.mutation.SetRemoveCompletedDownloads(b)
|
||||
@@ -213,7 +220,25 @@ func (dcu *DownloadClientsUpdate) ExecX(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (dcu *DownloadClientsUpdate) check() error {
|
||||
if v, ok := dcu.mutation.Implementation(); ok {
|
||||
if err := downloadclients.ImplementationValidator(v); err != nil {
|
||||
return &ValidationError{Name: "implementation", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.implementation": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := dcu.mutation.Priority1(); ok {
|
||||
if err := downloadclients.Priority1Validator(v); err != nil {
|
||||
return &ValidationError{Name: "priority1", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.priority1": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dcu *DownloadClientsUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if err := dcu.check(); err != nil {
|
||||
return n, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(downloadclients.Table, downloadclients.Columns, sqlgraph.NewFieldSpec(downloadclients.FieldID, field.TypeInt))
|
||||
if ps := dcu.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
@@ -229,7 +254,7 @@ func (dcu *DownloadClientsUpdate) sqlSave(ctx context.Context) (n int, err error
|
||||
_spec.SetField(downloadclients.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := dcu.mutation.Implementation(); ok {
|
||||
_spec.SetField(downloadclients.FieldImplementation, field.TypeString, value)
|
||||
_spec.SetField(downloadclients.FieldImplementation, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := dcu.mutation.URL(); ok {
|
||||
_spec.SetField(downloadclients.FieldURL, field.TypeString, value)
|
||||
@@ -243,8 +268,11 @@ func (dcu *DownloadClientsUpdate) sqlSave(ctx context.Context) (n int, err error
|
||||
if value, ok := dcu.mutation.Settings(); ok {
|
||||
_spec.SetField(downloadclients.FieldSettings, field.TypeString, value)
|
||||
}
|
||||
if value, ok := dcu.mutation.Priority(); ok {
|
||||
_spec.SetField(downloadclients.FieldPriority, field.TypeString, value)
|
||||
if value, ok := dcu.mutation.Priority1(); ok {
|
||||
_spec.SetField(downloadclients.FieldPriority1, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := dcu.mutation.AddedPriority1(); ok {
|
||||
_spec.AddField(downloadclients.FieldPriority1, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := dcu.mutation.RemoveCompletedDownloads(); ok {
|
||||
_spec.SetField(downloadclients.FieldRemoveCompletedDownloads, field.TypeBool, value)
|
||||
@@ -304,15 +332,15 @@ func (dcuo *DownloadClientsUpdateOne) SetNillableName(s *string) *DownloadClient
|
||||
}
|
||||
|
||||
// SetImplementation sets the "implementation" field.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetImplementation(s string) *DownloadClientsUpdateOne {
|
||||
dcuo.mutation.SetImplementation(s)
|
||||
func (dcuo *DownloadClientsUpdateOne) SetImplementation(d downloadclients.Implementation) *DownloadClientsUpdateOne {
|
||||
dcuo.mutation.SetImplementation(d)
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetNillableImplementation sets the "implementation" field if the given value is not nil.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetNillableImplementation(s *string) *DownloadClientsUpdateOne {
|
||||
if s != nil {
|
||||
dcuo.SetImplementation(*s)
|
||||
func (dcuo *DownloadClientsUpdateOne) SetNillableImplementation(d *downloadclients.Implementation) *DownloadClientsUpdateOne {
|
||||
if d != nil {
|
||||
dcuo.SetImplementation(*d)
|
||||
}
|
||||
return dcuo
|
||||
}
|
||||
@@ -373,20 +401,27 @@ func (dcuo *DownloadClientsUpdateOne) SetNillableSettings(s *string) *DownloadCl
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetPriority sets the "priority" field.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetPriority(s string) *DownloadClientsUpdateOne {
|
||||
dcuo.mutation.SetPriority(s)
|
||||
// SetPriority1 sets the "priority1" field.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetPriority1(i int) *DownloadClientsUpdateOne {
|
||||
dcuo.mutation.ResetPriority1()
|
||||
dcuo.mutation.SetPriority1(i)
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetNillablePriority sets the "priority" field if the given value is not nil.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetNillablePriority(s *string) *DownloadClientsUpdateOne {
|
||||
if s != nil {
|
||||
dcuo.SetPriority(*s)
|
||||
// SetNillablePriority1 sets the "priority1" field if the given value is not nil.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetNillablePriority1(i *int) *DownloadClientsUpdateOne {
|
||||
if i != nil {
|
||||
dcuo.SetPriority1(*i)
|
||||
}
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// AddPriority1 adds i to the "priority1" field.
|
||||
func (dcuo *DownloadClientsUpdateOne) AddPriority1(i int) *DownloadClientsUpdateOne {
|
||||
dcuo.mutation.AddPriority1(i)
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetRemoveCompletedDownloads sets the "remove_completed_downloads" field.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetRemoveCompletedDownloads(b bool) *DownloadClientsUpdateOne {
|
||||
dcuo.mutation.SetRemoveCompletedDownloads(b)
|
||||
@@ -474,7 +509,25 @@ func (dcuo *DownloadClientsUpdateOne) ExecX(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (dcuo *DownloadClientsUpdateOne) check() error {
|
||||
if v, ok := dcuo.mutation.Implementation(); ok {
|
||||
if err := downloadclients.ImplementationValidator(v); err != nil {
|
||||
return &ValidationError{Name: "implementation", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.implementation": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := dcuo.mutation.Priority1(); ok {
|
||||
if err := downloadclients.Priority1Validator(v); err != nil {
|
||||
return &ValidationError{Name: "priority1", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.priority1": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dcuo *DownloadClientsUpdateOne) sqlSave(ctx context.Context) (_node *DownloadClients, err error) {
|
||||
if err := dcuo.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(downloadclients.Table, downloadclients.Columns, sqlgraph.NewFieldSpec(downloadclients.FieldID, field.TypeInt))
|
||||
id, ok := dcuo.mutation.ID()
|
||||
if !ok {
|
||||
@@ -507,7 +560,7 @@ func (dcuo *DownloadClientsUpdateOne) sqlSave(ctx context.Context) (_node *Downl
|
||||
_spec.SetField(downloadclients.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := dcuo.mutation.Implementation(); ok {
|
||||
_spec.SetField(downloadclients.FieldImplementation, field.TypeString, value)
|
||||
_spec.SetField(downloadclients.FieldImplementation, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := dcuo.mutation.URL(); ok {
|
||||
_spec.SetField(downloadclients.FieldURL, field.TypeString, value)
|
||||
@@ -521,8 +574,11 @@ func (dcuo *DownloadClientsUpdateOne) sqlSave(ctx context.Context) (_node *Downl
|
||||
if value, ok := dcuo.mutation.Settings(); ok {
|
||||
_spec.SetField(downloadclients.FieldSettings, field.TypeString, value)
|
||||
}
|
||||
if value, ok := dcuo.mutation.Priority(); ok {
|
||||
_spec.SetField(downloadclients.FieldPriority, field.TypeString, value)
|
||||
if value, ok := dcuo.mutation.Priority1(); ok {
|
||||
_spec.SetField(downloadclients.FieldPriority1, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := dcuo.mutation.AddedPriority1(); ok {
|
||||
_spec.AddField(downloadclients.FieldPriority1, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := dcuo.mutation.RemoveCompletedDownloads(); ok {
|
||||
_spec.SetField(downloadclients.FieldRemoveCompletedDownloads, field.TypeBool, value)
|
||||
|
||||
20
ent/ent.go
@@ -6,11 +6,14 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/blacklist"
|
||||
"polaris/ent/downloadclients"
|
||||
"polaris/ent/episode"
|
||||
"polaris/ent/history"
|
||||
"polaris/ent/importlist"
|
||||
"polaris/ent/indexers"
|
||||
"polaris/ent/media"
|
||||
"polaris/ent/notificationclient"
|
||||
"polaris/ent/settings"
|
||||
"polaris/ent/storage"
|
||||
"reflect"
|
||||
@@ -79,13 +82,16 @@ var (
|
||||
func checkColumn(table, column string) error {
|
||||
initCheck.Do(func() {
|
||||
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
|
||||
downloadclients.Table: downloadclients.ValidColumn,
|
||||
episode.Table: episode.ValidColumn,
|
||||
history.Table: history.ValidColumn,
|
||||
indexers.Table: indexers.ValidColumn,
|
||||
media.Table: media.ValidColumn,
|
||||
settings.Table: settings.ValidColumn,
|
||||
storage.Table: storage.ValidColumn,
|
||||
blacklist.Table: blacklist.ValidColumn,
|
||||
downloadclients.Table: downloadclients.ValidColumn,
|
||||
episode.Table: episode.ValidColumn,
|
||||
history.Table: history.ValidColumn,
|
||||
importlist.Table: importlist.ValidColumn,
|
||||
indexers.Table: indexers.ValidColumn,
|
||||
media.Table: media.ValidColumn,
|
||||
notificationclient.Table: notificationclient.ValidColumn,
|
||||
settings.Table: settings.ValidColumn,
|
||||
storage.Table: storage.ValidColumn,
|
||||
})
|
||||
})
|
||||
return columnCheck(table, column)
|
||||
|
||||
@@ -31,8 +31,10 @@ type Episode struct {
|
||||
AirDate string `json:"air_date,omitempty"`
|
||||
// Status holds the value of the "status" field.
|
||||
Status episode.Status `json:"status,omitempty"`
|
||||
// FileInStorage holds the value of the "file_in_storage" field.
|
||||
FileInStorage string `json:"file_in_storage,omitempty"`
|
||||
// Monitored holds the value of the "monitored" field.
|
||||
Monitored bool `json:"monitored"`
|
||||
// TargetFile holds the value of the "target_file" field.
|
||||
TargetFile string `json:"target_file,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the EpisodeQuery when eager-loading is set.
|
||||
Edges EpisodeEdges `json:"edges"`
|
||||
@@ -64,9 +66,11 @@ func (*Episode) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case episode.FieldMonitored:
|
||||
values[i] = new(sql.NullBool)
|
||||
case episode.FieldID, episode.FieldMediaID, episode.FieldSeasonNumber, episode.FieldEpisodeNumber:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case episode.FieldTitle, episode.FieldOverview, episode.FieldAirDate, episode.FieldStatus, episode.FieldFileInStorage:
|
||||
case episode.FieldTitle, episode.FieldOverview, episode.FieldAirDate, episode.FieldStatus, episode.FieldTargetFile:
|
||||
values[i] = new(sql.NullString)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
@@ -131,11 +135,17 @@ func (e *Episode) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
e.Status = episode.Status(value.String)
|
||||
}
|
||||
case episode.FieldFileInStorage:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field file_in_storage", values[i])
|
||||
case episode.FieldMonitored:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field monitored", values[i])
|
||||
} else if value.Valid {
|
||||
e.FileInStorage = value.String
|
||||
e.Monitored = value.Bool
|
||||
}
|
||||
case episode.FieldTargetFile:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field target_file", values[i])
|
||||
} else if value.Valid {
|
||||
e.TargetFile = value.String
|
||||
}
|
||||
default:
|
||||
e.selectValues.Set(columns[i], values[i])
|
||||
@@ -199,8 +209,11 @@ func (e *Episode) String() string {
|
||||
builder.WriteString("status=")
|
||||
builder.WriteString(fmt.Sprintf("%v", e.Status))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("file_in_storage=")
|
||||
builder.WriteString(e.FileInStorage)
|
||||
builder.WriteString("monitored=")
|
||||
builder.WriteString(fmt.Sprintf("%v", e.Monitored))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("target_file=")
|
||||
builder.WriteString(e.TargetFile)
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -28,8 +28,10 @@ const (
|
||||
FieldAirDate = "air_date"
|
||||
// FieldStatus holds the string denoting the status field in the database.
|
||||
FieldStatus = "status"
|
||||
// FieldFileInStorage holds the string denoting the file_in_storage field in the database.
|
||||
FieldFileInStorage = "file_in_storage"
|
||||
// FieldMonitored holds the string denoting the monitored field in the database.
|
||||
FieldMonitored = "monitored"
|
||||
// FieldTargetFile holds the string denoting the target_file field in the database.
|
||||
FieldTargetFile = "target_file"
|
||||
// EdgeMedia holds the string denoting the media edge name in mutations.
|
||||
EdgeMedia = "media"
|
||||
// Table holds the table name of the episode in the database.
|
||||
@@ -53,7 +55,8 @@ var Columns = []string{
|
||||
FieldOverview,
|
||||
FieldAirDate,
|
||||
FieldStatus,
|
||||
FieldFileInStorage,
|
||||
FieldMonitored,
|
||||
FieldTargetFile,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
@@ -66,6 +69,11 @@ func ValidColumn(column string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// DefaultMonitored holds the default value on creation for the "monitored" field.
|
||||
DefaultMonitored bool
|
||||
)
|
||||
|
||||
// Status defines the type for the "status" enum field.
|
||||
type Status string
|
||||
|
||||
@@ -136,9 +144,14 @@ func ByStatus(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldStatus, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByFileInStorage orders the results by the file_in_storage field.
|
||||
func ByFileInStorage(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldFileInStorage, opts...).ToFunc()
|
||||
// ByMonitored orders the results by the monitored field.
|
||||
func ByMonitored(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldMonitored, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTargetFile orders the results by the target_file field.
|
||||
func ByTargetFile(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTargetFile, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByMediaField orders the results by media field.
|
||||
|
||||
@@ -84,9 +84,14 @@ func AirDate(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldEQ(FieldAirDate, v))
|
||||
}
|
||||
|
||||
// FileInStorage applies equality check predicate on the "file_in_storage" field. It's identical to FileInStorageEQ.
|
||||
func FileInStorage(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldEQ(FieldFileInStorage, v))
|
||||
// Monitored applies equality check predicate on the "monitored" field. It's identical to MonitoredEQ.
|
||||
func Monitored(v bool) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldEQ(FieldMonitored, v))
|
||||
}
|
||||
|
||||
// TargetFile applies equality check predicate on the "target_file" field. It's identical to TargetFileEQ.
|
||||
func TargetFile(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldEQ(FieldTargetFile, v))
|
||||
}
|
||||
|
||||
// MediaIDEQ applies the EQ predicate on the "media_id" field.
|
||||
@@ -414,79 +419,89 @@ func StatusNotIn(vs ...Status) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldNotIn(FieldStatus, vs...))
|
||||
}
|
||||
|
||||
// FileInStorageEQ applies the EQ predicate on the "file_in_storage" field.
|
||||
func FileInStorageEQ(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldEQ(FieldFileInStorage, v))
|
||||
// MonitoredEQ applies the EQ predicate on the "monitored" field.
|
||||
func MonitoredEQ(v bool) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldEQ(FieldMonitored, v))
|
||||
}
|
||||
|
||||
// FileInStorageNEQ applies the NEQ predicate on the "file_in_storage" field.
|
||||
func FileInStorageNEQ(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldNEQ(FieldFileInStorage, v))
|
||||
// MonitoredNEQ applies the NEQ predicate on the "monitored" field.
|
||||
func MonitoredNEQ(v bool) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldNEQ(FieldMonitored, v))
|
||||
}
|
||||
|
||||
// FileInStorageIn applies the In predicate on the "file_in_storage" field.
|
||||
func FileInStorageIn(vs ...string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldIn(FieldFileInStorage, vs...))
|
||||
// TargetFileEQ applies the EQ predicate on the "target_file" field.
|
||||
func TargetFileEQ(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldEQ(FieldTargetFile, v))
|
||||
}
|
||||
|
||||
// FileInStorageNotIn applies the NotIn predicate on the "file_in_storage" field.
|
||||
func FileInStorageNotIn(vs ...string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldNotIn(FieldFileInStorage, vs...))
|
||||
// TargetFileNEQ applies the NEQ predicate on the "target_file" field.
|
||||
func TargetFileNEQ(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldNEQ(FieldTargetFile, v))
|
||||
}
|
||||
|
||||
// FileInStorageGT applies the GT predicate on the "file_in_storage" field.
|
||||
func FileInStorageGT(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldGT(FieldFileInStorage, v))
|
||||
// TargetFileIn applies the In predicate on the "target_file" field.
|
||||
func TargetFileIn(vs ...string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldIn(FieldTargetFile, vs...))
|
||||
}
|
||||
|
||||
// FileInStorageGTE applies the GTE predicate on the "file_in_storage" field.
|
||||
func FileInStorageGTE(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldGTE(FieldFileInStorage, v))
|
||||
// TargetFileNotIn applies the NotIn predicate on the "target_file" field.
|
||||
func TargetFileNotIn(vs ...string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldNotIn(FieldTargetFile, vs...))
|
||||
}
|
||||
|
||||
// FileInStorageLT applies the LT predicate on the "file_in_storage" field.
|
||||
func FileInStorageLT(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldLT(FieldFileInStorage, v))
|
||||
// TargetFileGT applies the GT predicate on the "target_file" field.
|
||||
func TargetFileGT(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldGT(FieldTargetFile, v))
|
||||
}
|
||||
|
||||
// FileInStorageLTE applies the LTE predicate on the "file_in_storage" field.
|
||||
func FileInStorageLTE(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldLTE(FieldFileInStorage, v))
|
||||
// TargetFileGTE applies the GTE predicate on the "target_file" field.
|
||||
func TargetFileGTE(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldGTE(FieldTargetFile, v))
|
||||
}
|
||||
|
||||
// FileInStorageContains applies the Contains predicate on the "file_in_storage" field.
|
||||
func FileInStorageContains(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldContains(FieldFileInStorage, v))
|
||||
// TargetFileLT applies the LT predicate on the "target_file" field.
|
||||
func TargetFileLT(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldLT(FieldTargetFile, v))
|
||||
}
|
||||
|
||||
// FileInStorageHasPrefix applies the HasPrefix predicate on the "file_in_storage" field.
|
||||
func FileInStorageHasPrefix(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldHasPrefix(FieldFileInStorage, v))
|
||||
// TargetFileLTE applies the LTE predicate on the "target_file" field.
|
||||
func TargetFileLTE(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldLTE(FieldTargetFile, v))
|
||||
}
|
||||
|
||||
// FileInStorageHasSuffix applies the HasSuffix predicate on the "file_in_storage" field.
|
||||
func FileInStorageHasSuffix(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldHasSuffix(FieldFileInStorage, v))
|
||||
// TargetFileContains applies the Contains predicate on the "target_file" field.
|
||||
func TargetFileContains(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldContains(FieldTargetFile, v))
|
||||
}
|
||||
|
||||
// FileInStorageIsNil applies the IsNil predicate on the "file_in_storage" field.
|
||||
func FileInStorageIsNil() predicate.Episode {
|
||||
return predicate.Episode(sql.FieldIsNull(FieldFileInStorage))
|
||||
// TargetFileHasPrefix applies the HasPrefix predicate on the "target_file" field.
|
||||
func TargetFileHasPrefix(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldHasPrefix(FieldTargetFile, v))
|
||||
}
|
||||
|
||||
// FileInStorageNotNil applies the NotNil predicate on the "file_in_storage" field.
|
||||
func FileInStorageNotNil() predicate.Episode {
|
||||
return predicate.Episode(sql.FieldNotNull(FieldFileInStorage))
|
||||
// TargetFileHasSuffix applies the HasSuffix predicate on the "target_file" field.
|
||||
func TargetFileHasSuffix(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldHasSuffix(FieldTargetFile, v))
|
||||
}
|
||||
|
||||
// FileInStorageEqualFold applies the EqualFold predicate on the "file_in_storage" field.
|
||||
func FileInStorageEqualFold(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldEqualFold(FieldFileInStorage, v))
|
||||
// TargetFileIsNil applies the IsNil predicate on the "target_file" field.
|
||||
func TargetFileIsNil() predicate.Episode {
|
||||
return predicate.Episode(sql.FieldIsNull(FieldTargetFile))
|
||||
}
|
||||
|
||||
// FileInStorageContainsFold applies the ContainsFold predicate on the "file_in_storage" field.
|
||||
func FileInStorageContainsFold(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldContainsFold(FieldFileInStorage, v))
|
||||
// TargetFileNotNil applies the NotNil predicate on the "target_file" field.
|
||||
func TargetFileNotNil() predicate.Episode {
|
||||
return predicate.Episode(sql.FieldNotNull(FieldTargetFile))
|
||||
}
|
||||
|
||||
// TargetFileEqualFold applies the EqualFold predicate on the "target_file" field.
|
||||
func TargetFileEqualFold(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldEqualFold(FieldTargetFile, v))
|
||||
}
|
||||
|
||||
// TargetFileContainsFold applies the ContainsFold predicate on the "target_file" field.
|
||||
func TargetFileContainsFold(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldContainsFold(FieldTargetFile, v))
|
||||
}
|
||||
|
||||
// HasMedia applies the HasEdge predicate on the "media" edge.
|
||||
|
||||
@@ -78,16 +78,30 @@ func (ec *EpisodeCreate) SetNillableStatus(e *episode.Status) *EpisodeCreate {
|
||||
return ec
|
||||
}
|
||||
|
||||
// SetFileInStorage sets the "file_in_storage" field.
|
||||
func (ec *EpisodeCreate) SetFileInStorage(s string) *EpisodeCreate {
|
||||
ec.mutation.SetFileInStorage(s)
|
||||
// SetMonitored sets the "monitored" field.
|
||||
func (ec *EpisodeCreate) SetMonitored(b bool) *EpisodeCreate {
|
||||
ec.mutation.SetMonitored(b)
|
||||
return ec
|
||||
}
|
||||
|
||||
// SetNillableFileInStorage sets the "file_in_storage" field if the given value is not nil.
|
||||
func (ec *EpisodeCreate) SetNillableFileInStorage(s *string) *EpisodeCreate {
|
||||
// SetNillableMonitored sets the "monitored" field if the given value is not nil.
|
||||
func (ec *EpisodeCreate) SetNillableMonitored(b *bool) *EpisodeCreate {
|
||||
if b != nil {
|
||||
ec.SetMonitored(*b)
|
||||
}
|
||||
return ec
|
||||
}
|
||||
|
||||
// SetTargetFile sets the "target_file" field.
|
||||
func (ec *EpisodeCreate) SetTargetFile(s string) *EpisodeCreate {
|
||||
ec.mutation.SetTargetFile(s)
|
||||
return ec
|
||||
}
|
||||
|
||||
// SetNillableTargetFile sets the "target_file" field if the given value is not nil.
|
||||
func (ec *EpisodeCreate) SetNillableTargetFile(s *string) *EpisodeCreate {
|
||||
if s != nil {
|
||||
ec.SetFileInStorage(*s)
|
||||
ec.SetTargetFile(*s)
|
||||
}
|
||||
return ec
|
||||
}
|
||||
@@ -136,6 +150,10 @@ func (ec *EpisodeCreate) defaults() {
|
||||
v := episode.DefaultStatus
|
||||
ec.mutation.SetStatus(v)
|
||||
}
|
||||
if _, ok := ec.mutation.Monitored(); !ok {
|
||||
v := episode.DefaultMonitored
|
||||
ec.mutation.SetMonitored(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
@@ -163,6 +181,9 @@ func (ec *EpisodeCreate) check() error {
|
||||
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Episode.status": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := ec.mutation.Monitored(); !ok {
|
||||
return &ValidationError{Name: "monitored", err: errors.New(`ent: missing required field "Episode.monitored"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -213,9 +234,13 @@ func (ec *EpisodeCreate) createSpec() (*Episode, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(episode.FieldStatus, field.TypeEnum, value)
|
||||
_node.Status = value
|
||||
}
|
||||
if value, ok := ec.mutation.FileInStorage(); ok {
|
||||
_spec.SetField(episode.FieldFileInStorage, field.TypeString, value)
|
||||
_node.FileInStorage = value
|
||||
if value, ok := ec.mutation.Monitored(); ok {
|
||||
_spec.SetField(episode.FieldMonitored, field.TypeBool, value)
|
||||
_node.Monitored = value
|
||||
}
|
||||
if value, ok := ec.mutation.TargetFile(); ok {
|
||||
_spec.SetField(episode.FieldTargetFile, field.TypeString, value)
|
||||
_node.TargetFile = value
|
||||
}
|
||||
if nodes := ec.mutation.MediaIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
||||
@@ -146,23 +146,37 @@ func (eu *EpisodeUpdate) SetNillableStatus(e *episode.Status) *EpisodeUpdate {
|
||||
return eu
|
||||
}
|
||||
|
||||
// SetFileInStorage sets the "file_in_storage" field.
|
||||
func (eu *EpisodeUpdate) SetFileInStorage(s string) *EpisodeUpdate {
|
||||
eu.mutation.SetFileInStorage(s)
|
||||
// SetMonitored sets the "monitored" field.
|
||||
func (eu *EpisodeUpdate) SetMonitored(b bool) *EpisodeUpdate {
|
||||
eu.mutation.SetMonitored(b)
|
||||
return eu
|
||||
}
|
||||
|
||||
// SetNillableFileInStorage sets the "file_in_storage" field if the given value is not nil.
|
||||
func (eu *EpisodeUpdate) SetNillableFileInStorage(s *string) *EpisodeUpdate {
|
||||
if s != nil {
|
||||
eu.SetFileInStorage(*s)
|
||||
// SetNillableMonitored sets the "monitored" field if the given value is not nil.
|
||||
func (eu *EpisodeUpdate) SetNillableMonitored(b *bool) *EpisodeUpdate {
|
||||
if b != nil {
|
||||
eu.SetMonitored(*b)
|
||||
}
|
||||
return eu
|
||||
}
|
||||
|
||||
// ClearFileInStorage clears the value of the "file_in_storage" field.
|
||||
func (eu *EpisodeUpdate) ClearFileInStorage() *EpisodeUpdate {
|
||||
eu.mutation.ClearFileInStorage()
|
||||
// SetTargetFile sets the "target_file" field.
|
||||
func (eu *EpisodeUpdate) SetTargetFile(s string) *EpisodeUpdate {
|
||||
eu.mutation.SetTargetFile(s)
|
||||
return eu
|
||||
}
|
||||
|
||||
// SetNillableTargetFile sets the "target_file" field if the given value is not nil.
|
||||
func (eu *EpisodeUpdate) SetNillableTargetFile(s *string) *EpisodeUpdate {
|
||||
if s != nil {
|
||||
eu.SetTargetFile(*s)
|
||||
}
|
||||
return eu
|
||||
}
|
||||
|
||||
// ClearTargetFile clears the value of the "target_file" field.
|
||||
func (eu *EpisodeUpdate) ClearTargetFile() *EpisodeUpdate {
|
||||
eu.mutation.ClearTargetFile()
|
||||
return eu
|
||||
}
|
||||
|
||||
@@ -255,11 +269,14 @@ func (eu *EpisodeUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if value, ok := eu.mutation.Status(); ok {
|
||||
_spec.SetField(episode.FieldStatus, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := eu.mutation.FileInStorage(); ok {
|
||||
_spec.SetField(episode.FieldFileInStorage, field.TypeString, value)
|
||||
if value, ok := eu.mutation.Monitored(); ok {
|
||||
_spec.SetField(episode.FieldMonitored, field.TypeBool, value)
|
||||
}
|
||||
if eu.mutation.FileInStorageCleared() {
|
||||
_spec.ClearField(episode.FieldFileInStorage, field.TypeString)
|
||||
if value, ok := eu.mutation.TargetFile(); ok {
|
||||
_spec.SetField(episode.FieldTargetFile, field.TypeString, value)
|
||||
}
|
||||
if eu.mutation.TargetFileCleared() {
|
||||
_spec.ClearField(episode.FieldTargetFile, field.TypeString)
|
||||
}
|
||||
if eu.mutation.MediaCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
@@ -428,23 +445,37 @@ func (euo *EpisodeUpdateOne) SetNillableStatus(e *episode.Status) *EpisodeUpdate
|
||||
return euo
|
||||
}
|
||||
|
||||
// SetFileInStorage sets the "file_in_storage" field.
|
||||
func (euo *EpisodeUpdateOne) SetFileInStorage(s string) *EpisodeUpdateOne {
|
||||
euo.mutation.SetFileInStorage(s)
|
||||
// SetMonitored sets the "monitored" field.
|
||||
func (euo *EpisodeUpdateOne) SetMonitored(b bool) *EpisodeUpdateOne {
|
||||
euo.mutation.SetMonitored(b)
|
||||
return euo
|
||||
}
|
||||
|
||||
// SetNillableFileInStorage sets the "file_in_storage" field if the given value is not nil.
|
||||
func (euo *EpisodeUpdateOne) SetNillableFileInStorage(s *string) *EpisodeUpdateOne {
|
||||
if s != nil {
|
||||
euo.SetFileInStorage(*s)
|
||||
// SetNillableMonitored sets the "monitored" field if the given value is not nil.
|
||||
func (euo *EpisodeUpdateOne) SetNillableMonitored(b *bool) *EpisodeUpdateOne {
|
||||
if b != nil {
|
||||
euo.SetMonitored(*b)
|
||||
}
|
||||
return euo
|
||||
}
|
||||
|
||||
// ClearFileInStorage clears the value of the "file_in_storage" field.
|
||||
func (euo *EpisodeUpdateOne) ClearFileInStorage() *EpisodeUpdateOne {
|
||||
euo.mutation.ClearFileInStorage()
|
||||
// SetTargetFile sets the "target_file" field.
|
||||
func (euo *EpisodeUpdateOne) SetTargetFile(s string) *EpisodeUpdateOne {
|
||||
euo.mutation.SetTargetFile(s)
|
||||
return euo
|
||||
}
|
||||
|
||||
// SetNillableTargetFile sets the "target_file" field if the given value is not nil.
|
||||
func (euo *EpisodeUpdateOne) SetNillableTargetFile(s *string) *EpisodeUpdateOne {
|
||||
if s != nil {
|
||||
euo.SetTargetFile(*s)
|
||||
}
|
||||
return euo
|
||||
}
|
||||
|
||||
// ClearTargetFile clears the value of the "target_file" field.
|
||||
func (euo *EpisodeUpdateOne) ClearTargetFile() *EpisodeUpdateOne {
|
||||
euo.mutation.ClearTargetFile()
|
||||
return euo
|
||||
}
|
||||
|
||||
@@ -567,11 +598,14 @@ func (euo *EpisodeUpdateOne) sqlSave(ctx context.Context) (_node *Episode, err e
|
||||
if value, ok := euo.mutation.Status(); ok {
|
||||
_spec.SetField(episode.FieldStatus, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := euo.mutation.FileInStorage(); ok {
|
||||
_spec.SetField(episode.FieldFileInStorage, field.TypeString, value)
|
||||
if value, ok := euo.mutation.Monitored(); ok {
|
||||
_spec.SetField(episode.FieldMonitored, field.TypeBool, value)
|
||||
}
|
||||
if euo.mutation.FileInStorageCleared() {
|
||||
_spec.ClearField(episode.FieldFileInStorage, field.TypeString)
|
||||
if value, ok := euo.mutation.TargetFile(); ok {
|
||||
_spec.SetField(episode.FieldTargetFile, field.TypeString, value)
|
||||
}
|
||||
if euo.mutation.TargetFileCleared() {
|
||||
_spec.ClearField(episode.FieldTargetFile, field.TypeString)
|
||||
}
|
||||
if euo.mutation.MediaCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"polaris/ent/history"
|
||||
"strings"
|
||||
@@ -19,8 +20,12 @@ type History struct {
|
||||
ID int `json:"id,omitempty"`
|
||||
// MediaID holds the value of the "media_id" field.
|
||||
MediaID int `json:"media_id,omitempty"`
|
||||
// EpisodeID holds the value of the "episode_id" field.
|
||||
// deprecated
|
||||
EpisodeID int `json:"episode_id,omitempty"`
|
||||
// EpisodeNums holds the value of the "episode_nums" field.
|
||||
EpisodeNums []int `json:"episode_nums,omitempty"`
|
||||
// SeasonNum holds the value of the "season_num" field.
|
||||
SeasonNum int `json:"season_num,omitempty"`
|
||||
// SourceTitle holds the value of the "source_title" field.
|
||||
SourceTitle string `json:"source_title,omitempty"`
|
||||
// Date holds the value of the "date" field.
|
||||
@@ -29,9 +34,15 @@ type History struct {
|
||||
TargetDir string `json:"target_dir,omitempty"`
|
||||
// Size holds the value of the "size" field.
|
||||
Size int `json:"size,omitempty"`
|
||||
// DownloadClientID holds the value of the "download_client_id" field.
|
||||
DownloadClientID int `json:"download_client_id,omitempty"`
|
||||
// IndexerID holds the value of the "indexer_id" field.
|
||||
IndexerID int `json:"indexer_id,omitempty"`
|
||||
// Link holds the value of the "link" field.
|
||||
Link string `json:"link,omitempty"`
|
||||
// Status holds the value of the "status" field.
|
||||
Status history.Status `json:"status,omitempty"`
|
||||
// Saved holds the value of the "saved" field.
|
||||
// deprecated
|
||||
Saved string `json:"saved,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
@@ -41,9 +52,11 @@ func (*History) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case history.FieldID, history.FieldMediaID, history.FieldEpisodeID, history.FieldSize:
|
||||
case history.FieldEpisodeNums:
|
||||
values[i] = new([]byte)
|
||||
case history.FieldID, history.FieldMediaID, history.FieldEpisodeID, history.FieldSeasonNum, history.FieldSize, history.FieldDownloadClientID, history.FieldIndexerID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case history.FieldSourceTitle, history.FieldTargetDir, history.FieldStatus, history.FieldSaved:
|
||||
case history.FieldSourceTitle, history.FieldTargetDir, history.FieldLink, history.FieldStatus, history.FieldSaved:
|
||||
values[i] = new(sql.NullString)
|
||||
case history.FieldDate:
|
||||
values[i] = new(sql.NullTime)
|
||||
@@ -80,6 +93,20 @@ func (h *History) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
h.EpisodeID = int(value.Int64)
|
||||
}
|
||||
case history.FieldEpisodeNums:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field episode_nums", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
if err := json.Unmarshal(*value, &h.EpisodeNums); err != nil {
|
||||
return fmt.Errorf("unmarshal field episode_nums: %w", err)
|
||||
}
|
||||
}
|
||||
case history.FieldSeasonNum:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field season_num", values[i])
|
||||
} else if value.Valid {
|
||||
h.SeasonNum = int(value.Int64)
|
||||
}
|
||||
case history.FieldSourceTitle:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field source_title", values[i])
|
||||
@@ -104,6 +131,24 @@ func (h *History) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
h.Size = int(value.Int64)
|
||||
}
|
||||
case history.FieldDownloadClientID:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field download_client_id", values[i])
|
||||
} else if value.Valid {
|
||||
h.DownloadClientID = int(value.Int64)
|
||||
}
|
||||
case history.FieldIndexerID:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field indexer_id", values[i])
|
||||
} else if value.Valid {
|
||||
h.IndexerID = int(value.Int64)
|
||||
}
|
||||
case history.FieldLink:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field link", values[i])
|
||||
} else if value.Valid {
|
||||
h.Link = value.String
|
||||
}
|
||||
case history.FieldStatus:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field status", values[i])
|
||||
@@ -158,6 +203,12 @@ func (h *History) String() string {
|
||||
builder.WriteString("episode_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", h.EpisodeID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("episode_nums=")
|
||||
builder.WriteString(fmt.Sprintf("%v", h.EpisodeNums))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("season_num=")
|
||||
builder.WriteString(fmt.Sprintf("%v", h.SeasonNum))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("source_title=")
|
||||
builder.WriteString(h.SourceTitle)
|
||||
builder.WriteString(", ")
|
||||
@@ -170,6 +221,15 @@ func (h *History) String() string {
|
||||
builder.WriteString("size=")
|
||||
builder.WriteString(fmt.Sprintf("%v", h.Size))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("download_client_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", h.DownloadClientID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("indexer_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", h.IndexerID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("link=")
|
||||
builder.WriteString(h.Link)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("status=")
|
||||
builder.WriteString(fmt.Sprintf("%v", h.Status))
|
||||
builder.WriteString(", ")
|
||||
|
||||
@@ -17,6 +17,10 @@ const (
|
||||
FieldMediaID = "media_id"
|
||||
// FieldEpisodeID holds the string denoting the episode_id field in the database.
|
||||
FieldEpisodeID = "episode_id"
|
||||
// FieldEpisodeNums holds the string denoting the episode_nums field in the database.
|
||||
FieldEpisodeNums = "episode_nums"
|
||||
// FieldSeasonNum holds the string denoting the season_num field in the database.
|
||||
FieldSeasonNum = "season_num"
|
||||
// FieldSourceTitle holds the string denoting the source_title field in the database.
|
||||
FieldSourceTitle = "source_title"
|
||||
// FieldDate holds the string denoting the date field in the database.
|
||||
@@ -25,6 +29,12 @@ const (
|
||||
FieldTargetDir = "target_dir"
|
||||
// FieldSize holds the string denoting the size field in the database.
|
||||
FieldSize = "size"
|
||||
// FieldDownloadClientID holds the string denoting the download_client_id field in the database.
|
||||
FieldDownloadClientID = "download_client_id"
|
||||
// FieldIndexerID holds the string denoting the indexer_id field in the database.
|
||||
FieldIndexerID = "indexer_id"
|
||||
// FieldLink holds the string denoting the link field in the database.
|
||||
FieldLink = "link"
|
||||
// FieldStatus holds the string denoting the status field in the database.
|
||||
FieldStatus = "status"
|
||||
// FieldSaved holds the string denoting the saved field in the database.
|
||||
@@ -38,10 +48,15 @@ var Columns = []string{
|
||||
FieldID,
|
||||
FieldMediaID,
|
||||
FieldEpisodeID,
|
||||
FieldEpisodeNums,
|
||||
FieldSeasonNum,
|
||||
FieldSourceTitle,
|
||||
FieldDate,
|
||||
FieldTargetDir,
|
||||
FieldSize,
|
||||
FieldDownloadClientID,
|
||||
FieldIndexerID,
|
||||
FieldLink,
|
||||
FieldStatus,
|
||||
FieldSaved,
|
||||
}
|
||||
@@ -70,6 +85,7 @@ const (
|
||||
StatusSuccess Status = "success"
|
||||
StatusFail Status = "fail"
|
||||
StatusUploading Status = "uploading"
|
||||
StatusSeeding Status = "seeding"
|
||||
)
|
||||
|
||||
func (s Status) String() string {
|
||||
@@ -79,7 +95,7 @@ func (s Status) String() string {
|
||||
// StatusValidator is a validator for the "status" field enum values. It is called by the builders before save.
|
||||
func StatusValidator(s Status) error {
|
||||
switch s {
|
||||
case StatusRunning, StatusSuccess, StatusFail, StatusUploading:
|
||||
case StatusRunning, StatusSuccess, StatusFail, StatusUploading, StatusSeeding:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("history: invalid enum value for status field: %q", s)
|
||||
@@ -104,6 +120,11 @@ func ByEpisodeID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldEpisodeID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySeasonNum orders the results by the season_num field.
|
||||
func BySeasonNum(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSeasonNum, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySourceTitle orders the results by the source_title field.
|
||||
func BySourceTitle(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSourceTitle, opts...).ToFunc()
|
||||
@@ -124,6 +145,21 @@ func BySize(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSize, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDownloadClientID orders the results by the download_client_id field.
|
||||
func ByDownloadClientID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDownloadClientID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByIndexerID orders the results by the indexer_id field.
|
||||
func ByIndexerID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldIndexerID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLink orders the results by the link field.
|
||||
func ByLink(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLink, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByStatus orders the results by the status field.
|
||||
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldStatus, opts...).ToFunc()
|
||||
|
||||
@@ -64,6 +64,11 @@ func EpisodeID(v int) predicate.History {
|
||||
return predicate.History(sql.FieldEQ(FieldEpisodeID, v))
|
||||
}
|
||||
|
||||
// SeasonNum applies equality check predicate on the "season_num" field. It's identical to SeasonNumEQ.
|
||||
func SeasonNum(v int) predicate.History {
|
||||
return predicate.History(sql.FieldEQ(FieldSeasonNum, v))
|
||||
}
|
||||
|
||||
// SourceTitle applies equality check predicate on the "source_title" field. It's identical to SourceTitleEQ.
|
||||
func SourceTitle(v string) predicate.History {
|
||||
return predicate.History(sql.FieldEQ(FieldSourceTitle, v))
|
||||
@@ -84,6 +89,21 @@ func Size(v int) predicate.History {
|
||||
return predicate.History(sql.FieldEQ(FieldSize, v))
|
||||
}
|
||||
|
||||
// DownloadClientID applies equality check predicate on the "download_client_id" field. It's identical to DownloadClientIDEQ.
|
||||
func DownloadClientID(v int) predicate.History {
|
||||
return predicate.History(sql.FieldEQ(FieldDownloadClientID, v))
|
||||
}
|
||||
|
||||
// IndexerID applies equality check predicate on the "indexer_id" field. It's identical to IndexerIDEQ.
|
||||
func IndexerID(v int) predicate.History {
|
||||
return predicate.History(sql.FieldEQ(FieldIndexerID, v))
|
||||
}
|
||||
|
||||
// Link applies equality check predicate on the "link" field. It's identical to LinkEQ.
|
||||
func Link(v string) predicate.History {
|
||||
return predicate.History(sql.FieldEQ(FieldLink, v))
|
||||
}
|
||||
|
||||
// Saved applies equality check predicate on the "saved" field. It's identical to SavedEQ.
|
||||
func Saved(v string) predicate.History {
|
||||
return predicate.History(sql.FieldEQ(FieldSaved, v))
|
||||
@@ -179,6 +199,66 @@ func EpisodeIDNotNil() predicate.History {
|
||||
return predicate.History(sql.FieldNotNull(FieldEpisodeID))
|
||||
}
|
||||
|
||||
// EpisodeNumsIsNil applies the IsNil predicate on the "episode_nums" field.
|
||||
func EpisodeNumsIsNil() predicate.History {
|
||||
return predicate.History(sql.FieldIsNull(FieldEpisodeNums))
|
||||
}
|
||||
|
||||
// EpisodeNumsNotNil applies the NotNil predicate on the "episode_nums" field.
|
||||
func EpisodeNumsNotNil() predicate.History {
|
||||
return predicate.History(sql.FieldNotNull(FieldEpisodeNums))
|
||||
}
|
||||
|
||||
// SeasonNumEQ applies the EQ predicate on the "season_num" field.
|
||||
func SeasonNumEQ(v int) predicate.History {
|
||||
return predicate.History(sql.FieldEQ(FieldSeasonNum, v))
|
||||
}
|
||||
|
||||
// SeasonNumNEQ applies the NEQ predicate on the "season_num" field.
|
||||
func SeasonNumNEQ(v int) predicate.History {
|
||||
return predicate.History(sql.FieldNEQ(FieldSeasonNum, v))
|
||||
}
|
||||
|
||||
// SeasonNumIn applies the In predicate on the "season_num" field.
|
||||
func SeasonNumIn(vs ...int) predicate.History {
|
||||
return predicate.History(sql.FieldIn(FieldSeasonNum, vs...))
|
||||
}
|
||||
|
||||
// SeasonNumNotIn applies the NotIn predicate on the "season_num" field.
|
||||
func SeasonNumNotIn(vs ...int) predicate.History {
|
||||
return predicate.History(sql.FieldNotIn(FieldSeasonNum, vs...))
|
||||
}
|
||||
|
||||
// SeasonNumGT applies the GT predicate on the "season_num" field.
|
||||
func SeasonNumGT(v int) predicate.History {
|
||||
return predicate.History(sql.FieldGT(FieldSeasonNum, v))
|
||||
}
|
||||
|
||||
// SeasonNumGTE applies the GTE predicate on the "season_num" field.
|
||||
func SeasonNumGTE(v int) predicate.History {
|
||||
return predicate.History(sql.FieldGTE(FieldSeasonNum, v))
|
||||
}
|
||||
|
||||
// SeasonNumLT applies the LT predicate on the "season_num" field.
|
||||
func SeasonNumLT(v int) predicate.History {
|
||||
return predicate.History(sql.FieldLT(FieldSeasonNum, v))
|
||||
}
|
||||
|
||||
// SeasonNumLTE applies the LTE predicate on the "season_num" field.
|
||||
func SeasonNumLTE(v int) predicate.History {
|
||||
return predicate.History(sql.FieldLTE(FieldSeasonNum, v))
|
||||
}
|
||||
|
||||
// SeasonNumIsNil applies the IsNil predicate on the "season_num" field.
|
||||
func SeasonNumIsNil() predicate.History {
|
||||
return predicate.History(sql.FieldIsNull(FieldSeasonNum))
|
||||
}
|
||||
|
||||
// SeasonNumNotNil applies the NotNil predicate on the "season_num" field.
|
||||
func SeasonNumNotNil() predicate.History {
|
||||
return predicate.History(sql.FieldNotNull(FieldSeasonNum))
|
||||
}
|
||||
|
||||
// SourceTitleEQ applies the EQ predicate on the "source_title" field.
|
||||
func SourceTitleEQ(v string) predicate.History {
|
||||
return predicate.History(sql.FieldEQ(FieldSourceTitle, v))
|
||||
@@ -389,6 +469,181 @@ func SizeLTE(v int) predicate.History {
|
||||
return predicate.History(sql.FieldLTE(FieldSize, v))
|
||||
}
|
||||
|
||||
// DownloadClientIDEQ applies the EQ predicate on the "download_client_id" field.
|
||||
func DownloadClientIDEQ(v int) predicate.History {
|
||||
return predicate.History(sql.FieldEQ(FieldDownloadClientID, v))
|
||||
}
|
||||
|
||||
// DownloadClientIDNEQ applies the NEQ predicate on the "download_client_id" field.
|
||||
func DownloadClientIDNEQ(v int) predicate.History {
|
||||
return predicate.History(sql.FieldNEQ(FieldDownloadClientID, v))
|
||||
}
|
||||
|
||||
// DownloadClientIDIn applies the In predicate on the "download_client_id" field.
|
||||
func DownloadClientIDIn(vs ...int) predicate.History {
|
||||
return predicate.History(sql.FieldIn(FieldDownloadClientID, vs...))
|
||||
}
|
||||
|
||||
// DownloadClientIDNotIn applies the NotIn predicate on the "download_client_id" field.
|
||||
func DownloadClientIDNotIn(vs ...int) predicate.History {
|
||||
return predicate.History(sql.FieldNotIn(FieldDownloadClientID, vs...))
|
||||
}
|
||||
|
||||
// DownloadClientIDGT applies the GT predicate on the "download_client_id" field.
|
||||
func DownloadClientIDGT(v int) predicate.History {
|
||||
return predicate.History(sql.FieldGT(FieldDownloadClientID, v))
|
||||
}
|
||||
|
||||
// DownloadClientIDGTE applies the GTE predicate on the "download_client_id" field.
|
||||
func DownloadClientIDGTE(v int) predicate.History {
|
||||
return predicate.History(sql.FieldGTE(FieldDownloadClientID, v))
|
||||
}
|
||||
|
||||
// DownloadClientIDLT applies the LT predicate on the "download_client_id" field.
|
||||
func DownloadClientIDLT(v int) predicate.History {
|
||||
return predicate.History(sql.FieldLT(FieldDownloadClientID, v))
|
||||
}
|
||||
|
||||
// DownloadClientIDLTE applies the LTE predicate on the "download_client_id" field.
|
||||
func DownloadClientIDLTE(v int) predicate.History {
|
||||
return predicate.History(sql.FieldLTE(FieldDownloadClientID, v))
|
||||
}
|
||||
|
||||
// DownloadClientIDIsNil applies the IsNil predicate on the "download_client_id" field.
|
||||
func DownloadClientIDIsNil() predicate.History {
|
||||
return predicate.History(sql.FieldIsNull(FieldDownloadClientID))
|
||||
}
|
||||
|
||||
// DownloadClientIDNotNil applies the NotNil predicate on the "download_client_id" field.
|
||||
func DownloadClientIDNotNil() predicate.History {
|
||||
return predicate.History(sql.FieldNotNull(FieldDownloadClientID))
|
||||
}
|
||||
|
||||
// IndexerIDEQ applies the EQ predicate on the "indexer_id" field.
|
||||
func IndexerIDEQ(v int) predicate.History {
|
||||
return predicate.History(sql.FieldEQ(FieldIndexerID, v))
|
||||
}
|
||||
|
||||
// IndexerIDNEQ applies the NEQ predicate on the "indexer_id" field.
|
||||
func IndexerIDNEQ(v int) predicate.History {
|
||||
return predicate.History(sql.FieldNEQ(FieldIndexerID, v))
|
||||
}
|
||||
|
||||
// IndexerIDIn applies the In predicate on the "indexer_id" field.
|
||||
func IndexerIDIn(vs ...int) predicate.History {
|
||||
return predicate.History(sql.FieldIn(FieldIndexerID, vs...))
|
||||
}
|
||||
|
||||
// IndexerIDNotIn applies the NotIn predicate on the "indexer_id" field.
|
||||
func IndexerIDNotIn(vs ...int) predicate.History {
|
||||
return predicate.History(sql.FieldNotIn(FieldIndexerID, vs...))
|
||||
}
|
||||
|
||||
// IndexerIDGT applies the GT predicate on the "indexer_id" field.
|
||||
func IndexerIDGT(v int) predicate.History {
|
||||
return predicate.History(sql.FieldGT(FieldIndexerID, v))
|
||||
}
|
||||
|
||||
// IndexerIDGTE applies the GTE predicate on the "indexer_id" field.
|
||||
func IndexerIDGTE(v int) predicate.History {
|
||||
return predicate.History(sql.FieldGTE(FieldIndexerID, v))
|
||||
}
|
||||
|
||||
// IndexerIDLT applies the LT predicate on the "indexer_id" field.
|
||||
func IndexerIDLT(v int) predicate.History {
|
||||
return predicate.History(sql.FieldLT(FieldIndexerID, v))
|
||||
}
|
||||
|
||||
// IndexerIDLTE applies the LTE predicate on the "indexer_id" field.
|
||||
func IndexerIDLTE(v int) predicate.History {
|
||||
return predicate.History(sql.FieldLTE(FieldIndexerID, v))
|
||||
}
|
||||
|
||||
// IndexerIDIsNil applies the IsNil predicate on the "indexer_id" field.
|
||||
func IndexerIDIsNil() predicate.History {
|
||||
return predicate.History(sql.FieldIsNull(FieldIndexerID))
|
||||
}
|
||||
|
||||
// IndexerIDNotNil applies the NotNil predicate on the "indexer_id" field.
|
||||
func IndexerIDNotNil() predicate.History {
|
||||
return predicate.History(sql.FieldNotNull(FieldIndexerID))
|
||||
}
|
||||
|
||||
// LinkEQ applies the EQ predicate on the "link" field.
|
||||
func LinkEQ(v string) predicate.History {
|
||||
return predicate.History(sql.FieldEQ(FieldLink, v))
|
||||
}
|
||||
|
||||
// LinkNEQ applies the NEQ predicate on the "link" field.
|
||||
func LinkNEQ(v string) predicate.History {
|
||||
return predicate.History(sql.FieldNEQ(FieldLink, v))
|
||||
}
|
||||
|
||||
// LinkIn applies the In predicate on the "link" field.
|
||||
func LinkIn(vs ...string) predicate.History {
|
||||
return predicate.History(sql.FieldIn(FieldLink, vs...))
|
||||
}
|
||||
|
||||
// LinkNotIn applies the NotIn predicate on the "link" field.
|
||||
func LinkNotIn(vs ...string) predicate.History {
|
||||
return predicate.History(sql.FieldNotIn(FieldLink, vs...))
|
||||
}
|
||||
|
||||
// LinkGT applies the GT predicate on the "link" field.
|
||||
func LinkGT(v string) predicate.History {
|
||||
return predicate.History(sql.FieldGT(FieldLink, v))
|
||||
}
|
||||
|
||||
// LinkGTE applies the GTE predicate on the "link" field.
|
||||
func LinkGTE(v string) predicate.History {
|
||||
return predicate.History(sql.FieldGTE(FieldLink, v))
|
||||
}
|
||||
|
||||
// LinkLT applies the LT predicate on the "link" field.
|
||||
func LinkLT(v string) predicate.History {
|
||||
return predicate.History(sql.FieldLT(FieldLink, v))
|
||||
}
|
||||
|
||||
// LinkLTE applies the LTE predicate on the "link" field.
|
||||
func LinkLTE(v string) predicate.History {
|
||||
return predicate.History(sql.FieldLTE(FieldLink, v))
|
||||
}
|
||||
|
||||
// LinkContains applies the Contains predicate on the "link" field.
|
||||
func LinkContains(v string) predicate.History {
|
||||
return predicate.History(sql.FieldContains(FieldLink, v))
|
||||
}
|
||||
|
||||
// LinkHasPrefix applies the HasPrefix predicate on the "link" field.
|
||||
func LinkHasPrefix(v string) predicate.History {
|
||||
return predicate.History(sql.FieldHasPrefix(FieldLink, v))
|
||||
}
|
||||
|
||||
// LinkHasSuffix applies the HasSuffix predicate on the "link" field.
|
||||
func LinkHasSuffix(v string) predicate.History {
|
||||
return predicate.History(sql.FieldHasSuffix(FieldLink, v))
|
||||
}
|
||||
|
||||
// LinkIsNil applies the IsNil predicate on the "link" field.
|
||||
func LinkIsNil() predicate.History {
|
||||
return predicate.History(sql.FieldIsNull(FieldLink))
|
||||
}
|
||||
|
||||
// LinkNotNil applies the NotNil predicate on the "link" field.
|
||||
func LinkNotNil() predicate.History {
|
||||
return predicate.History(sql.FieldNotNull(FieldLink))
|
||||
}
|
||||
|
||||
// LinkEqualFold applies the EqualFold predicate on the "link" field.
|
||||
func LinkEqualFold(v string) predicate.History {
|
||||
return predicate.History(sql.FieldEqualFold(FieldLink, v))
|
||||
}
|
||||
|
||||
// LinkContainsFold applies the ContainsFold predicate on the "link" field.
|
||||
func LinkContainsFold(v string) predicate.History {
|
||||
return predicate.History(sql.FieldContainsFold(FieldLink, v))
|
||||
}
|
||||
|
||||
// StatusEQ applies the EQ predicate on the "status" field.
|
||||
func StatusEQ(v Status) predicate.History {
|
||||
return predicate.History(sql.FieldEQ(FieldStatus, v))
|
||||
|
||||
@@ -40,6 +40,26 @@ func (hc *HistoryCreate) SetNillableEpisodeID(i *int) *HistoryCreate {
|
||||
return hc
|
||||
}
|
||||
|
||||
// SetEpisodeNums sets the "episode_nums" field.
|
||||
func (hc *HistoryCreate) SetEpisodeNums(i []int) *HistoryCreate {
|
||||
hc.mutation.SetEpisodeNums(i)
|
||||
return hc
|
||||
}
|
||||
|
||||
// SetSeasonNum sets the "season_num" field.
|
||||
func (hc *HistoryCreate) SetSeasonNum(i int) *HistoryCreate {
|
||||
hc.mutation.SetSeasonNum(i)
|
||||
return hc
|
||||
}
|
||||
|
||||
// SetNillableSeasonNum sets the "season_num" field if the given value is not nil.
|
||||
func (hc *HistoryCreate) SetNillableSeasonNum(i *int) *HistoryCreate {
|
||||
if i != nil {
|
||||
hc.SetSeasonNum(*i)
|
||||
}
|
||||
return hc
|
||||
}
|
||||
|
||||
// SetSourceTitle sets the "source_title" field.
|
||||
func (hc *HistoryCreate) SetSourceTitle(s string) *HistoryCreate {
|
||||
hc.mutation.SetSourceTitle(s)
|
||||
@@ -72,6 +92,48 @@ func (hc *HistoryCreate) SetNillableSize(i *int) *HistoryCreate {
|
||||
return hc
|
||||
}
|
||||
|
||||
// SetDownloadClientID sets the "download_client_id" field.
|
||||
func (hc *HistoryCreate) SetDownloadClientID(i int) *HistoryCreate {
|
||||
hc.mutation.SetDownloadClientID(i)
|
||||
return hc
|
||||
}
|
||||
|
||||
// SetNillableDownloadClientID sets the "download_client_id" field if the given value is not nil.
|
||||
func (hc *HistoryCreate) SetNillableDownloadClientID(i *int) *HistoryCreate {
|
||||
if i != nil {
|
||||
hc.SetDownloadClientID(*i)
|
||||
}
|
||||
return hc
|
||||
}
|
||||
|
||||
// SetIndexerID sets the "indexer_id" field.
|
||||
func (hc *HistoryCreate) SetIndexerID(i int) *HistoryCreate {
|
||||
hc.mutation.SetIndexerID(i)
|
||||
return hc
|
||||
}
|
||||
|
||||
// SetNillableIndexerID sets the "indexer_id" field if the given value is not nil.
|
||||
func (hc *HistoryCreate) SetNillableIndexerID(i *int) *HistoryCreate {
|
||||
if i != nil {
|
||||
hc.SetIndexerID(*i)
|
||||
}
|
||||
return hc
|
||||
}
|
||||
|
||||
// SetLink sets the "link" field.
|
||||
func (hc *HistoryCreate) SetLink(s string) *HistoryCreate {
|
||||
hc.mutation.SetLink(s)
|
||||
return hc
|
||||
}
|
||||
|
||||
// SetNillableLink sets the "link" field if the given value is not nil.
|
||||
func (hc *HistoryCreate) SetNillableLink(s *string) *HistoryCreate {
|
||||
if s != nil {
|
||||
hc.SetLink(*s)
|
||||
}
|
||||
return hc
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (hc *HistoryCreate) SetStatus(h history.Status) *HistoryCreate {
|
||||
hc.mutation.SetStatus(h)
|
||||
@@ -192,6 +254,14 @@ func (hc *HistoryCreate) createSpec() (*History, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(history.FieldEpisodeID, field.TypeInt, value)
|
||||
_node.EpisodeID = value
|
||||
}
|
||||
if value, ok := hc.mutation.EpisodeNums(); ok {
|
||||
_spec.SetField(history.FieldEpisodeNums, field.TypeJSON, value)
|
||||
_node.EpisodeNums = value
|
||||
}
|
||||
if value, ok := hc.mutation.SeasonNum(); ok {
|
||||
_spec.SetField(history.FieldSeasonNum, field.TypeInt, value)
|
||||
_node.SeasonNum = value
|
||||
}
|
||||
if value, ok := hc.mutation.SourceTitle(); ok {
|
||||
_spec.SetField(history.FieldSourceTitle, field.TypeString, value)
|
||||
_node.SourceTitle = value
|
||||
@@ -208,6 +278,18 @@ func (hc *HistoryCreate) createSpec() (*History, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(history.FieldSize, field.TypeInt, value)
|
||||
_node.Size = value
|
||||
}
|
||||
if value, ok := hc.mutation.DownloadClientID(); ok {
|
||||
_spec.SetField(history.FieldDownloadClientID, field.TypeInt, value)
|
||||
_node.DownloadClientID = value
|
||||
}
|
||||
if value, ok := hc.mutation.IndexerID(); ok {
|
||||
_spec.SetField(history.FieldIndexerID, field.TypeInt, value)
|
||||
_node.IndexerID = value
|
||||
}
|
||||
if value, ok := hc.mutation.Link(); ok {
|
||||
_spec.SetField(history.FieldLink, field.TypeString, value)
|
||||
_node.Link = value
|
||||
}
|
||||
if value, ok := hc.mutation.Status(); ok {
|
||||
_spec.SetField(history.FieldStatus, field.TypeEnum, value)
|
||||
_node.Status = value
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/dialect/sql/sqljson"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
@@ -76,6 +77,51 @@ func (hu *HistoryUpdate) ClearEpisodeID() *HistoryUpdate {
|
||||
return hu
|
||||
}
|
||||
|
||||
// SetEpisodeNums sets the "episode_nums" field.
|
||||
func (hu *HistoryUpdate) SetEpisodeNums(i []int) *HistoryUpdate {
|
||||
hu.mutation.SetEpisodeNums(i)
|
||||
return hu
|
||||
}
|
||||
|
||||
// AppendEpisodeNums appends i to the "episode_nums" field.
|
||||
func (hu *HistoryUpdate) AppendEpisodeNums(i []int) *HistoryUpdate {
|
||||
hu.mutation.AppendEpisodeNums(i)
|
||||
return hu
|
||||
}
|
||||
|
||||
// ClearEpisodeNums clears the value of the "episode_nums" field.
|
||||
func (hu *HistoryUpdate) ClearEpisodeNums() *HistoryUpdate {
|
||||
hu.mutation.ClearEpisodeNums()
|
||||
return hu
|
||||
}
|
||||
|
||||
// SetSeasonNum sets the "season_num" field.
|
||||
func (hu *HistoryUpdate) SetSeasonNum(i int) *HistoryUpdate {
|
||||
hu.mutation.ResetSeasonNum()
|
||||
hu.mutation.SetSeasonNum(i)
|
||||
return hu
|
||||
}
|
||||
|
||||
// SetNillableSeasonNum sets the "season_num" field if the given value is not nil.
|
||||
func (hu *HistoryUpdate) SetNillableSeasonNum(i *int) *HistoryUpdate {
|
||||
if i != nil {
|
||||
hu.SetSeasonNum(*i)
|
||||
}
|
||||
return hu
|
||||
}
|
||||
|
||||
// AddSeasonNum adds i to the "season_num" field.
|
||||
func (hu *HistoryUpdate) AddSeasonNum(i int) *HistoryUpdate {
|
||||
hu.mutation.AddSeasonNum(i)
|
||||
return hu
|
||||
}
|
||||
|
||||
// ClearSeasonNum clears the value of the "season_num" field.
|
||||
func (hu *HistoryUpdate) ClearSeasonNum() *HistoryUpdate {
|
||||
hu.mutation.ClearSeasonNum()
|
||||
return hu
|
||||
}
|
||||
|
||||
// SetSourceTitle sets the "source_title" field.
|
||||
func (hu *HistoryUpdate) SetSourceTitle(s string) *HistoryUpdate {
|
||||
hu.mutation.SetSourceTitle(s)
|
||||
@@ -139,6 +185,80 @@ func (hu *HistoryUpdate) AddSize(i int) *HistoryUpdate {
|
||||
return hu
|
||||
}
|
||||
|
||||
// SetDownloadClientID sets the "download_client_id" field.
|
||||
func (hu *HistoryUpdate) SetDownloadClientID(i int) *HistoryUpdate {
|
||||
hu.mutation.ResetDownloadClientID()
|
||||
hu.mutation.SetDownloadClientID(i)
|
||||
return hu
|
||||
}
|
||||
|
||||
// SetNillableDownloadClientID sets the "download_client_id" field if the given value is not nil.
|
||||
func (hu *HistoryUpdate) SetNillableDownloadClientID(i *int) *HistoryUpdate {
|
||||
if i != nil {
|
||||
hu.SetDownloadClientID(*i)
|
||||
}
|
||||
return hu
|
||||
}
|
||||
|
||||
// AddDownloadClientID adds i to the "download_client_id" field.
|
||||
func (hu *HistoryUpdate) AddDownloadClientID(i int) *HistoryUpdate {
|
||||
hu.mutation.AddDownloadClientID(i)
|
||||
return hu
|
||||
}
|
||||
|
||||
// ClearDownloadClientID clears the value of the "download_client_id" field.
|
||||
func (hu *HistoryUpdate) ClearDownloadClientID() *HistoryUpdate {
|
||||
hu.mutation.ClearDownloadClientID()
|
||||
return hu
|
||||
}
|
||||
|
||||
// SetIndexerID sets the "indexer_id" field.
|
||||
func (hu *HistoryUpdate) SetIndexerID(i int) *HistoryUpdate {
|
||||
hu.mutation.ResetIndexerID()
|
||||
hu.mutation.SetIndexerID(i)
|
||||
return hu
|
||||
}
|
||||
|
||||
// SetNillableIndexerID sets the "indexer_id" field if the given value is not nil.
|
||||
func (hu *HistoryUpdate) SetNillableIndexerID(i *int) *HistoryUpdate {
|
||||
if i != nil {
|
||||
hu.SetIndexerID(*i)
|
||||
}
|
||||
return hu
|
||||
}
|
||||
|
||||
// AddIndexerID adds i to the "indexer_id" field.
|
||||
func (hu *HistoryUpdate) AddIndexerID(i int) *HistoryUpdate {
|
||||
hu.mutation.AddIndexerID(i)
|
||||
return hu
|
||||
}
|
||||
|
||||
// ClearIndexerID clears the value of the "indexer_id" field.
|
||||
func (hu *HistoryUpdate) ClearIndexerID() *HistoryUpdate {
|
||||
hu.mutation.ClearIndexerID()
|
||||
return hu
|
||||
}
|
||||
|
||||
// SetLink sets the "link" field.
|
||||
func (hu *HistoryUpdate) SetLink(s string) *HistoryUpdate {
|
||||
hu.mutation.SetLink(s)
|
||||
return hu
|
||||
}
|
||||
|
||||
// SetNillableLink sets the "link" field if the given value is not nil.
|
||||
func (hu *HistoryUpdate) SetNillableLink(s *string) *HistoryUpdate {
|
||||
if s != nil {
|
||||
hu.SetLink(*s)
|
||||
}
|
||||
return hu
|
||||
}
|
||||
|
||||
// ClearLink clears the value of the "link" field.
|
||||
func (hu *HistoryUpdate) ClearLink() *HistoryUpdate {
|
||||
hu.mutation.ClearLink()
|
||||
return hu
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (hu *HistoryUpdate) SetStatus(h history.Status) *HistoryUpdate {
|
||||
hu.mutation.SetStatus(h)
|
||||
@@ -242,6 +362,26 @@ func (hu *HistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if hu.mutation.EpisodeIDCleared() {
|
||||
_spec.ClearField(history.FieldEpisodeID, field.TypeInt)
|
||||
}
|
||||
if value, ok := hu.mutation.EpisodeNums(); ok {
|
||||
_spec.SetField(history.FieldEpisodeNums, field.TypeJSON, value)
|
||||
}
|
||||
if value, ok := hu.mutation.AppendedEpisodeNums(); ok {
|
||||
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
||||
sqljson.Append(u, history.FieldEpisodeNums, value)
|
||||
})
|
||||
}
|
||||
if hu.mutation.EpisodeNumsCleared() {
|
||||
_spec.ClearField(history.FieldEpisodeNums, field.TypeJSON)
|
||||
}
|
||||
if value, ok := hu.mutation.SeasonNum(); ok {
|
||||
_spec.SetField(history.FieldSeasonNum, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := hu.mutation.AddedSeasonNum(); ok {
|
||||
_spec.AddField(history.FieldSeasonNum, field.TypeInt, value)
|
||||
}
|
||||
if hu.mutation.SeasonNumCleared() {
|
||||
_spec.ClearField(history.FieldSeasonNum, field.TypeInt)
|
||||
}
|
||||
if value, ok := hu.mutation.SourceTitle(); ok {
|
||||
_spec.SetField(history.FieldSourceTitle, field.TypeString, value)
|
||||
}
|
||||
@@ -257,6 +397,30 @@ func (hu *HistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if value, ok := hu.mutation.AddedSize(); ok {
|
||||
_spec.AddField(history.FieldSize, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := hu.mutation.DownloadClientID(); ok {
|
||||
_spec.SetField(history.FieldDownloadClientID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := hu.mutation.AddedDownloadClientID(); ok {
|
||||
_spec.AddField(history.FieldDownloadClientID, field.TypeInt, value)
|
||||
}
|
||||
if hu.mutation.DownloadClientIDCleared() {
|
||||
_spec.ClearField(history.FieldDownloadClientID, field.TypeInt)
|
||||
}
|
||||
if value, ok := hu.mutation.IndexerID(); ok {
|
||||
_spec.SetField(history.FieldIndexerID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := hu.mutation.AddedIndexerID(); ok {
|
||||
_spec.AddField(history.FieldIndexerID, field.TypeInt, value)
|
||||
}
|
||||
if hu.mutation.IndexerIDCleared() {
|
||||
_spec.ClearField(history.FieldIndexerID, field.TypeInt)
|
||||
}
|
||||
if value, ok := hu.mutation.Link(); ok {
|
||||
_spec.SetField(history.FieldLink, field.TypeString, value)
|
||||
}
|
||||
if hu.mutation.LinkCleared() {
|
||||
_spec.ClearField(history.FieldLink, field.TypeString)
|
||||
}
|
||||
if value, ok := hu.mutation.Status(); ok {
|
||||
_spec.SetField(history.FieldStatus, field.TypeEnum, value)
|
||||
}
|
||||
@@ -334,6 +498,51 @@ func (huo *HistoryUpdateOne) ClearEpisodeID() *HistoryUpdateOne {
|
||||
return huo
|
||||
}
|
||||
|
||||
// SetEpisodeNums sets the "episode_nums" field.
|
||||
func (huo *HistoryUpdateOne) SetEpisodeNums(i []int) *HistoryUpdateOne {
|
||||
huo.mutation.SetEpisodeNums(i)
|
||||
return huo
|
||||
}
|
||||
|
||||
// AppendEpisodeNums appends i to the "episode_nums" field.
|
||||
func (huo *HistoryUpdateOne) AppendEpisodeNums(i []int) *HistoryUpdateOne {
|
||||
huo.mutation.AppendEpisodeNums(i)
|
||||
return huo
|
||||
}
|
||||
|
||||
// ClearEpisodeNums clears the value of the "episode_nums" field.
|
||||
func (huo *HistoryUpdateOne) ClearEpisodeNums() *HistoryUpdateOne {
|
||||
huo.mutation.ClearEpisodeNums()
|
||||
return huo
|
||||
}
|
||||
|
||||
// SetSeasonNum sets the "season_num" field.
|
||||
func (huo *HistoryUpdateOne) SetSeasonNum(i int) *HistoryUpdateOne {
|
||||
huo.mutation.ResetSeasonNum()
|
||||
huo.mutation.SetSeasonNum(i)
|
||||
return huo
|
||||
}
|
||||
|
||||
// SetNillableSeasonNum sets the "season_num" field if the given value is not nil.
|
||||
func (huo *HistoryUpdateOne) SetNillableSeasonNum(i *int) *HistoryUpdateOne {
|
||||
if i != nil {
|
||||
huo.SetSeasonNum(*i)
|
||||
}
|
||||
return huo
|
||||
}
|
||||
|
||||
// AddSeasonNum adds i to the "season_num" field.
|
||||
func (huo *HistoryUpdateOne) AddSeasonNum(i int) *HistoryUpdateOne {
|
||||
huo.mutation.AddSeasonNum(i)
|
||||
return huo
|
||||
}
|
||||
|
||||
// ClearSeasonNum clears the value of the "season_num" field.
|
||||
func (huo *HistoryUpdateOne) ClearSeasonNum() *HistoryUpdateOne {
|
||||
huo.mutation.ClearSeasonNum()
|
||||
return huo
|
||||
}
|
||||
|
||||
// SetSourceTitle sets the "source_title" field.
|
||||
func (huo *HistoryUpdateOne) SetSourceTitle(s string) *HistoryUpdateOne {
|
||||
huo.mutation.SetSourceTitle(s)
|
||||
@@ -397,6 +606,80 @@ func (huo *HistoryUpdateOne) AddSize(i int) *HistoryUpdateOne {
|
||||
return huo
|
||||
}
|
||||
|
||||
// SetDownloadClientID sets the "download_client_id" field.
|
||||
func (huo *HistoryUpdateOne) SetDownloadClientID(i int) *HistoryUpdateOne {
|
||||
huo.mutation.ResetDownloadClientID()
|
||||
huo.mutation.SetDownloadClientID(i)
|
||||
return huo
|
||||
}
|
||||
|
||||
// SetNillableDownloadClientID sets the "download_client_id" field if the given value is not nil.
|
||||
func (huo *HistoryUpdateOne) SetNillableDownloadClientID(i *int) *HistoryUpdateOne {
|
||||
if i != nil {
|
||||
huo.SetDownloadClientID(*i)
|
||||
}
|
||||
return huo
|
||||
}
|
||||
|
||||
// AddDownloadClientID adds i to the "download_client_id" field.
|
||||
func (huo *HistoryUpdateOne) AddDownloadClientID(i int) *HistoryUpdateOne {
|
||||
huo.mutation.AddDownloadClientID(i)
|
||||
return huo
|
||||
}
|
||||
|
||||
// ClearDownloadClientID clears the value of the "download_client_id" field.
|
||||
func (huo *HistoryUpdateOne) ClearDownloadClientID() *HistoryUpdateOne {
|
||||
huo.mutation.ClearDownloadClientID()
|
||||
return huo
|
||||
}
|
||||
|
||||
// SetIndexerID sets the "indexer_id" field.
|
||||
func (huo *HistoryUpdateOne) SetIndexerID(i int) *HistoryUpdateOne {
|
||||
huo.mutation.ResetIndexerID()
|
||||
huo.mutation.SetIndexerID(i)
|
||||
return huo
|
||||
}
|
||||
|
||||
// SetNillableIndexerID sets the "indexer_id" field if the given value is not nil.
|
||||
func (huo *HistoryUpdateOne) SetNillableIndexerID(i *int) *HistoryUpdateOne {
|
||||
if i != nil {
|
||||
huo.SetIndexerID(*i)
|
||||
}
|
||||
return huo
|
||||
}
|
||||
|
||||
// AddIndexerID adds i to the "indexer_id" field.
|
||||
func (huo *HistoryUpdateOne) AddIndexerID(i int) *HistoryUpdateOne {
|
||||
huo.mutation.AddIndexerID(i)
|
||||
return huo
|
||||
}
|
||||
|
||||
// ClearIndexerID clears the value of the "indexer_id" field.
|
||||
func (huo *HistoryUpdateOne) ClearIndexerID() *HistoryUpdateOne {
|
||||
huo.mutation.ClearIndexerID()
|
||||
return huo
|
||||
}
|
||||
|
||||
// SetLink sets the "link" field.
|
||||
func (huo *HistoryUpdateOne) SetLink(s string) *HistoryUpdateOne {
|
||||
huo.mutation.SetLink(s)
|
||||
return huo
|
||||
}
|
||||
|
||||
// SetNillableLink sets the "link" field if the given value is not nil.
|
||||
func (huo *HistoryUpdateOne) SetNillableLink(s *string) *HistoryUpdateOne {
|
||||
if s != nil {
|
||||
huo.SetLink(*s)
|
||||
}
|
||||
return huo
|
||||
}
|
||||
|
||||
// ClearLink clears the value of the "link" field.
|
||||
func (huo *HistoryUpdateOne) ClearLink() *HistoryUpdateOne {
|
||||
huo.mutation.ClearLink()
|
||||
return huo
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (huo *HistoryUpdateOne) SetStatus(h history.Status) *HistoryUpdateOne {
|
||||
huo.mutation.SetStatus(h)
|
||||
@@ -530,6 +813,26 @@ func (huo *HistoryUpdateOne) sqlSave(ctx context.Context) (_node *History, err e
|
||||
if huo.mutation.EpisodeIDCleared() {
|
||||
_spec.ClearField(history.FieldEpisodeID, field.TypeInt)
|
||||
}
|
||||
if value, ok := huo.mutation.EpisodeNums(); ok {
|
||||
_spec.SetField(history.FieldEpisodeNums, field.TypeJSON, value)
|
||||
}
|
||||
if value, ok := huo.mutation.AppendedEpisodeNums(); ok {
|
||||
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
||||
sqljson.Append(u, history.FieldEpisodeNums, value)
|
||||
})
|
||||
}
|
||||
if huo.mutation.EpisodeNumsCleared() {
|
||||
_spec.ClearField(history.FieldEpisodeNums, field.TypeJSON)
|
||||
}
|
||||
if value, ok := huo.mutation.SeasonNum(); ok {
|
||||
_spec.SetField(history.FieldSeasonNum, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := huo.mutation.AddedSeasonNum(); ok {
|
||||
_spec.AddField(history.FieldSeasonNum, field.TypeInt, value)
|
||||
}
|
||||
if huo.mutation.SeasonNumCleared() {
|
||||
_spec.ClearField(history.FieldSeasonNum, field.TypeInt)
|
||||
}
|
||||
if value, ok := huo.mutation.SourceTitle(); ok {
|
||||
_spec.SetField(history.FieldSourceTitle, field.TypeString, value)
|
||||
}
|
||||
@@ -545,6 +848,30 @@ func (huo *HistoryUpdateOne) sqlSave(ctx context.Context) (_node *History, err e
|
||||
if value, ok := huo.mutation.AddedSize(); ok {
|
||||
_spec.AddField(history.FieldSize, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := huo.mutation.DownloadClientID(); ok {
|
||||
_spec.SetField(history.FieldDownloadClientID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := huo.mutation.AddedDownloadClientID(); ok {
|
||||
_spec.AddField(history.FieldDownloadClientID, field.TypeInt, value)
|
||||
}
|
||||
if huo.mutation.DownloadClientIDCleared() {
|
||||
_spec.ClearField(history.FieldDownloadClientID, field.TypeInt)
|
||||
}
|
||||
if value, ok := huo.mutation.IndexerID(); ok {
|
||||
_spec.SetField(history.FieldIndexerID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := huo.mutation.AddedIndexerID(); ok {
|
||||
_spec.AddField(history.FieldIndexerID, field.TypeInt, value)
|
||||
}
|
||||
if huo.mutation.IndexerIDCleared() {
|
||||
_spec.ClearField(history.FieldIndexerID, field.TypeInt)
|
||||
}
|
||||
if value, ok := huo.mutation.Link(); ok {
|
||||
_spec.SetField(history.FieldLink, field.TypeString, value)
|
||||
}
|
||||
if huo.mutation.LinkCleared() {
|
||||
_spec.ClearField(history.FieldLink, field.TypeString)
|
||||
}
|
||||
if value, ok := huo.mutation.Status(); ok {
|
||||
_spec.SetField(history.FieldStatus, field.TypeEnum, value)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,18 @@ import (
|
||||
"polaris/ent"
|
||||
)
|
||||
|
||||
// The BlacklistFunc type is an adapter to allow the use of ordinary
|
||||
// function as Blacklist mutator.
|
||||
type BlacklistFunc func(context.Context, *ent.BlacklistMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f BlacklistFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.BlacklistMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.BlacklistMutation", m)
|
||||
}
|
||||
|
||||
// The DownloadClientsFunc type is an adapter to allow the use of ordinary
|
||||
// function as DownloadClients mutator.
|
||||
type DownloadClientsFunc func(context.Context, *ent.DownloadClientsMutation) (ent.Value, error)
|
||||
@@ -44,6 +56,18 @@ func (f HistoryFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, err
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.HistoryMutation", m)
|
||||
}
|
||||
|
||||
// The ImportListFunc type is an adapter to allow the use of ordinary
|
||||
// function as ImportList mutator.
|
||||
type ImportListFunc func(context.Context, *ent.ImportListMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f ImportListFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.ImportListMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ImportListMutation", m)
|
||||
}
|
||||
|
||||
// The IndexersFunc type is an adapter to allow the use of ordinary
|
||||
// function as Indexers mutator.
|
||||
type IndexersFunc func(context.Context, *ent.IndexersMutation) (ent.Value, error)
|
||||
@@ -68,6 +92,18 @@ func (f MediaFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MediaMutation", m)
|
||||
}
|
||||
|
||||
// The NotificationClientFunc type is an adapter to allow the use of ordinary
|
||||
// function as NotificationClient mutator.
|
||||
type NotificationClientFunc func(context.Context, *ent.NotificationClientMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f NotificationClientFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.NotificationClientMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.NotificationClientMutation", m)
|
||||
}
|
||||
|
||||
// The SettingsFunc type is an adapter to allow the use of ordinary
|
||||
// function as Settings mutator.
|
||||
type SettingsFunc func(context.Context, *ent.SettingsMutation) (ent.Value, error)
|
||||
|
||||
164
ent/importlist.go
Normal file
@@ -0,0 +1,164 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"polaris/ent/importlist"
|
||||
"polaris/ent/schema"
|
||||
"strings"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// ImportList is the model entity for the ImportList schema.
|
||||
type ImportList struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// Name holds the value of the "name" field.
|
||||
Name string `json:"name,omitempty"`
|
||||
// Type holds the value of the "type" field.
|
||||
Type importlist.Type `json:"type,omitempty"`
|
||||
// URL holds the value of the "url" field.
|
||||
URL string `json:"url,omitempty"`
|
||||
// Qulity holds the value of the "qulity" field.
|
||||
Qulity string `json:"qulity,omitempty"`
|
||||
// StorageID holds the value of the "storage_id" field.
|
||||
StorageID int `json:"storage_id,omitempty"`
|
||||
// Settings holds the value of the "settings" field.
|
||||
Settings schema.ImportListSettings `json:"settings,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*ImportList) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case importlist.FieldSettings:
|
||||
values[i] = new([]byte)
|
||||
case importlist.FieldID, importlist.FieldStorageID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case importlist.FieldName, importlist.FieldType, importlist.FieldURL, importlist.FieldQulity:
|
||||
values[i] = new(sql.NullString)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the ImportList fields.
|
||||
func (il *ImportList) 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 importlist.FieldID:
|
||||
value, ok := values[i].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
il.ID = int(value.Int64)
|
||||
case importlist.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
} else if value.Valid {
|
||||
il.Name = value.String
|
||||
}
|
||||
case importlist.FieldType:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field type", values[i])
|
||||
} else if value.Valid {
|
||||
il.Type = importlist.Type(value.String)
|
||||
}
|
||||
case importlist.FieldURL:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field url", values[i])
|
||||
} else if value.Valid {
|
||||
il.URL = value.String
|
||||
}
|
||||
case importlist.FieldQulity:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field qulity", values[i])
|
||||
} else if value.Valid {
|
||||
il.Qulity = value.String
|
||||
}
|
||||
case importlist.FieldStorageID:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field storage_id", values[i])
|
||||
} else if value.Valid {
|
||||
il.StorageID = int(value.Int64)
|
||||
}
|
||||
case importlist.FieldSettings:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field settings", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
if err := json.Unmarshal(*value, &il.Settings); err != nil {
|
||||
return fmt.Errorf("unmarshal field settings: %w", err)
|
||||
}
|
||||
}
|
||||
default:
|
||||
il.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the ImportList.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (il *ImportList) Value(name string) (ent.Value, error) {
|
||||
return il.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this ImportList.
|
||||
// Note that you need to call ImportList.Unwrap() before calling this method if this ImportList
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (il *ImportList) Update() *ImportListUpdateOne {
|
||||
return NewImportListClient(il.config).UpdateOne(il)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the ImportList 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 (il *ImportList) Unwrap() *ImportList {
|
||||
_tx, ok := il.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: ImportList is not a transactional entity")
|
||||
}
|
||||
il.config.driver = _tx.drv
|
||||
return il
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (il *ImportList) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("ImportList(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", il.ID))
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(il.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("type=")
|
||||
builder.WriteString(fmt.Sprintf("%v", il.Type))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("url=")
|
||||
builder.WriteString(il.URL)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("qulity=")
|
||||
builder.WriteString(il.Qulity)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("storage_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", il.StorageID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("settings=")
|
||||
builder.WriteString(fmt.Sprintf("%v", il.Settings))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// ImportLists is a parsable slice of ImportList.
|
||||
type ImportLists []*ImportList
|
||||
107
ent/importlist/importlist.go
Normal file
@@ -0,0 +1,107 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package importlist
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the importlist type in the database.
|
||||
Label = "import_list"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldName holds the string denoting the name field in the database.
|
||||
FieldName = "name"
|
||||
// FieldType holds the string denoting the type field in the database.
|
||||
FieldType = "type"
|
||||
// FieldURL holds the string denoting the url field in the database.
|
||||
FieldURL = "url"
|
||||
// FieldQulity holds the string denoting the qulity field in the database.
|
||||
FieldQulity = "qulity"
|
||||
// FieldStorageID holds the string denoting the storage_id field in the database.
|
||||
FieldStorageID = "storage_id"
|
||||
// FieldSettings holds the string denoting the settings field in the database.
|
||||
FieldSettings = "settings"
|
||||
// Table holds the table name of the importlist in the database.
|
||||
Table = "import_lists"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for importlist fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldName,
|
||||
FieldType,
|
||||
FieldURL,
|
||||
FieldQulity,
|
||||
FieldStorageID,
|
||||
FieldSettings,
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// Type defines the type for the "type" enum field.
|
||||
type Type string
|
||||
|
||||
// Type values.
|
||||
const (
|
||||
TypePlex Type = "plex"
|
||||
TypeDoulist Type = "doulist"
|
||||
)
|
||||
|
||||
func (_type Type) String() string {
|
||||
return string(_type)
|
||||
}
|
||||
|
||||
// TypeValidator is a validator for the "type" field enum values. It is called by the builders before save.
|
||||
func TypeValidator(_type Type) error {
|
||||
switch _type {
|
||||
case TypePlex, TypeDoulist:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("importlist: invalid enum value for type field: %q", _type)
|
||||
}
|
||||
}
|
||||
|
||||
// OrderOption defines the ordering options for the ImportList 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()
|
||||
}
|
||||
|
||||
// ByName orders the results by the name field.
|
||||
func ByName(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldName, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByType orders the results by the type field.
|
||||
func ByType(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldType, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByURL orders the results by the url field.
|
||||
func ByURL(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldURL, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByQulity orders the results by the qulity field.
|
||||
func ByQulity(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldQulity, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByStorageID orders the results by the storage_id field.
|
||||
func ByStorageID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldStorageID, opts...).ToFunc()
|
||||
}
|
||||
364
ent/importlist/where.go
Normal file
@@ -0,0 +1,364 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package importlist
|
||||
|
||||
import (
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id int) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
|
||||
func Name(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// URL applies equality check predicate on the "url" field. It's identical to URLEQ.
|
||||
func URL(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldEQ(FieldURL, v))
|
||||
}
|
||||
|
||||
// Qulity applies equality check predicate on the "qulity" field. It's identical to QulityEQ.
|
||||
func Qulity(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldEQ(FieldQulity, v))
|
||||
}
|
||||
|
||||
// StorageID applies equality check predicate on the "storage_id" field. It's identical to StorageIDEQ.
|
||||
func StorageID(v int) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldEQ(FieldStorageID, v))
|
||||
}
|
||||
|
||||
// NameEQ applies the EQ predicate on the "name" field.
|
||||
func NameEQ(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// NameNEQ applies the NEQ predicate on the "name" field.
|
||||
func NameNEQ(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldNEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// NameIn applies the In predicate on the "name" field.
|
||||
func NameIn(vs ...string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldIn(FieldName, vs...))
|
||||
}
|
||||
|
||||
// NameNotIn applies the NotIn predicate on the "name" field.
|
||||
func NameNotIn(vs ...string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldNotIn(FieldName, vs...))
|
||||
}
|
||||
|
||||
// NameGT applies the GT predicate on the "name" field.
|
||||
func NameGT(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldGT(FieldName, v))
|
||||
}
|
||||
|
||||
// NameGTE applies the GTE predicate on the "name" field.
|
||||
func NameGTE(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldGTE(FieldName, v))
|
||||
}
|
||||
|
||||
// NameLT applies the LT predicate on the "name" field.
|
||||
func NameLT(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldLT(FieldName, v))
|
||||
}
|
||||
|
||||
// NameLTE applies the LTE predicate on the "name" field.
|
||||
func NameLTE(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldLTE(FieldName, v))
|
||||
}
|
||||
|
||||
// NameContains applies the Contains predicate on the "name" field.
|
||||
func NameContains(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldContains(FieldName, v))
|
||||
}
|
||||
|
||||
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
|
||||
func NameHasPrefix(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldHasPrefix(FieldName, v))
|
||||
}
|
||||
|
||||
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
|
||||
func NameHasSuffix(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldHasSuffix(FieldName, v))
|
||||
}
|
||||
|
||||
// NameEqualFold applies the EqualFold predicate on the "name" field.
|
||||
func NameEqualFold(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldEqualFold(FieldName, v))
|
||||
}
|
||||
|
||||
// NameContainsFold applies the ContainsFold predicate on the "name" field.
|
||||
func NameContainsFold(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldContainsFold(FieldName, v))
|
||||
}
|
||||
|
||||
// TypeEQ applies the EQ predicate on the "type" field.
|
||||
func TypeEQ(v Type) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldEQ(FieldType, v))
|
||||
}
|
||||
|
||||
// TypeNEQ applies the NEQ predicate on the "type" field.
|
||||
func TypeNEQ(v Type) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldNEQ(FieldType, v))
|
||||
}
|
||||
|
||||
// TypeIn applies the In predicate on the "type" field.
|
||||
func TypeIn(vs ...Type) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldIn(FieldType, vs...))
|
||||
}
|
||||
|
||||
// TypeNotIn applies the NotIn predicate on the "type" field.
|
||||
func TypeNotIn(vs ...Type) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldNotIn(FieldType, vs...))
|
||||
}
|
||||
|
||||
// URLEQ applies the EQ predicate on the "url" field.
|
||||
func URLEQ(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldEQ(FieldURL, v))
|
||||
}
|
||||
|
||||
// URLNEQ applies the NEQ predicate on the "url" field.
|
||||
func URLNEQ(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldNEQ(FieldURL, v))
|
||||
}
|
||||
|
||||
// URLIn applies the In predicate on the "url" field.
|
||||
func URLIn(vs ...string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldIn(FieldURL, vs...))
|
||||
}
|
||||
|
||||
// URLNotIn applies the NotIn predicate on the "url" field.
|
||||
func URLNotIn(vs ...string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldNotIn(FieldURL, vs...))
|
||||
}
|
||||
|
||||
// URLGT applies the GT predicate on the "url" field.
|
||||
func URLGT(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldGT(FieldURL, v))
|
||||
}
|
||||
|
||||
// URLGTE applies the GTE predicate on the "url" field.
|
||||
func URLGTE(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldGTE(FieldURL, v))
|
||||
}
|
||||
|
||||
// URLLT applies the LT predicate on the "url" field.
|
||||
func URLLT(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldLT(FieldURL, v))
|
||||
}
|
||||
|
||||
// URLLTE applies the LTE predicate on the "url" field.
|
||||
func URLLTE(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldLTE(FieldURL, v))
|
||||
}
|
||||
|
||||
// URLContains applies the Contains predicate on the "url" field.
|
||||
func URLContains(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldContains(FieldURL, v))
|
||||
}
|
||||
|
||||
// URLHasPrefix applies the HasPrefix predicate on the "url" field.
|
||||
func URLHasPrefix(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldHasPrefix(FieldURL, v))
|
||||
}
|
||||
|
||||
// URLHasSuffix applies the HasSuffix predicate on the "url" field.
|
||||
func URLHasSuffix(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldHasSuffix(FieldURL, v))
|
||||
}
|
||||
|
||||
// URLIsNil applies the IsNil predicate on the "url" field.
|
||||
func URLIsNil() predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldIsNull(FieldURL))
|
||||
}
|
||||
|
||||
// URLNotNil applies the NotNil predicate on the "url" field.
|
||||
func URLNotNil() predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldNotNull(FieldURL))
|
||||
}
|
||||
|
||||
// URLEqualFold applies the EqualFold predicate on the "url" field.
|
||||
func URLEqualFold(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldEqualFold(FieldURL, v))
|
||||
}
|
||||
|
||||
// URLContainsFold applies the ContainsFold predicate on the "url" field.
|
||||
func URLContainsFold(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldContainsFold(FieldURL, v))
|
||||
}
|
||||
|
||||
// QulityEQ applies the EQ predicate on the "qulity" field.
|
||||
func QulityEQ(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldEQ(FieldQulity, v))
|
||||
}
|
||||
|
||||
// QulityNEQ applies the NEQ predicate on the "qulity" field.
|
||||
func QulityNEQ(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldNEQ(FieldQulity, v))
|
||||
}
|
||||
|
||||
// QulityIn applies the In predicate on the "qulity" field.
|
||||
func QulityIn(vs ...string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldIn(FieldQulity, vs...))
|
||||
}
|
||||
|
||||
// QulityNotIn applies the NotIn predicate on the "qulity" field.
|
||||
func QulityNotIn(vs ...string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldNotIn(FieldQulity, vs...))
|
||||
}
|
||||
|
||||
// QulityGT applies the GT predicate on the "qulity" field.
|
||||
func QulityGT(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldGT(FieldQulity, v))
|
||||
}
|
||||
|
||||
// QulityGTE applies the GTE predicate on the "qulity" field.
|
||||
func QulityGTE(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldGTE(FieldQulity, v))
|
||||
}
|
||||
|
||||
// QulityLT applies the LT predicate on the "qulity" field.
|
||||
func QulityLT(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldLT(FieldQulity, v))
|
||||
}
|
||||
|
||||
// QulityLTE applies the LTE predicate on the "qulity" field.
|
||||
func QulityLTE(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldLTE(FieldQulity, v))
|
||||
}
|
||||
|
||||
// QulityContains applies the Contains predicate on the "qulity" field.
|
||||
func QulityContains(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldContains(FieldQulity, v))
|
||||
}
|
||||
|
||||
// QulityHasPrefix applies the HasPrefix predicate on the "qulity" field.
|
||||
func QulityHasPrefix(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldHasPrefix(FieldQulity, v))
|
||||
}
|
||||
|
||||
// QulityHasSuffix applies the HasSuffix predicate on the "qulity" field.
|
||||
func QulityHasSuffix(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldHasSuffix(FieldQulity, v))
|
||||
}
|
||||
|
||||
// QulityEqualFold applies the EqualFold predicate on the "qulity" field.
|
||||
func QulityEqualFold(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldEqualFold(FieldQulity, v))
|
||||
}
|
||||
|
||||
// QulityContainsFold applies the ContainsFold predicate on the "qulity" field.
|
||||
func QulityContainsFold(v string) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldContainsFold(FieldQulity, v))
|
||||
}
|
||||
|
||||
// StorageIDEQ applies the EQ predicate on the "storage_id" field.
|
||||
func StorageIDEQ(v int) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldEQ(FieldStorageID, v))
|
||||
}
|
||||
|
||||
// StorageIDNEQ applies the NEQ predicate on the "storage_id" field.
|
||||
func StorageIDNEQ(v int) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldNEQ(FieldStorageID, v))
|
||||
}
|
||||
|
||||
// StorageIDIn applies the In predicate on the "storage_id" field.
|
||||
func StorageIDIn(vs ...int) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldIn(FieldStorageID, vs...))
|
||||
}
|
||||
|
||||
// StorageIDNotIn applies the NotIn predicate on the "storage_id" field.
|
||||
func StorageIDNotIn(vs ...int) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldNotIn(FieldStorageID, vs...))
|
||||
}
|
||||
|
||||
// StorageIDGT applies the GT predicate on the "storage_id" field.
|
||||
func StorageIDGT(v int) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldGT(FieldStorageID, v))
|
||||
}
|
||||
|
||||
// StorageIDGTE applies the GTE predicate on the "storage_id" field.
|
||||
func StorageIDGTE(v int) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldGTE(FieldStorageID, v))
|
||||
}
|
||||
|
||||
// StorageIDLT applies the LT predicate on the "storage_id" field.
|
||||
func StorageIDLT(v int) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldLT(FieldStorageID, v))
|
||||
}
|
||||
|
||||
// StorageIDLTE applies the LTE predicate on the "storage_id" field.
|
||||
func StorageIDLTE(v int) predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldLTE(FieldStorageID, v))
|
||||
}
|
||||
|
||||
// SettingsIsNil applies the IsNil predicate on the "settings" field.
|
||||
func SettingsIsNil() predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldIsNull(FieldSettings))
|
||||
}
|
||||
|
||||
// SettingsNotNil applies the NotNil predicate on the "settings" field.
|
||||
func SettingsNotNil() predicate.ImportList {
|
||||
return predicate.ImportList(sql.FieldNotNull(FieldSettings))
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.ImportList) predicate.ImportList {
|
||||
return predicate.ImportList(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.ImportList) predicate.ImportList {
|
||||
return predicate.ImportList(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.ImportList) predicate.ImportList {
|
||||
return predicate.ImportList(sql.NotPredicates(p))
|
||||
}
|
||||
264
ent/importlist_create.go
Normal file
@@ -0,0 +1,264 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/importlist"
|
||||
"polaris/ent/schema"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// ImportListCreate is the builder for creating a ImportList entity.
|
||||
type ImportListCreate struct {
|
||||
config
|
||||
mutation *ImportListMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (ilc *ImportListCreate) SetName(s string) *ImportListCreate {
|
||||
ilc.mutation.SetName(s)
|
||||
return ilc
|
||||
}
|
||||
|
||||
// SetType sets the "type" field.
|
||||
func (ilc *ImportListCreate) SetType(i importlist.Type) *ImportListCreate {
|
||||
ilc.mutation.SetType(i)
|
||||
return ilc
|
||||
}
|
||||
|
||||
// SetURL sets the "url" field.
|
||||
func (ilc *ImportListCreate) SetURL(s string) *ImportListCreate {
|
||||
ilc.mutation.SetURL(s)
|
||||
return ilc
|
||||
}
|
||||
|
||||
// SetNillableURL sets the "url" field if the given value is not nil.
|
||||
func (ilc *ImportListCreate) SetNillableURL(s *string) *ImportListCreate {
|
||||
if s != nil {
|
||||
ilc.SetURL(*s)
|
||||
}
|
||||
return ilc
|
||||
}
|
||||
|
||||
// SetQulity sets the "qulity" field.
|
||||
func (ilc *ImportListCreate) SetQulity(s string) *ImportListCreate {
|
||||
ilc.mutation.SetQulity(s)
|
||||
return ilc
|
||||
}
|
||||
|
||||
// SetStorageID sets the "storage_id" field.
|
||||
func (ilc *ImportListCreate) SetStorageID(i int) *ImportListCreate {
|
||||
ilc.mutation.SetStorageID(i)
|
||||
return ilc
|
||||
}
|
||||
|
||||
// SetSettings sets the "settings" field.
|
||||
func (ilc *ImportListCreate) SetSettings(sls schema.ImportListSettings) *ImportListCreate {
|
||||
ilc.mutation.SetSettings(sls)
|
||||
return ilc
|
||||
}
|
||||
|
||||
// SetNillableSettings sets the "settings" field if the given value is not nil.
|
||||
func (ilc *ImportListCreate) SetNillableSettings(sls *schema.ImportListSettings) *ImportListCreate {
|
||||
if sls != nil {
|
||||
ilc.SetSettings(*sls)
|
||||
}
|
||||
return ilc
|
||||
}
|
||||
|
||||
// Mutation returns the ImportListMutation object of the builder.
|
||||
func (ilc *ImportListCreate) Mutation() *ImportListMutation {
|
||||
return ilc.mutation
|
||||
}
|
||||
|
||||
// Save creates the ImportList in the database.
|
||||
func (ilc *ImportListCreate) Save(ctx context.Context) (*ImportList, error) {
|
||||
return withHooks(ctx, ilc.sqlSave, ilc.mutation, ilc.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (ilc *ImportListCreate) SaveX(ctx context.Context) *ImportList {
|
||||
v, err := ilc.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (ilc *ImportListCreate) Exec(ctx context.Context) error {
|
||||
_, err := ilc.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ilc *ImportListCreate) ExecX(ctx context.Context) {
|
||||
if err := ilc.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (ilc *ImportListCreate) check() error {
|
||||
if _, ok := ilc.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "ImportList.name"`)}
|
||||
}
|
||||
if _, ok := ilc.mutation.GetType(); !ok {
|
||||
return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "ImportList.type"`)}
|
||||
}
|
||||
if v, ok := ilc.mutation.GetType(); ok {
|
||||
if err := importlist.TypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "ImportList.type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := ilc.mutation.Qulity(); !ok {
|
||||
return &ValidationError{Name: "qulity", err: errors.New(`ent: missing required field "ImportList.qulity"`)}
|
||||
}
|
||||
if _, ok := ilc.mutation.StorageID(); !ok {
|
||||
return &ValidationError{Name: "storage_id", err: errors.New(`ent: missing required field "ImportList.storage_id"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ilc *ImportListCreate) sqlSave(ctx context.Context) (*ImportList, error) {
|
||||
if err := ilc.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := ilc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, ilc.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 = int(id)
|
||||
ilc.mutation.id = &_node.ID
|
||||
ilc.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (ilc *ImportListCreate) createSpec() (*ImportList, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &ImportList{config: ilc.config}
|
||||
_spec = sqlgraph.NewCreateSpec(importlist.Table, sqlgraph.NewFieldSpec(importlist.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := ilc.mutation.Name(); ok {
|
||||
_spec.SetField(importlist.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := ilc.mutation.GetType(); ok {
|
||||
_spec.SetField(importlist.FieldType, field.TypeEnum, value)
|
||||
_node.Type = value
|
||||
}
|
||||
if value, ok := ilc.mutation.URL(); ok {
|
||||
_spec.SetField(importlist.FieldURL, field.TypeString, value)
|
||||
_node.URL = value
|
||||
}
|
||||
if value, ok := ilc.mutation.Qulity(); ok {
|
||||
_spec.SetField(importlist.FieldQulity, field.TypeString, value)
|
||||
_node.Qulity = value
|
||||
}
|
||||
if value, ok := ilc.mutation.StorageID(); ok {
|
||||
_spec.SetField(importlist.FieldStorageID, field.TypeInt, value)
|
||||
_node.StorageID = value
|
||||
}
|
||||
if value, ok := ilc.mutation.Settings(); ok {
|
||||
_spec.SetField(importlist.FieldSettings, field.TypeJSON, value)
|
||||
_node.Settings = value
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// ImportListCreateBulk is the builder for creating many ImportList entities in bulk.
|
||||
type ImportListCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*ImportListCreate
|
||||
}
|
||||
|
||||
// Save creates the ImportList entities in the database.
|
||||
func (ilcb *ImportListCreateBulk) Save(ctx context.Context) ([]*ImportList, error) {
|
||||
if ilcb.err != nil {
|
||||
return nil, ilcb.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(ilcb.builders))
|
||||
nodes := make([]*ImportList, len(ilcb.builders))
|
||||
mutators := make([]Mutator, len(ilcb.builders))
|
||||
for i := range ilcb.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := ilcb.builders[i]
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*ImportListMutation)
|
||||
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, ilcb.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, ilcb.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 = int(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, ilcb.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (ilcb *ImportListCreateBulk) SaveX(ctx context.Context) []*ImportList {
|
||||
v, err := ilcb.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (ilcb *ImportListCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := ilcb.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ilcb *ImportListCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := ilcb.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
88
ent/importlist_delete.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"polaris/ent/importlist"
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// ImportListDelete is the builder for deleting a ImportList entity.
|
||||
type ImportListDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *ImportListMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ImportListDelete builder.
|
||||
func (ild *ImportListDelete) Where(ps ...predicate.ImportList) *ImportListDelete {
|
||||
ild.mutation.Where(ps...)
|
||||
return ild
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (ild *ImportListDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, ild.sqlExec, ild.mutation, ild.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ild *ImportListDelete) ExecX(ctx context.Context) int {
|
||||
n, err := ild.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (ild *ImportListDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(importlist.Table, sqlgraph.NewFieldSpec(importlist.FieldID, field.TypeInt))
|
||||
if ps := ild.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, ild.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
ild.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// ImportListDeleteOne is the builder for deleting a single ImportList entity.
|
||||
type ImportListDeleteOne struct {
|
||||
ild *ImportListDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ImportListDelete builder.
|
||||
func (ildo *ImportListDeleteOne) Where(ps ...predicate.ImportList) *ImportListDeleteOne {
|
||||
ildo.ild.mutation.Where(ps...)
|
||||
return ildo
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (ildo *ImportListDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := ildo.ild.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{importlist.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ildo *ImportListDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := ildo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
526
ent/importlist_query.go
Normal file
@@ -0,0 +1,526 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"polaris/ent/importlist"
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// ImportListQuery is the builder for querying ImportList entities.
|
||||
type ImportListQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []importlist.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.ImportList
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the ImportListQuery builder.
|
||||
func (ilq *ImportListQuery) Where(ps ...predicate.ImportList) *ImportListQuery {
|
||||
ilq.predicates = append(ilq.predicates, ps...)
|
||||
return ilq
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (ilq *ImportListQuery) Limit(limit int) *ImportListQuery {
|
||||
ilq.ctx.Limit = &limit
|
||||
return ilq
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (ilq *ImportListQuery) Offset(offset int) *ImportListQuery {
|
||||
ilq.ctx.Offset = &offset
|
||||
return ilq
|
||||
}
|
||||
|
||||
// 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 (ilq *ImportListQuery) Unique(unique bool) *ImportListQuery {
|
||||
ilq.ctx.Unique = &unique
|
||||
return ilq
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (ilq *ImportListQuery) Order(o ...importlist.OrderOption) *ImportListQuery {
|
||||
ilq.order = append(ilq.order, o...)
|
||||
return ilq
|
||||
}
|
||||
|
||||
// First returns the first ImportList entity from the query.
|
||||
// Returns a *NotFoundError when no ImportList was found.
|
||||
func (ilq *ImportListQuery) First(ctx context.Context) (*ImportList, error) {
|
||||
nodes, err := ilq.Limit(1).All(setContextOp(ctx, ilq.ctx, "First"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{importlist.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (ilq *ImportListQuery) FirstX(ctx context.Context) *ImportList {
|
||||
node, err := ilq.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first ImportList ID from the query.
|
||||
// Returns a *NotFoundError when no ImportList ID was found.
|
||||
func (ilq *ImportListQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = ilq.Limit(1).IDs(setContextOp(ctx, ilq.ctx, "FirstID")); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{importlist.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (ilq *ImportListQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := ilq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single ImportList entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one ImportList entity is found.
|
||||
// Returns a *NotFoundError when no ImportList entities are found.
|
||||
func (ilq *ImportListQuery) Only(ctx context.Context) (*ImportList, error) {
|
||||
nodes, err := ilq.Limit(2).All(setContextOp(ctx, ilq.ctx, "Only"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{importlist.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{importlist.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (ilq *ImportListQuery) OnlyX(ctx context.Context) *ImportList {
|
||||
node, err := ilq.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only ImportList ID in the query.
|
||||
// Returns a *NotSingularError when more than one ImportList ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (ilq *ImportListQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = ilq.Limit(2).IDs(setContextOp(ctx, ilq.ctx, "OnlyID")); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{importlist.Label}
|
||||
default:
|
||||
err = &NotSingularError{importlist.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (ilq *ImportListQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := ilq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of ImportLists.
|
||||
func (ilq *ImportListQuery) All(ctx context.Context) ([]*ImportList, error) {
|
||||
ctx = setContextOp(ctx, ilq.ctx, "All")
|
||||
if err := ilq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*ImportList, *ImportListQuery]()
|
||||
return withInterceptors[[]*ImportList](ctx, ilq, qr, ilq.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (ilq *ImportListQuery) AllX(ctx context.Context) []*ImportList {
|
||||
nodes, err := ilq.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of ImportList IDs.
|
||||
func (ilq *ImportListQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if ilq.ctx.Unique == nil && ilq.path != nil {
|
||||
ilq.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, ilq.ctx, "IDs")
|
||||
if err = ilq.Select(importlist.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (ilq *ImportListQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := ilq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (ilq *ImportListQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, ilq.ctx, "Count")
|
||||
if err := ilq.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, ilq, querierCount[*ImportListQuery](), ilq.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (ilq *ImportListQuery) CountX(ctx context.Context) int {
|
||||
count, err := ilq.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (ilq *ImportListQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, ilq.ctx, "Exist")
|
||||
switch _, err := ilq.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 (ilq *ImportListQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := ilq.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the ImportListQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (ilq *ImportListQuery) Clone() *ImportListQuery {
|
||||
if ilq == nil {
|
||||
return nil
|
||||
}
|
||||
return &ImportListQuery{
|
||||
config: ilq.config,
|
||||
ctx: ilq.ctx.Clone(),
|
||||
order: append([]importlist.OrderOption{}, ilq.order...),
|
||||
inters: append([]Interceptor{}, ilq.inters...),
|
||||
predicates: append([]predicate.ImportList{}, ilq.predicates...),
|
||||
// clone intermediate query.
|
||||
sql: ilq.sql.Clone(),
|
||||
path: ilq.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 {
|
||||
// Name string `json:"name,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.ImportList.Query().
|
||||
// GroupBy(importlist.FieldName).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (ilq *ImportListQuery) GroupBy(field string, fields ...string) *ImportListGroupBy {
|
||||
ilq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &ImportListGroupBy{build: ilq}
|
||||
grbuild.flds = &ilq.ctx.Fields
|
||||
grbuild.label = importlist.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 {
|
||||
// Name string `json:"name,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.ImportList.Query().
|
||||
// Select(importlist.FieldName).
|
||||
// Scan(ctx, &v)
|
||||
func (ilq *ImportListQuery) Select(fields ...string) *ImportListSelect {
|
||||
ilq.ctx.Fields = append(ilq.ctx.Fields, fields...)
|
||||
sbuild := &ImportListSelect{ImportListQuery: ilq}
|
||||
sbuild.label = importlist.Label
|
||||
sbuild.flds, sbuild.scan = &ilq.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a ImportListSelect configured with the given aggregations.
|
||||
func (ilq *ImportListQuery) Aggregate(fns ...AggregateFunc) *ImportListSelect {
|
||||
return ilq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (ilq *ImportListQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range ilq.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, ilq); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range ilq.ctx.Fields {
|
||||
if !importlist.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if ilq.path != nil {
|
||||
prev, err := ilq.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ilq.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ilq *ImportListQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ImportList, error) {
|
||||
var (
|
||||
nodes = []*ImportList{}
|
||||
_spec = ilq.querySpec()
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*ImportList).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &ImportList{config: ilq.config}
|
||||
nodes = append(nodes, node)
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, ilq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (ilq *ImportListQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := ilq.querySpec()
|
||||
_spec.Node.Columns = ilq.ctx.Fields
|
||||
if len(ilq.ctx.Fields) > 0 {
|
||||
_spec.Unique = ilq.ctx.Unique != nil && *ilq.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, ilq.driver, _spec)
|
||||
}
|
||||
|
||||
func (ilq *ImportListQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(importlist.Table, importlist.Columns, sqlgraph.NewFieldSpec(importlist.FieldID, field.TypeInt))
|
||||
_spec.From = ilq.sql
|
||||
if unique := ilq.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if ilq.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := ilq.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, importlist.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != importlist.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := ilq.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := ilq.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := ilq.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := ilq.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (ilq *ImportListQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(ilq.driver.Dialect())
|
||||
t1 := builder.Table(importlist.Table)
|
||||
columns := ilq.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = importlist.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if ilq.sql != nil {
|
||||
selector = ilq.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if ilq.ctx.Unique != nil && *ilq.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range ilq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range ilq.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := ilq.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 := ilq.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// ImportListGroupBy is the group-by builder for ImportList entities.
|
||||
type ImportListGroupBy struct {
|
||||
selector
|
||||
build *ImportListQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (ilgb *ImportListGroupBy) Aggregate(fns ...AggregateFunc) *ImportListGroupBy {
|
||||
ilgb.fns = append(ilgb.fns, fns...)
|
||||
return ilgb
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ilgb *ImportListGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ilgb.build.ctx, "GroupBy")
|
||||
if err := ilgb.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*ImportListQuery, *ImportListGroupBy](ctx, ilgb.build, ilgb, ilgb.build.inters, v)
|
||||
}
|
||||
|
||||
func (ilgb *ImportListGroupBy) sqlScan(ctx context.Context, root *ImportListQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(ilgb.fns))
|
||||
for _, fn := range ilgb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*ilgb.flds)+len(ilgb.fns))
|
||||
for _, f := range *ilgb.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*ilgb.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := ilgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// ImportListSelect is the builder for selecting fields of ImportList entities.
|
||||
type ImportListSelect struct {
|
||||
*ImportListQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ils *ImportListSelect) Aggregate(fns ...AggregateFunc) *ImportListSelect {
|
||||
ils.fns = append(ils.fns, fns...)
|
||||
return ils
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ils *ImportListSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ils.ctx, "Select")
|
||||
if err := ils.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*ImportListQuery, *ImportListSelect](ctx, ils.ImportListQuery, ils, ils.inters, v)
|
||||
}
|
||||
|
||||
func (ils *ImportListSelect) sqlScan(ctx context.Context, root *ImportListQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(ils.fns))
|
||||
for _, fn := range ils.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*ils.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 := ils.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
462
ent/importlist_update.go
Normal file
@@ -0,0 +1,462 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/importlist"
|
||||
"polaris/ent/predicate"
|
||||
"polaris/ent/schema"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// ImportListUpdate is the builder for updating ImportList entities.
|
||||
type ImportListUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *ImportListMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ImportListUpdate builder.
|
||||
func (ilu *ImportListUpdate) Where(ps ...predicate.ImportList) *ImportListUpdate {
|
||||
ilu.mutation.Where(ps...)
|
||||
return ilu
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (ilu *ImportListUpdate) SetName(s string) *ImportListUpdate {
|
||||
ilu.mutation.SetName(s)
|
||||
return ilu
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (ilu *ImportListUpdate) SetNillableName(s *string) *ImportListUpdate {
|
||||
if s != nil {
|
||||
ilu.SetName(*s)
|
||||
}
|
||||
return ilu
|
||||
}
|
||||
|
||||
// SetType sets the "type" field.
|
||||
func (ilu *ImportListUpdate) SetType(i importlist.Type) *ImportListUpdate {
|
||||
ilu.mutation.SetType(i)
|
||||
return ilu
|
||||
}
|
||||
|
||||
// SetNillableType sets the "type" field if the given value is not nil.
|
||||
func (ilu *ImportListUpdate) SetNillableType(i *importlist.Type) *ImportListUpdate {
|
||||
if i != nil {
|
||||
ilu.SetType(*i)
|
||||
}
|
||||
return ilu
|
||||
}
|
||||
|
||||
// SetURL sets the "url" field.
|
||||
func (ilu *ImportListUpdate) SetURL(s string) *ImportListUpdate {
|
||||
ilu.mutation.SetURL(s)
|
||||
return ilu
|
||||
}
|
||||
|
||||
// SetNillableURL sets the "url" field if the given value is not nil.
|
||||
func (ilu *ImportListUpdate) SetNillableURL(s *string) *ImportListUpdate {
|
||||
if s != nil {
|
||||
ilu.SetURL(*s)
|
||||
}
|
||||
return ilu
|
||||
}
|
||||
|
||||
// ClearURL clears the value of the "url" field.
|
||||
func (ilu *ImportListUpdate) ClearURL() *ImportListUpdate {
|
||||
ilu.mutation.ClearURL()
|
||||
return ilu
|
||||
}
|
||||
|
||||
// SetQulity sets the "qulity" field.
|
||||
func (ilu *ImportListUpdate) SetQulity(s string) *ImportListUpdate {
|
||||
ilu.mutation.SetQulity(s)
|
||||
return ilu
|
||||
}
|
||||
|
||||
// SetNillableQulity sets the "qulity" field if the given value is not nil.
|
||||
func (ilu *ImportListUpdate) SetNillableQulity(s *string) *ImportListUpdate {
|
||||
if s != nil {
|
||||
ilu.SetQulity(*s)
|
||||
}
|
||||
return ilu
|
||||
}
|
||||
|
||||
// SetStorageID sets the "storage_id" field.
|
||||
func (ilu *ImportListUpdate) SetStorageID(i int) *ImportListUpdate {
|
||||
ilu.mutation.ResetStorageID()
|
||||
ilu.mutation.SetStorageID(i)
|
||||
return ilu
|
||||
}
|
||||
|
||||
// SetNillableStorageID sets the "storage_id" field if the given value is not nil.
|
||||
func (ilu *ImportListUpdate) SetNillableStorageID(i *int) *ImportListUpdate {
|
||||
if i != nil {
|
||||
ilu.SetStorageID(*i)
|
||||
}
|
||||
return ilu
|
||||
}
|
||||
|
||||
// AddStorageID adds i to the "storage_id" field.
|
||||
func (ilu *ImportListUpdate) AddStorageID(i int) *ImportListUpdate {
|
||||
ilu.mutation.AddStorageID(i)
|
||||
return ilu
|
||||
}
|
||||
|
||||
// SetSettings sets the "settings" field.
|
||||
func (ilu *ImportListUpdate) SetSettings(sls schema.ImportListSettings) *ImportListUpdate {
|
||||
ilu.mutation.SetSettings(sls)
|
||||
return ilu
|
||||
}
|
||||
|
||||
// SetNillableSettings sets the "settings" field if the given value is not nil.
|
||||
func (ilu *ImportListUpdate) SetNillableSettings(sls *schema.ImportListSettings) *ImportListUpdate {
|
||||
if sls != nil {
|
||||
ilu.SetSettings(*sls)
|
||||
}
|
||||
return ilu
|
||||
}
|
||||
|
||||
// ClearSettings clears the value of the "settings" field.
|
||||
func (ilu *ImportListUpdate) ClearSettings() *ImportListUpdate {
|
||||
ilu.mutation.ClearSettings()
|
||||
return ilu
|
||||
}
|
||||
|
||||
// Mutation returns the ImportListMutation object of the builder.
|
||||
func (ilu *ImportListUpdate) Mutation() *ImportListMutation {
|
||||
return ilu.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (ilu *ImportListUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, ilu.sqlSave, ilu.mutation, ilu.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (ilu *ImportListUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := ilu.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (ilu *ImportListUpdate) Exec(ctx context.Context) error {
|
||||
_, err := ilu.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ilu *ImportListUpdate) ExecX(ctx context.Context) {
|
||||
if err := ilu.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (ilu *ImportListUpdate) check() error {
|
||||
if v, ok := ilu.mutation.GetType(); ok {
|
||||
if err := importlist.TypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "ImportList.type": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ilu *ImportListUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if err := ilu.check(); err != nil {
|
||||
return n, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(importlist.Table, importlist.Columns, sqlgraph.NewFieldSpec(importlist.FieldID, field.TypeInt))
|
||||
if ps := ilu.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := ilu.mutation.Name(); ok {
|
||||
_spec.SetField(importlist.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := ilu.mutation.GetType(); ok {
|
||||
_spec.SetField(importlist.FieldType, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := ilu.mutation.URL(); ok {
|
||||
_spec.SetField(importlist.FieldURL, field.TypeString, value)
|
||||
}
|
||||
if ilu.mutation.URLCleared() {
|
||||
_spec.ClearField(importlist.FieldURL, field.TypeString)
|
||||
}
|
||||
if value, ok := ilu.mutation.Qulity(); ok {
|
||||
_spec.SetField(importlist.FieldQulity, field.TypeString, value)
|
||||
}
|
||||
if value, ok := ilu.mutation.StorageID(); ok {
|
||||
_spec.SetField(importlist.FieldStorageID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := ilu.mutation.AddedStorageID(); ok {
|
||||
_spec.AddField(importlist.FieldStorageID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := ilu.mutation.Settings(); ok {
|
||||
_spec.SetField(importlist.FieldSettings, field.TypeJSON, value)
|
||||
}
|
||||
if ilu.mutation.SettingsCleared() {
|
||||
_spec.ClearField(importlist.FieldSettings, field.TypeJSON)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, ilu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{importlist.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
ilu.mutation.done = true
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// ImportListUpdateOne is the builder for updating a single ImportList entity.
|
||||
type ImportListUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *ImportListMutation
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (iluo *ImportListUpdateOne) SetName(s string) *ImportListUpdateOne {
|
||||
iluo.mutation.SetName(s)
|
||||
return iluo
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (iluo *ImportListUpdateOne) SetNillableName(s *string) *ImportListUpdateOne {
|
||||
if s != nil {
|
||||
iluo.SetName(*s)
|
||||
}
|
||||
return iluo
|
||||
}
|
||||
|
||||
// SetType sets the "type" field.
|
||||
func (iluo *ImportListUpdateOne) SetType(i importlist.Type) *ImportListUpdateOne {
|
||||
iluo.mutation.SetType(i)
|
||||
return iluo
|
||||
}
|
||||
|
||||
// SetNillableType sets the "type" field if the given value is not nil.
|
||||
func (iluo *ImportListUpdateOne) SetNillableType(i *importlist.Type) *ImportListUpdateOne {
|
||||
if i != nil {
|
||||
iluo.SetType(*i)
|
||||
}
|
||||
return iluo
|
||||
}
|
||||
|
||||
// SetURL sets the "url" field.
|
||||
func (iluo *ImportListUpdateOne) SetURL(s string) *ImportListUpdateOne {
|
||||
iluo.mutation.SetURL(s)
|
||||
return iluo
|
||||
}
|
||||
|
||||
// SetNillableURL sets the "url" field if the given value is not nil.
|
||||
func (iluo *ImportListUpdateOne) SetNillableURL(s *string) *ImportListUpdateOne {
|
||||
if s != nil {
|
||||
iluo.SetURL(*s)
|
||||
}
|
||||
return iluo
|
||||
}
|
||||
|
||||
// ClearURL clears the value of the "url" field.
|
||||
func (iluo *ImportListUpdateOne) ClearURL() *ImportListUpdateOne {
|
||||
iluo.mutation.ClearURL()
|
||||
return iluo
|
||||
}
|
||||
|
||||
// SetQulity sets the "qulity" field.
|
||||
func (iluo *ImportListUpdateOne) SetQulity(s string) *ImportListUpdateOne {
|
||||
iluo.mutation.SetQulity(s)
|
||||
return iluo
|
||||
}
|
||||
|
||||
// SetNillableQulity sets the "qulity" field if the given value is not nil.
|
||||
func (iluo *ImportListUpdateOne) SetNillableQulity(s *string) *ImportListUpdateOne {
|
||||
if s != nil {
|
||||
iluo.SetQulity(*s)
|
||||
}
|
||||
return iluo
|
||||
}
|
||||
|
||||
// SetStorageID sets the "storage_id" field.
|
||||
func (iluo *ImportListUpdateOne) SetStorageID(i int) *ImportListUpdateOne {
|
||||
iluo.mutation.ResetStorageID()
|
||||
iluo.mutation.SetStorageID(i)
|
||||
return iluo
|
||||
}
|
||||
|
||||
// SetNillableStorageID sets the "storage_id" field if the given value is not nil.
|
||||
func (iluo *ImportListUpdateOne) SetNillableStorageID(i *int) *ImportListUpdateOne {
|
||||
if i != nil {
|
||||
iluo.SetStorageID(*i)
|
||||
}
|
||||
return iluo
|
||||
}
|
||||
|
||||
// AddStorageID adds i to the "storage_id" field.
|
||||
func (iluo *ImportListUpdateOne) AddStorageID(i int) *ImportListUpdateOne {
|
||||
iluo.mutation.AddStorageID(i)
|
||||
return iluo
|
||||
}
|
||||
|
||||
// SetSettings sets the "settings" field.
|
||||
func (iluo *ImportListUpdateOne) SetSettings(sls schema.ImportListSettings) *ImportListUpdateOne {
|
||||
iluo.mutation.SetSettings(sls)
|
||||
return iluo
|
||||
}
|
||||
|
||||
// SetNillableSettings sets the "settings" field if the given value is not nil.
|
||||
func (iluo *ImportListUpdateOne) SetNillableSettings(sls *schema.ImportListSettings) *ImportListUpdateOne {
|
||||
if sls != nil {
|
||||
iluo.SetSettings(*sls)
|
||||
}
|
||||
return iluo
|
||||
}
|
||||
|
||||
// ClearSettings clears the value of the "settings" field.
|
||||
func (iluo *ImportListUpdateOne) ClearSettings() *ImportListUpdateOne {
|
||||
iluo.mutation.ClearSettings()
|
||||
return iluo
|
||||
}
|
||||
|
||||
// Mutation returns the ImportListMutation object of the builder.
|
||||
func (iluo *ImportListUpdateOne) Mutation() *ImportListMutation {
|
||||
return iluo.mutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ImportListUpdate builder.
|
||||
func (iluo *ImportListUpdateOne) Where(ps ...predicate.ImportList) *ImportListUpdateOne {
|
||||
iluo.mutation.Where(ps...)
|
||||
return iluo
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (iluo *ImportListUpdateOne) Select(field string, fields ...string) *ImportListUpdateOne {
|
||||
iluo.fields = append([]string{field}, fields...)
|
||||
return iluo
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated ImportList entity.
|
||||
func (iluo *ImportListUpdateOne) Save(ctx context.Context) (*ImportList, error) {
|
||||
return withHooks(ctx, iluo.sqlSave, iluo.mutation, iluo.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (iluo *ImportListUpdateOne) SaveX(ctx context.Context) *ImportList {
|
||||
node, err := iluo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (iluo *ImportListUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := iluo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (iluo *ImportListUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := iluo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (iluo *ImportListUpdateOne) check() error {
|
||||
if v, ok := iluo.mutation.GetType(); ok {
|
||||
if err := importlist.TypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "ImportList.type": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (iluo *ImportListUpdateOne) sqlSave(ctx context.Context) (_node *ImportList, err error) {
|
||||
if err := iluo.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(importlist.Table, importlist.Columns, sqlgraph.NewFieldSpec(importlist.FieldID, field.TypeInt))
|
||||
id, ok := iluo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ImportList.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := iluo.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, importlist.FieldID)
|
||||
for _, f := range fields {
|
||||
if !importlist.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != importlist.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := iluo.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := iluo.mutation.Name(); ok {
|
||||
_spec.SetField(importlist.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := iluo.mutation.GetType(); ok {
|
||||
_spec.SetField(importlist.FieldType, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := iluo.mutation.URL(); ok {
|
||||
_spec.SetField(importlist.FieldURL, field.TypeString, value)
|
||||
}
|
||||
if iluo.mutation.URLCleared() {
|
||||
_spec.ClearField(importlist.FieldURL, field.TypeString)
|
||||
}
|
||||
if value, ok := iluo.mutation.Qulity(); ok {
|
||||
_spec.SetField(importlist.FieldQulity, field.TypeString, value)
|
||||
}
|
||||
if value, ok := iluo.mutation.StorageID(); ok {
|
||||
_spec.SetField(importlist.FieldStorageID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := iluo.mutation.AddedStorageID(); ok {
|
||||
_spec.AddField(importlist.FieldStorageID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := iluo.mutation.Settings(); ok {
|
||||
_spec.SetField(importlist.FieldSettings, field.TypeJSON, value)
|
||||
}
|
||||
if iluo.mutation.SettingsCleared() {
|
||||
_spec.ClearField(importlist.FieldSettings, field.TypeJSON)
|
||||
}
|
||||
_node = &ImportList{config: iluo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, iluo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{importlist.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
iluo.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
@@ -25,7 +25,11 @@ type Indexers struct {
|
||||
// EnableRss holds the value of the "enable_rss" field.
|
||||
EnableRss bool `json:"enable_rss,omitempty"`
|
||||
// Priority holds the value of the "priority" field.
|
||||
Priority int `json:"priority,omitempty"`
|
||||
Priority int `json:"priority,omitempty"`
|
||||
// minimal seed ratio requied, before removing torrent
|
||||
SeedRatio float32 `json:"seed_ratio,omitempty"`
|
||||
// Disabled holds the value of the "disabled" field.
|
||||
Disabled bool `json:"disabled,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
@@ -34,8 +38,10 @@ func (*Indexers) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case indexers.FieldEnableRss:
|
||||
case indexers.FieldEnableRss, indexers.FieldDisabled:
|
||||
values[i] = new(sql.NullBool)
|
||||
case indexers.FieldSeedRatio:
|
||||
values[i] = new(sql.NullFloat64)
|
||||
case indexers.FieldID, indexers.FieldPriority:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case indexers.FieldName, indexers.FieldImplementation, indexers.FieldSettings:
|
||||
@@ -91,6 +97,18 @@ func (i *Indexers) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
i.Priority = int(value.Int64)
|
||||
}
|
||||
case indexers.FieldSeedRatio:
|
||||
if value, ok := values[j].(*sql.NullFloat64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field seed_ratio", values[j])
|
||||
} else if value.Valid {
|
||||
i.SeedRatio = float32(value.Float64)
|
||||
}
|
||||
case indexers.FieldDisabled:
|
||||
if value, ok := values[j].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field disabled", values[j])
|
||||
} else if value.Valid {
|
||||
i.Disabled = value.Bool
|
||||
}
|
||||
default:
|
||||
i.selectValues.Set(columns[j], values[j])
|
||||
}
|
||||
@@ -141,6 +159,12 @@ func (i *Indexers) String() string {
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("priority=")
|
||||
builder.WriteString(fmt.Sprintf("%v", i.Priority))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("seed_ratio=")
|
||||
builder.WriteString(fmt.Sprintf("%v", i.SeedRatio))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("disabled=")
|
||||
builder.WriteString(fmt.Sprintf("%v", i.Disabled))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ const (
|
||||
FieldEnableRss = "enable_rss"
|
||||
// FieldPriority holds the string denoting the priority field in the database.
|
||||
FieldPriority = "priority"
|
||||
// FieldSeedRatio holds the string denoting the seed_ratio field in the database.
|
||||
FieldSeedRatio = "seed_ratio"
|
||||
// FieldDisabled holds the string denoting the disabled field in the database.
|
||||
FieldDisabled = "disabled"
|
||||
// Table holds the table name of the indexers in the database.
|
||||
Table = "indexers"
|
||||
)
|
||||
@@ -33,6 +37,8 @@ var Columns = []string{
|
||||
FieldSettings,
|
||||
FieldEnableRss,
|
||||
FieldPriority,
|
||||
FieldSeedRatio,
|
||||
FieldDisabled,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
@@ -48,6 +54,12 @@ func ValidColumn(column string) bool {
|
||||
var (
|
||||
// DefaultEnableRss holds the default value on creation for the "enable_rss" field.
|
||||
DefaultEnableRss bool
|
||||
// DefaultPriority holds the default value on creation for the "priority" field.
|
||||
DefaultPriority int
|
||||
// DefaultSeedRatio holds the default value on creation for the "seed_ratio" field.
|
||||
DefaultSeedRatio float32
|
||||
// DefaultDisabled holds the default value on creation for the "disabled" field.
|
||||
DefaultDisabled bool
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the Indexers queries.
|
||||
@@ -82,3 +94,13 @@ func ByEnableRss(opts ...sql.OrderTermOption) OrderOption {
|
||||
func ByPriority(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPriority, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySeedRatio orders the results by the seed_ratio field.
|
||||
func BySeedRatio(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSeedRatio, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDisabled orders the results by the disabled field.
|
||||
func ByDisabled(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDisabled, opts...).ToFunc()
|
||||
}
|
||||
|
||||
@@ -78,6 +78,16 @@ func Priority(v int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldPriority, v))
|
||||
}
|
||||
|
||||
// SeedRatio applies equality check predicate on the "seed_ratio" field. It's identical to SeedRatioEQ.
|
||||
func SeedRatio(v float32) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldSeedRatio, v))
|
||||
}
|
||||
|
||||
// Disabled applies equality check predicate on the "disabled" field. It's identical to DisabledEQ.
|
||||
func Disabled(v bool) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldDisabled, v))
|
||||
}
|
||||
|
||||
// NameEQ applies the EQ predicate on the "name" field.
|
||||
func NameEQ(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldName, v))
|
||||
@@ -323,6 +333,76 @@ func PriorityLTE(v int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldLTE(FieldPriority, v))
|
||||
}
|
||||
|
||||
// SeedRatioEQ applies the EQ predicate on the "seed_ratio" field.
|
||||
func SeedRatioEQ(v float32) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldSeedRatio, v))
|
||||
}
|
||||
|
||||
// SeedRatioNEQ applies the NEQ predicate on the "seed_ratio" field.
|
||||
func SeedRatioNEQ(v float32) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNEQ(FieldSeedRatio, v))
|
||||
}
|
||||
|
||||
// SeedRatioIn applies the In predicate on the "seed_ratio" field.
|
||||
func SeedRatioIn(vs ...float32) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldIn(FieldSeedRatio, vs...))
|
||||
}
|
||||
|
||||
// SeedRatioNotIn applies the NotIn predicate on the "seed_ratio" field.
|
||||
func SeedRatioNotIn(vs ...float32) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNotIn(FieldSeedRatio, vs...))
|
||||
}
|
||||
|
||||
// SeedRatioGT applies the GT predicate on the "seed_ratio" field.
|
||||
func SeedRatioGT(v float32) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldGT(FieldSeedRatio, v))
|
||||
}
|
||||
|
||||
// SeedRatioGTE applies the GTE predicate on the "seed_ratio" field.
|
||||
func SeedRatioGTE(v float32) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldGTE(FieldSeedRatio, v))
|
||||
}
|
||||
|
||||
// SeedRatioLT applies the LT predicate on the "seed_ratio" field.
|
||||
func SeedRatioLT(v float32) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldLT(FieldSeedRatio, v))
|
||||
}
|
||||
|
||||
// SeedRatioLTE applies the LTE predicate on the "seed_ratio" field.
|
||||
func SeedRatioLTE(v float32) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldLTE(FieldSeedRatio, v))
|
||||
}
|
||||
|
||||
// SeedRatioIsNil applies the IsNil predicate on the "seed_ratio" field.
|
||||
func SeedRatioIsNil() predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldIsNull(FieldSeedRatio))
|
||||
}
|
||||
|
||||
// SeedRatioNotNil applies the NotNil predicate on the "seed_ratio" field.
|
||||
func SeedRatioNotNil() predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNotNull(FieldSeedRatio))
|
||||
}
|
||||
|
||||
// DisabledEQ applies the EQ predicate on the "disabled" field.
|
||||
func DisabledEQ(v bool) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldDisabled, v))
|
||||
}
|
||||
|
||||
// DisabledNEQ applies the NEQ predicate on the "disabled" field.
|
||||
func DisabledNEQ(v bool) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNEQ(FieldDisabled, v))
|
||||
}
|
||||
|
||||
// DisabledIsNil applies the IsNil predicate on the "disabled" field.
|
||||
func DisabledIsNil() predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldIsNull(FieldDisabled))
|
||||
}
|
||||
|
||||
// DisabledNotNil applies the NotNil predicate on the "disabled" field.
|
||||
func DisabledNotNil() predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNotNull(FieldDisabled))
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Indexers) predicate.Indexers {
|
||||
return predicate.Indexers(sql.AndPredicates(predicates...))
|
||||
|
||||
@@ -57,6 +57,42 @@ func (ic *IndexersCreate) SetPriority(i int) *IndexersCreate {
|
||||
return ic
|
||||
}
|
||||
|
||||
// SetNillablePriority sets the "priority" field if the given value is not nil.
|
||||
func (ic *IndexersCreate) SetNillablePriority(i *int) *IndexersCreate {
|
||||
if i != nil {
|
||||
ic.SetPriority(*i)
|
||||
}
|
||||
return ic
|
||||
}
|
||||
|
||||
// SetSeedRatio sets the "seed_ratio" field.
|
||||
func (ic *IndexersCreate) SetSeedRatio(f float32) *IndexersCreate {
|
||||
ic.mutation.SetSeedRatio(f)
|
||||
return ic
|
||||
}
|
||||
|
||||
// SetNillableSeedRatio sets the "seed_ratio" field if the given value is not nil.
|
||||
func (ic *IndexersCreate) SetNillableSeedRatio(f *float32) *IndexersCreate {
|
||||
if f != nil {
|
||||
ic.SetSeedRatio(*f)
|
||||
}
|
||||
return ic
|
||||
}
|
||||
|
||||
// SetDisabled sets the "disabled" field.
|
||||
func (ic *IndexersCreate) SetDisabled(b bool) *IndexersCreate {
|
||||
ic.mutation.SetDisabled(b)
|
||||
return ic
|
||||
}
|
||||
|
||||
// SetNillableDisabled sets the "disabled" field if the given value is not nil.
|
||||
func (ic *IndexersCreate) SetNillableDisabled(b *bool) *IndexersCreate {
|
||||
if b != nil {
|
||||
ic.SetDisabled(*b)
|
||||
}
|
||||
return ic
|
||||
}
|
||||
|
||||
// Mutation returns the IndexersMutation object of the builder.
|
||||
func (ic *IndexersCreate) Mutation() *IndexersMutation {
|
||||
return ic.mutation
|
||||
@@ -96,6 +132,18 @@ func (ic *IndexersCreate) defaults() {
|
||||
v := indexers.DefaultEnableRss
|
||||
ic.mutation.SetEnableRss(v)
|
||||
}
|
||||
if _, ok := ic.mutation.Priority(); !ok {
|
||||
v := indexers.DefaultPriority
|
||||
ic.mutation.SetPriority(v)
|
||||
}
|
||||
if _, ok := ic.mutation.SeedRatio(); !ok {
|
||||
v := indexers.DefaultSeedRatio
|
||||
ic.mutation.SetSeedRatio(v)
|
||||
}
|
||||
if _, ok := ic.mutation.Disabled(); !ok {
|
||||
v := indexers.DefaultDisabled
|
||||
ic.mutation.SetDisabled(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
@@ -161,6 +209,14 @@ func (ic *IndexersCreate) createSpec() (*Indexers, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(indexers.FieldPriority, field.TypeInt, value)
|
||||
_node.Priority = value
|
||||
}
|
||||
if value, ok := ic.mutation.SeedRatio(); ok {
|
||||
_spec.SetField(indexers.FieldSeedRatio, field.TypeFloat32, value)
|
||||
_node.SeedRatio = value
|
||||
}
|
||||
if value, ok := ic.mutation.Disabled(); ok {
|
||||
_spec.SetField(indexers.FieldDisabled, field.TypeBool, value)
|
||||
_node.Disabled = value
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
|
||||
@@ -104,6 +104,53 @@ func (iu *IndexersUpdate) AddPriority(i int) *IndexersUpdate {
|
||||
return iu
|
||||
}
|
||||
|
||||
// SetSeedRatio sets the "seed_ratio" field.
|
||||
func (iu *IndexersUpdate) SetSeedRatio(f float32) *IndexersUpdate {
|
||||
iu.mutation.ResetSeedRatio()
|
||||
iu.mutation.SetSeedRatio(f)
|
||||
return iu
|
||||
}
|
||||
|
||||
// SetNillableSeedRatio sets the "seed_ratio" field if the given value is not nil.
|
||||
func (iu *IndexersUpdate) SetNillableSeedRatio(f *float32) *IndexersUpdate {
|
||||
if f != nil {
|
||||
iu.SetSeedRatio(*f)
|
||||
}
|
||||
return iu
|
||||
}
|
||||
|
||||
// AddSeedRatio adds f to the "seed_ratio" field.
|
||||
func (iu *IndexersUpdate) AddSeedRatio(f float32) *IndexersUpdate {
|
||||
iu.mutation.AddSeedRatio(f)
|
||||
return iu
|
||||
}
|
||||
|
||||
// ClearSeedRatio clears the value of the "seed_ratio" field.
|
||||
func (iu *IndexersUpdate) ClearSeedRatio() *IndexersUpdate {
|
||||
iu.mutation.ClearSeedRatio()
|
||||
return iu
|
||||
}
|
||||
|
||||
// SetDisabled sets the "disabled" field.
|
||||
func (iu *IndexersUpdate) SetDisabled(b bool) *IndexersUpdate {
|
||||
iu.mutation.SetDisabled(b)
|
||||
return iu
|
||||
}
|
||||
|
||||
// SetNillableDisabled sets the "disabled" field if the given value is not nil.
|
||||
func (iu *IndexersUpdate) SetNillableDisabled(b *bool) *IndexersUpdate {
|
||||
if b != nil {
|
||||
iu.SetDisabled(*b)
|
||||
}
|
||||
return iu
|
||||
}
|
||||
|
||||
// ClearDisabled clears the value of the "disabled" field.
|
||||
func (iu *IndexersUpdate) ClearDisabled() *IndexersUpdate {
|
||||
iu.mutation.ClearDisabled()
|
||||
return iu
|
||||
}
|
||||
|
||||
// Mutation returns the IndexersMutation object of the builder.
|
||||
func (iu *IndexersUpdate) Mutation() *IndexersMutation {
|
||||
return iu.mutation
|
||||
@@ -163,6 +210,21 @@ func (iu *IndexersUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if value, ok := iu.mutation.AddedPriority(); ok {
|
||||
_spec.AddField(indexers.FieldPriority, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := iu.mutation.SeedRatio(); ok {
|
||||
_spec.SetField(indexers.FieldSeedRatio, field.TypeFloat32, value)
|
||||
}
|
||||
if value, ok := iu.mutation.AddedSeedRatio(); ok {
|
||||
_spec.AddField(indexers.FieldSeedRatio, field.TypeFloat32, value)
|
||||
}
|
||||
if iu.mutation.SeedRatioCleared() {
|
||||
_spec.ClearField(indexers.FieldSeedRatio, field.TypeFloat32)
|
||||
}
|
||||
if value, ok := iu.mutation.Disabled(); ok {
|
||||
_spec.SetField(indexers.FieldDisabled, field.TypeBool, value)
|
||||
}
|
||||
if iu.mutation.DisabledCleared() {
|
||||
_spec.ClearField(indexers.FieldDisabled, field.TypeBool)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, iu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{indexers.Label}
|
||||
@@ -260,6 +322,53 @@ func (iuo *IndexersUpdateOne) AddPriority(i int) *IndexersUpdateOne {
|
||||
return iuo
|
||||
}
|
||||
|
||||
// SetSeedRatio sets the "seed_ratio" field.
|
||||
func (iuo *IndexersUpdateOne) SetSeedRatio(f float32) *IndexersUpdateOne {
|
||||
iuo.mutation.ResetSeedRatio()
|
||||
iuo.mutation.SetSeedRatio(f)
|
||||
return iuo
|
||||
}
|
||||
|
||||
// SetNillableSeedRatio sets the "seed_ratio" field if the given value is not nil.
|
||||
func (iuo *IndexersUpdateOne) SetNillableSeedRatio(f *float32) *IndexersUpdateOne {
|
||||
if f != nil {
|
||||
iuo.SetSeedRatio(*f)
|
||||
}
|
||||
return iuo
|
||||
}
|
||||
|
||||
// AddSeedRatio adds f to the "seed_ratio" field.
|
||||
func (iuo *IndexersUpdateOne) AddSeedRatio(f float32) *IndexersUpdateOne {
|
||||
iuo.mutation.AddSeedRatio(f)
|
||||
return iuo
|
||||
}
|
||||
|
||||
// ClearSeedRatio clears the value of the "seed_ratio" field.
|
||||
func (iuo *IndexersUpdateOne) ClearSeedRatio() *IndexersUpdateOne {
|
||||
iuo.mutation.ClearSeedRatio()
|
||||
return iuo
|
||||
}
|
||||
|
||||
// SetDisabled sets the "disabled" field.
|
||||
func (iuo *IndexersUpdateOne) SetDisabled(b bool) *IndexersUpdateOne {
|
||||
iuo.mutation.SetDisabled(b)
|
||||
return iuo
|
||||
}
|
||||
|
||||
// SetNillableDisabled sets the "disabled" field if the given value is not nil.
|
||||
func (iuo *IndexersUpdateOne) SetNillableDisabled(b *bool) *IndexersUpdateOne {
|
||||
if b != nil {
|
||||
iuo.SetDisabled(*b)
|
||||
}
|
||||
return iuo
|
||||
}
|
||||
|
||||
// ClearDisabled clears the value of the "disabled" field.
|
||||
func (iuo *IndexersUpdateOne) ClearDisabled() *IndexersUpdateOne {
|
||||
iuo.mutation.ClearDisabled()
|
||||
return iuo
|
||||
}
|
||||
|
||||
// Mutation returns the IndexersMutation object of the builder.
|
||||
func (iuo *IndexersUpdateOne) Mutation() *IndexersMutation {
|
||||
return iuo.mutation
|
||||
@@ -349,6 +458,21 @@ func (iuo *IndexersUpdateOne) sqlSave(ctx context.Context) (_node *Indexers, err
|
||||
if value, ok := iuo.mutation.AddedPriority(); ok {
|
||||
_spec.AddField(indexers.FieldPriority, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := iuo.mutation.SeedRatio(); ok {
|
||||
_spec.SetField(indexers.FieldSeedRatio, field.TypeFloat32, value)
|
||||
}
|
||||
if value, ok := iuo.mutation.AddedSeedRatio(); ok {
|
||||
_spec.AddField(indexers.FieldSeedRatio, field.TypeFloat32, value)
|
||||
}
|
||||
if iuo.mutation.SeedRatioCleared() {
|
||||
_spec.ClearField(indexers.FieldSeedRatio, field.TypeFloat32)
|
||||
}
|
||||
if value, ok := iuo.mutation.Disabled(); ok {
|
||||
_spec.SetField(indexers.FieldDisabled, field.TypeBool, value)
|
||||
}
|
||||
if iuo.mutation.DisabledCleared() {
|
||||
_spec.ClearField(indexers.FieldDisabled, field.TypeBool)
|
||||
}
|
||||
_node = &Indexers{config: iuo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
|
||||
56
ent/media.go
@@ -3,8 +3,10 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"polaris/ent/media"
|
||||
"polaris/ent/schema"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -41,6 +43,14 @@ type Media struct {
|
||||
StorageID int `json:"storage_id,omitempty"`
|
||||
// TargetDir holds the value of the "target_dir" field.
|
||||
TargetDir string `json:"target_dir,omitempty"`
|
||||
// tv series only
|
||||
DownloadHistoryEpisodes bool `json:"download_history_episodes,omitempty"`
|
||||
// Limiter holds the value of the "limiter" field.
|
||||
Limiter schema.MediaLimiter `json:"limiter,omitempty"`
|
||||
// Extras holds the value of the "extras" field.
|
||||
Extras schema.MediaExtras `json:"extras,omitempty"`
|
||||
// AlternativeTitles holds the value of the "alternative_titles" field.
|
||||
AlternativeTitles []schema.AlternativeTilte `json:"alternative_titles,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the MediaQuery when eager-loading is set.
|
||||
Edges MediaEdges `json:"edges"`
|
||||
@@ -70,6 +80,10 @@ func (*Media) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case media.FieldLimiter, media.FieldExtras, media.FieldAlternativeTitles:
|
||||
values[i] = new([]byte)
|
||||
case media.FieldDownloadHistoryEpisodes:
|
||||
values[i] = new(sql.NullBool)
|
||||
case media.FieldID, media.FieldTmdbID, media.FieldStorageID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case media.FieldImdbID, media.FieldMediaType, media.FieldNameCn, media.FieldNameEn, media.FieldOriginalName, media.FieldOverview, media.FieldAirDate, media.FieldResolution, media.FieldTargetDir:
|
||||
@@ -169,6 +183,36 @@ func (m *Media) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
m.TargetDir = value.String
|
||||
}
|
||||
case media.FieldDownloadHistoryEpisodes:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field download_history_episodes", values[i])
|
||||
} else if value.Valid {
|
||||
m.DownloadHistoryEpisodes = value.Bool
|
||||
}
|
||||
case media.FieldLimiter:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field limiter", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
if err := json.Unmarshal(*value, &m.Limiter); err != nil {
|
||||
return fmt.Errorf("unmarshal field limiter: %w", err)
|
||||
}
|
||||
}
|
||||
case media.FieldExtras:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field extras", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
if err := json.Unmarshal(*value, &m.Extras); err != nil {
|
||||
return fmt.Errorf("unmarshal field extras: %w", err)
|
||||
}
|
||||
}
|
||||
case media.FieldAlternativeTitles:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field alternative_titles", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
if err := json.Unmarshal(*value, &m.AlternativeTitles); err != nil {
|
||||
return fmt.Errorf("unmarshal field alternative_titles: %w", err)
|
||||
}
|
||||
}
|
||||
default:
|
||||
m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
@@ -245,6 +289,18 @@ func (m *Media) String() string {
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("target_dir=")
|
||||
builder.WriteString(m.TargetDir)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("download_history_episodes=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.DownloadHistoryEpisodes))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("limiter=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.Limiter))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("extras=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.Extras))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("alternative_titles=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.AlternativeTitles))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -39,6 +39,14 @@ const (
|
||||
FieldStorageID = "storage_id"
|
||||
// FieldTargetDir holds the string denoting the target_dir field in the database.
|
||||
FieldTargetDir = "target_dir"
|
||||
// FieldDownloadHistoryEpisodes holds the string denoting the download_history_episodes field in the database.
|
||||
FieldDownloadHistoryEpisodes = "download_history_episodes"
|
||||
// FieldLimiter holds the string denoting the limiter field in the database.
|
||||
FieldLimiter = "limiter"
|
||||
// FieldExtras holds the string denoting the extras field in the database.
|
||||
FieldExtras = "extras"
|
||||
// FieldAlternativeTitles holds the string denoting the alternative_titles field in the database.
|
||||
FieldAlternativeTitles = "alternative_titles"
|
||||
// EdgeEpisodes holds the string denoting the episodes edge name in mutations.
|
||||
EdgeEpisodes = "episodes"
|
||||
// Table holds the table name of the media in the database.
|
||||
@@ -67,6 +75,10 @@ var Columns = []string{
|
||||
FieldResolution,
|
||||
FieldStorageID,
|
||||
FieldTargetDir,
|
||||
FieldDownloadHistoryEpisodes,
|
||||
FieldLimiter,
|
||||
FieldExtras,
|
||||
FieldAlternativeTitles,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
@@ -84,6 +96,8 @@ var (
|
||||
DefaultCreatedAt time.Time
|
||||
// DefaultAirDate holds the default value on creation for the "air_date" field.
|
||||
DefaultAirDate string
|
||||
// DefaultDownloadHistoryEpisodes holds the default value on creation for the "download_history_episodes" field.
|
||||
DefaultDownloadHistoryEpisodes bool
|
||||
)
|
||||
|
||||
// MediaType defines the type for the "media_type" enum field.
|
||||
@@ -119,7 +133,8 @@ const DefaultResolution = Resolution1080p
|
||||
const (
|
||||
Resolution720p Resolution = "720p"
|
||||
Resolution1080p Resolution = "1080p"
|
||||
Resolution4k Resolution = "4k"
|
||||
Resolution2160p Resolution = "2160p"
|
||||
ResolutionAny Resolution = "any"
|
||||
)
|
||||
|
||||
func (r Resolution) String() string {
|
||||
@@ -129,7 +144,7 @@ func (r Resolution) String() string {
|
||||
// ResolutionValidator is a validator for the "resolution" field enum values. It is called by the builders before save.
|
||||
func ResolutionValidator(r Resolution) error {
|
||||
switch r {
|
||||
case Resolution720p, Resolution1080p, Resolution4k:
|
||||
case Resolution720p, Resolution1080p, Resolution2160p, ResolutionAny:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("media: invalid enum value for resolution field: %q", r)
|
||||
@@ -204,6 +219,11 @@ func ByTargetDir(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTargetDir, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDownloadHistoryEpisodes orders the results by the download_history_episodes field.
|
||||
func ByDownloadHistoryEpisodes(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDownloadHistoryEpisodes, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByEpisodesCount orders the results by episodes count.
|
||||
func ByEpisodesCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
|
||||
@@ -105,6 +105,11 @@ func TargetDir(v string) predicate.Media {
|
||||
return predicate.Media(sql.FieldEQ(FieldTargetDir, v))
|
||||
}
|
||||
|
||||
// DownloadHistoryEpisodes applies equality check predicate on the "download_history_episodes" field. It's identical to DownloadHistoryEpisodesEQ.
|
||||
func DownloadHistoryEpisodes(v bool) predicate.Media {
|
||||
return predicate.Media(sql.FieldEQ(FieldDownloadHistoryEpisodes, v))
|
||||
}
|
||||
|
||||
// TmdbIDEQ applies the EQ predicate on the "tmdb_id" field.
|
||||
func TmdbIDEQ(v int) predicate.Media {
|
||||
return predicate.Media(sql.FieldEQ(FieldTmdbID, v))
|
||||
@@ -750,6 +755,56 @@ func TargetDirContainsFold(v string) predicate.Media {
|
||||
return predicate.Media(sql.FieldContainsFold(FieldTargetDir, v))
|
||||
}
|
||||
|
||||
// DownloadHistoryEpisodesEQ applies the EQ predicate on the "download_history_episodes" field.
|
||||
func DownloadHistoryEpisodesEQ(v bool) predicate.Media {
|
||||
return predicate.Media(sql.FieldEQ(FieldDownloadHistoryEpisodes, v))
|
||||
}
|
||||
|
||||
// DownloadHistoryEpisodesNEQ applies the NEQ predicate on the "download_history_episodes" field.
|
||||
func DownloadHistoryEpisodesNEQ(v bool) predicate.Media {
|
||||
return predicate.Media(sql.FieldNEQ(FieldDownloadHistoryEpisodes, v))
|
||||
}
|
||||
|
||||
// DownloadHistoryEpisodesIsNil applies the IsNil predicate on the "download_history_episodes" field.
|
||||
func DownloadHistoryEpisodesIsNil() predicate.Media {
|
||||
return predicate.Media(sql.FieldIsNull(FieldDownloadHistoryEpisodes))
|
||||
}
|
||||
|
||||
// DownloadHistoryEpisodesNotNil applies the NotNil predicate on the "download_history_episodes" field.
|
||||
func DownloadHistoryEpisodesNotNil() predicate.Media {
|
||||
return predicate.Media(sql.FieldNotNull(FieldDownloadHistoryEpisodes))
|
||||
}
|
||||
|
||||
// LimiterIsNil applies the IsNil predicate on the "limiter" field.
|
||||
func LimiterIsNil() predicate.Media {
|
||||
return predicate.Media(sql.FieldIsNull(FieldLimiter))
|
||||
}
|
||||
|
||||
// LimiterNotNil applies the NotNil predicate on the "limiter" field.
|
||||
func LimiterNotNil() predicate.Media {
|
||||
return predicate.Media(sql.FieldNotNull(FieldLimiter))
|
||||
}
|
||||
|
||||
// ExtrasIsNil applies the IsNil predicate on the "extras" field.
|
||||
func ExtrasIsNil() predicate.Media {
|
||||
return predicate.Media(sql.FieldIsNull(FieldExtras))
|
||||
}
|
||||
|
||||
// ExtrasNotNil applies the NotNil predicate on the "extras" field.
|
||||
func ExtrasNotNil() predicate.Media {
|
||||
return predicate.Media(sql.FieldNotNull(FieldExtras))
|
||||
}
|
||||
|
||||
// AlternativeTitlesIsNil applies the IsNil predicate on the "alternative_titles" field.
|
||||
func AlternativeTitlesIsNil() predicate.Media {
|
||||
return predicate.Media(sql.FieldIsNull(FieldAlternativeTitles))
|
||||
}
|
||||
|
||||
// AlternativeTitlesNotNil applies the NotNil predicate on the "alternative_titles" field.
|
||||
func AlternativeTitlesNotNil() predicate.Media {
|
||||
return predicate.Media(sql.FieldNotNull(FieldAlternativeTitles))
|
||||
}
|
||||
|
||||
// HasEpisodes applies the HasEdge predicate on the "episodes" edge.
|
||||
func HasEpisodes() predicate.Media {
|
||||
return predicate.Media(func(s *sql.Selector) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"polaris/ent/episode"
|
||||
"polaris/ent/media"
|
||||
"polaris/ent/schema"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -141,6 +142,54 @@ func (mc *MediaCreate) SetNillableTargetDir(s *string) *MediaCreate {
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetDownloadHistoryEpisodes sets the "download_history_episodes" field.
|
||||
func (mc *MediaCreate) SetDownloadHistoryEpisodes(b bool) *MediaCreate {
|
||||
mc.mutation.SetDownloadHistoryEpisodes(b)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableDownloadHistoryEpisodes sets the "download_history_episodes" field if the given value is not nil.
|
||||
func (mc *MediaCreate) SetNillableDownloadHistoryEpisodes(b *bool) *MediaCreate {
|
||||
if b != nil {
|
||||
mc.SetDownloadHistoryEpisodes(*b)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetLimiter sets the "limiter" field.
|
||||
func (mc *MediaCreate) SetLimiter(sl schema.MediaLimiter) *MediaCreate {
|
||||
mc.mutation.SetLimiter(sl)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableLimiter sets the "limiter" field if the given value is not nil.
|
||||
func (mc *MediaCreate) SetNillableLimiter(sl *schema.MediaLimiter) *MediaCreate {
|
||||
if sl != nil {
|
||||
mc.SetLimiter(*sl)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetExtras sets the "extras" field.
|
||||
func (mc *MediaCreate) SetExtras(se schema.MediaExtras) *MediaCreate {
|
||||
mc.mutation.SetExtras(se)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableExtras sets the "extras" field if the given value is not nil.
|
||||
func (mc *MediaCreate) SetNillableExtras(se *schema.MediaExtras) *MediaCreate {
|
||||
if se != nil {
|
||||
mc.SetExtras(*se)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetAlternativeTitles sets the "alternative_titles" field.
|
||||
func (mc *MediaCreate) SetAlternativeTitles(st []schema.AlternativeTilte) *MediaCreate {
|
||||
mc.mutation.SetAlternativeTitles(st)
|
||||
return mc
|
||||
}
|
||||
|
||||
// AddEpisodeIDs adds the "episodes" edge to the Episode entity by IDs.
|
||||
func (mc *MediaCreate) AddEpisodeIDs(ids ...int) *MediaCreate {
|
||||
mc.mutation.AddEpisodeIDs(ids...)
|
||||
@@ -203,6 +252,10 @@ func (mc *MediaCreate) defaults() {
|
||||
v := media.DefaultResolution
|
||||
mc.mutation.SetResolution(v)
|
||||
}
|
||||
if _, ok := mc.mutation.DownloadHistoryEpisodes(); !ok {
|
||||
v := media.DefaultDownloadHistoryEpisodes
|
||||
mc.mutation.SetDownloadHistoryEpisodes(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
@@ -318,6 +371,22 @@ func (mc *MediaCreate) createSpec() (*Media, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(media.FieldTargetDir, field.TypeString, value)
|
||||
_node.TargetDir = value
|
||||
}
|
||||
if value, ok := mc.mutation.DownloadHistoryEpisodes(); ok {
|
||||
_spec.SetField(media.FieldDownloadHistoryEpisodes, field.TypeBool, value)
|
||||
_node.DownloadHistoryEpisodes = value
|
||||
}
|
||||
if value, ok := mc.mutation.Limiter(); ok {
|
||||
_spec.SetField(media.FieldLimiter, field.TypeJSON, value)
|
||||
_node.Limiter = value
|
||||
}
|
||||
if value, ok := mc.mutation.Extras(); ok {
|
||||
_spec.SetField(media.FieldExtras, field.TypeJSON, value)
|
||||
_node.Extras = value
|
||||
}
|
||||
if value, ok := mc.mutation.AlternativeTitles(); ok {
|
||||
_spec.SetField(media.FieldAlternativeTitles, field.TypeJSON, value)
|
||||
_node.AlternativeTitles = value
|
||||
}
|
||||
if nodes := mc.mutation.EpisodesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
|
||||
@@ -9,10 +9,12 @@ import (
|
||||
"polaris/ent/episode"
|
||||
"polaris/ent/media"
|
||||
"polaris/ent/predicate"
|
||||
"polaris/ent/schema"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/dialect/sql/sqljson"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
@@ -229,6 +231,84 @@ func (mu *MediaUpdate) ClearTargetDir() *MediaUpdate {
|
||||
return mu
|
||||
}
|
||||
|
||||
// SetDownloadHistoryEpisodes sets the "download_history_episodes" field.
|
||||
func (mu *MediaUpdate) SetDownloadHistoryEpisodes(b bool) *MediaUpdate {
|
||||
mu.mutation.SetDownloadHistoryEpisodes(b)
|
||||
return mu
|
||||
}
|
||||
|
||||
// SetNillableDownloadHistoryEpisodes sets the "download_history_episodes" field if the given value is not nil.
|
||||
func (mu *MediaUpdate) SetNillableDownloadHistoryEpisodes(b *bool) *MediaUpdate {
|
||||
if b != nil {
|
||||
mu.SetDownloadHistoryEpisodes(*b)
|
||||
}
|
||||
return mu
|
||||
}
|
||||
|
||||
// ClearDownloadHistoryEpisodes clears the value of the "download_history_episodes" field.
|
||||
func (mu *MediaUpdate) ClearDownloadHistoryEpisodes() *MediaUpdate {
|
||||
mu.mutation.ClearDownloadHistoryEpisodes()
|
||||
return mu
|
||||
}
|
||||
|
||||
// SetLimiter sets the "limiter" field.
|
||||
func (mu *MediaUpdate) SetLimiter(sl schema.MediaLimiter) *MediaUpdate {
|
||||
mu.mutation.SetLimiter(sl)
|
||||
return mu
|
||||
}
|
||||
|
||||
// SetNillableLimiter sets the "limiter" field if the given value is not nil.
|
||||
func (mu *MediaUpdate) SetNillableLimiter(sl *schema.MediaLimiter) *MediaUpdate {
|
||||
if sl != nil {
|
||||
mu.SetLimiter(*sl)
|
||||
}
|
||||
return mu
|
||||
}
|
||||
|
||||
// ClearLimiter clears the value of the "limiter" field.
|
||||
func (mu *MediaUpdate) ClearLimiter() *MediaUpdate {
|
||||
mu.mutation.ClearLimiter()
|
||||
return mu
|
||||
}
|
||||
|
||||
// SetExtras sets the "extras" field.
|
||||
func (mu *MediaUpdate) SetExtras(se schema.MediaExtras) *MediaUpdate {
|
||||
mu.mutation.SetExtras(se)
|
||||
return mu
|
||||
}
|
||||
|
||||
// SetNillableExtras sets the "extras" field if the given value is not nil.
|
||||
func (mu *MediaUpdate) SetNillableExtras(se *schema.MediaExtras) *MediaUpdate {
|
||||
if se != nil {
|
||||
mu.SetExtras(*se)
|
||||
}
|
||||
return mu
|
||||
}
|
||||
|
||||
// ClearExtras clears the value of the "extras" field.
|
||||
func (mu *MediaUpdate) ClearExtras() *MediaUpdate {
|
||||
mu.mutation.ClearExtras()
|
||||
return mu
|
||||
}
|
||||
|
||||
// SetAlternativeTitles sets the "alternative_titles" field.
|
||||
func (mu *MediaUpdate) SetAlternativeTitles(st []schema.AlternativeTilte) *MediaUpdate {
|
||||
mu.mutation.SetAlternativeTitles(st)
|
||||
return mu
|
||||
}
|
||||
|
||||
// AppendAlternativeTitles appends st to the "alternative_titles" field.
|
||||
func (mu *MediaUpdate) AppendAlternativeTitles(st []schema.AlternativeTilte) *MediaUpdate {
|
||||
mu.mutation.AppendAlternativeTitles(st)
|
||||
return mu
|
||||
}
|
||||
|
||||
// ClearAlternativeTitles clears the value of the "alternative_titles" field.
|
||||
func (mu *MediaUpdate) ClearAlternativeTitles() *MediaUpdate {
|
||||
mu.mutation.ClearAlternativeTitles()
|
||||
return mu
|
||||
}
|
||||
|
||||
// AddEpisodeIDs adds the "episodes" edge to the Episode entity by IDs.
|
||||
func (mu *MediaUpdate) AddEpisodeIDs(ids ...int) *MediaUpdate {
|
||||
mu.mutation.AddEpisodeIDs(ids...)
|
||||
@@ -375,6 +455,35 @@ func (mu *MediaUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if mu.mutation.TargetDirCleared() {
|
||||
_spec.ClearField(media.FieldTargetDir, field.TypeString)
|
||||
}
|
||||
if value, ok := mu.mutation.DownloadHistoryEpisodes(); ok {
|
||||
_spec.SetField(media.FieldDownloadHistoryEpisodes, field.TypeBool, value)
|
||||
}
|
||||
if mu.mutation.DownloadHistoryEpisodesCleared() {
|
||||
_spec.ClearField(media.FieldDownloadHistoryEpisodes, field.TypeBool)
|
||||
}
|
||||
if value, ok := mu.mutation.Limiter(); ok {
|
||||
_spec.SetField(media.FieldLimiter, field.TypeJSON, value)
|
||||
}
|
||||
if mu.mutation.LimiterCleared() {
|
||||
_spec.ClearField(media.FieldLimiter, field.TypeJSON)
|
||||
}
|
||||
if value, ok := mu.mutation.Extras(); ok {
|
||||
_spec.SetField(media.FieldExtras, field.TypeJSON, value)
|
||||
}
|
||||
if mu.mutation.ExtrasCleared() {
|
||||
_spec.ClearField(media.FieldExtras, field.TypeJSON)
|
||||
}
|
||||
if value, ok := mu.mutation.AlternativeTitles(); ok {
|
||||
_spec.SetField(media.FieldAlternativeTitles, field.TypeJSON, value)
|
||||
}
|
||||
if value, ok := mu.mutation.AppendedAlternativeTitles(); ok {
|
||||
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
||||
sqljson.Append(u, media.FieldAlternativeTitles, value)
|
||||
})
|
||||
}
|
||||
if mu.mutation.AlternativeTitlesCleared() {
|
||||
_spec.ClearField(media.FieldAlternativeTitles, field.TypeJSON)
|
||||
}
|
||||
if mu.mutation.EpisodesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
@@ -640,6 +749,84 @@ func (muo *MediaUpdateOne) ClearTargetDir() *MediaUpdateOne {
|
||||
return muo
|
||||
}
|
||||
|
||||
// SetDownloadHistoryEpisodes sets the "download_history_episodes" field.
|
||||
func (muo *MediaUpdateOne) SetDownloadHistoryEpisodes(b bool) *MediaUpdateOne {
|
||||
muo.mutation.SetDownloadHistoryEpisodes(b)
|
||||
return muo
|
||||
}
|
||||
|
||||
// SetNillableDownloadHistoryEpisodes sets the "download_history_episodes" field if the given value is not nil.
|
||||
func (muo *MediaUpdateOne) SetNillableDownloadHistoryEpisodes(b *bool) *MediaUpdateOne {
|
||||
if b != nil {
|
||||
muo.SetDownloadHistoryEpisodes(*b)
|
||||
}
|
||||
return muo
|
||||
}
|
||||
|
||||
// ClearDownloadHistoryEpisodes clears the value of the "download_history_episodes" field.
|
||||
func (muo *MediaUpdateOne) ClearDownloadHistoryEpisodes() *MediaUpdateOne {
|
||||
muo.mutation.ClearDownloadHistoryEpisodes()
|
||||
return muo
|
||||
}
|
||||
|
||||
// SetLimiter sets the "limiter" field.
|
||||
func (muo *MediaUpdateOne) SetLimiter(sl schema.MediaLimiter) *MediaUpdateOne {
|
||||
muo.mutation.SetLimiter(sl)
|
||||
return muo
|
||||
}
|
||||
|
||||
// SetNillableLimiter sets the "limiter" field if the given value is not nil.
|
||||
func (muo *MediaUpdateOne) SetNillableLimiter(sl *schema.MediaLimiter) *MediaUpdateOne {
|
||||
if sl != nil {
|
||||
muo.SetLimiter(*sl)
|
||||
}
|
||||
return muo
|
||||
}
|
||||
|
||||
// ClearLimiter clears the value of the "limiter" field.
|
||||
func (muo *MediaUpdateOne) ClearLimiter() *MediaUpdateOne {
|
||||
muo.mutation.ClearLimiter()
|
||||
return muo
|
||||
}
|
||||
|
||||
// SetExtras sets the "extras" field.
|
||||
func (muo *MediaUpdateOne) SetExtras(se schema.MediaExtras) *MediaUpdateOne {
|
||||
muo.mutation.SetExtras(se)
|
||||
return muo
|
||||
}
|
||||
|
||||
// SetNillableExtras sets the "extras" field if the given value is not nil.
|
||||
func (muo *MediaUpdateOne) SetNillableExtras(se *schema.MediaExtras) *MediaUpdateOne {
|
||||
if se != nil {
|
||||
muo.SetExtras(*se)
|
||||
}
|
||||
return muo
|
||||
}
|
||||
|
||||
// ClearExtras clears the value of the "extras" field.
|
||||
func (muo *MediaUpdateOne) ClearExtras() *MediaUpdateOne {
|
||||
muo.mutation.ClearExtras()
|
||||
return muo
|
||||
}
|
||||
|
||||
// SetAlternativeTitles sets the "alternative_titles" field.
|
||||
func (muo *MediaUpdateOne) SetAlternativeTitles(st []schema.AlternativeTilte) *MediaUpdateOne {
|
||||
muo.mutation.SetAlternativeTitles(st)
|
||||
return muo
|
||||
}
|
||||
|
||||
// AppendAlternativeTitles appends st to the "alternative_titles" field.
|
||||
func (muo *MediaUpdateOne) AppendAlternativeTitles(st []schema.AlternativeTilte) *MediaUpdateOne {
|
||||
muo.mutation.AppendAlternativeTitles(st)
|
||||
return muo
|
||||
}
|
||||
|
||||
// ClearAlternativeTitles clears the value of the "alternative_titles" field.
|
||||
func (muo *MediaUpdateOne) ClearAlternativeTitles() *MediaUpdateOne {
|
||||
muo.mutation.ClearAlternativeTitles()
|
||||
return muo
|
||||
}
|
||||
|
||||
// AddEpisodeIDs adds the "episodes" edge to the Episode entity by IDs.
|
||||
func (muo *MediaUpdateOne) AddEpisodeIDs(ids ...int) *MediaUpdateOne {
|
||||
muo.mutation.AddEpisodeIDs(ids...)
|
||||
@@ -816,6 +1003,35 @@ func (muo *MediaUpdateOne) sqlSave(ctx context.Context) (_node *Media, err error
|
||||
if muo.mutation.TargetDirCleared() {
|
||||
_spec.ClearField(media.FieldTargetDir, field.TypeString)
|
||||
}
|
||||
if value, ok := muo.mutation.DownloadHistoryEpisodes(); ok {
|
||||
_spec.SetField(media.FieldDownloadHistoryEpisodes, field.TypeBool, value)
|
||||
}
|
||||
if muo.mutation.DownloadHistoryEpisodesCleared() {
|
||||
_spec.ClearField(media.FieldDownloadHistoryEpisodes, field.TypeBool)
|
||||
}
|
||||
if value, ok := muo.mutation.Limiter(); ok {
|
||||
_spec.SetField(media.FieldLimiter, field.TypeJSON, value)
|
||||
}
|
||||
if muo.mutation.LimiterCleared() {
|
||||
_spec.ClearField(media.FieldLimiter, field.TypeJSON)
|
||||
}
|
||||
if value, ok := muo.mutation.Extras(); ok {
|
||||
_spec.SetField(media.FieldExtras, field.TypeJSON, value)
|
||||
}
|
||||
if muo.mutation.ExtrasCleared() {
|
||||
_spec.ClearField(media.FieldExtras, field.TypeJSON)
|
||||
}
|
||||
if value, ok := muo.mutation.AlternativeTitles(); ok {
|
||||
_spec.SetField(media.FieldAlternativeTitles, field.TypeJSON, value)
|
||||
}
|
||||
if value, ok := muo.mutation.AppendedAlternativeTitles(); ok {
|
||||
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
||||
sqljson.Append(u, media.FieldAlternativeTitles, value)
|
||||
})
|
||||
}
|
||||
if muo.mutation.AlternativeTitlesCleared() {
|
||||
_spec.ClearField(media.FieldAlternativeTitles, field.TypeJSON)
|
||||
}
|
||||
if muo.mutation.EpisodesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
|
||||
@@ -8,17 +8,30 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
// BlacklistsColumns holds the columns for the "blacklists" table.
|
||||
BlacklistsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "type", Type: field.TypeEnum, Enums: []string{"media", "torrent"}},
|
||||
{Name: "value", Type: field.TypeJSON},
|
||||
{Name: "notes", Type: field.TypeString, Nullable: true},
|
||||
}
|
||||
// BlacklistsTable holds the schema information for the "blacklists" table.
|
||||
BlacklistsTable = &schema.Table{
|
||||
Name: "blacklists",
|
||||
Columns: BlacklistsColumns,
|
||||
PrimaryKey: []*schema.Column{BlacklistsColumns[0]},
|
||||
}
|
||||
// DownloadClientsColumns holds the columns for the "download_clients" table.
|
||||
DownloadClientsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "enable", Type: field.TypeBool},
|
||||
{Name: "name", Type: field.TypeString},
|
||||
{Name: "implementation", Type: field.TypeString},
|
||||
{Name: "implementation", Type: field.TypeEnum, Enums: []string{"transmission", "qbittorrent"}},
|
||||
{Name: "url", Type: field.TypeString},
|
||||
{Name: "user", Type: field.TypeString, Default: ""},
|
||||
{Name: "password", Type: field.TypeString, Default: ""},
|
||||
{Name: "settings", Type: field.TypeString, Default: ""},
|
||||
{Name: "priority", Type: field.TypeString, Default: ""},
|
||||
{Name: "priority1", Type: field.TypeInt, Default: 1},
|
||||
{Name: "remove_completed_downloads", Type: field.TypeBool, Default: true},
|
||||
{Name: "remove_failed_downloads", Type: field.TypeBool, Default: true},
|
||||
{Name: "tags", Type: field.TypeString, Default: ""},
|
||||
@@ -38,7 +51,8 @@ var (
|
||||
{Name: "overview", Type: field.TypeString},
|
||||
{Name: "air_date", Type: field.TypeString},
|
||||
{Name: "status", Type: field.TypeEnum, Enums: []string{"missing", "downloading", "downloaded"}, Default: "missing"},
|
||||
{Name: "file_in_storage", Type: field.TypeString, Nullable: true},
|
||||
{Name: "monitored", Type: field.TypeBool, Default: false},
|
||||
{Name: "target_file", Type: field.TypeString, Nullable: true},
|
||||
{Name: "media_id", Type: field.TypeInt, Nullable: true},
|
||||
}
|
||||
// EpisodesTable holds the schema information for the "episodes" table.
|
||||
@@ -49,7 +63,7 @@ var (
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "episodes_media_episodes",
|
||||
Columns: []*schema.Column{EpisodesColumns[8]},
|
||||
Columns: []*schema.Column{EpisodesColumns[9]},
|
||||
RefColumns: []*schema.Column{MediaColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
@@ -60,11 +74,16 @@ var (
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "media_id", Type: field.TypeInt},
|
||||
{Name: "episode_id", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "episode_nums", Type: field.TypeJSON, Nullable: true},
|
||||
{Name: "season_num", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "source_title", Type: field.TypeString},
|
||||
{Name: "date", Type: field.TypeTime},
|
||||
{Name: "target_dir", Type: field.TypeString},
|
||||
{Name: "size", Type: field.TypeInt, Default: 0},
|
||||
{Name: "status", Type: field.TypeEnum, Enums: []string{"running", "success", "fail", "uploading"}},
|
||||
{Name: "download_client_id", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "indexer_id", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "link", Type: field.TypeString, Nullable: true},
|
||||
{Name: "status", Type: field.TypeEnum, Enums: []string{"running", "success", "fail", "uploading", "seeding"}},
|
||||
{Name: "saved", Type: field.TypeString, Nullable: true},
|
||||
}
|
||||
// HistoriesTable holds the schema information for the "histories" table.
|
||||
@@ -73,6 +92,22 @@ var (
|
||||
Columns: HistoriesColumns,
|
||||
PrimaryKey: []*schema.Column{HistoriesColumns[0]},
|
||||
}
|
||||
// ImportListsColumns holds the columns for the "import_lists" table.
|
||||
ImportListsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "name", Type: field.TypeString},
|
||||
{Name: "type", Type: field.TypeEnum, Enums: []string{"plex", "doulist"}},
|
||||
{Name: "url", Type: field.TypeString, Nullable: true},
|
||||
{Name: "qulity", Type: field.TypeString},
|
||||
{Name: "storage_id", Type: field.TypeInt},
|
||||
{Name: "settings", Type: field.TypeJSON, Nullable: true},
|
||||
}
|
||||
// ImportListsTable holds the schema information for the "import_lists" table.
|
||||
ImportListsTable = &schema.Table{
|
||||
Name: "import_lists",
|
||||
Columns: ImportListsColumns,
|
||||
PrimaryKey: []*schema.Column{ImportListsColumns[0]},
|
||||
}
|
||||
// IndexersColumns holds the columns for the "indexers" table.
|
||||
IndexersColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
@@ -80,7 +115,9 @@ var (
|
||||
{Name: "implementation", Type: field.TypeString},
|
||||
{Name: "settings", Type: field.TypeString},
|
||||
{Name: "enable_rss", Type: field.TypeBool, Default: true},
|
||||
{Name: "priority", Type: field.TypeInt},
|
||||
{Name: "priority", Type: field.TypeInt, Default: 50},
|
||||
{Name: "seed_ratio", Type: field.TypeFloat32, Nullable: true, Default: 0},
|
||||
{Name: "disabled", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
}
|
||||
// IndexersTable holds the schema information for the "indexers" table.
|
||||
IndexersTable = &schema.Table{
|
||||
@@ -100,9 +137,13 @@ var (
|
||||
{Name: "overview", Type: field.TypeString},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "air_date", Type: field.TypeString, Default: ""},
|
||||
{Name: "resolution", Type: field.TypeEnum, Enums: []string{"720p", "1080p", "4k"}, Default: "1080p"},
|
||||
{Name: "resolution", Type: field.TypeEnum, Enums: []string{"720p", "1080p", "2160p", "any"}, Default: "1080p"},
|
||||
{Name: "storage_id", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "target_dir", Type: field.TypeString, Nullable: true},
|
||||
{Name: "download_history_episodes", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "limiter", Type: field.TypeJSON, Nullable: true},
|
||||
{Name: "extras", Type: field.TypeJSON, Nullable: true},
|
||||
{Name: "alternative_titles", Type: field.TypeJSON, Nullable: true},
|
||||
}
|
||||
// MediaTable holds the schema information for the "media" table.
|
||||
MediaTable = &schema.Table{
|
||||
@@ -110,6 +151,20 @@ var (
|
||||
Columns: MediaColumns,
|
||||
PrimaryKey: []*schema.Column{MediaColumns[0]},
|
||||
}
|
||||
// NotificationClientsColumns holds the columns for the "notification_clients" table.
|
||||
NotificationClientsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "name", Type: field.TypeString},
|
||||
{Name: "service", Type: field.TypeString},
|
||||
{Name: "settings", Type: field.TypeString},
|
||||
{Name: "enabled", Type: field.TypeBool, Default: true},
|
||||
}
|
||||
// NotificationClientsTable holds the schema information for the "notification_clients" table.
|
||||
NotificationClientsTable = &schema.Table{
|
||||
Name: "notification_clients",
|
||||
Columns: NotificationClientsColumns,
|
||||
PrimaryKey: []*schema.Column{NotificationClientsColumns[0]},
|
||||
}
|
||||
// SettingsColumns holds the columns for the "settings" table.
|
||||
SettingsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
@@ -126,7 +181,9 @@ var (
|
||||
StoragesColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "name", Type: field.TypeString, Unique: true},
|
||||
{Name: "implementation", Type: field.TypeEnum, Enums: []string{"webdav", "local"}},
|
||||
{Name: "implementation", Type: field.TypeEnum, Enums: []string{"webdav", "local", "alist"}},
|
||||
{Name: "tv_path", Type: field.TypeString, Nullable: true},
|
||||
{Name: "movie_path", Type: field.TypeString, Nullable: true},
|
||||
{Name: "settings", Type: field.TypeString, Nullable: true},
|
||||
{Name: "deleted", Type: field.TypeBool, Default: false},
|
||||
{Name: "default", Type: field.TypeBool, Default: false},
|
||||
@@ -139,11 +196,14 @@ var (
|
||||
}
|
||||
// Tables holds all the tables in the schema.
|
||||
Tables = []*schema.Table{
|
||||
BlacklistsTable,
|
||||
DownloadClientsTable,
|
||||
EpisodesTable,
|
||||
HistoriesTable,
|
||||
ImportListsTable,
|
||||
IndexersTable,
|
||||
MediaTable,
|
||||
NotificationClientsTable,
|
||||
SettingsTable,
|
||||
StoragesTable,
|
||||
}
|
||||
|
||||
3090
ent/mutation.go
138
ent/notificationclient.go
Normal file
@@ -0,0 +1,138 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"polaris/ent/notificationclient"
|
||||
"strings"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// NotificationClient is the model entity for the NotificationClient schema.
|
||||
type NotificationClient struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// Name holds the value of the "name" field.
|
||||
Name string `json:"name,omitempty"`
|
||||
// Service holds the value of the "service" field.
|
||||
Service string `json:"service,omitempty"`
|
||||
// Settings holds the value of the "settings" field.
|
||||
Settings string `json:"settings,omitempty"`
|
||||
// Enabled holds the value of the "enabled" field.
|
||||
Enabled bool `json:"enabled,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*NotificationClient) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case notificationclient.FieldEnabled:
|
||||
values[i] = new(sql.NullBool)
|
||||
case notificationclient.FieldID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case notificationclient.FieldName, notificationclient.FieldService, notificationclient.FieldSettings:
|
||||
values[i] = new(sql.NullString)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the NotificationClient fields.
|
||||
func (nc *NotificationClient) 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 notificationclient.FieldID:
|
||||
value, ok := values[i].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
nc.ID = int(value.Int64)
|
||||
case notificationclient.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
} else if value.Valid {
|
||||
nc.Name = value.String
|
||||
}
|
||||
case notificationclient.FieldService:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field service", values[i])
|
||||
} else if value.Valid {
|
||||
nc.Service = value.String
|
||||
}
|
||||
case notificationclient.FieldSettings:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field settings", values[i])
|
||||
} else if value.Valid {
|
||||
nc.Settings = value.String
|
||||
}
|
||||
case notificationclient.FieldEnabled:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field enabled", values[i])
|
||||
} else if value.Valid {
|
||||
nc.Enabled = value.Bool
|
||||
}
|
||||
default:
|
||||
nc.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the NotificationClient.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (nc *NotificationClient) Value(name string) (ent.Value, error) {
|
||||
return nc.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this NotificationClient.
|
||||
// Note that you need to call NotificationClient.Unwrap() before calling this method if this NotificationClient
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (nc *NotificationClient) Update() *NotificationClientUpdateOne {
|
||||
return NewNotificationClientClient(nc.config).UpdateOne(nc)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the NotificationClient 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 (nc *NotificationClient) Unwrap() *NotificationClient {
|
||||
_tx, ok := nc.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: NotificationClient is not a transactional entity")
|
||||
}
|
||||
nc.config.driver = _tx.drv
|
||||
return nc
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (nc *NotificationClient) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("NotificationClient(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", nc.ID))
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(nc.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("service=")
|
||||
builder.WriteString(nc.Service)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("settings=")
|
||||
builder.WriteString(nc.Settings)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("enabled=")
|
||||
builder.WriteString(fmt.Sprintf("%v", nc.Enabled))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// NotificationClients is a parsable slice of NotificationClient.
|
||||
type NotificationClients []*NotificationClient
|
||||
76
ent/notificationclient/notificationclient.go
Normal file
@@ -0,0 +1,76 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package notificationclient
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the notificationclient type in the database.
|
||||
Label = "notification_client"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldName holds the string denoting the name field in the database.
|
||||
FieldName = "name"
|
||||
// FieldService holds the string denoting the service field in the database.
|
||||
FieldService = "service"
|
||||
// FieldSettings holds the string denoting the settings field in the database.
|
||||
FieldSettings = "settings"
|
||||
// FieldEnabled holds the string denoting the enabled field in the database.
|
||||
FieldEnabled = "enabled"
|
||||
// Table holds the table name of the notificationclient in the database.
|
||||
Table = "notification_clients"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for notificationclient fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldName,
|
||||
FieldService,
|
||||
FieldSettings,
|
||||
FieldEnabled,
|
||||
}
|
||||
|
||||
// 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 (
|
||||
// DefaultEnabled holds the default value on creation for the "enabled" field.
|
||||
DefaultEnabled bool
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the NotificationClient 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()
|
||||
}
|
||||
|
||||
// ByName orders the results by the name field.
|
||||
func ByName(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldName, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByService orders the results by the service field.
|
||||
func ByService(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldService, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySettings orders the results by the settings field.
|
||||
func BySettings(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSettings, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByEnabled orders the results by the enabled field.
|
||||
func ByEnabled(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldEnabled, opts...).ToFunc()
|
||||
}
|
||||
294
ent/notificationclient/where.go
Normal file
@@ -0,0 +1,294 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package notificationclient
|
||||
|
||||
import (
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id int) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
|
||||
func Name(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// Service applies equality check predicate on the "service" field. It's identical to ServiceEQ.
|
||||
func Service(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldEQ(FieldService, v))
|
||||
}
|
||||
|
||||
// Settings applies equality check predicate on the "settings" field. It's identical to SettingsEQ.
|
||||
func Settings(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldEQ(FieldSettings, v))
|
||||
}
|
||||
|
||||
// Enabled applies equality check predicate on the "enabled" field. It's identical to EnabledEQ.
|
||||
func Enabled(v bool) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldEQ(FieldEnabled, v))
|
||||
}
|
||||
|
||||
// NameEQ applies the EQ predicate on the "name" field.
|
||||
func NameEQ(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// NameNEQ applies the NEQ predicate on the "name" field.
|
||||
func NameNEQ(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldNEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// NameIn applies the In predicate on the "name" field.
|
||||
func NameIn(vs ...string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldIn(FieldName, vs...))
|
||||
}
|
||||
|
||||
// NameNotIn applies the NotIn predicate on the "name" field.
|
||||
func NameNotIn(vs ...string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldNotIn(FieldName, vs...))
|
||||
}
|
||||
|
||||
// NameGT applies the GT predicate on the "name" field.
|
||||
func NameGT(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldGT(FieldName, v))
|
||||
}
|
||||
|
||||
// NameGTE applies the GTE predicate on the "name" field.
|
||||
func NameGTE(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldGTE(FieldName, v))
|
||||
}
|
||||
|
||||
// NameLT applies the LT predicate on the "name" field.
|
||||
func NameLT(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldLT(FieldName, v))
|
||||
}
|
||||
|
||||
// NameLTE applies the LTE predicate on the "name" field.
|
||||
func NameLTE(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldLTE(FieldName, v))
|
||||
}
|
||||
|
||||
// NameContains applies the Contains predicate on the "name" field.
|
||||
func NameContains(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldContains(FieldName, v))
|
||||
}
|
||||
|
||||
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
|
||||
func NameHasPrefix(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldHasPrefix(FieldName, v))
|
||||
}
|
||||
|
||||
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
|
||||
func NameHasSuffix(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldHasSuffix(FieldName, v))
|
||||
}
|
||||
|
||||
// NameEqualFold applies the EqualFold predicate on the "name" field.
|
||||
func NameEqualFold(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldEqualFold(FieldName, v))
|
||||
}
|
||||
|
||||
// NameContainsFold applies the ContainsFold predicate on the "name" field.
|
||||
func NameContainsFold(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldContainsFold(FieldName, v))
|
||||
}
|
||||
|
||||
// ServiceEQ applies the EQ predicate on the "service" field.
|
||||
func ServiceEQ(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldEQ(FieldService, v))
|
||||
}
|
||||
|
||||
// ServiceNEQ applies the NEQ predicate on the "service" field.
|
||||
func ServiceNEQ(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldNEQ(FieldService, v))
|
||||
}
|
||||
|
||||
// ServiceIn applies the In predicate on the "service" field.
|
||||
func ServiceIn(vs ...string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldIn(FieldService, vs...))
|
||||
}
|
||||
|
||||
// ServiceNotIn applies the NotIn predicate on the "service" field.
|
||||
func ServiceNotIn(vs ...string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldNotIn(FieldService, vs...))
|
||||
}
|
||||
|
||||
// ServiceGT applies the GT predicate on the "service" field.
|
||||
func ServiceGT(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldGT(FieldService, v))
|
||||
}
|
||||
|
||||
// ServiceGTE applies the GTE predicate on the "service" field.
|
||||
func ServiceGTE(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldGTE(FieldService, v))
|
||||
}
|
||||
|
||||
// ServiceLT applies the LT predicate on the "service" field.
|
||||
func ServiceLT(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldLT(FieldService, v))
|
||||
}
|
||||
|
||||
// ServiceLTE applies the LTE predicate on the "service" field.
|
||||
func ServiceLTE(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldLTE(FieldService, v))
|
||||
}
|
||||
|
||||
// ServiceContains applies the Contains predicate on the "service" field.
|
||||
func ServiceContains(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldContains(FieldService, v))
|
||||
}
|
||||
|
||||
// ServiceHasPrefix applies the HasPrefix predicate on the "service" field.
|
||||
func ServiceHasPrefix(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldHasPrefix(FieldService, v))
|
||||
}
|
||||
|
||||
// ServiceHasSuffix applies the HasSuffix predicate on the "service" field.
|
||||
func ServiceHasSuffix(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldHasSuffix(FieldService, v))
|
||||
}
|
||||
|
||||
// ServiceEqualFold applies the EqualFold predicate on the "service" field.
|
||||
func ServiceEqualFold(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldEqualFold(FieldService, v))
|
||||
}
|
||||
|
||||
// ServiceContainsFold applies the ContainsFold predicate on the "service" field.
|
||||
func ServiceContainsFold(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldContainsFold(FieldService, v))
|
||||
}
|
||||
|
||||
// SettingsEQ applies the EQ predicate on the "settings" field.
|
||||
func SettingsEQ(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldEQ(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsNEQ applies the NEQ predicate on the "settings" field.
|
||||
func SettingsNEQ(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldNEQ(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsIn applies the In predicate on the "settings" field.
|
||||
func SettingsIn(vs ...string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldIn(FieldSettings, vs...))
|
||||
}
|
||||
|
||||
// SettingsNotIn applies the NotIn predicate on the "settings" field.
|
||||
func SettingsNotIn(vs ...string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldNotIn(FieldSettings, vs...))
|
||||
}
|
||||
|
||||
// SettingsGT applies the GT predicate on the "settings" field.
|
||||
func SettingsGT(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldGT(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsGTE applies the GTE predicate on the "settings" field.
|
||||
func SettingsGTE(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldGTE(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsLT applies the LT predicate on the "settings" field.
|
||||
func SettingsLT(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldLT(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsLTE applies the LTE predicate on the "settings" field.
|
||||
func SettingsLTE(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldLTE(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsContains applies the Contains predicate on the "settings" field.
|
||||
func SettingsContains(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldContains(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsHasPrefix applies the HasPrefix predicate on the "settings" field.
|
||||
func SettingsHasPrefix(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldHasPrefix(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsHasSuffix applies the HasSuffix predicate on the "settings" field.
|
||||
func SettingsHasSuffix(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldHasSuffix(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsEqualFold applies the EqualFold predicate on the "settings" field.
|
||||
func SettingsEqualFold(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldEqualFold(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsContainsFold applies the ContainsFold predicate on the "settings" field.
|
||||
func SettingsContainsFold(v string) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldContainsFold(FieldSettings, v))
|
||||
}
|
||||
|
||||
// EnabledEQ applies the EQ predicate on the "enabled" field.
|
||||
func EnabledEQ(v bool) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldEQ(FieldEnabled, v))
|
||||
}
|
||||
|
||||
// EnabledNEQ applies the NEQ predicate on the "enabled" field.
|
||||
func EnabledNEQ(v bool) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.FieldNEQ(FieldEnabled, v))
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.NotificationClient) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.NotificationClient) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.NotificationClient) predicate.NotificationClient {
|
||||
return predicate.NotificationClient(sql.NotPredicates(p))
|
||||
}
|
||||
240
ent/notificationclient_create.go
Normal file
@@ -0,0 +1,240 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/notificationclient"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// NotificationClientCreate is the builder for creating a NotificationClient entity.
|
||||
type NotificationClientCreate struct {
|
||||
config
|
||||
mutation *NotificationClientMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (ncc *NotificationClientCreate) SetName(s string) *NotificationClientCreate {
|
||||
ncc.mutation.SetName(s)
|
||||
return ncc
|
||||
}
|
||||
|
||||
// SetService sets the "service" field.
|
||||
func (ncc *NotificationClientCreate) SetService(s string) *NotificationClientCreate {
|
||||
ncc.mutation.SetService(s)
|
||||
return ncc
|
||||
}
|
||||
|
||||
// SetSettings sets the "settings" field.
|
||||
func (ncc *NotificationClientCreate) SetSettings(s string) *NotificationClientCreate {
|
||||
ncc.mutation.SetSettings(s)
|
||||
return ncc
|
||||
}
|
||||
|
||||
// SetEnabled sets the "enabled" field.
|
||||
func (ncc *NotificationClientCreate) SetEnabled(b bool) *NotificationClientCreate {
|
||||
ncc.mutation.SetEnabled(b)
|
||||
return ncc
|
||||
}
|
||||
|
||||
// SetNillableEnabled sets the "enabled" field if the given value is not nil.
|
||||
func (ncc *NotificationClientCreate) SetNillableEnabled(b *bool) *NotificationClientCreate {
|
||||
if b != nil {
|
||||
ncc.SetEnabled(*b)
|
||||
}
|
||||
return ncc
|
||||
}
|
||||
|
||||
// Mutation returns the NotificationClientMutation object of the builder.
|
||||
func (ncc *NotificationClientCreate) Mutation() *NotificationClientMutation {
|
||||
return ncc.mutation
|
||||
}
|
||||
|
||||
// Save creates the NotificationClient in the database.
|
||||
func (ncc *NotificationClientCreate) Save(ctx context.Context) (*NotificationClient, error) {
|
||||
ncc.defaults()
|
||||
return withHooks(ctx, ncc.sqlSave, ncc.mutation, ncc.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (ncc *NotificationClientCreate) SaveX(ctx context.Context) *NotificationClient {
|
||||
v, err := ncc.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (ncc *NotificationClientCreate) Exec(ctx context.Context) error {
|
||||
_, err := ncc.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ncc *NotificationClientCreate) ExecX(ctx context.Context) {
|
||||
if err := ncc.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (ncc *NotificationClientCreate) defaults() {
|
||||
if _, ok := ncc.mutation.Enabled(); !ok {
|
||||
v := notificationclient.DefaultEnabled
|
||||
ncc.mutation.SetEnabled(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (ncc *NotificationClientCreate) check() error {
|
||||
if _, ok := ncc.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "NotificationClient.name"`)}
|
||||
}
|
||||
if _, ok := ncc.mutation.Service(); !ok {
|
||||
return &ValidationError{Name: "service", err: errors.New(`ent: missing required field "NotificationClient.service"`)}
|
||||
}
|
||||
if _, ok := ncc.mutation.Settings(); !ok {
|
||||
return &ValidationError{Name: "settings", err: errors.New(`ent: missing required field "NotificationClient.settings"`)}
|
||||
}
|
||||
if _, ok := ncc.mutation.Enabled(); !ok {
|
||||
return &ValidationError{Name: "enabled", err: errors.New(`ent: missing required field "NotificationClient.enabled"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ncc *NotificationClientCreate) sqlSave(ctx context.Context) (*NotificationClient, error) {
|
||||
if err := ncc.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := ncc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, ncc.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 = int(id)
|
||||
ncc.mutation.id = &_node.ID
|
||||
ncc.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (ncc *NotificationClientCreate) createSpec() (*NotificationClient, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &NotificationClient{config: ncc.config}
|
||||
_spec = sqlgraph.NewCreateSpec(notificationclient.Table, sqlgraph.NewFieldSpec(notificationclient.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := ncc.mutation.Name(); ok {
|
||||
_spec.SetField(notificationclient.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := ncc.mutation.Service(); ok {
|
||||
_spec.SetField(notificationclient.FieldService, field.TypeString, value)
|
||||
_node.Service = value
|
||||
}
|
||||
if value, ok := ncc.mutation.Settings(); ok {
|
||||
_spec.SetField(notificationclient.FieldSettings, field.TypeString, value)
|
||||
_node.Settings = value
|
||||
}
|
||||
if value, ok := ncc.mutation.Enabled(); ok {
|
||||
_spec.SetField(notificationclient.FieldEnabled, field.TypeBool, value)
|
||||
_node.Enabled = value
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// NotificationClientCreateBulk is the builder for creating many NotificationClient entities in bulk.
|
||||
type NotificationClientCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*NotificationClientCreate
|
||||
}
|
||||
|
||||
// Save creates the NotificationClient entities in the database.
|
||||
func (nccb *NotificationClientCreateBulk) Save(ctx context.Context) ([]*NotificationClient, error) {
|
||||
if nccb.err != nil {
|
||||
return nil, nccb.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(nccb.builders))
|
||||
nodes := make([]*NotificationClient, len(nccb.builders))
|
||||
mutators := make([]Mutator, len(nccb.builders))
|
||||
for i := range nccb.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := nccb.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*NotificationClientMutation)
|
||||
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, nccb.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, nccb.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 = int(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, nccb.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (nccb *NotificationClientCreateBulk) SaveX(ctx context.Context) []*NotificationClient {
|
||||
v, err := nccb.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (nccb *NotificationClientCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := nccb.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (nccb *NotificationClientCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := nccb.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
88
ent/notificationclient_delete.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"polaris/ent/notificationclient"
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// NotificationClientDelete is the builder for deleting a NotificationClient entity.
|
||||
type NotificationClientDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *NotificationClientMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the NotificationClientDelete builder.
|
||||
func (ncd *NotificationClientDelete) Where(ps ...predicate.NotificationClient) *NotificationClientDelete {
|
||||
ncd.mutation.Where(ps...)
|
||||
return ncd
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (ncd *NotificationClientDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, ncd.sqlExec, ncd.mutation, ncd.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ncd *NotificationClientDelete) ExecX(ctx context.Context) int {
|
||||
n, err := ncd.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (ncd *NotificationClientDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(notificationclient.Table, sqlgraph.NewFieldSpec(notificationclient.FieldID, field.TypeInt))
|
||||
if ps := ncd.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, ncd.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
ncd.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// NotificationClientDeleteOne is the builder for deleting a single NotificationClient entity.
|
||||
type NotificationClientDeleteOne struct {
|
||||
ncd *NotificationClientDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the NotificationClientDelete builder.
|
||||
func (ncdo *NotificationClientDeleteOne) Where(ps ...predicate.NotificationClient) *NotificationClientDeleteOne {
|
||||
ncdo.ncd.mutation.Where(ps...)
|
||||
return ncdo
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (ncdo *NotificationClientDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := ncdo.ncd.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{notificationclient.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ncdo *NotificationClientDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := ncdo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
526
ent/notificationclient_query.go
Normal file
@@ -0,0 +1,526 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"polaris/ent/notificationclient"
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// NotificationClientQuery is the builder for querying NotificationClient entities.
|
||||
type NotificationClientQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []notificationclient.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.NotificationClient
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the NotificationClientQuery builder.
|
||||
func (ncq *NotificationClientQuery) Where(ps ...predicate.NotificationClient) *NotificationClientQuery {
|
||||
ncq.predicates = append(ncq.predicates, ps...)
|
||||
return ncq
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (ncq *NotificationClientQuery) Limit(limit int) *NotificationClientQuery {
|
||||
ncq.ctx.Limit = &limit
|
||||
return ncq
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (ncq *NotificationClientQuery) Offset(offset int) *NotificationClientQuery {
|
||||
ncq.ctx.Offset = &offset
|
||||
return ncq
|
||||
}
|
||||
|
||||
// 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 (ncq *NotificationClientQuery) Unique(unique bool) *NotificationClientQuery {
|
||||
ncq.ctx.Unique = &unique
|
||||
return ncq
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (ncq *NotificationClientQuery) Order(o ...notificationclient.OrderOption) *NotificationClientQuery {
|
||||
ncq.order = append(ncq.order, o...)
|
||||
return ncq
|
||||
}
|
||||
|
||||
// First returns the first NotificationClient entity from the query.
|
||||
// Returns a *NotFoundError when no NotificationClient was found.
|
||||
func (ncq *NotificationClientQuery) First(ctx context.Context) (*NotificationClient, error) {
|
||||
nodes, err := ncq.Limit(1).All(setContextOp(ctx, ncq.ctx, "First"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{notificationclient.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (ncq *NotificationClientQuery) FirstX(ctx context.Context) *NotificationClient {
|
||||
node, err := ncq.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first NotificationClient ID from the query.
|
||||
// Returns a *NotFoundError when no NotificationClient ID was found.
|
||||
func (ncq *NotificationClientQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = ncq.Limit(1).IDs(setContextOp(ctx, ncq.ctx, "FirstID")); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{notificationclient.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (ncq *NotificationClientQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := ncq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single NotificationClient entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one NotificationClient entity is found.
|
||||
// Returns a *NotFoundError when no NotificationClient entities are found.
|
||||
func (ncq *NotificationClientQuery) Only(ctx context.Context) (*NotificationClient, error) {
|
||||
nodes, err := ncq.Limit(2).All(setContextOp(ctx, ncq.ctx, "Only"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{notificationclient.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{notificationclient.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (ncq *NotificationClientQuery) OnlyX(ctx context.Context) *NotificationClient {
|
||||
node, err := ncq.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only NotificationClient ID in the query.
|
||||
// Returns a *NotSingularError when more than one NotificationClient ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (ncq *NotificationClientQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = ncq.Limit(2).IDs(setContextOp(ctx, ncq.ctx, "OnlyID")); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{notificationclient.Label}
|
||||
default:
|
||||
err = &NotSingularError{notificationclient.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (ncq *NotificationClientQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := ncq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of NotificationClients.
|
||||
func (ncq *NotificationClientQuery) All(ctx context.Context) ([]*NotificationClient, error) {
|
||||
ctx = setContextOp(ctx, ncq.ctx, "All")
|
||||
if err := ncq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*NotificationClient, *NotificationClientQuery]()
|
||||
return withInterceptors[[]*NotificationClient](ctx, ncq, qr, ncq.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (ncq *NotificationClientQuery) AllX(ctx context.Context) []*NotificationClient {
|
||||
nodes, err := ncq.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of NotificationClient IDs.
|
||||
func (ncq *NotificationClientQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if ncq.ctx.Unique == nil && ncq.path != nil {
|
||||
ncq.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, ncq.ctx, "IDs")
|
||||
if err = ncq.Select(notificationclient.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (ncq *NotificationClientQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := ncq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (ncq *NotificationClientQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, ncq.ctx, "Count")
|
||||
if err := ncq.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, ncq, querierCount[*NotificationClientQuery](), ncq.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (ncq *NotificationClientQuery) CountX(ctx context.Context) int {
|
||||
count, err := ncq.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (ncq *NotificationClientQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, ncq.ctx, "Exist")
|
||||
switch _, err := ncq.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 (ncq *NotificationClientQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := ncq.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the NotificationClientQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (ncq *NotificationClientQuery) Clone() *NotificationClientQuery {
|
||||
if ncq == nil {
|
||||
return nil
|
||||
}
|
||||
return &NotificationClientQuery{
|
||||
config: ncq.config,
|
||||
ctx: ncq.ctx.Clone(),
|
||||
order: append([]notificationclient.OrderOption{}, ncq.order...),
|
||||
inters: append([]Interceptor{}, ncq.inters...),
|
||||
predicates: append([]predicate.NotificationClient{}, ncq.predicates...),
|
||||
// clone intermediate query.
|
||||
sql: ncq.sql.Clone(),
|
||||
path: ncq.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 {
|
||||
// Name string `json:"name,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.NotificationClient.Query().
|
||||
// GroupBy(notificationclient.FieldName).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (ncq *NotificationClientQuery) GroupBy(field string, fields ...string) *NotificationClientGroupBy {
|
||||
ncq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &NotificationClientGroupBy{build: ncq}
|
||||
grbuild.flds = &ncq.ctx.Fields
|
||||
grbuild.label = notificationclient.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 {
|
||||
// Name string `json:"name,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.NotificationClient.Query().
|
||||
// Select(notificationclient.FieldName).
|
||||
// Scan(ctx, &v)
|
||||
func (ncq *NotificationClientQuery) Select(fields ...string) *NotificationClientSelect {
|
||||
ncq.ctx.Fields = append(ncq.ctx.Fields, fields...)
|
||||
sbuild := &NotificationClientSelect{NotificationClientQuery: ncq}
|
||||
sbuild.label = notificationclient.Label
|
||||
sbuild.flds, sbuild.scan = &ncq.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a NotificationClientSelect configured with the given aggregations.
|
||||
func (ncq *NotificationClientQuery) Aggregate(fns ...AggregateFunc) *NotificationClientSelect {
|
||||
return ncq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (ncq *NotificationClientQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range ncq.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, ncq); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range ncq.ctx.Fields {
|
||||
if !notificationclient.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if ncq.path != nil {
|
||||
prev, err := ncq.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ncq.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ncq *NotificationClientQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*NotificationClient, error) {
|
||||
var (
|
||||
nodes = []*NotificationClient{}
|
||||
_spec = ncq.querySpec()
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*NotificationClient).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &NotificationClient{config: ncq.config}
|
||||
nodes = append(nodes, node)
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, ncq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (ncq *NotificationClientQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := ncq.querySpec()
|
||||
_spec.Node.Columns = ncq.ctx.Fields
|
||||
if len(ncq.ctx.Fields) > 0 {
|
||||
_spec.Unique = ncq.ctx.Unique != nil && *ncq.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, ncq.driver, _spec)
|
||||
}
|
||||
|
||||
func (ncq *NotificationClientQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(notificationclient.Table, notificationclient.Columns, sqlgraph.NewFieldSpec(notificationclient.FieldID, field.TypeInt))
|
||||
_spec.From = ncq.sql
|
||||
if unique := ncq.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if ncq.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := ncq.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, notificationclient.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != notificationclient.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := ncq.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := ncq.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := ncq.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := ncq.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (ncq *NotificationClientQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(ncq.driver.Dialect())
|
||||
t1 := builder.Table(notificationclient.Table)
|
||||
columns := ncq.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = notificationclient.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if ncq.sql != nil {
|
||||
selector = ncq.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if ncq.ctx.Unique != nil && *ncq.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range ncq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range ncq.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := ncq.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 := ncq.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// NotificationClientGroupBy is the group-by builder for NotificationClient entities.
|
||||
type NotificationClientGroupBy struct {
|
||||
selector
|
||||
build *NotificationClientQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (ncgb *NotificationClientGroupBy) Aggregate(fns ...AggregateFunc) *NotificationClientGroupBy {
|
||||
ncgb.fns = append(ncgb.fns, fns...)
|
||||
return ncgb
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ncgb *NotificationClientGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ncgb.build.ctx, "GroupBy")
|
||||
if err := ncgb.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*NotificationClientQuery, *NotificationClientGroupBy](ctx, ncgb.build, ncgb, ncgb.build.inters, v)
|
||||
}
|
||||
|
||||
func (ncgb *NotificationClientGroupBy) sqlScan(ctx context.Context, root *NotificationClientQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(ncgb.fns))
|
||||
for _, fn := range ncgb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*ncgb.flds)+len(ncgb.fns))
|
||||
for _, f := range *ncgb.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*ncgb.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := ncgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// NotificationClientSelect is the builder for selecting fields of NotificationClient entities.
|
||||
type NotificationClientSelect struct {
|
||||
*NotificationClientQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ncs *NotificationClientSelect) Aggregate(fns ...AggregateFunc) *NotificationClientSelect {
|
||||
ncs.fns = append(ncs.fns, fns...)
|
||||
return ncs
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ncs *NotificationClientSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ncs.ctx, "Select")
|
||||
if err := ncs.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*NotificationClientQuery, *NotificationClientSelect](ctx, ncs.NotificationClientQuery, ncs, ncs.inters, v)
|
||||
}
|
||||
|
||||
func (ncs *NotificationClientSelect) sqlScan(ctx context.Context, root *NotificationClientQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(ncs.fns))
|
||||
for _, fn := range ncs.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*ncs.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 := ncs.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
311
ent/notificationclient_update.go
Normal file
@@ -0,0 +1,311 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/notificationclient"
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// NotificationClientUpdate is the builder for updating NotificationClient entities.
|
||||
type NotificationClientUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *NotificationClientMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the NotificationClientUpdate builder.
|
||||
func (ncu *NotificationClientUpdate) Where(ps ...predicate.NotificationClient) *NotificationClientUpdate {
|
||||
ncu.mutation.Where(ps...)
|
||||
return ncu
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (ncu *NotificationClientUpdate) SetName(s string) *NotificationClientUpdate {
|
||||
ncu.mutation.SetName(s)
|
||||
return ncu
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (ncu *NotificationClientUpdate) SetNillableName(s *string) *NotificationClientUpdate {
|
||||
if s != nil {
|
||||
ncu.SetName(*s)
|
||||
}
|
||||
return ncu
|
||||
}
|
||||
|
||||
// SetService sets the "service" field.
|
||||
func (ncu *NotificationClientUpdate) SetService(s string) *NotificationClientUpdate {
|
||||
ncu.mutation.SetService(s)
|
||||
return ncu
|
||||
}
|
||||
|
||||
// SetNillableService sets the "service" field if the given value is not nil.
|
||||
func (ncu *NotificationClientUpdate) SetNillableService(s *string) *NotificationClientUpdate {
|
||||
if s != nil {
|
||||
ncu.SetService(*s)
|
||||
}
|
||||
return ncu
|
||||
}
|
||||
|
||||
// SetSettings sets the "settings" field.
|
||||
func (ncu *NotificationClientUpdate) SetSettings(s string) *NotificationClientUpdate {
|
||||
ncu.mutation.SetSettings(s)
|
||||
return ncu
|
||||
}
|
||||
|
||||
// SetNillableSettings sets the "settings" field if the given value is not nil.
|
||||
func (ncu *NotificationClientUpdate) SetNillableSettings(s *string) *NotificationClientUpdate {
|
||||
if s != nil {
|
||||
ncu.SetSettings(*s)
|
||||
}
|
||||
return ncu
|
||||
}
|
||||
|
||||
// SetEnabled sets the "enabled" field.
|
||||
func (ncu *NotificationClientUpdate) SetEnabled(b bool) *NotificationClientUpdate {
|
||||
ncu.mutation.SetEnabled(b)
|
||||
return ncu
|
||||
}
|
||||
|
||||
// SetNillableEnabled sets the "enabled" field if the given value is not nil.
|
||||
func (ncu *NotificationClientUpdate) SetNillableEnabled(b *bool) *NotificationClientUpdate {
|
||||
if b != nil {
|
||||
ncu.SetEnabled(*b)
|
||||
}
|
||||
return ncu
|
||||
}
|
||||
|
||||
// Mutation returns the NotificationClientMutation object of the builder.
|
||||
func (ncu *NotificationClientUpdate) Mutation() *NotificationClientMutation {
|
||||
return ncu.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (ncu *NotificationClientUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, ncu.sqlSave, ncu.mutation, ncu.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (ncu *NotificationClientUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := ncu.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (ncu *NotificationClientUpdate) Exec(ctx context.Context) error {
|
||||
_, err := ncu.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ncu *NotificationClientUpdate) ExecX(ctx context.Context) {
|
||||
if err := ncu.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (ncu *NotificationClientUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(notificationclient.Table, notificationclient.Columns, sqlgraph.NewFieldSpec(notificationclient.FieldID, field.TypeInt))
|
||||
if ps := ncu.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := ncu.mutation.Name(); ok {
|
||||
_spec.SetField(notificationclient.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := ncu.mutation.Service(); ok {
|
||||
_spec.SetField(notificationclient.FieldService, field.TypeString, value)
|
||||
}
|
||||
if value, ok := ncu.mutation.Settings(); ok {
|
||||
_spec.SetField(notificationclient.FieldSettings, field.TypeString, value)
|
||||
}
|
||||
if value, ok := ncu.mutation.Enabled(); ok {
|
||||
_spec.SetField(notificationclient.FieldEnabled, field.TypeBool, value)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, ncu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{notificationclient.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
ncu.mutation.done = true
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// NotificationClientUpdateOne is the builder for updating a single NotificationClient entity.
|
||||
type NotificationClientUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *NotificationClientMutation
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (ncuo *NotificationClientUpdateOne) SetName(s string) *NotificationClientUpdateOne {
|
||||
ncuo.mutation.SetName(s)
|
||||
return ncuo
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (ncuo *NotificationClientUpdateOne) SetNillableName(s *string) *NotificationClientUpdateOne {
|
||||
if s != nil {
|
||||
ncuo.SetName(*s)
|
||||
}
|
||||
return ncuo
|
||||
}
|
||||
|
||||
// SetService sets the "service" field.
|
||||
func (ncuo *NotificationClientUpdateOne) SetService(s string) *NotificationClientUpdateOne {
|
||||
ncuo.mutation.SetService(s)
|
||||
return ncuo
|
||||
}
|
||||
|
||||
// SetNillableService sets the "service" field if the given value is not nil.
|
||||
func (ncuo *NotificationClientUpdateOne) SetNillableService(s *string) *NotificationClientUpdateOne {
|
||||
if s != nil {
|
||||
ncuo.SetService(*s)
|
||||
}
|
||||
return ncuo
|
||||
}
|
||||
|
||||
// SetSettings sets the "settings" field.
|
||||
func (ncuo *NotificationClientUpdateOne) SetSettings(s string) *NotificationClientUpdateOne {
|
||||
ncuo.mutation.SetSettings(s)
|
||||
return ncuo
|
||||
}
|
||||
|
||||
// SetNillableSettings sets the "settings" field if the given value is not nil.
|
||||
func (ncuo *NotificationClientUpdateOne) SetNillableSettings(s *string) *NotificationClientUpdateOne {
|
||||
if s != nil {
|
||||
ncuo.SetSettings(*s)
|
||||
}
|
||||
return ncuo
|
||||
}
|
||||
|
||||
// SetEnabled sets the "enabled" field.
|
||||
func (ncuo *NotificationClientUpdateOne) SetEnabled(b bool) *NotificationClientUpdateOne {
|
||||
ncuo.mutation.SetEnabled(b)
|
||||
return ncuo
|
||||
}
|
||||
|
||||
// SetNillableEnabled sets the "enabled" field if the given value is not nil.
|
||||
func (ncuo *NotificationClientUpdateOne) SetNillableEnabled(b *bool) *NotificationClientUpdateOne {
|
||||
if b != nil {
|
||||
ncuo.SetEnabled(*b)
|
||||
}
|
||||
return ncuo
|
||||
}
|
||||
|
||||
// Mutation returns the NotificationClientMutation object of the builder.
|
||||
func (ncuo *NotificationClientUpdateOne) Mutation() *NotificationClientMutation {
|
||||
return ncuo.mutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the NotificationClientUpdate builder.
|
||||
func (ncuo *NotificationClientUpdateOne) Where(ps ...predicate.NotificationClient) *NotificationClientUpdateOne {
|
||||
ncuo.mutation.Where(ps...)
|
||||
return ncuo
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (ncuo *NotificationClientUpdateOne) Select(field string, fields ...string) *NotificationClientUpdateOne {
|
||||
ncuo.fields = append([]string{field}, fields...)
|
||||
return ncuo
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated NotificationClient entity.
|
||||
func (ncuo *NotificationClientUpdateOne) Save(ctx context.Context) (*NotificationClient, error) {
|
||||
return withHooks(ctx, ncuo.sqlSave, ncuo.mutation, ncuo.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (ncuo *NotificationClientUpdateOne) SaveX(ctx context.Context) *NotificationClient {
|
||||
node, err := ncuo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (ncuo *NotificationClientUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := ncuo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ncuo *NotificationClientUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := ncuo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (ncuo *NotificationClientUpdateOne) sqlSave(ctx context.Context) (_node *NotificationClient, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(notificationclient.Table, notificationclient.Columns, sqlgraph.NewFieldSpec(notificationclient.FieldID, field.TypeInt))
|
||||
id, ok := ncuo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "NotificationClient.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := ncuo.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, notificationclient.FieldID)
|
||||
for _, f := range fields {
|
||||
if !notificationclient.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != notificationclient.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := ncuo.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := ncuo.mutation.Name(); ok {
|
||||
_spec.SetField(notificationclient.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := ncuo.mutation.Service(); ok {
|
||||
_spec.SetField(notificationclient.FieldService, field.TypeString, value)
|
||||
}
|
||||
if value, ok := ncuo.mutation.Settings(); ok {
|
||||
_spec.SetField(notificationclient.FieldSettings, field.TypeString, value)
|
||||
}
|
||||
if value, ok := ncuo.mutation.Enabled(); ok {
|
||||
_spec.SetField(notificationclient.FieldEnabled, field.TypeBool, value)
|
||||
}
|
||||
_node = &NotificationClient{config: ncuo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, ncuo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{notificationclient.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
ncuo.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
@@ -6,6 +6,9 @@ import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// Blacklist is the predicate function for blacklist builders.
|
||||
type Blacklist func(*sql.Selector)
|
||||
|
||||
// DownloadClients is the predicate function for downloadclients builders.
|
||||
type DownloadClients func(*sql.Selector)
|
||||
|
||||
@@ -15,12 +18,18 @@ type Episode func(*sql.Selector)
|
||||
// History is the predicate function for history builders.
|
||||
type History func(*sql.Selector)
|
||||
|
||||
// ImportList is the predicate function for importlist builders.
|
||||
type ImportList func(*sql.Selector)
|
||||
|
||||
// Indexers is the predicate function for indexers builders.
|
||||
type Indexers func(*sql.Selector)
|
||||
|
||||
// Media is the predicate function for media builders.
|
||||
type Media func(*sql.Selector)
|
||||
|
||||
// NotificationClient is the predicate function for notificationclient builders.
|
||||
type NotificationClient func(*sql.Selector)
|
||||
|
||||
// Settings is the predicate function for settings builders.
|
||||
type Settings func(*sql.Selector)
|
||||
|
||||
|
||||
@@ -3,10 +3,13 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"polaris/ent/blacklist"
|
||||
"polaris/ent/downloadclients"
|
||||
"polaris/ent/episode"
|
||||
"polaris/ent/history"
|
||||
"polaris/ent/indexers"
|
||||
"polaris/ent/media"
|
||||
"polaris/ent/notificationclient"
|
||||
"polaris/ent/schema"
|
||||
"polaris/ent/storage"
|
||||
"time"
|
||||
@@ -16,6 +19,12 @@ import (
|
||||
// (default values, validators, hooks and policies) and stitches it
|
||||
// to their package variables.
|
||||
func init() {
|
||||
blacklistFields := schema.Blacklist{}.Fields()
|
||||
_ = blacklistFields
|
||||
// blacklistDescValue is the schema descriptor for value field.
|
||||
blacklistDescValue := blacklistFields[1].Descriptor()
|
||||
// blacklist.DefaultValue holds the default value on creation for the value field.
|
||||
blacklist.DefaultValue = blacklistDescValue.Default.(schema.BlacklistValue)
|
||||
downloadclientsFields := schema.DownloadClients{}.Fields()
|
||||
_ = downloadclientsFields
|
||||
// downloadclientsDescUser is the schema descriptor for user field.
|
||||
@@ -30,10 +39,12 @@ func init() {
|
||||
downloadclientsDescSettings := downloadclientsFields[6].Descriptor()
|
||||
// downloadclients.DefaultSettings holds the default value on creation for the settings field.
|
||||
downloadclients.DefaultSettings = downloadclientsDescSettings.Default.(string)
|
||||
// downloadclientsDescPriority is the schema descriptor for priority field.
|
||||
downloadclientsDescPriority := downloadclientsFields[7].Descriptor()
|
||||
// downloadclients.DefaultPriority holds the default value on creation for the priority field.
|
||||
downloadclients.DefaultPriority = downloadclientsDescPriority.Default.(string)
|
||||
// downloadclientsDescPriority1 is the schema descriptor for priority1 field.
|
||||
downloadclientsDescPriority1 := downloadclientsFields[7].Descriptor()
|
||||
// downloadclients.DefaultPriority1 holds the default value on creation for the priority1 field.
|
||||
downloadclients.DefaultPriority1 = downloadclientsDescPriority1.Default.(int)
|
||||
// downloadclients.Priority1Validator is a validator for the "priority1" field. It is called by the builders before save.
|
||||
downloadclients.Priority1Validator = downloadclientsDescPriority1.Validators[0].(func(int) error)
|
||||
// downloadclientsDescRemoveCompletedDownloads is the schema descriptor for remove_completed_downloads field.
|
||||
downloadclientsDescRemoveCompletedDownloads := downloadclientsFields[8].Descriptor()
|
||||
// downloadclients.DefaultRemoveCompletedDownloads holds the default value on creation for the remove_completed_downloads field.
|
||||
@@ -48,10 +59,14 @@ func init() {
|
||||
downloadclients.DefaultTags = downloadclientsDescTags.Default.(string)
|
||||
episodeFields := schema.Episode{}.Fields()
|
||||
_ = episodeFields
|
||||
// episodeDescMonitored is the schema descriptor for monitored field.
|
||||
episodeDescMonitored := episodeFields[7].Descriptor()
|
||||
// episode.DefaultMonitored holds the default value on creation for the monitored field.
|
||||
episode.DefaultMonitored = episodeDescMonitored.Default.(bool)
|
||||
historyFields := schema.History{}.Fields()
|
||||
_ = historyFields
|
||||
// historyDescSize is the schema descriptor for size field.
|
||||
historyDescSize := historyFields[5].Descriptor()
|
||||
historyDescSize := historyFields[7].Descriptor()
|
||||
// history.DefaultSize holds the default value on creation for the size field.
|
||||
history.DefaultSize = historyDescSize.Default.(int)
|
||||
indexersFields := schema.Indexers{}.Fields()
|
||||
@@ -60,6 +75,18 @@ func init() {
|
||||
indexersDescEnableRss := indexersFields[3].Descriptor()
|
||||
// indexers.DefaultEnableRss holds the default value on creation for the enable_rss field.
|
||||
indexers.DefaultEnableRss = indexersDescEnableRss.Default.(bool)
|
||||
// indexersDescPriority is the schema descriptor for priority field.
|
||||
indexersDescPriority := indexersFields[4].Descriptor()
|
||||
// indexers.DefaultPriority holds the default value on creation for the priority field.
|
||||
indexers.DefaultPriority = indexersDescPriority.Default.(int)
|
||||
// indexersDescSeedRatio is the schema descriptor for seed_ratio field.
|
||||
indexersDescSeedRatio := indexersFields[5].Descriptor()
|
||||
// indexers.DefaultSeedRatio holds the default value on creation for the seed_ratio field.
|
||||
indexers.DefaultSeedRatio = indexersDescSeedRatio.Default.(float32)
|
||||
// indexersDescDisabled is the schema descriptor for disabled field.
|
||||
indexersDescDisabled := indexersFields[6].Descriptor()
|
||||
// indexers.DefaultDisabled holds the default value on creation for the disabled field.
|
||||
indexers.DefaultDisabled = indexersDescDisabled.Default.(bool)
|
||||
mediaFields := schema.Media{}.Fields()
|
||||
_ = mediaFields
|
||||
// mediaDescCreatedAt is the schema descriptor for created_at field.
|
||||
@@ -70,14 +97,24 @@ func init() {
|
||||
mediaDescAirDate := mediaFields[8].Descriptor()
|
||||
// media.DefaultAirDate holds the default value on creation for the air_date field.
|
||||
media.DefaultAirDate = mediaDescAirDate.Default.(string)
|
||||
// mediaDescDownloadHistoryEpisodes is the schema descriptor for download_history_episodes field.
|
||||
mediaDescDownloadHistoryEpisodes := mediaFields[12].Descriptor()
|
||||
// media.DefaultDownloadHistoryEpisodes holds the default value on creation for the download_history_episodes field.
|
||||
media.DefaultDownloadHistoryEpisodes = mediaDescDownloadHistoryEpisodes.Default.(bool)
|
||||
notificationclientFields := schema.NotificationClient{}.Fields()
|
||||
_ = notificationclientFields
|
||||
// notificationclientDescEnabled is the schema descriptor for enabled field.
|
||||
notificationclientDescEnabled := notificationclientFields[3].Descriptor()
|
||||
// notificationclient.DefaultEnabled holds the default value on creation for the enabled field.
|
||||
notificationclient.DefaultEnabled = notificationclientDescEnabled.Default.(bool)
|
||||
storageFields := schema.Storage{}.Fields()
|
||||
_ = storageFields
|
||||
// storageDescDeleted is the schema descriptor for deleted field.
|
||||
storageDescDeleted := storageFields[3].Descriptor()
|
||||
storageDescDeleted := storageFields[5].Descriptor()
|
||||
// storage.DefaultDeleted holds the default value on creation for the deleted field.
|
||||
storage.DefaultDeleted = storageDescDeleted.Default.(bool)
|
||||
// storageDescDefault is the schema descriptor for default field.
|
||||
storageDescDefault := storageFields[4].Descriptor()
|
||||
storageDescDefault := storageFields[6].Descriptor()
|
||||
// storage.DefaultDefault holds the default value on creation for the default field.
|
||||
storage.DefaultDefault = storageDescDefault.Default.(bool)
|
||||
}
|
||||
|
||||
30
ent/schema/blacklist.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// Blacklist holds the schema definition for the Blacklist entity.
|
||||
type Blacklist struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the Blacklist.
|
||||
func (Blacklist) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Enum("type").Values("media", "torrent"),
|
||||
field.JSON("value", BlacklistValue{}).Default(BlacklistValue{}),
|
||||
field.String("notes").Optional(),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the Blacklist.
|
||||
func (Blacklist) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
||||
|
||||
type BlacklistValue struct {
|
||||
TmdbID int `json:"tmdb_id"`
|
||||
TorrentHash string `json:"torrent_hash"`
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
@@ -15,12 +17,20 @@ func (DownloadClients) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Bool("enable"),
|
||||
field.String("name"),
|
||||
field.String("implementation"),
|
||||
field.Enum("implementation").Values("transmission", "qbittorrent"),
|
||||
field.String("url"),
|
||||
field.String("user").Default(""),
|
||||
field.String("password").Default(""),
|
||||
field.String("settings").Default(""),
|
||||
field.String("priority").Default(""),
|
||||
field.Int("priority1").Default(1).Validate(func(i int) error {
|
||||
if i > 50 {
|
||||
return errors.ErrUnsupported
|
||||
}
|
||||
if i <= 0 {
|
||||
return errors.ErrUnsupported
|
||||
}
|
||||
return nil
|
||||
}),
|
||||
field.Bool("remove_completed_downloads").Default(true),
|
||||
field.Bool("remove_failed_downloads").Default(true),
|
||||
field.String("tags").Default(""),
|
||||
|
||||
@@ -21,17 +21,18 @@ func (Episode) Fields() []ent.Field {
|
||||
field.String("overview"),
|
||||
field.String("air_date"),
|
||||
field.Enum("status").Values("missing", "downloading", "downloaded").Default("missing"),
|
||||
field.String("file_in_storage").Optional(),
|
||||
field.Bool("monitored").Default(false).StructTag("json:\"monitored\""), //whether this episode is monitored
|
||||
field.String("target_file").Optional(),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the Episode.
|
||||
func (Episode) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("media", Media.Type).
|
||||
Ref("episodes").
|
||||
Unique().
|
||||
edge.From("media", Media.Type).
|
||||
Ref("episodes").
|
||||
Unique().
|
||||
Field("media_id"),
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,13 +14,18 @@ type History struct {
|
||||
func (History) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int("media_id"),
|
||||
field.Int("episode_id").Optional(),
|
||||
field.Int("episode_id").Optional().Comment("deprecated"),
|
||||
field.Ints("episode_nums").Optional(),
|
||||
field.Int("season_num").Optional(),
|
||||
field.String("source_title"),
|
||||
field.Time("date"),
|
||||
field.String("target_dir"),
|
||||
field.Int("size").Default(0),
|
||||
field.Enum("status").Values("running", "success", "fail", "uploading"),
|
||||
field.String("saved").Optional(),
|
||||
field.Int("download_client_id").Optional(),
|
||||
field.Int("indexer_id").Optional(),
|
||||
field.String("link").Optional(), //should be magnet link
|
||||
field.Enum("status").Values("running", "success", "fail", "uploading", "seeding"),
|
||||
field.String("saved").Optional().Comment("deprecated"), //deprecated
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
32
ent/schema/importlist.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// ImportList holds the schema definition for the ImportList entity.
|
||||
type ImportList struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the ImportList.
|
||||
func (ImportList) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("name"),
|
||||
field.Enum("type").Values("plex", "doulist"),
|
||||
field.String("url").Optional(),
|
||||
field.String("qulity"),
|
||||
field.Int("storage_id"),
|
||||
field.JSON("settings", ImportListSettings{}).Optional(),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the ImportList.
|
||||
func (ImportList) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
||||
|
||||
type ImportListSettings struct {
|
||||
//Url string `json:"url"`
|
||||
}
|
||||
@@ -17,7 +17,9 @@ func (Indexers) Fields() []ent.Field {
|
||||
field.String("implementation"),
|
||||
field.String("settings"),
|
||||
field.Bool("enable_rss").Default(true),
|
||||
field.Int("priority"),
|
||||
field.Int("priority").Default(50),
|
||||
field.Float32("seed_ratio").Optional().Default(0).Comment("minimal seed ratio requied, before removing torrent"),
|
||||
field.Bool("disabled").Optional().Default(false),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,13 @@ func (Media) Fields() []ent.Field {
|
||||
field.String("overview"),
|
||||
field.Time("created_at").Default(time.Now()),
|
||||
field.String("air_date").Default(""),
|
||||
field.Enum("resolution").Values("720p", "1080p", "4k").Default("1080p"),
|
||||
field.Enum("resolution").Values("720p", "1080p", "2160p", "any").Default("1080p"),
|
||||
field.Int("storage_id").Optional(),
|
||||
field.String("target_dir").Optional(),
|
||||
field.Bool("download_history_episodes").Optional().Default(false).Comment("tv series only"),
|
||||
field.JSON("limiter", MediaLimiter{}).Optional(),
|
||||
field.JSON("extras", MediaExtras{}).Optional(),
|
||||
field.JSON("alternative_titles", []AlternativeTilte{}).Optional(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,3 +41,30 @@ func (Media) Edges() []ent.Edge {
|
||||
edge.To("episodes", Episode.Type),
|
||||
}
|
||||
}
|
||||
|
||||
type AlternativeTilte struct {
|
||||
Iso3166_1 string `json:"iso_3166_1"`
|
||||
Title string `json:"title"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
type MediaLimiter struct {
|
||||
SizeMin int64 `json:"size_min"` //in B
|
||||
SizeMax int64 `json:"size_max"` //in B
|
||||
PreferSize int64 `json:"prefer_max"`
|
||||
}
|
||||
|
||||
type MediaExtras struct {
|
||||
IsAdultMovie bool `json:"is_adult_movie"`
|
||||
JavId string `json:"javid"`
|
||||
//OriginCountry []string `json:"origin_country"`
|
||||
OriginalLanguage string `json:"original_language"`
|
||||
Genres []struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
} `json:"genres"`
|
||||
}
|
||||
|
||||
func (m *MediaExtras) IsJav() bool {
|
||||
return m.IsAdultMovie && m.JavId != ""
|
||||
}
|
||||
|
||||
26
ent/schema/notificationclient.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// NotificationClient holds the schema definition for the NotificationClient entity.
|
||||
type NotificationClient struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the NotificationClient.
|
||||
func (NotificationClient) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("name"),
|
||||
field.String("service"),
|
||||
field.String("settings"),
|
||||
field.Bool("enabled").Default(true),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the NotificationClient.
|
||||
func (NotificationClient) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
||||
@@ -14,7 +14,9 @@ type Storage struct {
|
||||
func (Storage) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("name").Unique(),
|
||||
field.Enum("implementation").Values("webdav", "local"),
|
||||
field.Enum("implementation").Values("webdav", "local", "alist"),
|
||||
field.String("tv_path").Optional(),
|
||||
field.String("movie_path").Optional(),
|
||||
field.String("settings").Optional(),
|
||||
field.Bool("deleted").Default(false),
|
||||
field.Bool("default").Default(false),
|
||||
|
||||
@@ -20,6 +20,10 @@ type Storage struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
// Implementation holds the value of the "implementation" field.
|
||||
Implementation storage.Implementation `json:"implementation,omitempty"`
|
||||
// TvPath holds the value of the "tv_path" field.
|
||||
TvPath string `json:"tv_path,omitempty"`
|
||||
// MoviePath holds the value of the "movie_path" field.
|
||||
MoviePath string `json:"movie_path,omitempty"`
|
||||
// Settings holds the value of the "settings" field.
|
||||
Settings string `json:"settings,omitempty"`
|
||||
// Deleted holds the value of the "deleted" field.
|
||||
@@ -38,7 +42,7 @@ func (*Storage) scanValues(columns []string) ([]any, error) {
|
||||
values[i] = new(sql.NullBool)
|
||||
case storage.FieldID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case storage.FieldName, storage.FieldImplementation, storage.FieldSettings:
|
||||
case storage.FieldName, storage.FieldImplementation, storage.FieldTvPath, storage.FieldMoviePath, storage.FieldSettings:
|
||||
values[i] = new(sql.NullString)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
@@ -73,6 +77,18 @@ func (s *Storage) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
s.Implementation = storage.Implementation(value.String)
|
||||
}
|
||||
case storage.FieldTvPath:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field tv_path", values[i])
|
||||
} else if value.Valid {
|
||||
s.TvPath = value.String
|
||||
}
|
||||
case storage.FieldMoviePath:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field movie_path", values[i])
|
||||
} else if value.Valid {
|
||||
s.MoviePath = value.String
|
||||
}
|
||||
case storage.FieldSettings:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field settings", values[i])
|
||||
@@ -133,6 +149,12 @@ func (s *Storage) String() string {
|
||||
builder.WriteString("implementation=")
|
||||
builder.WriteString(fmt.Sprintf("%v", s.Implementation))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("tv_path=")
|
||||
builder.WriteString(s.TvPath)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("movie_path=")
|
||||
builder.WriteString(s.MoviePath)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("settings=")
|
||||
builder.WriteString(s.Settings)
|
||||
builder.WriteString(", ")
|
||||
|
||||
@@ -17,6 +17,10 @@ const (
|
||||
FieldName = "name"
|
||||
// FieldImplementation holds the string denoting the implementation field in the database.
|
||||
FieldImplementation = "implementation"
|
||||
// FieldTvPath holds the string denoting the tv_path field in the database.
|
||||
FieldTvPath = "tv_path"
|
||||
// FieldMoviePath holds the string denoting the movie_path field in the database.
|
||||
FieldMoviePath = "movie_path"
|
||||
// FieldSettings holds the string denoting the settings field in the database.
|
||||
FieldSettings = "settings"
|
||||
// FieldDeleted holds the string denoting the deleted field in the database.
|
||||
@@ -32,6 +36,8 @@ var Columns = []string{
|
||||
FieldID,
|
||||
FieldName,
|
||||
FieldImplementation,
|
||||
FieldTvPath,
|
||||
FieldMoviePath,
|
||||
FieldSettings,
|
||||
FieldDeleted,
|
||||
FieldDefault,
|
||||
@@ -61,6 +67,7 @@ type Implementation string
|
||||
const (
|
||||
ImplementationWebdav Implementation = "webdav"
|
||||
ImplementationLocal Implementation = "local"
|
||||
ImplementationAlist Implementation = "alist"
|
||||
)
|
||||
|
||||
func (i Implementation) String() string {
|
||||
@@ -70,7 +77,7 @@ func (i Implementation) String() string {
|
||||
// ImplementationValidator is a validator for the "implementation" field enum values. It is called by the builders before save.
|
||||
func ImplementationValidator(i Implementation) error {
|
||||
switch i {
|
||||
case ImplementationWebdav, ImplementationLocal:
|
||||
case ImplementationWebdav, ImplementationLocal, ImplementationAlist:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("storage: invalid enum value for implementation field: %q", i)
|
||||
@@ -95,6 +102,16 @@ func ByImplementation(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldImplementation, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTvPath orders the results by the tv_path field.
|
||||
func ByTvPath(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTvPath, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByMoviePath orders the results by the movie_path field.
|
||||
func ByMoviePath(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldMoviePath, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySettings orders the results by the settings field.
|
||||
func BySettings(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSettings, opts...).ToFunc()
|
||||
|
||||
@@ -58,6 +58,16 @@ func Name(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// TvPath applies equality check predicate on the "tv_path" field. It's identical to TvPathEQ.
|
||||
func TvPath(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldEQ(FieldTvPath, v))
|
||||
}
|
||||
|
||||
// MoviePath applies equality check predicate on the "movie_path" field. It's identical to MoviePathEQ.
|
||||
func MoviePath(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldEQ(FieldMoviePath, v))
|
||||
}
|
||||
|
||||
// Settings applies equality check predicate on the "settings" field. It's identical to SettingsEQ.
|
||||
func Settings(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldEQ(FieldSettings, v))
|
||||
@@ -158,6 +168,156 @@ func ImplementationNotIn(vs ...Implementation) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldNotIn(FieldImplementation, vs...))
|
||||
}
|
||||
|
||||
// TvPathEQ applies the EQ predicate on the "tv_path" field.
|
||||
func TvPathEQ(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldEQ(FieldTvPath, v))
|
||||
}
|
||||
|
||||
// TvPathNEQ applies the NEQ predicate on the "tv_path" field.
|
||||
func TvPathNEQ(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldNEQ(FieldTvPath, v))
|
||||
}
|
||||
|
||||
// TvPathIn applies the In predicate on the "tv_path" field.
|
||||
func TvPathIn(vs ...string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldIn(FieldTvPath, vs...))
|
||||
}
|
||||
|
||||
// TvPathNotIn applies the NotIn predicate on the "tv_path" field.
|
||||
func TvPathNotIn(vs ...string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldNotIn(FieldTvPath, vs...))
|
||||
}
|
||||
|
||||
// TvPathGT applies the GT predicate on the "tv_path" field.
|
||||
func TvPathGT(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldGT(FieldTvPath, v))
|
||||
}
|
||||
|
||||
// TvPathGTE applies the GTE predicate on the "tv_path" field.
|
||||
func TvPathGTE(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldGTE(FieldTvPath, v))
|
||||
}
|
||||
|
||||
// TvPathLT applies the LT predicate on the "tv_path" field.
|
||||
func TvPathLT(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldLT(FieldTvPath, v))
|
||||
}
|
||||
|
||||
// TvPathLTE applies the LTE predicate on the "tv_path" field.
|
||||
func TvPathLTE(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldLTE(FieldTvPath, v))
|
||||
}
|
||||
|
||||
// TvPathContains applies the Contains predicate on the "tv_path" field.
|
||||
func TvPathContains(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldContains(FieldTvPath, v))
|
||||
}
|
||||
|
||||
// TvPathHasPrefix applies the HasPrefix predicate on the "tv_path" field.
|
||||
func TvPathHasPrefix(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldHasPrefix(FieldTvPath, v))
|
||||
}
|
||||
|
||||
// TvPathHasSuffix applies the HasSuffix predicate on the "tv_path" field.
|
||||
func TvPathHasSuffix(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldHasSuffix(FieldTvPath, v))
|
||||
}
|
||||
|
||||
// TvPathIsNil applies the IsNil predicate on the "tv_path" field.
|
||||
func TvPathIsNil() predicate.Storage {
|
||||
return predicate.Storage(sql.FieldIsNull(FieldTvPath))
|
||||
}
|
||||
|
||||
// TvPathNotNil applies the NotNil predicate on the "tv_path" field.
|
||||
func TvPathNotNil() predicate.Storage {
|
||||
return predicate.Storage(sql.FieldNotNull(FieldTvPath))
|
||||
}
|
||||
|
||||
// TvPathEqualFold applies the EqualFold predicate on the "tv_path" field.
|
||||
func TvPathEqualFold(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldEqualFold(FieldTvPath, v))
|
||||
}
|
||||
|
||||
// TvPathContainsFold applies the ContainsFold predicate on the "tv_path" field.
|
||||
func TvPathContainsFold(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldContainsFold(FieldTvPath, v))
|
||||
}
|
||||
|
||||
// MoviePathEQ applies the EQ predicate on the "movie_path" field.
|
||||
func MoviePathEQ(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldEQ(FieldMoviePath, v))
|
||||
}
|
||||
|
||||
// MoviePathNEQ applies the NEQ predicate on the "movie_path" field.
|
||||
func MoviePathNEQ(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldNEQ(FieldMoviePath, v))
|
||||
}
|
||||
|
||||
// MoviePathIn applies the In predicate on the "movie_path" field.
|
||||
func MoviePathIn(vs ...string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldIn(FieldMoviePath, vs...))
|
||||
}
|
||||
|
||||
// MoviePathNotIn applies the NotIn predicate on the "movie_path" field.
|
||||
func MoviePathNotIn(vs ...string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldNotIn(FieldMoviePath, vs...))
|
||||
}
|
||||
|
||||
// MoviePathGT applies the GT predicate on the "movie_path" field.
|
||||
func MoviePathGT(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldGT(FieldMoviePath, v))
|
||||
}
|
||||
|
||||
// MoviePathGTE applies the GTE predicate on the "movie_path" field.
|
||||
func MoviePathGTE(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldGTE(FieldMoviePath, v))
|
||||
}
|
||||
|
||||
// MoviePathLT applies the LT predicate on the "movie_path" field.
|
||||
func MoviePathLT(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldLT(FieldMoviePath, v))
|
||||
}
|
||||
|
||||
// MoviePathLTE applies the LTE predicate on the "movie_path" field.
|
||||
func MoviePathLTE(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldLTE(FieldMoviePath, v))
|
||||
}
|
||||
|
||||
// MoviePathContains applies the Contains predicate on the "movie_path" field.
|
||||
func MoviePathContains(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldContains(FieldMoviePath, v))
|
||||
}
|
||||
|
||||
// MoviePathHasPrefix applies the HasPrefix predicate on the "movie_path" field.
|
||||
func MoviePathHasPrefix(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldHasPrefix(FieldMoviePath, v))
|
||||
}
|
||||
|
||||
// MoviePathHasSuffix applies the HasSuffix predicate on the "movie_path" field.
|
||||
func MoviePathHasSuffix(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldHasSuffix(FieldMoviePath, v))
|
||||
}
|
||||
|
||||
// MoviePathIsNil applies the IsNil predicate on the "movie_path" field.
|
||||
func MoviePathIsNil() predicate.Storage {
|
||||
return predicate.Storage(sql.FieldIsNull(FieldMoviePath))
|
||||
}
|
||||
|
||||
// MoviePathNotNil applies the NotNil predicate on the "movie_path" field.
|
||||
func MoviePathNotNil() predicate.Storage {
|
||||
return predicate.Storage(sql.FieldNotNull(FieldMoviePath))
|
||||
}
|
||||
|
||||
// MoviePathEqualFold applies the EqualFold predicate on the "movie_path" field.
|
||||
func MoviePathEqualFold(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldEqualFold(FieldMoviePath, v))
|
||||
}
|
||||
|
||||
// MoviePathContainsFold applies the ContainsFold predicate on the "movie_path" field.
|
||||
func MoviePathContainsFold(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldContainsFold(FieldMoviePath, v))
|
||||
}
|
||||
|
||||
// SettingsEQ applies the EQ predicate on the "settings" field.
|
||||
func SettingsEQ(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldEQ(FieldSettings, v))
|
||||
|
||||