mirror of
https://github.com/simon-ding/polaris.git
synced 2026-02-16 12:00:50 +08:00
Compare commits
74 Commits
v0.22.0
...
dev-kratos
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
76f50930de | ||
|
|
f8203df26a | ||
|
|
ad950f6c28 | ||
|
|
068aa121a4 | ||
|
|
5e143edda3 | ||
|
|
a491a5f1ea | ||
|
|
094c7a24b9 | ||
|
|
b80d38788c | ||
|
|
f59a0682c6 | ||
|
|
ead022e17d | ||
|
|
b69100d9b4 | ||
|
|
bb0d5d1b58 | ||
|
|
992fa7ddd0 | ||
|
|
bb2c567da7 | ||
|
|
2dae168cb2 | ||
|
|
9719c6a7c9 | ||
|
|
5375f66018 | ||
|
|
3a73d0c33e | ||
|
|
3eb1f37387 | ||
|
|
9b791ba86f | ||
|
|
22db6b15cf | ||
|
|
33d82951c1 | ||
|
|
dd77e25b38 | ||
|
|
c58a038daf | ||
|
|
b81c5d327c | ||
|
|
04dcbf04e7 | ||
|
|
4bf72a7976 | ||
|
|
9e14be7322 | ||
|
|
483e1caf83 | ||
|
|
f074d38f4f | ||
|
|
9c7129660c | ||
|
|
8b11e72427 | ||
|
|
2267b0450a | ||
|
|
8973fe9d5d | ||
|
|
9d3b206762 | ||
|
|
386e5ce100 | ||
|
|
78573b71a9 | ||
|
|
62fd7e2c18 | ||
|
|
2641a5fccd | ||
|
|
98823e251b | ||
|
|
269a5bf030 | ||
|
|
502d482ea9 | ||
|
|
cff83e4d5f | ||
|
|
9b7527defe | ||
|
|
aecbc5f657 | ||
|
|
9e41a1513c | ||
|
|
0d527c22e5 | ||
|
|
0dea185077 | ||
|
|
834254b9b8 | ||
|
|
fdcf7f487c | ||
|
|
1a3807acc9 | ||
|
|
549aaf60ca | ||
|
|
2fad5ea69b | ||
|
|
3c7d7aa263 | ||
|
|
17f357e33a | ||
|
|
7ccc73e044 | ||
|
|
ff2f290641 | ||
|
|
aee32c7bbf | ||
|
|
8e9ba101c8 | ||
|
|
ec3f9b2f96 | ||
|
|
8f354fff41 | ||
|
|
d44060ff33 | ||
|
|
1ea8246cfc | ||
|
|
8aef9260a1 | ||
|
|
ef3b555036 | ||
|
|
26dc488d48 | ||
|
|
14764c7b06 | ||
|
|
951b73bc4e | ||
|
|
55c2a3c8e2 | ||
|
|
310c83a27c | ||
|
|
75ef1a42ae | ||
|
|
fa78e40baf | ||
|
|
aefc4a28c2 | ||
|
|
4bc0a44c33 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,6 +12,7 @@ config.yml
|
||||
.DS_Store
|
||||
*.db
|
||||
data/
|
||||
!internal/data/
|
||||
|
||||
ui/node_modules/
|
||||
ui/dist/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM golang:1.23 as builder
|
||||
FROM golang:1.24 as builder
|
||||
|
||||
# 启用go module
|
||||
ENV GO111MODULE=on
|
||||
|
||||
87
Makefile
87
Makefile
@@ -1,6 +1,87 @@
|
||||
.PHONY: windows
|
||||
GOHOSTOS:=$(shell go env GOHOSTOS)
|
||||
GOPATH:=$(shell go env GOPATH)
|
||||
VERSION=$(shell git describe --tags --always)
|
||||
|
||||
ifeq ($(GOHOSTOS), windows)
|
||||
#the `find.exe` is different from `find` in bash/shell.
|
||||
#to see https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/find.
|
||||
#changed to use git-bash.exe to run find cli or other cli friendly, caused of every developer has a Git.
|
||||
#Git_Bash= $(subst cmd\,bin\bash.exe,$(dir $(shell where git)))
|
||||
Git_Bash=$(subst \,/,$(subst cmd\,bin\bash.exe,$(dir $(shell where git))))
|
||||
INTERNAL_PROTO_FILES=$(shell $(Git_Bash) -c "find internal -name *.proto")
|
||||
API_PROTO_FILES=$(shell $(Git_Bash) -c "find api -name *.proto")
|
||||
else
|
||||
INTERNAL_PROTO_FILES=$(shell find internal -name *.proto)
|
||||
API_PROTO_FILES=$(shell find api -name *.proto)
|
||||
endif
|
||||
|
||||
.PHONY: init
|
||||
# init env
|
||||
init:
|
||||
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
|
||||
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
|
||||
go install github.com/go-kratos/kratos/cmd/kratos/v2@latest
|
||||
go install github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2@latest
|
||||
go install github.com/google/gnostic/cmd/protoc-gen-openapi@latest
|
||||
go install github.com/google/wire/cmd/wire@latest
|
||||
|
||||
.PHONY: config
|
||||
# generate internal proto
|
||||
config:
|
||||
protoc --proto_path=./internal \
|
||||
--proto_path=./third_party \
|
||||
--go_out=paths=source_relative:./internal \
|
||||
$(INTERNAL_PROTO_FILES)
|
||||
|
||||
.PHONY: api
|
||||
# generate api proto
|
||||
api:
|
||||
protoc --proto_path=./api \
|
||||
--proto_path=./third_party \
|
||||
--go_out=paths=source_relative:./api \
|
||||
--go-http_out=paths=source_relative:./api \
|
||||
--go-grpc_out=paths=source_relative:./api \
|
||||
--openapi_out=fq_schema_naming=true,default_response=false:. \
|
||||
$(API_PROTO_FILES)
|
||||
|
||||
.PHONY: build
|
||||
# build
|
||||
build:
|
||||
mkdir -p bin/ && go build -ldflags "-X main.Version=$(VERSION)" -o ./bin/ ./...
|
||||
|
||||
.PHONY: generate
|
||||
# generate
|
||||
generate:
|
||||
go generate ./...
|
||||
go mod tidy
|
||||
|
||||
.PHONY: all
|
||||
# generate all
|
||||
all:
|
||||
make api;
|
||||
make config;
|
||||
make generate;
|
||||
|
||||
# show help
|
||||
help:
|
||||
@echo ''
|
||||
@echo 'Usage:'
|
||||
@echo ' make [target]'
|
||||
@echo ''
|
||||
@echo 'Targets:'
|
||||
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
|
||||
helpMessage = match(lastLine, /^# (.*)/); \
|
||||
if (helpMessage) { \
|
||||
helpCommand = substr($$1, 0, index($$1, ":")); \
|
||||
helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \
|
||||
printf "\033[36m%-22s\033[0m %s\n", helpCommand,helpMessage; \
|
||||
} \
|
||||
} \
|
||||
{ lastLine = $$0 }' $(MAKEFILE_LIST)
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
windows:
|
||||
@echo "Building for Windows..."
|
||||
go build -tags c -ldflags="-X polaris/db.Version=$(git describe --tags --long)" -buildmode=c-shared -o ui/windows/libpolaris.dll ./cmd/binding
|
||||
cd ui && flutter build windows
|
||||
go build -tags lib -ldflags="-X polaris/db.Version=$(git describe --tags --long)" -buildmode=c-shared -o ui/windows/libpolaris.dll ./cmd/binding
|
||||
cd ui && flutter build windows
|
||||
|
||||
@@ -21,7 +21,14 @@
|
||||
|
||||
## 快速开始
|
||||
|
||||
使用此程序参考 [【快速开始】](./doc/quick_start.md)
|
||||
若要体验,请确保本机有docker环境,然后执行:
|
||||
|
||||
```bash
|
||||
docker run -p 8080:8080 ghcr.io/simon-ding/polaris:latest
|
||||
```
|
||||
随后访问 http://127.0.0.1:8080 ,即可快速体验Polaris的功能
|
||||
|
||||
正式部署请参考 [【快速开始】](./doc/quick_start.md)
|
||||
|
||||
## Features
|
||||
|
||||
|
||||
135
api/helloworld/v1/error_reason.pb.go
Normal file
135
api/helloworld/v1/error_reason.pb.go
Normal file
@@ -0,0 +1,135 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.27.1
|
||||
// protoc v3.19.3
|
||||
// source: helloworld/v1/error_reason.proto
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type ErrorReason int32
|
||||
|
||||
const (
|
||||
ErrorReason_GEETER_UNSPECIFIED ErrorReason = 0
|
||||
ErrorReason_USER_NOT_FOUND ErrorReason = 1
|
||||
)
|
||||
|
||||
// Enum value maps for ErrorReason.
|
||||
var (
|
||||
ErrorReason_name = map[int32]string{
|
||||
0: "GEETER_UNSPECIFIED",
|
||||
1: "USER_NOT_FOUND",
|
||||
}
|
||||
ErrorReason_value = map[string]int32{
|
||||
"GEETER_UNSPECIFIED": 0,
|
||||
"USER_NOT_FOUND": 1,
|
||||
}
|
||||
)
|
||||
|
||||
func (x ErrorReason) Enum() *ErrorReason {
|
||||
p := new(ErrorReason)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
|
||||
func (x ErrorReason) String() string {
|
||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||
}
|
||||
|
||||
func (ErrorReason) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_helloworld_v1_error_reason_proto_enumTypes[0].Descriptor()
|
||||
}
|
||||
|
||||
func (ErrorReason) Type() protoreflect.EnumType {
|
||||
return &file_helloworld_v1_error_reason_proto_enumTypes[0]
|
||||
}
|
||||
|
||||
func (x ErrorReason) Number() protoreflect.EnumNumber {
|
||||
return protoreflect.EnumNumber(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ErrorReason.Descriptor instead.
|
||||
func (ErrorReason) EnumDescriptor() ([]byte, []int) {
|
||||
return file_helloworld_v1_error_reason_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
var File_helloworld_v1_error_reason_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_helloworld_v1_error_reason_proto_rawDesc = []byte{
|
||||
0x0a, 0x20, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2f, 0x76, 0x31, 0x2f,
|
||||
0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x12, 0x0d, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x76,
|
||||
0x31, 0x2a, 0x39, 0x0a, 0x0b, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e,
|
||||
0x12, 0x16, 0x0a, 0x12, 0x47, 0x45, 0x45, 0x54, 0x45, 0x52, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45,
|
||||
0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x55, 0x53, 0x45, 0x52,
|
||||
0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x46, 0x4f, 0x55, 0x4e, 0x44, 0x10, 0x01, 0x42, 0x5c, 0x0a, 0x0d,
|
||||
0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x76, 0x31, 0x50, 0x01, 0x5a,
|
||||
0x37, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x2d, 0x6b,
|
||||
0x72, 0x61, 0x74, 0x6f, 0x73, 0x2f, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2d, 0x6c, 0x61, 0x79,
|
||||
0x6f, 0x75, 0x74, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72,
|
||||
0x6c, 0x64, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0xa2, 0x02, 0x0f, 0x41, 0x50, 0x49, 0x48, 0x65,
|
||||
0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_helloworld_v1_error_reason_proto_rawDescOnce sync.Once
|
||||
file_helloworld_v1_error_reason_proto_rawDescData = file_helloworld_v1_error_reason_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_helloworld_v1_error_reason_proto_rawDescGZIP() []byte {
|
||||
file_helloworld_v1_error_reason_proto_rawDescOnce.Do(func() {
|
||||
file_helloworld_v1_error_reason_proto_rawDescData = protoimpl.X.CompressGZIP(file_helloworld_v1_error_reason_proto_rawDescData)
|
||||
})
|
||||
return file_helloworld_v1_error_reason_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_helloworld_v1_error_reason_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_helloworld_v1_error_reason_proto_goTypes = []interface{}{
|
||||
(ErrorReason)(0), // 0: helloworld.v1.ErrorReason
|
||||
}
|
||||
var file_helloworld_v1_error_reason_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_helloworld_v1_error_reason_proto_init() }
|
||||
func file_helloworld_v1_error_reason_proto_init() {
|
||||
if File_helloworld_v1_error_reason_proto != nil {
|
||||
return
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_helloworld_v1_error_reason_proto_rawDesc,
|
||||
NumEnums: 1,
|
||||
NumMessages: 0,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_helloworld_v1_error_reason_proto_goTypes,
|
||||
DependencyIndexes: file_helloworld_v1_error_reason_proto_depIdxs,
|
||||
EnumInfos: file_helloworld_v1_error_reason_proto_enumTypes,
|
||||
}.Build()
|
||||
File_helloworld_v1_error_reason_proto = out.File
|
||||
file_helloworld_v1_error_reason_proto_rawDesc = nil
|
||||
file_helloworld_v1_error_reason_proto_goTypes = nil
|
||||
file_helloworld_v1_error_reason_proto_depIdxs = nil
|
||||
}
|
||||
13
api/helloworld/v1/error_reason.proto
Normal file
13
api/helloworld/v1/error_reason.proto
Normal file
@@ -0,0 +1,13 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package helloworld.v1;
|
||||
|
||||
option go_package = "polaris/api/helloworld/v1;v1";
|
||||
option java_multiple_files = true;
|
||||
option java_package = "helloworld.v1";
|
||||
option objc_class_prefix = "APIHelloworldV1";
|
||||
|
||||
enum ErrorReason {
|
||||
GREETER_UNSPECIFIED = 0;
|
||||
USER_NOT_FOUND = 1;
|
||||
}
|
||||
225
api/helloworld/v1/greeter.pb.go
Normal file
225
api/helloworld/v1/greeter.pb.go
Normal file
@@ -0,0 +1,225 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.27.1
|
||||
// protoc v3.19.3
|
||||
// source: helloworld/v1/greeter.proto
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// The request message containing the user's name.
|
||||
type HelloRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
}
|
||||
|
||||
func (x *HelloRequest) Reset() {
|
||||
*x = HelloRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_helloworld_v1_greeter_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *HelloRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*HelloRequest) ProtoMessage() {}
|
||||
|
||||
func (x *HelloRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_helloworld_v1_greeter_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead.
|
||||
func (*HelloRequest) Descriptor() ([]byte, []int) {
|
||||
return file_helloworld_v1_greeter_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *HelloRequest) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// The response message containing the greetings
|
||||
type HelloReply struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
|
||||
}
|
||||
|
||||
func (x *HelloReply) Reset() {
|
||||
*x = HelloReply{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_helloworld_v1_greeter_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *HelloReply) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*HelloReply) ProtoMessage() {}
|
||||
|
||||
func (x *HelloReply) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_helloworld_v1_greeter_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use HelloReply.ProtoReflect.Descriptor instead.
|
||||
func (*HelloReply) Descriptor() ([]byte, []int) {
|
||||
return file_helloworld_v1_greeter_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *HelloReply) GetMessage() string {
|
||||
if x != nil {
|
||||
return x.Message
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_helloworld_v1_greeter_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_helloworld_v1_greeter_proto_rawDesc = []byte{
|
||||
0x0a, 0x1b, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2f, 0x76, 0x31, 0x2f,
|
||||
0x67, 0x72, 0x65, 0x65, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x68,
|
||||
0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x76, 0x31, 0x1a, 0x1c, 0x67, 0x6f,
|
||||
0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x22, 0x0a, 0x0c, 0x48, 0x65,
|
||||
0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61,
|
||||
0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x26,
|
||||
0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07,
|
||||
0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d,
|
||||
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x69, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65, 0x74, 0x65,
|
||||
0x72, 0x12, 0x5e, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, 0x1b, 0x2e,
|
||||
0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x65,
|
||||
0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x68, 0x65, 0x6c,
|
||||
0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f,
|
||||
0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x12, 0x12, 0x2f,
|
||||
0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65,
|
||||
0x7d, 0x42, 0x6c, 0x0a, 0x1c, 0x64, 0x65, 0x76, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e,
|
||||
0x61, 0x70, 0x69, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x76,
|
||||
0x31, 0x42, 0x11, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x50, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x56, 0x31, 0x50, 0x01, 0x5a, 0x37, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
|
||||
0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x2d, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2f, 0x6b, 0x72, 0x61,
|
||||
0x74, 0x6f, 0x73, 0x2d, 0x6c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x68,
|
||||
0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62,
|
||||
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_helloworld_v1_greeter_proto_rawDescOnce sync.Once
|
||||
file_helloworld_v1_greeter_proto_rawDescData = file_helloworld_v1_greeter_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_helloworld_v1_greeter_proto_rawDescGZIP() []byte {
|
||||
file_helloworld_v1_greeter_proto_rawDescOnce.Do(func() {
|
||||
file_helloworld_v1_greeter_proto_rawDescData = protoimpl.X.CompressGZIP(file_helloworld_v1_greeter_proto_rawDescData)
|
||||
})
|
||||
return file_helloworld_v1_greeter_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_helloworld_v1_greeter_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_helloworld_v1_greeter_proto_goTypes = []interface{}{
|
||||
(*HelloRequest)(nil), // 0: helloworld.v1.HelloRequest
|
||||
(*HelloReply)(nil), // 1: helloworld.v1.HelloReply
|
||||
}
|
||||
var file_helloworld_v1_greeter_proto_depIdxs = []int32{
|
||||
0, // 0: helloworld.v1.Greeter.SayHello:input_type -> helloworld.v1.HelloRequest
|
||||
1, // 1: helloworld.v1.Greeter.SayHello:output_type -> helloworld.v1.HelloReply
|
||||
1, // [1:2] is the sub-list for method output_type
|
||||
0, // [0:1] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_helloworld_v1_greeter_proto_init() }
|
||||
func file_helloworld_v1_greeter_proto_init() {
|
||||
if File_helloworld_v1_greeter_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_helloworld_v1_greeter_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*HelloRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_helloworld_v1_greeter_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*HelloReply); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_helloworld_v1_greeter_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_helloworld_v1_greeter_proto_goTypes,
|
||||
DependencyIndexes: file_helloworld_v1_greeter_proto_depIdxs,
|
||||
MessageInfos: file_helloworld_v1_greeter_proto_msgTypes,
|
||||
}.Build()
|
||||
File_helloworld_v1_greeter_proto = out.File
|
||||
file_helloworld_v1_greeter_proto_rawDesc = nil
|
||||
file_helloworld_v1_greeter_proto_goTypes = nil
|
||||
file_helloworld_v1_greeter_proto_depIdxs = nil
|
||||
}
|
||||
30
api/helloworld/v1/greeter.proto
Normal file
30
api/helloworld/v1/greeter.proto
Normal file
@@ -0,0 +1,30 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package helloworld.v1;
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
|
||||
option go_package = "polaris/api/helloworld/v1;v1";
|
||||
option java_multiple_files = true;
|
||||
option java_package = "dev.kratos.api.helloworld.v1";
|
||||
option java_outer_classname = "HelloworldProtoV1";
|
||||
|
||||
// The greeting service definition.
|
||||
service Greeter {
|
||||
// Sends a greeting
|
||||
rpc SayHello (HelloRequest) returns (HelloReply) {
|
||||
option (google.api.http) = {
|
||||
get: "/helloworld/{name}"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// The request message containing the user's name.
|
||||
message HelloRequest {
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
// The response message containing the greetings
|
||||
message HelloReply {
|
||||
string message = 1;
|
||||
}
|
||||
107
api/helloworld/v1/greeter_grpc.pb.go
Normal file
107
api/helloworld/v1/greeter_grpc.pb.go
Normal file
@@ -0,0 +1,107 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc v3.19.3
|
||||
// source: helloworld/v1/greeter.proto
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
// GreeterClient is the client API for Greeter service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type GreeterClient interface {
|
||||
// Sends a greeting
|
||||
SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error)
|
||||
}
|
||||
|
||||
type greeterClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient {
|
||||
return &greeterClient{cc}
|
||||
}
|
||||
|
||||
func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) {
|
||||
out := new(HelloReply)
|
||||
err := c.cc.Invoke(ctx, "/helloworld.v1.Greeter/SayHello", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// GreeterServer is the server API for Greeter service.
|
||||
// All implementations must embed UnimplementedGreeterServer
|
||||
// for forward compatibility
|
||||
type GreeterServer interface {
|
||||
// Sends a greeting
|
||||
SayHello(context.Context, *HelloRequest) (*HelloReply, error)
|
||||
mustEmbedUnimplementedGreeterServer()
|
||||
}
|
||||
|
||||
// UnimplementedGreeterServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedGreeterServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented")
|
||||
}
|
||||
func (UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer() {}
|
||||
|
||||
// UnsafeGreeterServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to GreeterServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeGreeterServer interface {
|
||||
mustEmbedUnimplementedGreeterServer()
|
||||
}
|
||||
|
||||
func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer) {
|
||||
s.RegisterService(&Greeter_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(HelloRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(GreeterServer).SayHello(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/helloworld.v1.Greeter/SayHello",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Greeter_ServiceDesc is the grpc.ServiceDesc for Greeter service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Greeter_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "helloworld.v1.Greeter",
|
||||
HandlerType: (*GreeterServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "SayHello",
|
||||
Handler: _Greeter_SayHello_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "helloworld/v1/greeter.proto",
|
||||
}
|
||||
74
api/helloworld/v1/greeter_http.pb.go
Normal file
74
api/helloworld/v1/greeter_http.pb.go
Normal file
@@ -0,0 +1,74 @@
|
||||
// Code generated by protoc-gen-go-http. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go-http v2.1.3
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
context "context"
|
||||
http "github.com/go-kratos/kratos/v2/transport/http"
|
||||
binding "github.com/go-kratos/kratos/v2/transport/http/binding"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the kratos package it is being compiled against.
|
||||
var _ = new(context.Context)
|
||||
var _ = binding.EncodeURL
|
||||
|
||||
const _ = http.SupportPackageIsVersion1
|
||||
|
||||
type GreeterHTTPServer interface {
|
||||
SayHello(context.Context, *HelloRequest) (*HelloReply, error)
|
||||
}
|
||||
|
||||
func RegisterGreeterHTTPServer(s *http.Server, srv GreeterHTTPServer) {
|
||||
r := s.Route("/")
|
||||
r.GET("/helloworld/{name}", _Greeter_SayHello0_HTTP_Handler(srv))
|
||||
}
|
||||
|
||||
func _Greeter_SayHello0_HTTP_Handler(srv GreeterHTTPServer) func(ctx http.Context) error {
|
||||
return func(ctx http.Context) error {
|
||||
var in HelloRequest
|
||||
if err := ctx.BindQuery(&in); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ctx.BindVars(&in); err != nil {
|
||||
return err
|
||||
}
|
||||
http.SetOperation(ctx, "/helloworld.v1.Greeter/SayHello")
|
||||
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.SayHello(ctx, req.(*HelloRequest))
|
||||
})
|
||||
out, err := h(ctx, &in)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
reply := out.(*HelloReply)
|
||||
return ctx.Result(200, reply)
|
||||
}
|
||||
}
|
||||
|
||||
type GreeterHTTPClient interface {
|
||||
SayHello(ctx context.Context, req *HelloRequest, opts ...http.CallOption) (rsp *HelloReply, err error)
|
||||
}
|
||||
|
||||
type GreeterHTTPClientImpl struct {
|
||||
cc *http.Client
|
||||
}
|
||||
|
||||
func NewGreeterHTTPClient(client *http.Client) GreeterHTTPClient {
|
||||
return &GreeterHTTPClientImpl{client}
|
||||
}
|
||||
|
||||
func (c *GreeterHTTPClientImpl) SayHello(ctx context.Context, in *HelloRequest, opts ...http.CallOption) (*HelloReply, error) {
|
||||
var out HelloReply
|
||||
pattern := "/helloworld/{name}"
|
||||
path := binding.EncodeURL(pattern, in, true)
|
||||
opts = append(opts, http.Operation("/helloworld.v1.Greeter/SayHello"))
|
||||
opts = append(opts, http.PathTemplate(pattern))
|
||||
err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, err
|
||||
}
|
||||
472
api/polaris/v1/api.pb.go
Normal file
472
api/polaris/v1/api.pb.go
Normal file
@@ -0,0 +1,472 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.6
|
||||
// protoc v3.21.11
|
||||
// source: api/polaris/v1/api.proto
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type CreateApiRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *CreateApiRequest) Reset() {
|
||||
*x = CreateApiRequest{}
|
||||
mi := &file_api_polaris_v1_api_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *CreateApiRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CreateApiRequest) ProtoMessage() {}
|
||||
|
||||
func (x *CreateApiRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_polaris_v1_api_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use CreateApiRequest.ProtoReflect.Descriptor instead.
|
||||
func (*CreateApiRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_polaris_v1_api_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
type CreateApiReply struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *CreateApiReply) Reset() {
|
||||
*x = CreateApiReply{}
|
||||
mi := &file_api_polaris_v1_api_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *CreateApiReply) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CreateApiReply) ProtoMessage() {}
|
||||
|
||||
func (x *CreateApiReply) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_polaris_v1_api_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use CreateApiReply.ProtoReflect.Descriptor instead.
|
||||
func (*CreateApiReply) Descriptor() ([]byte, []int) {
|
||||
return file_api_polaris_v1_api_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
type UpdateApiRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *UpdateApiRequest) Reset() {
|
||||
*x = UpdateApiRequest{}
|
||||
mi := &file_api_polaris_v1_api_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *UpdateApiRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UpdateApiRequest) ProtoMessage() {}
|
||||
|
||||
func (x *UpdateApiRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_polaris_v1_api_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UpdateApiRequest.ProtoReflect.Descriptor instead.
|
||||
func (*UpdateApiRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_polaris_v1_api_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
type UpdateApiReply struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *UpdateApiReply) Reset() {
|
||||
*x = UpdateApiReply{}
|
||||
mi := &file_api_polaris_v1_api_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *UpdateApiReply) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UpdateApiReply) ProtoMessage() {}
|
||||
|
||||
func (x *UpdateApiReply) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_polaris_v1_api_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UpdateApiReply.ProtoReflect.Descriptor instead.
|
||||
func (*UpdateApiReply) Descriptor() ([]byte, []int) {
|
||||
return file_api_polaris_v1_api_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
type DeleteApiRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *DeleteApiRequest) Reset() {
|
||||
*x = DeleteApiRequest{}
|
||||
mi := &file_api_polaris_v1_api_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *DeleteApiRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DeleteApiRequest) ProtoMessage() {}
|
||||
|
||||
func (x *DeleteApiRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_polaris_v1_api_proto_msgTypes[4]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DeleteApiRequest.ProtoReflect.Descriptor instead.
|
||||
func (*DeleteApiRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_polaris_v1_api_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
type DeleteApiReply struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *DeleteApiReply) Reset() {
|
||||
*x = DeleteApiReply{}
|
||||
mi := &file_api_polaris_v1_api_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *DeleteApiReply) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DeleteApiReply) ProtoMessage() {}
|
||||
|
||||
func (x *DeleteApiReply) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_polaris_v1_api_proto_msgTypes[5]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DeleteApiReply.ProtoReflect.Descriptor instead.
|
||||
func (*DeleteApiReply) Descriptor() ([]byte, []int) {
|
||||
return file_api_polaris_v1_api_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
type GetApiRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetApiRequest) Reset() {
|
||||
*x = GetApiRequest{}
|
||||
mi := &file_api_polaris_v1_api_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetApiRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetApiRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetApiRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_polaris_v1_api_proto_msgTypes[6]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetApiRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetApiRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_polaris_v1_api_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
type GetApiReply struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetApiReply) Reset() {
|
||||
*x = GetApiReply{}
|
||||
mi := &file_api_polaris_v1_api_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetApiReply) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetApiReply) ProtoMessage() {}
|
||||
|
||||
func (x *GetApiReply) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_polaris_v1_api_proto_msgTypes[7]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetApiReply.ProtoReflect.Descriptor instead.
|
||||
func (*GetApiReply) Descriptor() ([]byte, []int) {
|
||||
return file_api_polaris_v1_api_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
type ListApiRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ListApiRequest) Reset() {
|
||||
*x = ListApiRequest{}
|
||||
mi := &file_api_polaris_v1_api_proto_msgTypes[8]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ListApiRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ListApiRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ListApiRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_polaris_v1_api_proto_msgTypes[8]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ListApiRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ListApiRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_polaris_v1_api_proto_rawDescGZIP(), []int{8}
|
||||
}
|
||||
|
||||
type ListApiReply struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ListApiReply) Reset() {
|
||||
*x = ListApiReply{}
|
||||
mi := &file_api_polaris_v1_api_proto_msgTypes[9]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ListApiReply) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ListApiReply) ProtoMessage() {}
|
||||
|
||||
func (x *ListApiReply) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_polaris_v1_api_proto_msgTypes[9]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ListApiReply.ProtoReflect.Descriptor instead.
|
||||
func (*ListApiReply) Descriptor() ([]byte, []int) {
|
||||
return file_api_polaris_v1_api_proto_rawDescGZIP(), []int{9}
|
||||
}
|
||||
|
||||
var File_api_polaris_v1_api_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_api_polaris_v1_api_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x18api/polaris/v1/api.proto\x12\x0eapi.polaris.v1\"\x12\n" +
|
||||
"\x10CreateApiRequest\"\x10\n" +
|
||||
"\x0eCreateApiReply\"\x12\n" +
|
||||
"\x10UpdateApiRequest\"\x10\n" +
|
||||
"\x0eUpdateApiReply\"\x12\n" +
|
||||
"\x10DeleteApiRequest\"\x10\n" +
|
||||
"\x0eDeleteApiReply\"\x0f\n" +
|
||||
"\rGetApiRequest\"\r\n" +
|
||||
"\vGetApiReply\"\x10\n" +
|
||||
"\x0eListApiRequest\"\x0e\n" +
|
||||
"\fListApiReply2\x81\x03\n" +
|
||||
"\x03Api\x12M\n" +
|
||||
"\tCreateApi\x12 .api.polaris.v1.CreateApiRequest\x1a\x1e.api.polaris.v1.CreateApiReply\x12M\n" +
|
||||
"\tUpdateApi\x12 .api.polaris.v1.UpdateApiRequest\x1a\x1e.api.polaris.v1.UpdateApiReply\x12M\n" +
|
||||
"\tDeleteApi\x12 .api.polaris.v1.DeleteApiRequest\x1a\x1e.api.polaris.v1.DeleteApiReply\x12D\n" +
|
||||
"\x06GetApi\x12\x1d.api.polaris.v1.GetApiRequest\x1a\x1b.api.polaris.v1.GetApiReply\x12G\n" +
|
||||
"\aListApi\x12\x1e.api.polaris.v1.ListApiRequest\x1a\x1c.api.polaris.v1.ListApiReplyB-\n" +
|
||||
"\x0eapi.polaris.v1P\x01Z\x19polaris/api/polaris/v1;v1b\x06proto3"
|
||||
|
||||
var (
|
||||
file_api_polaris_v1_api_proto_rawDescOnce sync.Once
|
||||
file_api_polaris_v1_api_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_api_polaris_v1_api_proto_rawDescGZIP() []byte {
|
||||
file_api_polaris_v1_api_proto_rawDescOnce.Do(func() {
|
||||
file_api_polaris_v1_api_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_polaris_v1_api_proto_rawDesc), len(file_api_polaris_v1_api_proto_rawDesc)))
|
||||
})
|
||||
return file_api_polaris_v1_api_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_api_polaris_v1_api_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
|
||||
var file_api_polaris_v1_api_proto_goTypes = []any{
|
||||
(*CreateApiRequest)(nil), // 0: api.polaris.v1.CreateApiRequest
|
||||
(*CreateApiReply)(nil), // 1: api.polaris.v1.CreateApiReply
|
||||
(*UpdateApiRequest)(nil), // 2: api.polaris.v1.UpdateApiRequest
|
||||
(*UpdateApiReply)(nil), // 3: api.polaris.v1.UpdateApiReply
|
||||
(*DeleteApiRequest)(nil), // 4: api.polaris.v1.DeleteApiRequest
|
||||
(*DeleteApiReply)(nil), // 5: api.polaris.v1.DeleteApiReply
|
||||
(*GetApiRequest)(nil), // 6: api.polaris.v1.GetApiRequest
|
||||
(*GetApiReply)(nil), // 7: api.polaris.v1.GetApiReply
|
||||
(*ListApiRequest)(nil), // 8: api.polaris.v1.ListApiRequest
|
||||
(*ListApiReply)(nil), // 9: api.polaris.v1.ListApiReply
|
||||
}
|
||||
var file_api_polaris_v1_api_proto_depIdxs = []int32{
|
||||
0, // 0: api.polaris.v1.Api.CreateApi:input_type -> api.polaris.v1.CreateApiRequest
|
||||
2, // 1: api.polaris.v1.Api.UpdateApi:input_type -> api.polaris.v1.UpdateApiRequest
|
||||
4, // 2: api.polaris.v1.Api.DeleteApi:input_type -> api.polaris.v1.DeleteApiRequest
|
||||
6, // 3: api.polaris.v1.Api.GetApi:input_type -> api.polaris.v1.GetApiRequest
|
||||
8, // 4: api.polaris.v1.Api.ListApi:input_type -> api.polaris.v1.ListApiRequest
|
||||
1, // 5: api.polaris.v1.Api.CreateApi:output_type -> api.polaris.v1.CreateApiReply
|
||||
3, // 6: api.polaris.v1.Api.UpdateApi:output_type -> api.polaris.v1.UpdateApiReply
|
||||
5, // 7: api.polaris.v1.Api.DeleteApi:output_type -> api.polaris.v1.DeleteApiReply
|
||||
7, // 8: api.polaris.v1.Api.GetApi:output_type -> api.polaris.v1.GetApiReply
|
||||
9, // 9: api.polaris.v1.Api.ListApi:output_type -> api.polaris.v1.ListApiReply
|
||||
5, // [5:10] is the sub-list for method output_type
|
||||
0, // [0:5] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_api_polaris_v1_api_proto_init() }
|
||||
func file_api_polaris_v1_api_proto_init() {
|
||||
if File_api_polaris_v1_api_proto != nil {
|
||||
return
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_polaris_v1_api_proto_rawDesc), len(file_api_polaris_v1_api_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 10,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_api_polaris_v1_api_proto_goTypes,
|
||||
DependencyIndexes: file_api_polaris_v1_api_proto_depIdxs,
|
||||
MessageInfos: file_api_polaris_v1_api_proto_msgTypes,
|
||||
}.Build()
|
||||
File_api_polaris_v1_api_proto = out.File
|
||||
file_api_polaris_v1_api_proto_goTypes = nil
|
||||
file_api_polaris_v1_api_proto_depIdxs = nil
|
||||
}
|
||||
30
api/polaris/v1/api.proto
Normal file
30
api/polaris/v1/api.proto
Normal file
@@ -0,0 +1,30 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package api.polaris.v1;
|
||||
|
||||
option go_package = "polaris/api/polaris/v1;v1";
|
||||
option java_multiple_files = true;
|
||||
option java_package = "api.polaris.v1";
|
||||
|
||||
service Api {
|
||||
rpc CreateApi (CreateApiRequest) returns (CreateApiReply);
|
||||
rpc UpdateApi (UpdateApiRequest) returns (UpdateApiReply);
|
||||
rpc DeleteApi (DeleteApiRequest) returns (DeleteApiReply);
|
||||
rpc GetApi (GetApiRequest) returns (GetApiReply);
|
||||
rpc ListApi (ListApiRequest) returns (ListApiReply);
|
||||
}
|
||||
|
||||
message CreateApiRequest {}
|
||||
message CreateApiReply {}
|
||||
|
||||
message UpdateApiRequest {}
|
||||
message UpdateApiReply {}
|
||||
|
||||
message DeleteApiRequest {}
|
||||
message DeleteApiReply {}
|
||||
|
||||
message GetApiRequest {}
|
||||
message GetApiReply {}
|
||||
|
||||
message ListApiRequest {}
|
||||
message ListApiReply {}
|
||||
273
api/polaris/v1/api_grpc.pb.go
Normal file
273
api/polaris/v1/api_grpc.pb.go
Normal file
@@ -0,0 +1,273 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v3.21.11
|
||||
// source: api/polaris/v1/api.proto
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
Api_CreateApi_FullMethodName = "/api.polaris.v1.Api/CreateApi"
|
||||
Api_UpdateApi_FullMethodName = "/api.polaris.v1.Api/UpdateApi"
|
||||
Api_DeleteApi_FullMethodName = "/api.polaris.v1.Api/DeleteApi"
|
||||
Api_GetApi_FullMethodName = "/api.polaris.v1.Api/GetApi"
|
||||
Api_ListApi_FullMethodName = "/api.polaris.v1.Api/ListApi"
|
||||
)
|
||||
|
||||
// ApiClient is the client API for Api service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type ApiClient interface {
|
||||
CreateApi(ctx context.Context, in *CreateApiRequest, opts ...grpc.CallOption) (*CreateApiReply, error)
|
||||
UpdateApi(ctx context.Context, in *UpdateApiRequest, opts ...grpc.CallOption) (*UpdateApiReply, error)
|
||||
DeleteApi(ctx context.Context, in *DeleteApiRequest, opts ...grpc.CallOption) (*DeleteApiReply, error)
|
||||
GetApi(ctx context.Context, in *GetApiRequest, opts ...grpc.CallOption) (*GetApiReply, error)
|
||||
ListApi(ctx context.Context, in *ListApiRequest, opts ...grpc.CallOption) (*ListApiReply, error)
|
||||
}
|
||||
|
||||
type apiClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewApiClient(cc grpc.ClientConnInterface) ApiClient {
|
||||
return &apiClient{cc}
|
||||
}
|
||||
|
||||
func (c *apiClient) CreateApi(ctx context.Context, in *CreateApiRequest, opts ...grpc.CallOption) (*CreateApiReply, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(CreateApiReply)
|
||||
err := c.cc.Invoke(ctx, Api_CreateApi_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *apiClient) UpdateApi(ctx context.Context, in *UpdateApiRequest, opts ...grpc.CallOption) (*UpdateApiReply, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(UpdateApiReply)
|
||||
err := c.cc.Invoke(ctx, Api_UpdateApi_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *apiClient) DeleteApi(ctx context.Context, in *DeleteApiRequest, opts ...grpc.CallOption) (*DeleteApiReply, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(DeleteApiReply)
|
||||
err := c.cc.Invoke(ctx, Api_DeleteApi_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *apiClient) GetApi(ctx context.Context, in *GetApiRequest, opts ...grpc.CallOption) (*GetApiReply, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetApiReply)
|
||||
err := c.cc.Invoke(ctx, Api_GetApi_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *apiClient) ListApi(ctx context.Context, in *ListApiRequest, opts ...grpc.CallOption) (*ListApiReply, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListApiReply)
|
||||
err := c.cc.Invoke(ctx, Api_ListApi_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// ApiServer is the server API for Api service.
|
||||
// All implementations must embed UnimplementedApiServer
|
||||
// for forward compatibility.
|
||||
type ApiServer interface {
|
||||
CreateApi(context.Context, *CreateApiRequest) (*CreateApiReply, error)
|
||||
UpdateApi(context.Context, *UpdateApiRequest) (*UpdateApiReply, error)
|
||||
DeleteApi(context.Context, *DeleteApiRequest) (*DeleteApiReply, error)
|
||||
GetApi(context.Context, *GetApiRequest) (*GetApiReply, error)
|
||||
ListApi(context.Context, *ListApiRequest) (*ListApiReply, error)
|
||||
mustEmbedUnimplementedApiServer()
|
||||
}
|
||||
|
||||
// UnimplementedApiServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedApiServer struct{}
|
||||
|
||||
func (UnimplementedApiServer) CreateApi(context.Context, *CreateApiRequest) (*CreateApiReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CreateApi not implemented")
|
||||
}
|
||||
func (UnimplementedApiServer) UpdateApi(context.Context, *UpdateApiRequest) (*UpdateApiReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateApi not implemented")
|
||||
}
|
||||
func (UnimplementedApiServer) DeleteApi(context.Context, *DeleteApiRequest) (*DeleteApiReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method DeleteApi not implemented")
|
||||
}
|
||||
func (UnimplementedApiServer) GetApi(context.Context, *GetApiRequest) (*GetApiReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetApi not implemented")
|
||||
}
|
||||
func (UnimplementedApiServer) ListApi(context.Context, *ListApiRequest) (*ListApiReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ListApi not implemented")
|
||||
}
|
||||
func (UnimplementedApiServer) mustEmbedUnimplementedApiServer() {}
|
||||
func (UnimplementedApiServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeApiServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to ApiServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeApiServer interface {
|
||||
mustEmbedUnimplementedApiServer()
|
||||
}
|
||||
|
||||
func RegisterApiServer(s grpc.ServiceRegistrar, srv ApiServer) {
|
||||
// If the following call pancis, it indicates UnimplementedApiServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&Api_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Api_CreateApi_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateApiRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ApiServer).CreateApi(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Api_CreateApi_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ApiServer).CreateApi(ctx, req.(*CreateApiRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Api_UpdateApi_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpdateApiRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ApiServer).UpdateApi(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Api_UpdateApi_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ApiServer).UpdateApi(ctx, req.(*UpdateApiRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Api_DeleteApi_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeleteApiRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ApiServer).DeleteApi(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Api_DeleteApi_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ApiServer).DeleteApi(ctx, req.(*DeleteApiRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Api_GetApi_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetApiRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ApiServer).GetApi(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Api_GetApi_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ApiServer).GetApi(ctx, req.(*GetApiRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Api_ListApi_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListApiRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ApiServer).ListApi(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Api_ListApi_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ApiServer).ListApi(ctx, req.(*ListApiRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Api_ServiceDesc is the grpc.ServiceDesc for Api service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Api_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "api.polaris.v1.Api",
|
||||
HandlerType: (*ApiServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "CreateApi",
|
||||
Handler: _Api_CreateApi_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateApi",
|
||||
Handler: _Api_UpdateApi_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DeleteApi",
|
||||
Handler: _Api_DeleteApi_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetApi",
|
||||
Handler: _Api_GetApi_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListApi",
|
||||
Handler: _Api_ListApi_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api/polaris/v1/api.proto",
|
||||
}
|
||||
@@ -2,20 +2,45 @@ package main
|
||||
|
||||
import "C"
|
||||
import (
|
||||
"os"
|
||||
"polaris/cmd"
|
||||
"polaris/internal/db"
|
||||
"polaris/log"
|
||||
"polaris/internal/biz/server"
|
||||
)
|
||||
|
||||
func main() {}
|
||||
|
||||
var srv *server.Server
|
||||
var port int
|
||||
|
||||
//export Start
|
||||
func Start() {
|
||||
cmd.Start(true)
|
||||
func Start() (C.int, *C.char) {
|
||||
if srv != nil {
|
||||
return C.int(port), nil
|
||||
}
|
||||
log.InitLogger(true)
|
||||
|
||||
log.Infof("------------------- Starting Polaris ---------------------")
|
||||
dbClient, err := db.Open()
|
||||
if err != nil {
|
||||
log.Panicf("init db error: %v", err)
|
||||
return C.int(0), C.CString(err.Error())
|
||||
}
|
||||
|
||||
s := server.NewServer(dbClient)
|
||||
if p, err := s.Start(""); err != nil {
|
||||
return C.int(0), C.CString(err.Error())
|
||||
} else {
|
||||
port = p
|
||||
srv = s
|
||||
return C.int(p), C.CString("")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//export Stop
|
||||
func Stop() {
|
||||
log.Infof("stop polaris")
|
||||
os.Exit(0)
|
||||
if srv != nil {
|
||||
srv.Stop()
|
||||
}
|
||||
srv = nil
|
||||
}
|
||||
|
||||
26
cmd/doc.go
26
cmd/doc.go
@@ -1,27 +1 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
"polaris/db"
|
||||
"polaris/log"
|
||||
"polaris/server"
|
||||
)
|
||||
|
||||
func Start(sharedLib bool) {
|
||||
if sharedLib || os.Getenv("GIN_MODE") == "release" {
|
||||
log.InitLogger(true)
|
||||
} else {
|
||||
log.InitLogger(false)
|
||||
}
|
||||
|
||||
log.Infof("------------------- Starting Polaris ---------------------")
|
||||
dbClient, err := db.Open()
|
||||
if err != nil {
|
||||
log.Panicf("init db error: %v", err)
|
||||
}
|
||||
|
||||
s := server.NewServer(dbClient)
|
||||
if err := s.Serve(); err != nil {
|
||||
log.Errorf("server start error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,26 @@
|
||||
package main
|
||||
|
||||
import "polaris/cmd"
|
||||
import (
|
||||
"os"
|
||||
"polaris/internal/db"
|
||||
"polaris/log"
|
||||
"polaris/internal/biz/server"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cmd.Start(false)
|
||||
}
|
||||
if os.Getenv("GIN_MODE") == "release" {
|
||||
log.InitLogger(true)
|
||||
}
|
||||
|
||||
log.Infof("------------------- Starting Polaris ---------------------")
|
||||
dbClient, err := db.Open()
|
||||
if err != nil {
|
||||
log.Panicf("init db error: %v", err)
|
||||
}
|
||||
|
||||
s := server.NewServer(dbClient)
|
||||
if _, err := s.Start(":8080"); err != nil {
|
||||
log.Errorf("server start error: %v", err)
|
||||
}
|
||||
select {} //wait indefinitely
|
||||
}
|
||||
|
||||
87
cmd/server/main.go
Normal file
87
cmd/server/main.go
Normal file
@@ -0,0 +1,87 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
|
||||
"polaris/internal/conf"
|
||||
|
||||
"github.com/go-kratos/kratos/v2"
|
||||
"github.com/go-kratos/kratos/v2/config"
|
||||
"github.com/go-kratos/kratos/v2/config/file"
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
"github.com/go-kratos/kratos/v2/middleware/tracing"
|
||||
"github.com/go-kratos/kratos/v2/transport/grpc"
|
||||
"github.com/go-kratos/kratos/v2/transport/http"
|
||||
|
||||
_ "go.uber.org/automaxprocs"
|
||||
)
|
||||
|
||||
// go build -ldflags "-X main.Version=x.y.z"
|
||||
var (
|
||||
// Name is the name of the compiled software.
|
||||
Name string
|
||||
// Version is the version of the compiled software.
|
||||
Version string
|
||||
// flagconf is the config flag.
|
||||
flagconf string
|
||||
|
||||
id, _ = os.Hostname()
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.StringVar(&flagconf, "conf", "../../configs", "config path, eg: -conf config.yaml")
|
||||
}
|
||||
|
||||
func newApp(logger log.Logger, gs *grpc.Server, hs *http.Server) *kratos.App {
|
||||
return kratos.New(
|
||||
kratos.ID(id),
|
||||
kratos.Name(Name),
|
||||
kratos.Version(Version),
|
||||
kratos.Metadata(map[string]string{}),
|
||||
kratos.Logger(logger),
|
||||
kratos.Server(
|
||||
gs,
|
||||
hs,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
logger := log.With(log.NewStdLogger(os.Stdout),
|
||||
"ts", log.DefaultTimestamp,
|
||||
"caller", log.DefaultCaller,
|
||||
"service.id", id,
|
||||
"service.name", Name,
|
||||
"service.version", Version,
|
||||
"trace.id", tracing.TraceID(),
|
||||
"span.id", tracing.SpanID(),
|
||||
)
|
||||
c := config.New(
|
||||
config.WithSource(
|
||||
file.NewSource(flagconf),
|
||||
),
|
||||
)
|
||||
defer c.Close()
|
||||
|
||||
if err := c.Load(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var bc conf.Bootstrap
|
||||
if err := c.Scan(&bc); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
app, cleanup, err := wireApp(bc.Server, bc.Data, logger)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer cleanup()
|
||||
|
||||
// start and wait for stop signal
|
||||
if err := app.Run(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
23
cmd/server/wire.go
Normal file
23
cmd/server/wire.go
Normal file
@@ -0,0 +1,23 @@
|
||||
//go:build wireinject
|
||||
// +build wireinject
|
||||
|
||||
// The build tag makes sure the stub is not built in the final build.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"polaris/internal/biz"
|
||||
"polaris/internal/conf"
|
||||
"polaris/internal/data"
|
||||
"polaris/internal/server"
|
||||
"polaris/internal/service"
|
||||
|
||||
"github.com/go-kratos/kratos/v2"
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
"github.com/google/wire"
|
||||
)
|
||||
|
||||
// wireApp init kratos application.
|
||||
func wireApp(*conf.Server, *conf.Data, log.Logger) (*kratos.App, func(), error) {
|
||||
panic(wire.Build(server.ProviderSet, data.ProviderSet, biz.ProviderSet, service.ProviderSet, newApp))
|
||||
}
|
||||
40
cmd/server/wire_gen.go
Normal file
40
cmd/server/wire_gen.go
Normal file
@@ -0,0 +1,40 @@
|
||||
// Code generated by Wire. DO NOT EDIT.
|
||||
|
||||
//go:generate go run -mod=mod github.com/google/wire/cmd/wire
|
||||
//go:build !wireinject
|
||||
// +build !wireinject
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"polaris/internal/biz"
|
||||
"polaris/internal/conf"
|
||||
"polaris/internal/data"
|
||||
"polaris/internal/server"
|
||||
"polaris/internal/service"
|
||||
"github.com/go-kratos/kratos/v2"
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
)
|
||||
|
||||
import (
|
||||
_ "go.uber.org/automaxprocs"
|
||||
)
|
||||
|
||||
// Injectors from wire.go:
|
||||
|
||||
// wireApp init kratos application.
|
||||
func wireApp(confServer *conf.Server, confData *conf.Data, logger log.Logger) (*kratos.App, func(), error) {
|
||||
dataData, cleanup, err := data.NewData(confData, logger)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
greeterRepo := data.NewGreeterRepo(dataData, logger)
|
||||
greeterUsecase := biz.NewGreeterUsecase(greeterRepo, logger)
|
||||
greeterService := service.NewGreeterService(greeterUsecase)
|
||||
grpcServer := server.NewGRPCServer(confServer, greeterService, logger)
|
||||
httpServer := server.NewHTTPServer(confServer, greeterService, logger)
|
||||
app := newApp(logger, grpcServer, httpServer)
|
||||
return app, func() {
|
||||
cleanup()
|
||||
}, nil
|
||||
}
|
||||
15
configs/config.yaml
Normal file
15
configs/config.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
server:
|
||||
http:
|
||||
addr: 0.0.0.0:8000
|
||||
timeout: 1s
|
||||
grpc:
|
||||
addr: 0.0.0.0:9000
|
||||
timeout: 1s
|
||||
data:
|
||||
database:
|
||||
driver: mysql
|
||||
source: root:root@tcp(127.0.0.1:3306)/test?parseTime=True&loc=Local
|
||||
redis:
|
||||
addr: 127.0.0.1:6379
|
||||
read_timeout: 0.2s
|
||||
write_timeout: 0.2s
|
||||
9
doc/stun_nat_traversal.md
Normal file
9
doc/stun_nat_traversal.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# 利用STUN进行NAT内网穿透
|
||||
|
||||
可以在下载器选项里打开 *使用内置STUN NAT穿透* 功能,即使处在NAT网络环境下,BT/PT也可以满速上传。打开后Polaris自动更改下载客户端的监听端口,并代理BT的上传流量。
|
||||
|
||||
要想正常使用此功能,需要具备以下几个条件:
|
||||
|
||||
1. 所在的NAT网络非对称NAT(Symmetric NAT),可以使用 [NatTypeTester](https://github.com/HMBSbige/NatTypeTester/releases/) 检查自己的网络的NAT类型
|
||||
2. 下载器设置选项中下载器地址为下载器docker的实际地址,而非映射地址。达到这一目标可以使用host网络创建下载器,也可以利用docker-compose自带的域名解析来实现
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"polaris/ent/blacklist"
|
||||
"polaris/ent/schema"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
@@ -20,8 +19,14 @@ type Blacklist struct {
|
||||
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"`
|
||||
// TorrentHash holds the value of the "torrent_hash" field.
|
||||
TorrentHash string `json:"torrent_hash,omitempty"`
|
||||
// TorrentName holds the value of the "torrent_name" field.
|
||||
TorrentName string `json:"torrent_name,omitempty"`
|
||||
// MediaID holds the value of the "media_id" field.
|
||||
MediaID int `json:"media_id,omitempty"`
|
||||
// CreateTime holds the value of the "create_time" field.
|
||||
CreateTime time.Time `json:"create_time,omitempty"`
|
||||
// Notes holds the value of the "notes" field.
|
||||
Notes string `json:"notes,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
@@ -32,12 +37,12 @@ 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:
|
||||
case blacklist.FieldID, blacklist.FieldMediaID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case blacklist.FieldType, blacklist.FieldNotes:
|
||||
case blacklist.FieldType, blacklist.FieldTorrentHash, blacklist.FieldTorrentName, blacklist.FieldNotes:
|
||||
values[i] = new(sql.NullString)
|
||||
case blacklist.FieldCreateTime:
|
||||
values[i] = new(sql.NullTime)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
@@ -65,13 +70,29 @@ func (b *Blacklist) assignValues(columns []string, values []any) error {
|
||||
} 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.FieldTorrentHash:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field torrent_hash", values[i])
|
||||
} else if value.Valid {
|
||||
b.TorrentHash = value.String
|
||||
}
|
||||
case blacklist.FieldTorrentName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field torrent_name", values[i])
|
||||
} else if value.Valid {
|
||||
b.TorrentName = value.String
|
||||
}
|
||||
case blacklist.FieldMediaID:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field media_id", values[i])
|
||||
} else if value.Valid {
|
||||
b.MediaID = int(value.Int64)
|
||||
}
|
||||
case blacklist.FieldCreateTime:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field create_time", values[i])
|
||||
} else if value.Valid {
|
||||
b.CreateTime = value.Time
|
||||
}
|
||||
case blacklist.FieldNotes:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
@@ -86,9 +107,9 @@ func (b *Blacklist) assignValues(columns []string, values []any) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetValue returns the ent.Value that was dynamically selected and assigned to the Blacklist.
|
||||
// Value 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) {
|
||||
func (b *Blacklist) Value(name string) (ent.Value, error) {
|
||||
return b.selectValues.Get(name)
|
||||
}
|
||||
|
||||
@@ -118,8 +139,17 @@ func (b *Blacklist) String() string {
|
||||
builder.WriteString("type=")
|
||||
builder.WriteString(fmt.Sprintf("%v", b.Type))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("value=")
|
||||
builder.WriteString(fmt.Sprintf("%v", b.Value))
|
||||
builder.WriteString("torrent_hash=")
|
||||
builder.WriteString(b.TorrentHash)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("torrent_name=")
|
||||
builder.WriteString(b.TorrentName)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("media_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", b.MediaID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("create_time=")
|
||||
builder.WriteString(b.CreateTime.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("notes=")
|
||||
builder.WriteString(b.Notes)
|
||||
|
||||
@@ -4,7 +4,7 @@ package blacklist
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"polaris/ent/schema"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
@@ -16,8 +16,14 @@ const (
|
||||
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"
|
||||
// FieldTorrentHash holds the string denoting the torrent_hash field in the database.
|
||||
FieldTorrentHash = "torrent_hash"
|
||||
// FieldTorrentName holds the string denoting the torrent_name field in the database.
|
||||
FieldTorrentName = "torrent_name"
|
||||
// FieldMediaID holds the string denoting the media_id field in the database.
|
||||
FieldMediaID = "media_id"
|
||||
// FieldCreateTime holds the string denoting the create_time field in the database.
|
||||
FieldCreateTime = "create_time"
|
||||
// FieldNotes holds the string denoting the notes field in the database.
|
||||
FieldNotes = "notes"
|
||||
// Table holds the table name of the blacklist in the database.
|
||||
@@ -28,7 +34,10 @@ const (
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldType,
|
||||
FieldValue,
|
||||
FieldTorrentHash,
|
||||
FieldTorrentName,
|
||||
FieldMediaID,
|
||||
FieldCreateTime,
|
||||
FieldNotes,
|
||||
}
|
||||
|
||||
@@ -43,13 +52,16 @@ func ValidColumn(column string) bool {
|
||||
}
|
||||
|
||||
var (
|
||||
// DefaultValue holds the default value on creation for the "value" field.
|
||||
DefaultValue schema.BlacklistValue
|
||||
// DefaultCreateTime holds the default value on creation for the "create_time" field.
|
||||
DefaultCreateTime func() time.Time
|
||||
)
|
||||
|
||||
// Type defines the type for the "type" enum field.
|
||||
type Type string
|
||||
|
||||
// TypeTorrent is the default value of the Type enum.
|
||||
const DefaultType = TypeTorrent
|
||||
|
||||
// Type values.
|
||||
const (
|
||||
TypeMedia Type = "media"
|
||||
@@ -83,6 +95,26 @@ func ByType(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldType, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTorrentHash orders the results by the torrent_hash field.
|
||||
func ByTorrentHash(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTorrentHash, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTorrentName orders the results by the torrent_name field.
|
||||
func ByTorrentName(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTorrentName, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByMediaID orders the results by the media_id field.
|
||||
func ByMediaID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldMediaID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreateTime orders the results by the create_time field.
|
||||
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByNotes orders the results by the notes field.
|
||||
func ByNotes(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldNotes, opts...).ToFunc()
|
||||
|
||||
@@ -4,6 +4,7 @@ package blacklist
|
||||
|
||||
import (
|
||||
"polaris/ent/predicate"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
@@ -53,6 +54,26 @@ func IDLTE(id int) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// TorrentHash applies equality check predicate on the "torrent_hash" field. It's identical to TorrentHashEQ.
|
||||
func TorrentHash(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldEQ(FieldTorrentHash, v))
|
||||
}
|
||||
|
||||
// TorrentName applies equality check predicate on the "torrent_name" field. It's identical to TorrentNameEQ.
|
||||
func TorrentName(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldEQ(FieldTorrentName, v))
|
||||
}
|
||||
|
||||
// MediaID applies equality check predicate on the "media_id" field. It's identical to MediaIDEQ.
|
||||
func MediaID(v int) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldEQ(FieldMediaID, v))
|
||||
}
|
||||
|
||||
// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ.
|
||||
func CreateTime(v time.Time) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// 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))
|
||||
@@ -78,6 +99,256 @@ func TypeNotIn(vs ...Type) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldNotIn(FieldType, vs...))
|
||||
}
|
||||
|
||||
// TorrentHashEQ applies the EQ predicate on the "torrent_hash" field.
|
||||
func TorrentHashEQ(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldEQ(FieldTorrentHash, v))
|
||||
}
|
||||
|
||||
// TorrentHashNEQ applies the NEQ predicate on the "torrent_hash" field.
|
||||
func TorrentHashNEQ(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldNEQ(FieldTorrentHash, v))
|
||||
}
|
||||
|
||||
// TorrentHashIn applies the In predicate on the "torrent_hash" field.
|
||||
func TorrentHashIn(vs ...string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldIn(FieldTorrentHash, vs...))
|
||||
}
|
||||
|
||||
// TorrentHashNotIn applies the NotIn predicate on the "torrent_hash" field.
|
||||
func TorrentHashNotIn(vs ...string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldNotIn(FieldTorrentHash, vs...))
|
||||
}
|
||||
|
||||
// TorrentHashGT applies the GT predicate on the "torrent_hash" field.
|
||||
func TorrentHashGT(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldGT(FieldTorrentHash, v))
|
||||
}
|
||||
|
||||
// TorrentHashGTE applies the GTE predicate on the "torrent_hash" field.
|
||||
func TorrentHashGTE(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldGTE(FieldTorrentHash, v))
|
||||
}
|
||||
|
||||
// TorrentHashLT applies the LT predicate on the "torrent_hash" field.
|
||||
func TorrentHashLT(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldLT(FieldTorrentHash, v))
|
||||
}
|
||||
|
||||
// TorrentHashLTE applies the LTE predicate on the "torrent_hash" field.
|
||||
func TorrentHashLTE(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldLTE(FieldTorrentHash, v))
|
||||
}
|
||||
|
||||
// TorrentHashContains applies the Contains predicate on the "torrent_hash" field.
|
||||
func TorrentHashContains(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldContains(FieldTorrentHash, v))
|
||||
}
|
||||
|
||||
// TorrentHashHasPrefix applies the HasPrefix predicate on the "torrent_hash" field.
|
||||
func TorrentHashHasPrefix(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldHasPrefix(FieldTorrentHash, v))
|
||||
}
|
||||
|
||||
// TorrentHashHasSuffix applies the HasSuffix predicate on the "torrent_hash" field.
|
||||
func TorrentHashHasSuffix(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldHasSuffix(FieldTorrentHash, v))
|
||||
}
|
||||
|
||||
// TorrentHashIsNil applies the IsNil predicate on the "torrent_hash" field.
|
||||
func TorrentHashIsNil() predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldIsNull(FieldTorrentHash))
|
||||
}
|
||||
|
||||
// TorrentHashNotNil applies the NotNil predicate on the "torrent_hash" field.
|
||||
func TorrentHashNotNil() predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldNotNull(FieldTorrentHash))
|
||||
}
|
||||
|
||||
// TorrentHashEqualFold applies the EqualFold predicate on the "torrent_hash" field.
|
||||
func TorrentHashEqualFold(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldEqualFold(FieldTorrentHash, v))
|
||||
}
|
||||
|
||||
// TorrentHashContainsFold applies the ContainsFold predicate on the "torrent_hash" field.
|
||||
func TorrentHashContainsFold(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldContainsFold(FieldTorrentHash, v))
|
||||
}
|
||||
|
||||
// TorrentNameEQ applies the EQ predicate on the "torrent_name" field.
|
||||
func TorrentNameEQ(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldEQ(FieldTorrentName, v))
|
||||
}
|
||||
|
||||
// TorrentNameNEQ applies the NEQ predicate on the "torrent_name" field.
|
||||
func TorrentNameNEQ(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldNEQ(FieldTorrentName, v))
|
||||
}
|
||||
|
||||
// TorrentNameIn applies the In predicate on the "torrent_name" field.
|
||||
func TorrentNameIn(vs ...string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldIn(FieldTorrentName, vs...))
|
||||
}
|
||||
|
||||
// TorrentNameNotIn applies the NotIn predicate on the "torrent_name" field.
|
||||
func TorrentNameNotIn(vs ...string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldNotIn(FieldTorrentName, vs...))
|
||||
}
|
||||
|
||||
// TorrentNameGT applies the GT predicate on the "torrent_name" field.
|
||||
func TorrentNameGT(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldGT(FieldTorrentName, v))
|
||||
}
|
||||
|
||||
// TorrentNameGTE applies the GTE predicate on the "torrent_name" field.
|
||||
func TorrentNameGTE(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldGTE(FieldTorrentName, v))
|
||||
}
|
||||
|
||||
// TorrentNameLT applies the LT predicate on the "torrent_name" field.
|
||||
func TorrentNameLT(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldLT(FieldTorrentName, v))
|
||||
}
|
||||
|
||||
// TorrentNameLTE applies the LTE predicate on the "torrent_name" field.
|
||||
func TorrentNameLTE(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldLTE(FieldTorrentName, v))
|
||||
}
|
||||
|
||||
// TorrentNameContains applies the Contains predicate on the "torrent_name" field.
|
||||
func TorrentNameContains(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldContains(FieldTorrentName, v))
|
||||
}
|
||||
|
||||
// TorrentNameHasPrefix applies the HasPrefix predicate on the "torrent_name" field.
|
||||
func TorrentNameHasPrefix(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldHasPrefix(FieldTorrentName, v))
|
||||
}
|
||||
|
||||
// TorrentNameHasSuffix applies the HasSuffix predicate on the "torrent_name" field.
|
||||
func TorrentNameHasSuffix(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldHasSuffix(FieldTorrentName, v))
|
||||
}
|
||||
|
||||
// TorrentNameIsNil applies the IsNil predicate on the "torrent_name" field.
|
||||
func TorrentNameIsNil() predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldIsNull(FieldTorrentName))
|
||||
}
|
||||
|
||||
// TorrentNameNotNil applies the NotNil predicate on the "torrent_name" field.
|
||||
func TorrentNameNotNil() predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldNotNull(FieldTorrentName))
|
||||
}
|
||||
|
||||
// TorrentNameEqualFold applies the EqualFold predicate on the "torrent_name" field.
|
||||
func TorrentNameEqualFold(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldEqualFold(FieldTorrentName, v))
|
||||
}
|
||||
|
||||
// TorrentNameContainsFold applies the ContainsFold predicate on the "torrent_name" field.
|
||||
func TorrentNameContainsFold(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldContainsFold(FieldTorrentName, v))
|
||||
}
|
||||
|
||||
// MediaIDEQ applies the EQ predicate on the "media_id" field.
|
||||
func MediaIDEQ(v int) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldEQ(FieldMediaID, v))
|
||||
}
|
||||
|
||||
// MediaIDNEQ applies the NEQ predicate on the "media_id" field.
|
||||
func MediaIDNEQ(v int) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldNEQ(FieldMediaID, v))
|
||||
}
|
||||
|
||||
// MediaIDIn applies the In predicate on the "media_id" field.
|
||||
func MediaIDIn(vs ...int) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldIn(FieldMediaID, vs...))
|
||||
}
|
||||
|
||||
// MediaIDNotIn applies the NotIn predicate on the "media_id" field.
|
||||
func MediaIDNotIn(vs ...int) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldNotIn(FieldMediaID, vs...))
|
||||
}
|
||||
|
||||
// MediaIDGT applies the GT predicate on the "media_id" field.
|
||||
func MediaIDGT(v int) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldGT(FieldMediaID, v))
|
||||
}
|
||||
|
||||
// MediaIDGTE applies the GTE predicate on the "media_id" field.
|
||||
func MediaIDGTE(v int) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldGTE(FieldMediaID, v))
|
||||
}
|
||||
|
||||
// MediaIDLT applies the LT predicate on the "media_id" field.
|
||||
func MediaIDLT(v int) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldLT(FieldMediaID, v))
|
||||
}
|
||||
|
||||
// MediaIDLTE applies the LTE predicate on the "media_id" field.
|
||||
func MediaIDLTE(v int) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldLTE(FieldMediaID, v))
|
||||
}
|
||||
|
||||
// MediaIDIsNil applies the IsNil predicate on the "media_id" field.
|
||||
func MediaIDIsNil() predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldIsNull(FieldMediaID))
|
||||
}
|
||||
|
||||
// MediaIDNotNil applies the NotNil predicate on the "media_id" field.
|
||||
func MediaIDNotNil() predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldNotNull(FieldMediaID))
|
||||
}
|
||||
|
||||
// CreateTimeEQ applies the EQ predicate on the "create_time" field.
|
||||
func CreateTimeEQ(v time.Time) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeNEQ applies the NEQ predicate on the "create_time" field.
|
||||
func CreateTimeNEQ(v time.Time) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldNEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeIn applies the In predicate on the "create_time" field.
|
||||
func CreateTimeIn(vs ...time.Time) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeNotIn applies the NotIn predicate on the "create_time" field.
|
||||
func CreateTimeNotIn(vs ...time.Time) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldNotIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeGT applies the GT predicate on the "create_time" field.
|
||||
func CreateTimeGT(v time.Time) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldGT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeGTE applies the GTE predicate on the "create_time" field.
|
||||
func CreateTimeGTE(v time.Time) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldGTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLT applies the LT predicate on the "create_time" field.
|
||||
func CreateTimeLT(v time.Time) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldLT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLTE applies the LTE predicate on the "create_time" field.
|
||||
func CreateTimeLTE(v time.Time) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldLTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeIsNil applies the IsNil predicate on the "create_time" field.
|
||||
func CreateTimeIsNil() predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldIsNull(FieldCreateTime))
|
||||
}
|
||||
|
||||
// CreateTimeNotNil applies the NotNil predicate on the "create_time" field.
|
||||
func CreateTimeNotNil() predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldNotNull(FieldCreateTime))
|
||||
}
|
||||
|
||||
// NotesEQ applies the EQ predicate on the "notes" field.
|
||||
func NotesEQ(v string) predicate.Blacklist {
|
||||
return predicate.Blacklist(sql.FieldEQ(FieldNotes, v))
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/blacklist"
|
||||
"polaris/ent/schema"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
@@ -26,16 +26,66 @@ func (bc *BlacklistCreate) SetType(b blacklist.Type) *BlacklistCreate {
|
||||
return bc
|
||||
}
|
||||
|
||||
// SetValue sets the "value" field.
|
||||
func (bc *BlacklistCreate) SetValue(sv schema.BlacklistValue) *BlacklistCreate {
|
||||
bc.mutation.SetValue(sv)
|
||||
// SetNillableType sets the "type" field if the given value is not nil.
|
||||
func (bc *BlacklistCreate) SetNillableType(b *blacklist.Type) *BlacklistCreate {
|
||||
if b != nil {
|
||||
bc.SetType(*b)
|
||||
}
|
||||
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)
|
||||
// SetTorrentHash sets the "torrent_hash" field.
|
||||
func (bc *BlacklistCreate) SetTorrentHash(s string) *BlacklistCreate {
|
||||
bc.mutation.SetTorrentHash(s)
|
||||
return bc
|
||||
}
|
||||
|
||||
// SetNillableTorrentHash sets the "torrent_hash" field if the given value is not nil.
|
||||
func (bc *BlacklistCreate) SetNillableTorrentHash(s *string) *BlacklistCreate {
|
||||
if s != nil {
|
||||
bc.SetTorrentHash(*s)
|
||||
}
|
||||
return bc
|
||||
}
|
||||
|
||||
// SetTorrentName sets the "torrent_name" field.
|
||||
func (bc *BlacklistCreate) SetTorrentName(s string) *BlacklistCreate {
|
||||
bc.mutation.SetTorrentName(s)
|
||||
return bc
|
||||
}
|
||||
|
||||
// SetNillableTorrentName sets the "torrent_name" field if the given value is not nil.
|
||||
func (bc *BlacklistCreate) SetNillableTorrentName(s *string) *BlacklistCreate {
|
||||
if s != nil {
|
||||
bc.SetTorrentName(*s)
|
||||
}
|
||||
return bc
|
||||
}
|
||||
|
||||
// SetMediaID sets the "media_id" field.
|
||||
func (bc *BlacklistCreate) SetMediaID(i int) *BlacklistCreate {
|
||||
bc.mutation.SetMediaID(i)
|
||||
return bc
|
||||
}
|
||||
|
||||
// SetNillableMediaID sets the "media_id" field if the given value is not nil.
|
||||
func (bc *BlacklistCreate) SetNillableMediaID(i *int) *BlacklistCreate {
|
||||
if i != nil {
|
||||
bc.SetMediaID(*i)
|
||||
}
|
||||
return bc
|
||||
}
|
||||
|
||||
// SetCreateTime sets the "create_time" field.
|
||||
func (bc *BlacklistCreate) SetCreateTime(t time.Time) *BlacklistCreate {
|
||||
bc.mutation.SetCreateTime(t)
|
||||
return bc
|
||||
}
|
||||
|
||||
// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
|
||||
func (bc *BlacklistCreate) SetNillableCreateTime(t *time.Time) *BlacklistCreate {
|
||||
if t != nil {
|
||||
bc.SetCreateTime(*t)
|
||||
}
|
||||
return bc
|
||||
}
|
||||
@@ -89,9 +139,13 @@ func (bc *BlacklistCreate) ExecX(ctx context.Context) {
|
||||
|
||||
// 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)
|
||||
if _, ok := bc.mutation.GetType(); !ok {
|
||||
v := blacklist.DefaultType
|
||||
bc.mutation.SetType(v)
|
||||
}
|
||||
if _, ok := bc.mutation.CreateTime(); !ok {
|
||||
v := blacklist.DefaultCreateTime()
|
||||
bc.mutation.SetCreateTime(v)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,9 +159,6 @@ func (bc *BlacklistCreate) check() error {
|
||||
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
|
||||
}
|
||||
|
||||
@@ -138,9 +189,21 @@ func (bc *BlacklistCreate) createSpec() (*Blacklist, *sqlgraph.CreateSpec) {
|
||||
_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.TorrentHash(); ok {
|
||||
_spec.SetField(blacklist.FieldTorrentHash, field.TypeString, value)
|
||||
_node.TorrentHash = value
|
||||
}
|
||||
if value, ok := bc.mutation.TorrentName(); ok {
|
||||
_spec.SetField(blacklist.FieldTorrentName, field.TypeString, value)
|
||||
_node.TorrentName = value
|
||||
}
|
||||
if value, ok := bc.mutation.MediaID(); ok {
|
||||
_spec.SetField(blacklist.FieldMediaID, field.TypeInt, value)
|
||||
_node.MediaID = value
|
||||
}
|
||||
if value, ok := bc.mutation.CreateTime(); ok {
|
||||
_spec.SetField(blacklist.FieldCreateTime, field.TypeTime, value)
|
||||
_node.CreateTime = value
|
||||
}
|
||||
if value, ok := bc.mutation.Notes(); ok {
|
||||
_spec.SetField(blacklist.FieldNotes, field.TypeString, value)
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"fmt"
|
||||
"polaris/ent/blacklist"
|
||||
"polaris/ent/predicate"
|
||||
"polaris/ent/schema"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -42,20 +41,73 @@ func (bu *BlacklistUpdate) SetNillableType(b *blacklist.Type) *BlacklistUpdate {
|
||||
return bu
|
||||
}
|
||||
|
||||
// SetValue sets the "value" field.
|
||||
func (bu *BlacklistUpdate) SetValue(sv schema.BlacklistValue) *BlacklistUpdate {
|
||||
bu.mutation.SetValue(sv)
|
||||
// SetTorrentHash sets the "torrent_hash" field.
|
||||
func (bu *BlacklistUpdate) SetTorrentHash(s string) *BlacklistUpdate {
|
||||
bu.mutation.SetTorrentHash(s)
|
||||
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)
|
||||
// SetNillableTorrentHash sets the "torrent_hash" field if the given value is not nil.
|
||||
func (bu *BlacklistUpdate) SetNillableTorrentHash(s *string) *BlacklistUpdate {
|
||||
if s != nil {
|
||||
bu.SetTorrentHash(*s)
|
||||
}
|
||||
return bu
|
||||
}
|
||||
|
||||
// ClearTorrentHash clears the value of the "torrent_hash" field.
|
||||
func (bu *BlacklistUpdate) ClearTorrentHash() *BlacklistUpdate {
|
||||
bu.mutation.ClearTorrentHash()
|
||||
return bu
|
||||
}
|
||||
|
||||
// SetTorrentName sets the "torrent_name" field.
|
||||
func (bu *BlacklistUpdate) SetTorrentName(s string) *BlacklistUpdate {
|
||||
bu.mutation.SetTorrentName(s)
|
||||
return bu
|
||||
}
|
||||
|
||||
// SetNillableTorrentName sets the "torrent_name" field if the given value is not nil.
|
||||
func (bu *BlacklistUpdate) SetNillableTorrentName(s *string) *BlacklistUpdate {
|
||||
if s != nil {
|
||||
bu.SetTorrentName(*s)
|
||||
}
|
||||
return bu
|
||||
}
|
||||
|
||||
// ClearTorrentName clears the value of the "torrent_name" field.
|
||||
func (bu *BlacklistUpdate) ClearTorrentName() *BlacklistUpdate {
|
||||
bu.mutation.ClearTorrentName()
|
||||
return bu
|
||||
}
|
||||
|
||||
// SetMediaID sets the "media_id" field.
|
||||
func (bu *BlacklistUpdate) SetMediaID(i int) *BlacklistUpdate {
|
||||
bu.mutation.ResetMediaID()
|
||||
bu.mutation.SetMediaID(i)
|
||||
return bu
|
||||
}
|
||||
|
||||
// SetNillableMediaID sets the "media_id" field if the given value is not nil.
|
||||
func (bu *BlacklistUpdate) SetNillableMediaID(i *int) *BlacklistUpdate {
|
||||
if i != nil {
|
||||
bu.SetMediaID(*i)
|
||||
}
|
||||
return bu
|
||||
}
|
||||
|
||||
// AddMediaID adds i to the "media_id" field.
|
||||
func (bu *BlacklistUpdate) AddMediaID(i int) *BlacklistUpdate {
|
||||
bu.mutation.AddMediaID(i)
|
||||
return bu
|
||||
}
|
||||
|
||||
// ClearMediaID clears the value of the "media_id" field.
|
||||
func (bu *BlacklistUpdate) ClearMediaID() *BlacklistUpdate {
|
||||
bu.mutation.ClearMediaID()
|
||||
return bu
|
||||
}
|
||||
|
||||
// SetNotes sets the "notes" field.
|
||||
func (bu *BlacklistUpdate) SetNotes(s string) *BlacklistUpdate {
|
||||
bu.mutation.SetNotes(s)
|
||||
@@ -133,8 +185,29 @@ func (bu *BlacklistUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
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.TorrentHash(); ok {
|
||||
_spec.SetField(blacklist.FieldTorrentHash, field.TypeString, value)
|
||||
}
|
||||
if bu.mutation.TorrentHashCleared() {
|
||||
_spec.ClearField(blacklist.FieldTorrentHash, field.TypeString)
|
||||
}
|
||||
if value, ok := bu.mutation.TorrentName(); ok {
|
||||
_spec.SetField(blacklist.FieldTorrentName, field.TypeString, value)
|
||||
}
|
||||
if bu.mutation.TorrentNameCleared() {
|
||||
_spec.ClearField(blacklist.FieldTorrentName, field.TypeString)
|
||||
}
|
||||
if value, ok := bu.mutation.MediaID(); ok {
|
||||
_spec.SetField(blacklist.FieldMediaID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := bu.mutation.AddedMediaID(); ok {
|
||||
_spec.AddField(blacklist.FieldMediaID, field.TypeInt, value)
|
||||
}
|
||||
if bu.mutation.MediaIDCleared() {
|
||||
_spec.ClearField(blacklist.FieldMediaID, field.TypeInt)
|
||||
}
|
||||
if bu.mutation.CreateTimeCleared() {
|
||||
_spec.ClearField(blacklist.FieldCreateTime, field.TypeTime)
|
||||
}
|
||||
if value, ok := bu.mutation.Notes(); ok {
|
||||
_spec.SetField(blacklist.FieldNotes, field.TypeString, value)
|
||||
@@ -176,20 +249,73 @@ func (buo *BlacklistUpdateOne) SetNillableType(b *blacklist.Type) *BlacklistUpda
|
||||
return buo
|
||||
}
|
||||
|
||||
// SetValue sets the "value" field.
|
||||
func (buo *BlacklistUpdateOne) SetValue(sv schema.BlacklistValue) *BlacklistUpdateOne {
|
||||
buo.mutation.SetValue(sv)
|
||||
// SetTorrentHash sets the "torrent_hash" field.
|
||||
func (buo *BlacklistUpdateOne) SetTorrentHash(s string) *BlacklistUpdateOne {
|
||||
buo.mutation.SetTorrentHash(s)
|
||||
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)
|
||||
// SetNillableTorrentHash sets the "torrent_hash" field if the given value is not nil.
|
||||
func (buo *BlacklistUpdateOne) SetNillableTorrentHash(s *string) *BlacklistUpdateOne {
|
||||
if s != nil {
|
||||
buo.SetTorrentHash(*s)
|
||||
}
|
||||
return buo
|
||||
}
|
||||
|
||||
// ClearTorrentHash clears the value of the "torrent_hash" field.
|
||||
func (buo *BlacklistUpdateOne) ClearTorrentHash() *BlacklistUpdateOne {
|
||||
buo.mutation.ClearTorrentHash()
|
||||
return buo
|
||||
}
|
||||
|
||||
// SetTorrentName sets the "torrent_name" field.
|
||||
func (buo *BlacklistUpdateOne) SetTorrentName(s string) *BlacklistUpdateOne {
|
||||
buo.mutation.SetTorrentName(s)
|
||||
return buo
|
||||
}
|
||||
|
||||
// SetNillableTorrentName sets the "torrent_name" field if the given value is not nil.
|
||||
func (buo *BlacklistUpdateOne) SetNillableTorrentName(s *string) *BlacklistUpdateOne {
|
||||
if s != nil {
|
||||
buo.SetTorrentName(*s)
|
||||
}
|
||||
return buo
|
||||
}
|
||||
|
||||
// ClearTorrentName clears the value of the "torrent_name" field.
|
||||
func (buo *BlacklistUpdateOne) ClearTorrentName() *BlacklistUpdateOne {
|
||||
buo.mutation.ClearTorrentName()
|
||||
return buo
|
||||
}
|
||||
|
||||
// SetMediaID sets the "media_id" field.
|
||||
func (buo *BlacklistUpdateOne) SetMediaID(i int) *BlacklistUpdateOne {
|
||||
buo.mutation.ResetMediaID()
|
||||
buo.mutation.SetMediaID(i)
|
||||
return buo
|
||||
}
|
||||
|
||||
// SetNillableMediaID sets the "media_id" field if the given value is not nil.
|
||||
func (buo *BlacklistUpdateOne) SetNillableMediaID(i *int) *BlacklistUpdateOne {
|
||||
if i != nil {
|
||||
buo.SetMediaID(*i)
|
||||
}
|
||||
return buo
|
||||
}
|
||||
|
||||
// AddMediaID adds i to the "media_id" field.
|
||||
func (buo *BlacklistUpdateOne) AddMediaID(i int) *BlacklistUpdateOne {
|
||||
buo.mutation.AddMediaID(i)
|
||||
return buo
|
||||
}
|
||||
|
||||
// ClearMediaID clears the value of the "media_id" field.
|
||||
func (buo *BlacklistUpdateOne) ClearMediaID() *BlacklistUpdateOne {
|
||||
buo.mutation.ClearMediaID()
|
||||
return buo
|
||||
}
|
||||
|
||||
// SetNotes sets the "notes" field.
|
||||
func (buo *BlacklistUpdateOne) SetNotes(s string) *BlacklistUpdateOne {
|
||||
buo.mutation.SetNotes(s)
|
||||
@@ -297,8 +423,29 @@ func (buo *BlacklistUpdateOne) sqlSave(ctx context.Context) (_node *Blacklist, e
|
||||
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.TorrentHash(); ok {
|
||||
_spec.SetField(blacklist.FieldTorrentHash, field.TypeString, value)
|
||||
}
|
||||
if buo.mutation.TorrentHashCleared() {
|
||||
_spec.ClearField(blacklist.FieldTorrentHash, field.TypeString)
|
||||
}
|
||||
if value, ok := buo.mutation.TorrentName(); ok {
|
||||
_spec.SetField(blacklist.FieldTorrentName, field.TypeString, value)
|
||||
}
|
||||
if buo.mutation.TorrentNameCleared() {
|
||||
_spec.ClearField(blacklist.FieldTorrentName, field.TypeString)
|
||||
}
|
||||
if value, ok := buo.mutation.MediaID(); ok {
|
||||
_spec.SetField(blacklist.FieldMediaID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := buo.mutation.AddedMediaID(); ok {
|
||||
_spec.AddField(blacklist.FieldMediaID, field.TypeInt, value)
|
||||
}
|
||||
if buo.mutation.MediaIDCleared() {
|
||||
_spec.ClearField(blacklist.FieldMediaID, field.TypeInt)
|
||||
}
|
||||
if buo.mutation.CreateTimeCleared() {
|
||||
_spec.ClearField(blacklist.FieldCreateTime, field.TypeTime)
|
||||
}
|
||||
if value, ok := buo.mutation.Notes(); ok {
|
||||
_spec.SetField(blacklist.FieldNotes, field.TypeString, value)
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"polaris/ent/downloadclients"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
@@ -32,12 +33,16 @@ type DownloadClients struct {
|
||||
Settings string `json:"settings,omitempty"`
|
||||
// Priority1 holds the value of the "priority1" field.
|
||||
Priority1 int `json:"priority1,omitempty"`
|
||||
// use stun server to do nat traversal, enable download client to do uploading successfully
|
||||
UseNatTraversal bool `json:"use_nat_traversal,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.
|
||||
RemoveFailedDownloads bool `json:"remove_failed_downloads,omitempty"`
|
||||
// Tags holds the value of the "tags" field.
|
||||
Tags string `json:"tags,omitempty"`
|
||||
Tags string `json:"tags,omitempty"`
|
||||
// CreateTime holds the value of the "create_time" field.
|
||||
CreateTime time.Time `json:"create_time,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
@@ -46,12 +51,14 @@ func (*DownloadClients) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case downloadclients.FieldEnable, downloadclients.FieldRemoveCompletedDownloads, downloadclients.FieldRemoveFailedDownloads:
|
||||
case downloadclients.FieldEnable, downloadclients.FieldUseNatTraversal, downloadclients.FieldRemoveCompletedDownloads, downloadclients.FieldRemoveFailedDownloads:
|
||||
values[i] = new(sql.NullBool)
|
||||
case downloadclients.FieldID, downloadclients.FieldPriority1:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case downloadclients.FieldName, downloadclients.FieldImplementation, downloadclients.FieldURL, downloadclients.FieldUser, downloadclients.FieldPassword, downloadclients.FieldSettings, downloadclients.FieldTags:
|
||||
values[i] = new(sql.NullString)
|
||||
case downloadclients.FieldCreateTime:
|
||||
values[i] = new(sql.NullTime)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
@@ -121,6 +128,12 @@ func (dc *DownloadClients) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
dc.Priority1 = int(value.Int64)
|
||||
}
|
||||
case downloadclients.FieldUseNatTraversal:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field use_nat_traversal", values[i])
|
||||
} else if value.Valid {
|
||||
dc.UseNatTraversal = value.Bool
|
||||
}
|
||||
case downloadclients.FieldRemoveCompletedDownloads:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field remove_completed_downloads", values[i])
|
||||
@@ -139,6 +152,12 @@ func (dc *DownloadClients) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
dc.Tags = value.String
|
||||
}
|
||||
case downloadclients.FieldCreateTime:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field create_time", values[i])
|
||||
} else if value.Valid {
|
||||
dc.CreateTime = value.Time
|
||||
}
|
||||
default:
|
||||
dc.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
@@ -199,6 +218,9 @@ func (dc *DownloadClients) String() string {
|
||||
builder.WriteString("priority1=")
|
||||
builder.WriteString(fmt.Sprintf("%v", dc.Priority1))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("use_nat_traversal=")
|
||||
builder.WriteString(fmt.Sprintf("%v", dc.UseNatTraversal))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("remove_completed_downloads=")
|
||||
builder.WriteString(fmt.Sprintf("%v", dc.RemoveCompletedDownloads))
|
||||
builder.WriteString(", ")
|
||||
@@ -207,6 +229,9 @@ func (dc *DownloadClients) String() string {
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("tags=")
|
||||
builder.WriteString(dc.Tags)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("create_time=")
|
||||
builder.WriteString(dc.CreateTime.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ package downloadclients
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
@@ -29,12 +30,16 @@ const (
|
||||
FieldSettings = "settings"
|
||||
// FieldPriority1 holds the string denoting the priority1 field in the database.
|
||||
FieldPriority1 = "priority1"
|
||||
// FieldUseNatTraversal holds the string denoting the use_nat_traversal field in the database.
|
||||
FieldUseNatTraversal = "use_nat_traversal"
|
||||
// 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.
|
||||
FieldRemoveFailedDownloads = "remove_failed_downloads"
|
||||
// FieldTags holds the string denoting the tags field in the database.
|
||||
FieldTags = "tags"
|
||||
// FieldCreateTime holds the string denoting the create_time field in the database.
|
||||
FieldCreateTime = "create_time"
|
||||
// Table holds the table name of the downloadclients in the database.
|
||||
Table = "download_clients"
|
||||
)
|
||||
@@ -50,9 +55,11 @@ var Columns = []string{
|
||||
FieldPassword,
|
||||
FieldSettings,
|
||||
FieldPriority1,
|
||||
FieldUseNatTraversal,
|
||||
FieldRemoveCompletedDownloads,
|
||||
FieldRemoveFailedDownloads,
|
||||
FieldTags,
|
||||
FieldCreateTime,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
@@ -76,12 +83,16 @@ var (
|
||||
DefaultPriority1 int
|
||||
// Priority1Validator is a validator for the "priority1" field. It is called by the builders before save.
|
||||
Priority1Validator func(int) error
|
||||
// DefaultUseNatTraversal holds the default value on creation for the "use_nat_traversal" field.
|
||||
DefaultUseNatTraversal bool
|
||||
// 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.
|
||||
DefaultRemoveFailedDownloads bool
|
||||
// DefaultTags holds the default value on creation for the "tags" field.
|
||||
DefaultTags string
|
||||
// DefaultCreateTime holds the default value on creation for the "create_time" field.
|
||||
DefaultCreateTime func() time.Time
|
||||
)
|
||||
|
||||
// Implementation defines the type for the "implementation" enum field.
|
||||
@@ -156,6 +167,11 @@ func ByPriority1(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPriority1, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUseNatTraversal orders the results by the use_nat_traversal field.
|
||||
func ByUseNatTraversal(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUseNatTraversal, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByRemoveCompletedDownloads orders the results by the remove_completed_downloads field.
|
||||
func ByRemoveCompletedDownloads(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldRemoveCompletedDownloads, opts...).ToFunc()
|
||||
@@ -170,3 +186,8 @@ func ByRemoveFailedDownloads(opts ...sql.OrderTermOption) OrderOption {
|
||||
func ByTags(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTags, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreateTime orders the results by the create_time field.
|
||||
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ package downloadclients
|
||||
|
||||
import (
|
||||
"polaris/ent/predicate"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
@@ -88,6 +89,11 @@ func Priority1(v int) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldPriority1, v))
|
||||
}
|
||||
|
||||
// UseNatTraversal applies equality check predicate on the "use_nat_traversal" field. It's identical to UseNatTraversalEQ.
|
||||
func UseNatTraversal(v bool) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldUseNatTraversal, v))
|
||||
}
|
||||
|
||||
// RemoveCompletedDownloads applies equality check predicate on the "remove_completed_downloads" field. It's identical to RemoveCompletedDownloadsEQ.
|
||||
func RemoveCompletedDownloads(v bool) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldRemoveCompletedDownloads, v))
|
||||
@@ -103,6 +109,11 @@ func Tags(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldTags, v))
|
||||
}
|
||||
|
||||
// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ.
|
||||
func CreateTime(v time.Time) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// EnableEQ applies the EQ predicate on the "enable" field.
|
||||
func EnableEQ(v bool) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldEnable, v))
|
||||
@@ -498,6 +509,26 @@ func Priority1LTE(v int) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldLTE(FieldPriority1, v))
|
||||
}
|
||||
|
||||
// UseNatTraversalEQ applies the EQ predicate on the "use_nat_traversal" field.
|
||||
func UseNatTraversalEQ(v bool) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldUseNatTraversal, v))
|
||||
}
|
||||
|
||||
// UseNatTraversalNEQ applies the NEQ predicate on the "use_nat_traversal" field.
|
||||
func UseNatTraversalNEQ(v bool) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNEQ(FieldUseNatTraversal, v))
|
||||
}
|
||||
|
||||
// UseNatTraversalIsNil applies the IsNil predicate on the "use_nat_traversal" field.
|
||||
func UseNatTraversalIsNil() predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldIsNull(FieldUseNatTraversal))
|
||||
}
|
||||
|
||||
// UseNatTraversalNotNil applies the NotNil predicate on the "use_nat_traversal" field.
|
||||
func UseNatTraversalNotNil() predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNotNull(FieldUseNatTraversal))
|
||||
}
|
||||
|
||||
// RemoveCompletedDownloadsEQ applies the EQ predicate on the "remove_completed_downloads" field.
|
||||
func RemoveCompletedDownloadsEQ(v bool) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldRemoveCompletedDownloads, v))
|
||||
@@ -583,6 +614,56 @@ func TagsContainsFold(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldContainsFold(FieldTags, v))
|
||||
}
|
||||
|
||||
// CreateTimeEQ applies the EQ predicate on the "create_time" field.
|
||||
func CreateTimeEQ(v time.Time) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeNEQ applies the NEQ predicate on the "create_time" field.
|
||||
func CreateTimeNEQ(v time.Time) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeIn applies the In predicate on the "create_time" field.
|
||||
func CreateTimeIn(vs ...time.Time) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeNotIn applies the NotIn predicate on the "create_time" field.
|
||||
func CreateTimeNotIn(vs ...time.Time) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNotIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeGT applies the GT predicate on the "create_time" field.
|
||||
func CreateTimeGT(v time.Time) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldGT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeGTE applies the GTE predicate on the "create_time" field.
|
||||
func CreateTimeGTE(v time.Time) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldGTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLT applies the LT predicate on the "create_time" field.
|
||||
func CreateTimeLT(v time.Time) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldLT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLTE applies the LTE predicate on the "create_time" field.
|
||||
func CreateTimeLTE(v time.Time) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldLTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeIsNil applies the IsNil predicate on the "create_time" field.
|
||||
func CreateTimeIsNil() predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldIsNull(FieldCreateTime))
|
||||
}
|
||||
|
||||
// CreateTimeNotNil applies the NotNil predicate on the "create_time" field.
|
||||
func CreateTimeNotNil() predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNotNull(FieldCreateTime))
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.DownloadClients) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.AndPredicates(predicates...))
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/downloadclients"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
@@ -99,6 +100,20 @@ func (dcc *DownloadClientsCreate) SetNillablePriority1(i *int) *DownloadClientsC
|
||||
return dcc
|
||||
}
|
||||
|
||||
// SetUseNatTraversal sets the "use_nat_traversal" field.
|
||||
func (dcc *DownloadClientsCreate) SetUseNatTraversal(b bool) *DownloadClientsCreate {
|
||||
dcc.mutation.SetUseNatTraversal(b)
|
||||
return dcc
|
||||
}
|
||||
|
||||
// SetNillableUseNatTraversal sets the "use_nat_traversal" field if the given value is not nil.
|
||||
func (dcc *DownloadClientsCreate) SetNillableUseNatTraversal(b *bool) *DownloadClientsCreate {
|
||||
if b != nil {
|
||||
dcc.SetUseNatTraversal(*b)
|
||||
}
|
||||
return dcc
|
||||
}
|
||||
|
||||
// SetRemoveCompletedDownloads sets the "remove_completed_downloads" field.
|
||||
func (dcc *DownloadClientsCreate) SetRemoveCompletedDownloads(b bool) *DownloadClientsCreate {
|
||||
dcc.mutation.SetRemoveCompletedDownloads(b)
|
||||
@@ -141,6 +156,20 @@ func (dcc *DownloadClientsCreate) SetNillableTags(s *string) *DownloadClientsCre
|
||||
return dcc
|
||||
}
|
||||
|
||||
// SetCreateTime sets the "create_time" field.
|
||||
func (dcc *DownloadClientsCreate) SetCreateTime(t time.Time) *DownloadClientsCreate {
|
||||
dcc.mutation.SetCreateTime(t)
|
||||
return dcc
|
||||
}
|
||||
|
||||
// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
|
||||
func (dcc *DownloadClientsCreate) SetNillableCreateTime(t *time.Time) *DownloadClientsCreate {
|
||||
if t != nil {
|
||||
dcc.SetCreateTime(*t)
|
||||
}
|
||||
return dcc
|
||||
}
|
||||
|
||||
// Mutation returns the DownloadClientsMutation object of the builder.
|
||||
func (dcc *DownloadClientsCreate) Mutation() *DownloadClientsMutation {
|
||||
return dcc.mutation
|
||||
@@ -192,6 +221,10 @@ func (dcc *DownloadClientsCreate) defaults() {
|
||||
v := downloadclients.DefaultPriority1
|
||||
dcc.mutation.SetPriority1(v)
|
||||
}
|
||||
if _, ok := dcc.mutation.UseNatTraversal(); !ok {
|
||||
v := downloadclients.DefaultUseNatTraversal
|
||||
dcc.mutation.SetUseNatTraversal(v)
|
||||
}
|
||||
if _, ok := dcc.mutation.RemoveCompletedDownloads(); !ok {
|
||||
v := downloadclients.DefaultRemoveCompletedDownloads
|
||||
dcc.mutation.SetRemoveCompletedDownloads(v)
|
||||
@@ -204,6 +237,10 @@ func (dcc *DownloadClientsCreate) defaults() {
|
||||
v := downloadclients.DefaultTags
|
||||
dcc.mutation.SetTags(v)
|
||||
}
|
||||
if _, ok := dcc.mutation.CreateTime(); !ok {
|
||||
v := downloadclients.DefaultCreateTime()
|
||||
dcc.mutation.SetCreateTime(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
@@ -309,6 +346,10 @@ func (dcc *DownloadClientsCreate) createSpec() (*DownloadClients, *sqlgraph.Crea
|
||||
_spec.SetField(downloadclients.FieldPriority1, field.TypeInt, value)
|
||||
_node.Priority1 = value
|
||||
}
|
||||
if value, ok := dcc.mutation.UseNatTraversal(); ok {
|
||||
_spec.SetField(downloadclients.FieldUseNatTraversal, field.TypeBool, value)
|
||||
_node.UseNatTraversal = value
|
||||
}
|
||||
if value, ok := dcc.mutation.RemoveCompletedDownloads(); ok {
|
||||
_spec.SetField(downloadclients.FieldRemoveCompletedDownloads, field.TypeBool, value)
|
||||
_node.RemoveCompletedDownloads = value
|
||||
@@ -321,6 +362,10 @@ func (dcc *DownloadClientsCreate) createSpec() (*DownloadClients, *sqlgraph.Crea
|
||||
_spec.SetField(downloadclients.FieldTags, field.TypeString, value)
|
||||
_node.Tags = value
|
||||
}
|
||||
if value, ok := dcc.mutation.CreateTime(); ok {
|
||||
_spec.SetField(downloadclients.FieldCreateTime, field.TypeTime, value)
|
||||
_node.CreateTime = value
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
|
||||
@@ -146,6 +146,26 @@ func (dcu *DownloadClientsUpdate) AddPriority1(i int) *DownloadClientsUpdate {
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetUseNatTraversal sets the "use_nat_traversal" field.
|
||||
func (dcu *DownloadClientsUpdate) SetUseNatTraversal(b bool) *DownloadClientsUpdate {
|
||||
dcu.mutation.SetUseNatTraversal(b)
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetNillableUseNatTraversal sets the "use_nat_traversal" field if the given value is not nil.
|
||||
func (dcu *DownloadClientsUpdate) SetNillableUseNatTraversal(b *bool) *DownloadClientsUpdate {
|
||||
if b != nil {
|
||||
dcu.SetUseNatTraversal(*b)
|
||||
}
|
||||
return dcu
|
||||
}
|
||||
|
||||
// ClearUseNatTraversal clears the value of the "use_nat_traversal" field.
|
||||
func (dcu *DownloadClientsUpdate) ClearUseNatTraversal() *DownloadClientsUpdate {
|
||||
dcu.mutation.ClearUseNatTraversal()
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetRemoveCompletedDownloads sets the "remove_completed_downloads" field.
|
||||
func (dcu *DownloadClientsUpdate) SetRemoveCompletedDownloads(b bool) *DownloadClientsUpdate {
|
||||
dcu.mutation.SetRemoveCompletedDownloads(b)
|
||||
@@ -274,6 +294,12 @@ func (dcu *DownloadClientsUpdate) sqlSave(ctx context.Context) (n int, err error
|
||||
if value, ok := dcu.mutation.AddedPriority1(); ok {
|
||||
_spec.AddField(downloadclients.FieldPriority1, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := dcu.mutation.UseNatTraversal(); ok {
|
||||
_spec.SetField(downloadclients.FieldUseNatTraversal, field.TypeBool, value)
|
||||
}
|
||||
if dcu.mutation.UseNatTraversalCleared() {
|
||||
_spec.ClearField(downloadclients.FieldUseNatTraversal, field.TypeBool)
|
||||
}
|
||||
if value, ok := dcu.mutation.RemoveCompletedDownloads(); ok {
|
||||
_spec.SetField(downloadclients.FieldRemoveCompletedDownloads, field.TypeBool, value)
|
||||
}
|
||||
@@ -283,6 +309,9 @@ func (dcu *DownloadClientsUpdate) sqlSave(ctx context.Context) (n int, err error
|
||||
if value, ok := dcu.mutation.Tags(); ok {
|
||||
_spec.SetField(downloadclients.FieldTags, field.TypeString, value)
|
||||
}
|
||||
if dcu.mutation.CreateTimeCleared() {
|
||||
_spec.ClearField(downloadclients.FieldCreateTime, field.TypeTime)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, dcu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{downloadclients.Label}
|
||||
@@ -422,6 +451,26 @@ func (dcuo *DownloadClientsUpdateOne) AddPriority1(i int) *DownloadClientsUpdate
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetUseNatTraversal sets the "use_nat_traversal" field.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetUseNatTraversal(b bool) *DownloadClientsUpdateOne {
|
||||
dcuo.mutation.SetUseNatTraversal(b)
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetNillableUseNatTraversal sets the "use_nat_traversal" field if the given value is not nil.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetNillableUseNatTraversal(b *bool) *DownloadClientsUpdateOne {
|
||||
if b != nil {
|
||||
dcuo.SetUseNatTraversal(*b)
|
||||
}
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// ClearUseNatTraversal clears the value of the "use_nat_traversal" field.
|
||||
func (dcuo *DownloadClientsUpdateOne) ClearUseNatTraversal() *DownloadClientsUpdateOne {
|
||||
dcuo.mutation.ClearUseNatTraversal()
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetRemoveCompletedDownloads sets the "remove_completed_downloads" field.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetRemoveCompletedDownloads(b bool) *DownloadClientsUpdateOne {
|
||||
dcuo.mutation.SetRemoveCompletedDownloads(b)
|
||||
@@ -580,6 +629,12 @@ func (dcuo *DownloadClientsUpdateOne) sqlSave(ctx context.Context) (_node *Downl
|
||||
if value, ok := dcuo.mutation.AddedPriority1(); ok {
|
||||
_spec.AddField(downloadclients.FieldPriority1, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := dcuo.mutation.UseNatTraversal(); ok {
|
||||
_spec.SetField(downloadclients.FieldUseNatTraversal, field.TypeBool, value)
|
||||
}
|
||||
if dcuo.mutation.UseNatTraversalCleared() {
|
||||
_spec.ClearField(downloadclients.FieldUseNatTraversal, field.TypeBool)
|
||||
}
|
||||
if value, ok := dcuo.mutation.RemoveCompletedDownloads(); ok {
|
||||
_spec.SetField(downloadclients.FieldRemoveCompletedDownloads, field.TypeBool, value)
|
||||
}
|
||||
@@ -589,6 +644,9 @@ func (dcuo *DownloadClientsUpdateOne) sqlSave(ctx context.Context) (_node *Downl
|
||||
if value, ok := dcuo.mutation.Tags(); ok {
|
||||
_spec.SetField(downloadclients.FieldTags, field.TypeString, value)
|
||||
}
|
||||
if dcuo.mutation.CreateTimeCleared() {
|
||||
_spec.ClearField(downloadclients.FieldCreateTime, field.TypeTime)
|
||||
}
|
||||
_node = &DownloadClients{config: dcuo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"polaris/ent/episode"
|
||||
"polaris/ent/media"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
@@ -35,6 +36,8 @@ type Episode struct {
|
||||
Monitored bool `json:"monitored"`
|
||||
// TargetFile holds the value of the "target_file" field.
|
||||
TargetFile string `json:"target_file,omitempty"`
|
||||
// CreateTime holds the value of the "create_time" field.
|
||||
CreateTime time.Time `json:"create_time,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"`
|
||||
@@ -72,6 +75,8 @@ func (*Episode) scanValues(columns []string) ([]any, error) {
|
||||
values[i] = new(sql.NullInt64)
|
||||
case episode.FieldTitle, episode.FieldOverview, episode.FieldAirDate, episode.FieldStatus, episode.FieldTargetFile:
|
||||
values[i] = new(sql.NullString)
|
||||
case episode.FieldCreateTime:
|
||||
values[i] = new(sql.NullTime)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
@@ -147,6 +152,12 @@ func (e *Episode) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
e.TargetFile = value.String
|
||||
}
|
||||
case episode.FieldCreateTime:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field create_time", values[i])
|
||||
} else if value.Valid {
|
||||
e.CreateTime = value.Time
|
||||
}
|
||||
default:
|
||||
e.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
@@ -214,6 +225,9 @@ func (e *Episode) String() string {
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("target_file=")
|
||||
builder.WriteString(e.TargetFile)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("create_time=")
|
||||
builder.WriteString(e.CreateTime.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ package episode
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -32,6 +33,8 @@ const (
|
||||
FieldMonitored = "monitored"
|
||||
// FieldTargetFile holds the string denoting the target_file field in the database.
|
||||
FieldTargetFile = "target_file"
|
||||
// FieldCreateTime holds the string denoting the create_time field in the database.
|
||||
FieldCreateTime = "create_time"
|
||||
// EdgeMedia holds the string denoting the media edge name in mutations.
|
||||
EdgeMedia = "media"
|
||||
// Table holds the table name of the episode in the database.
|
||||
@@ -57,6 +60,7 @@ var Columns = []string{
|
||||
FieldStatus,
|
||||
FieldMonitored,
|
||||
FieldTargetFile,
|
||||
FieldCreateTime,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
@@ -72,6 +76,8 @@ func ValidColumn(column string) bool {
|
||||
var (
|
||||
// DefaultMonitored holds the default value on creation for the "monitored" field.
|
||||
DefaultMonitored bool
|
||||
// DefaultCreateTime holds the default value on creation for the "create_time" field.
|
||||
DefaultCreateTime func() time.Time
|
||||
)
|
||||
|
||||
// Status defines the type for the "status" enum field.
|
||||
@@ -154,6 +160,11 @@ func ByTargetFile(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTargetFile, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreateTime orders the results by the create_time field.
|
||||
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByMediaField orders the results by media field.
|
||||
func ByMediaField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
|
||||
@@ -4,6 +4,7 @@ package episode
|
||||
|
||||
import (
|
||||
"polaris/ent/predicate"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -94,6 +95,11 @@ func TargetFile(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldEQ(FieldTargetFile, v))
|
||||
}
|
||||
|
||||
// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ.
|
||||
func CreateTime(v time.Time) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// MediaIDEQ applies the EQ predicate on the "media_id" field.
|
||||
func MediaIDEQ(v int) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldEQ(FieldMediaID, v))
|
||||
@@ -504,6 +510,56 @@ func TargetFileContainsFold(v string) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldContainsFold(FieldTargetFile, v))
|
||||
}
|
||||
|
||||
// CreateTimeEQ applies the EQ predicate on the "create_time" field.
|
||||
func CreateTimeEQ(v time.Time) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeNEQ applies the NEQ predicate on the "create_time" field.
|
||||
func CreateTimeNEQ(v time.Time) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldNEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeIn applies the In predicate on the "create_time" field.
|
||||
func CreateTimeIn(vs ...time.Time) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeNotIn applies the NotIn predicate on the "create_time" field.
|
||||
func CreateTimeNotIn(vs ...time.Time) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldNotIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeGT applies the GT predicate on the "create_time" field.
|
||||
func CreateTimeGT(v time.Time) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldGT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeGTE applies the GTE predicate on the "create_time" field.
|
||||
func CreateTimeGTE(v time.Time) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldGTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLT applies the LT predicate on the "create_time" field.
|
||||
func CreateTimeLT(v time.Time) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldLT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLTE applies the LTE predicate on the "create_time" field.
|
||||
func CreateTimeLTE(v time.Time) predicate.Episode {
|
||||
return predicate.Episode(sql.FieldLTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeIsNil applies the IsNil predicate on the "create_time" field.
|
||||
func CreateTimeIsNil() predicate.Episode {
|
||||
return predicate.Episode(sql.FieldIsNull(FieldCreateTime))
|
||||
}
|
||||
|
||||
// CreateTimeNotNil applies the NotNil predicate on the "create_time" field.
|
||||
func CreateTimeNotNil() predicate.Episode {
|
||||
return predicate.Episode(sql.FieldNotNull(FieldCreateTime))
|
||||
}
|
||||
|
||||
// HasMedia applies the HasEdge predicate on the "media" edge.
|
||||
func HasMedia() predicate.Episode {
|
||||
return predicate.Episode(func(s *sql.Selector) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"polaris/ent/episode"
|
||||
"polaris/ent/media"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
@@ -106,6 +107,20 @@ func (ec *EpisodeCreate) SetNillableTargetFile(s *string) *EpisodeCreate {
|
||||
return ec
|
||||
}
|
||||
|
||||
// SetCreateTime sets the "create_time" field.
|
||||
func (ec *EpisodeCreate) SetCreateTime(t time.Time) *EpisodeCreate {
|
||||
ec.mutation.SetCreateTime(t)
|
||||
return ec
|
||||
}
|
||||
|
||||
// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
|
||||
func (ec *EpisodeCreate) SetNillableCreateTime(t *time.Time) *EpisodeCreate {
|
||||
if t != nil {
|
||||
ec.SetCreateTime(*t)
|
||||
}
|
||||
return ec
|
||||
}
|
||||
|
||||
// SetMedia sets the "media" edge to the Media entity.
|
||||
func (ec *EpisodeCreate) SetMedia(m *Media) *EpisodeCreate {
|
||||
return ec.SetMediaID(m.ID)
|
||||
@@ -154,6 +169,10 @@ func (ec *EpisodeCreate) defaults() {
|
||||
v := episode.DefaultMonitored
|
||||
ec.mutation.SetMonitored(v)
|
||||
}
|
||||
if _, ok := ec.mutation.CreateTime(); !ok {
|
||||
v := episode.DefaultCreateTime()
|
||||
ec.mutation.SetCreateTime(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
@@ -242,6 +261,10 @@ func (ec *EpisodeCreate) createSpec() (*Episode, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(episode.FieldTargetFile, field.TypeString, value)
|
||||
_node.TargetFile = value
|
||||
}
|
||||
if value, ok := ec.mutation.CreateTime(); ok {
|
||||
_spec.SetField(episode.FieldCreateTime, field.TypeTime, value)
|
||||
_node.CreateTime = value
|
||||
}
|
||||
if nodes := ec.mutation.MediaIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
|
||||
@@ -278,6 +278,9 @@ func (eu *EpisodeUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if eu.mutation.TargetFileCleared() {
|
||||
_spec.ClearField(episode.FieldTargetFile, field.TypeString)
|
||||
}
|
||||
if eu.mutation.CreateTimeCleared() {
|
||||
_spec.ClearField(episode.FieldCreateTime, field.TypeTime)
|
||||
}
|
||||
if eu.mutation.MediaCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
@@ -607,6 +610,9 @@ func (euo *EpisodeUpdateOne) sqlSave(ctx context.Context) (_node *Episode, err e
|
||||
if euo.mutation.TargetFileCleared() {
|
||||
_spec.ClearField(episode.FieldTargetFile, field.TypeString)
|
||||
}
|
||||
if euo.mutation.CreateTimeCleared() {
|
||||
_spec.ClearField(episode.FieldCreateTime, field.TypeTime)
|
||||
}
|
||||
if euo.mutation.MediaCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
|
||||
@@ -36,12 +36,14 @@ type History struct {
|
||||
DownloadClientID int `json:"download_client_id,omitempty"`
|
||||
// IndexerID holds the value of the "indexer_id" field.
|
||||
IndexerID int `json:"indexer_id,omitempty"`
|
||||
// deprecated, use hash instead
|
||||
// torrent link
|
||||
Link string `json:"link,omitempty"`
|
||||
// torrent hash
|
||||
Hash string `json:"hash,omitempty"`
|
||||
// Status holds the value of the "status" field.
|
||||
Status history.Status `json:"status,omitempty"`
|
||||
Status history.Status `json:"status,omitempty"`
|
||||
// CreateTime holds the value of the "create_time" field.
|
||||
CreateTime time.Time `json:"create_time,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
@@ -56,7 +58,7 @@ func (*History) scanValues(columns []string) ([]any, error) {
|
||||
values[i] = new(sql.NullInt64)
|
||||
case history.FieldSourceTitle, history.FieldTargetDir, history.FieldLink, history.FieldHash, history.FieldStatus:
|
||||
values[i] = new(sql.NullString)
|
||||
case history.FieldDate:
|
||||
case history.FieldDate, history.FieldCreateTime:
|
||||
values[i] = new(sql.NullTime)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
@@ -153,6 +155,12 @@ func (h *History) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
h.Status = history.Status(value.String)
|
||||
}
|
||||
case history.FieldCreateTime:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field create_time", values[i])
|
||||
} else if value.Valid {
|
||||
h.CreateTime = value.Time
|
||||
}
|
||||
default:
|
||||
h.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
@@ -224,6 +232,9 @@ func (h *History) String() string {
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("status=")
|
||||
builder.WriteString(fmt.Sprintf("%v", h.Status))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("create_time=")
|
||||
builder.WriteString(h.CreateTime.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ package history
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
@@ -37,6 +38,8 @@ const (
|
||||
FieldHash = "hash"
|
||||
// FieldStatus holds the string denoting the status field in the database.
|
||||
FieldStatus = "status"
|
||||
// FieldCreateTime holds the string denoting the create_time field in the database.
|
||||
FieldCreateTime = "create_time"
|
||||
// Table holds the table name of the history in the database.
|
||||
Table = "histories"
|
||||
)
|
||||
@@ -56,6 +59,7 @@ var Columns = []string{
|
||||
FieldLink,
|
||||
FieldHash,
|
||||
FieldStatus,
|
||||
FieldCreateTime,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
@@ -71,6 +75,8 @@ func ValidColumn(column string) bool {
|
||||
var (
|
||||
// DefaultSize holds the default value on creation for the "size" field.
|
||||
DefaultSize int
|
||||
// DefaultCreateTime holds the default value on creation for the "create_time" field.
|
||||
DefaultCreateTime func() time.Time
|
||||
)
|
||||
|
||||
// Status defines the type for the "status" enum field.
|
||||
@@ -162,3 +168,8 @@ func ByHash(opts ...sql.OrderTermOption) OrderOption {
|
||||
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldStatus, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreateTime orders the results by the create_time field.
|
||||
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
|
||||
}
|
||||
|
||||
@@ -104,6 +104,11 @@ func Hash(v string) predicate.History {
|
||||
return predicate.History(sql.FieldEQ(FieldHash, v))
|
||||
}
|
||||
|
||||
// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ.
|
||||
func CreateTime(v time.Time) predicate.History {
|
||||
return predicate.History(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// MediaIDEQ applies the EQ predicate on the "media_id" field.
|
||||
func MediaIDEQ(v int) predicate.History {
|
||||
return predicate.History(sql.FieldEQ(FieldMediaID, v))
|
||||
@@ -684,6 +689,56 @@ func StatusNotIn(vs ...Status) predicate.History {
|
||||
return predicate.History(sql.FieldNotIn(FieldStatus, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeEQ applies the EQ predicate on the "create_time" field.
|
||||
func CreateTimeEQ(v time.Time) predicate.History {
|
||||
return predicate.History(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeNEQ applies the NEQ predicate on the "create_time" field.
|
||||
func CreateTimeNEQ(v time.Time) predicate.History {
|
||||
return predicate.History(sql.FieldNEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeIn applies the In predicate on the "create_time" field.
|
||||
func CreateTimeIn(vs ...time.Time) predicate.History {
|
||||
return predicate.History(sql.FieldIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeNotIn applies the NotIn predicate on the "create_time" field.
|
||||
func CreateTimeNotIn(vs ...time.Time) predicate.History {
|
||||
return predicate.History(sql.FieldNotIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeGT applies the GT predicate on the "create_time" field.
|
||||
func CreateTimeGT(v time.Time) predicate.History {
|
||||
return predicate.History(sql.FieldGT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeGTE applies the GTE predicate on the "create_time" field.
|
||||
func CreateTimeGTE(v time.Time) predicate.History {
|
||||
return predicate.History(sql.FieldGTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLT applies the LT predicate on the "create_time" field.
|
||||
func CreateTimeLT(v time.Time) predicate.History {
|
||||
return predicate.History(sql.FieldLT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLTE applies the LTE predicate on the "create_time" field.
|
||||
func CreateTimeLTE(v time.Time) predicate.History {
|
||||
return predicate.History(sql.FieldLTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeIsNil applies the IsNil predicate on the "create_time" field.
|
||||
func CreateTimeIsNil() predicate.History {
|
||||
return predicate.History(sql.FieldIsNull(FieldCreateTime))
|
||||
}
|
||||
|
||||
// CreateTimeNotNil applies the NotNil predicate on the "create_time" field.
|
||||
func CreateTimeNotNil() predicate.History {
|
||||
return predicate.History(sql.FieldNotNull(FieldCreateTime))
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.History) predicate.History {
|
||||
return predicate.History(sql.AndPredicates(predicates...))
|
||||
|
||||
@@ -140,6 +140,20 @@ func (hc *HistoryCreate) SetStatus(h history.Status) *HistoryCreate {
|
||||
return hc
|
||||
}
|
||||
|
||||
// SetCreateTime sets the "create_time" field.
|
||||
func (hc *HistoryCreate) SetCreateTime(t time.Time) *HistoryCreate {
|
||||
hc.mutation.SetCreateTime(t)
|
||||
return hc
|
||||
}
|
||||
|
||||
// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
|
||||
func (hc *HistoryCreate) SetNillableCreateTime(t *time.Time) *HistoryCreate {
|
||||
if t != nil {
|
||||
hc.SetCreateTime(*t)
|
||||
}
|
||||
return hc
|
||||
}
|
||||
|
||||
// Mutation returns the HistoryMutation object of the builder.
|
||||
func (hc *HistoryCreate) Mutation() *HistoryMutation {
|
||||
return hc.mutation
|
||||
@@ -179,6 +193,10 @@ func (hc *HistoryCreate) defaults() {
|
||||
v := history.DefaultSize
|
||||
hc.mutation.SetSize(v)
|
||||
}
|
||||
if _, ok := hc.mutation.CreateTime(); !ok {
|
||||
v := history.DefaultCreateTime()
|
||||
hc.mutation.SetCreateTime(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
@@ -280,6 +298,10 @@ func (hc *HistoryCreate) createSpec() (*History, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(history.FieldStatus, field.TypeEnum, value)
|
||||
_node.Status = value
|
||||
}
|
||||
if value, ok := hc.mutation.CreateTime(); ok {
|
||||
_spec.SetField(history.FieldCreateTime, field.TypeTime, value)
|
||||
_node.CreateTime = value
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
|
||||
@@ -394,6 +394,9 @@ func (hu *HistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if value, ok := hu.mutation.Status(); ok {
|
||||
_spec.SetField(history.FieldStatus, field.TypeEnum, value)
|
||||
}
|
||||
if hu.mutation.CreateTimeCleared() {
|
||||
_spec.ClearField(history.FieldCreateTime, field.TypeTime)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, hu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{history.Label}
|
||||
@@ -809,6 +812,9 @@ func (huo *HistoryUpdateOne) sqlSave(ctx context.Context) (_node *History, err e
|
||||
if value, ok := huo.mutation.Status(); ok {
|
||||
_spec.SetField(history.FieldStatus, field.TypeEnum, value)
|
||||
}
|
||||
if huo.mutation.CreateTimeCleared() {
|
||||
_spec.ClearField(history.FieldCreateTime, field.TypeTime)
|
||||
}
|
||||
_node = &History{config: huo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"polaris/ent/indexers"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
@@ -39,7 +40,9 @@ type Indexers struct {
|
||||
// URL holds the value of the "url" field.
|
||||
URL string `json:"url,omitempty"`
|
||||
// synced from prowlarr
|
||||
Synced bool `json:"synced,omitempty"`
|
||||
Synced bool `json:"synced,omitempty"`
|
||||
// CreateTime holds the value of the "create_time" field.
|
||||
CreateTime time.Time `json:"create_time,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
@@ -56,6 +59,8 @@ func (*Indexers) scanValues(columns []string) ([]any, error) {
|
||||
values[i] = new(sql.NullInt64)
|
||||
case indexers.FieldName, indexers.FieldImplementation, indexers.FieldSettings, indexers.FieldAPIKey, indexers.FieldURL:
|
||||
values[i] = new(sql.NullString)
|
||||
case indexers.FieldCreateTime:
|
||||
values[i] = new(sql.NullTime)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
@@ -149,6 +154,12 @@ func (i *Indexers) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
i.Synced = value.Bool
|
||||
}
|
||||
case indexers.FieldCreateTime:
|
||||
if value, ok := values[j].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field create_time", values[j])
|
||||
} else if value.Valid {
|
||||
i.CreateTime = value.Time
|
||||
}
|
||||
default:
|
||||
i.selectValues.Set(columns[j], values[j])
|
||||
}
|
||||
@@ -220,6 +231,9 @@ func (i *Indexers) String() string {
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("synced=")
|
||||
builder.WriteString(fmt.Sprintf("%v", i.Synced))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("create_time=")
|
||||
builder.WriteString(i.CreateTime.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
package indexers
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
@@ -35,6 +37,8 @@ const (
|
||||
FieldURL = "url"
|
||||
// FieldSynced holds the string denoting the synced field in the database.
|
||||
FieldSynced = "synced"
|
||||
// FieldCreateTime holds the string denoting the create_time field in the database.
|
||||
FieldCreateTime = "create_time"
|
||||
// Table holds the table name of the indexers in the database.
|
||||
Table = "indexers"
|
||||
)
|
||||
@@ -54,6 +58,7 @@ var Columns = []string{
|
||||
FieldAPIKey,
|
||||
FieldURL,
|
||||
FieldSynced,
|
||||
FieldCreateTime,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
@@ -73,6 +78,8 @@ var (
|
||||
DefaultEnableRss bool
|
||||
// DefaultPriority holds the default value on creation for the "priority" field.
|
||||
DefaultPriority int
|
||||
// PriorityValidator is a validator for the "priority" field. It is called by the builders before save.
|
||||
PriorityValidator func(int) error
|
||||
// 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.
|
||||
@@ -83,6 +90,8 @@ var (
|
||||
DefaultMovieSearch bool
|
||||
// DefaultSynced holds the default value on creation for the "synced" field.
|
||||
DefaultSynced bool
|
||||
// DefaultCreateTime holds the default value on creation for the "create_time" field.
|
||||
DefaultCreateTime func() time.Time
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the Indexers queries.
|
||||
@@ -152,3 +161,8 @@ func ByURL(opts ...sql.OrderTermOption) OrderOption {
|
||||
func BySynced(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSynced, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreateTime orders the results by the create_time field.
|
||||
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ package indexers
|
||||
|
||||
import (
|
||||
"polaris/ent/predicate"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
@@ -113,6 +114,11 @@ func Synced(v bool) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldSynced, v))
|
||||
}
|
||||
|
||||
// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ.
|
||||
func CreateTime(v time.Time) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// NameEQ applies the EQ predicate on the "name" field.
|
||||
func NameEQ(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldName, v))
|
||||
@@ -648,6 +654,56 @@ func SyncedNotNil() predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNotNull(FieldSynced))
|
||||
}
|
||||
|
||||
// CreateTimeEQ applies the EQ predicate on the "create_time" field.
|
||||
func CreateTimeEQ(v time.Time) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeNEQ applies the NEQ predicate on the "create_time" field.
|
||||
func CreateTimeNEQ(v time.Time) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeIn applies the In predicate on the "create_time" field.
|
||||
func CreateTimeIn(vs ...time.Time) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeNotIn applies the NotIn predicate on the "create_time" field.
|
||||
func CreateTimeNotIn(vs ...time.Time) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNotIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeGT applies the GT predicate on the "create_time" field.
|
||||
func CreateTimeGT(v time.Time) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldGT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeGTE applies the GTE predicate on the "create_time" field.
|
||||
func CreateTimeGTE(v time.Time) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldGTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLT applies the LT predicate on the "create_time" field.
|
||||
func CreateTimeLT(v time.Time) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldLT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLTE applies the LTE predicate on the "create_time" field.
|
||||
func CreateTimeLTE(v time.Time) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldLTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeIsNil applies the IsNil predicate on the "create_time" field.
|
||||
func CreateTimeIsNil() predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldIsNull(FieldCreateTime))
|
||||
}
|
||||
|
||||
// CreateTimeNotNil applies the NotNil predicate on the "create_time" field.
|
||||
func CreateTimeNotNil() predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNotNull(FieldCreateTime))
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Indexers) predicate.Indexers {
|
||||
return predicate.Indexers(sql.AndPredicates(predicates...))
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/indexers"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
@@ -171,6 +172,20 @@ func (ic *IndexersCreate) SetNillableSynced(b *bool) *IndexersCreate {
|
||||
return ic
|
||||
}
|
||||
|
||||
// SetCreateTime sets the "create_time" field.
|
||||
func (ic *IndexersCreate) SetCreateTime(t time.Time) *IndexersCreate {
|
||||
ic.mutation.SetCreateTime(t)
|
||||
return ic
|
||||
}
|
||||
|
||||
// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
|
||||
func (ic *IndexersCreate) SetNillableCreateTime(t *time.Time) *IndexersCreate {
|
||||
if t != nil {
|
||||
ic.SetCreateTime(*t)
|
||||
}
|
||||
return ic
|
||||
}
|
||||
|
||||
// Mutation returns the IndexersMutation object of the builder.
|
||||
func (ic *IndexersCreate) Mutation() *IndexersMutation {
|
||||
return ic.mutation
|
||||
@@ -238,6 +253,10 @@ func (ic *IndexersCreate) defaults() {
|
||||
v := indexers.DefaultSynced
|
||||
ic.mutation.SetSynced(v)
|
||||
}
|
||||
if _, ok := ic.mutation.CreateTime(); !ok {
|
||||
v := indexers.DefaultCreateTime()
|
||||
ic.mutation.SetCreateTime(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
@@ -254,6 +273,11 @@ func (ic *IndexersCreate) check() error {
|
||||
if _, ok := ic.mutation.Priority(); !ok {
|
||||
return &ValidationError{Name: "priority", err: errors.New(`ent: missing required field "Indexers.priority"`)}
|
||||
}
|
||||
if v, ok := ic.mutation.Priority(); ok {
|
||||
if err := indexers.PriorityValidator(v); err != nil {
|
||||
return &ValidationError{Name: "priority", err: fmt.Errorf(`ent: validator failed for field "Indexers.priority": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -328,6 +352,10 @@ func (ic *IndexersCreate) createSpec() (*Indexers, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(indexers.FieldSynced, field.TypeBool, value)
|
||||
_node.Synced = value
|
||||
}
|
||||
if value, ok := ic.mutation.CreateTime(); ok {
|
||||
_spec.SetField(indexers.FieldCreateTime, field.TypeTime, value)
|
||||
_node.CreateTime = value
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
|
||||
@@ -289,7 +289,20 @@ func (iu *IndexersUpdate) ExecX(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (iu *IndexersUpdate) check() error {
|
||||
if v, ok := iu.mutation.Priority(); ok {
|
||||
if err := indexers.PriorityValidator(v); err != nil {
|
||||
return &ValidationError{Name: "priority", err: fmt.Errorf(`ent: validator failed for field "Indexers.priority": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (iu *IndexersUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if err := iu.check(); err != nil {
|
||||
return n, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(indexers.Table, indexers.Columns, sqlgraph.NewFieldSpec(indexers.FieldID, field.TypeInt))
|
||||
if ps := iu.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
@@ -364,6 +377,9 @@ func (iu *IndexersUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if iu.mutation.SyncedCleared() {
|
||||
_spec.ClearField(indexers.FieldSynced, field.TypeBool)
|
||||
}
|
||||
if iu.mutation.CreateTimeCleared() {
|
||||
_spec.ClearField(indexers.FieldCreateTime, field.TypeTime)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, iu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{indexers.Label}
|
||||
@@ -659,7 +675,20 @@ func (iuo *IndexersUpdateOne) ExecX(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (iuo *IndexersUpdateOne) check() error {
|
||||
if v, ok := iuo.mutation.Priority(); ok {
|
||||
if err := indexers.PriorityValidator(v); err != nil {
|
||||
return &ValidationError{Name: "priority", err: fmt.Errorf(`ent: validator failed for field "Indexers.priority": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (iuo *IndexersUpdateOne) sqlSave(ctx context.Context) (_node *Indexers, err error) {
|
||||
if err := iuo.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(indexers.Table, indexers.Columns, sqlgraph.NewFieldSpec(indexers.FieldID, field.TypeInt))
|
||||
id, ok := iuo.mutation.ID()
|
||||
if !ok {
|
||||
@@ -751,6 +780,9 @@ func (iuo *IndexersUpdateOne) sqlSave(ctx context.Context) (_node *Indexers, err
|
||||
if iuo.mutation.SyncedCleared() {
|
||||
_spec.ClearField(indexers.FieldSynced, field.TypeBool)
|
||||
}
|
||||
if iuo.mutation.CreateTimeCleared() {
|
||||
_spec.ClearField(indexers.FieldCreateTime, field.TypeTime)
|
||||
}
|
||||
_node = &Indexers{config: iuo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
|
||||
13
ent/media.go
13
ent/media.go
@@ -51,6 +51,8 @@ type Media struct {
|
||||
Extras schema.MediaExtras `json:"extras,omitempty"`
|
||||
// AlternativeTitles holds the value of the "alternative_titles" field.
|
||||
AlternativeTitles []schema.AlternativeTilte `json:"alternative_titles,omitempty"`
|
||||
// CreateTime holds the value of the "create_time" field.
|
||||
CreateTime time.Time `json:"create_time,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"`
|
||||
@@ -88,7 +90,7 @@ func (*Media) scanValues(columns []string) ([]any, error) {
|
||||
values[i] = new(sql.NullInt64)
|
||||
case media.FieldImdbID, media.FieldMediaType, media.FieldNameCn, media.FieldNameEn, media.FieldOriginalName, media.FieldOverview, media.FieldAirDate, media.FieldResolution, media.FieldTargetDir:
|
||||
values[i] = new(sql.NullString)
|
||||
case media.FieldCreatedAt:
|
||||
case media.FieldCreatedAt, media.FieldCreateTime:
|
||||
values[i] = new(sql.NullTime)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
@@ -213,6 +215,12 @@ func (m *Media) assignValues(columns []string, values []any) error {
|
||||
return fmt.Errorf("unmarshal field alternative_titles: %w", err)
|
||||
}
|
||||
}
|
||||
case media.FieldCreateTime:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field create_time", values[i])
|
||||
} else if value.Valid {
|
||||
m.CreateTime = value.Time
|
||||
}
|
||||
default:
|
||||
m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
@@ -301,6 +309,9 @@ func (m *Media) String() string {
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("alternative_titles=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.AlternativeTitles))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("create_time=")
|
||||
builder.WriteString(m.CreateTime.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -47,6 +47,8 @@ const (
|
||||
FieldExtras = "extras"
|
||||
// FieldAlternativeTitles holds the string denoting the alternative_titles field in the database.
|
||||
FieldAlternativeTitles = "alternative_titles"
|
||||
// FieldCreateTime holds the string denoting the create_time field in the database.
|
||||
FieldCreateTime = "create_time"
|
||||
// EdgeEpisodes holds the string denoting the episodes edge name in mutations.
|
||||
EdgeEpisodes = "episodes"
|
||||
// Table holds the table name of the media in the database.
|
||||
@@ -79,6 +81,7 @@ var Columns = []string{
|
||||
FieldLimiter,
|
||||
FieldExtras,
|
||||
FieldAlternativeTitles,
|
||||
FieldCreateTime,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
@@ -98,6 +101,8 @@ var (
|
||||
DefaultAirDate string
|
||||
// DefaultDownloadHistoryEpisodes holds the default value on creation for the "download_history_episodes" field.
|
||||
DefaultDownloadHistoryEpisodes bool
|
||||
// DefaultCreateTime holds the default value on creation for the "create_time" field.
|
||||
DefaultCreateTime func() time.Time
|
||||
)
|
||||
|
||||
// MediaType defines the type for the "media_type" enum field.
|
||||
@@ -224,6 +229,11 @@ func ByDownloadHistoryEpisodes(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDownloadHistoryEpisodes, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreateTime orders the results by the create_time field.
|
||||
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByEpisodesCount orders the results by episodes count.
|
||||
func ByEpisodesCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
|
||||
@@ -110,6 +110,11 @@ func DownloadHistoryEpisodes(v bool) predicate.Media {
|
||||
return predicate.Media(sql.FieldEQ(FieldDownloadHistoryEpisodes, v))
|
||||
}
|
||||
|
||||
// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ.
|
||||
func CreateTime(v time.Time) predicate.Media {
|
||||
return predicate.Media(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// TmdbIDEQ applies the EQ predicate on the "tmdb_id" field.
|
||||
func TmdbIDEQ(v int) predicate.Media {
|
||||
return predicate.Media(sql.FieldEQ(FieldTmdbID, v))
|
||||
@@ -805,6 +810,56 @@ func AlternativeTitlesNotNil() predicate.Media {
|
||||
return predicate.Media(sql.FieldNotNull(FieldAlternativeTitles))
|
||||
}
|
||||
|
||||
// CreateTimeEQ applies the EQ predicate on the "create_time" field.
|
||||
func CreateTimeEQ(v time.Time) predicate.Media {
|
||||
return predicate.Media(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeNEQ applies the NEQ predicate on the "create_time" field.
|
||||
func CreateTimeNEQ(v time.Time) predicate.Media {
|
||||
return predicate.Media(sql.FieldNEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeIn applies the In predicate on the "create_time" field.
|
||||
func CreateTimeIn(vs ...time.Time) predicate.Media {
|
||||
return predicate.Media(sql.FieldIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeNotIn applies the NotIn predicate on the "create_time" field.
|
||||
func CreateTimeNotIn(vs ...time.Time) predicate.Media {
|
||||
return predicate.Media(sql.FieldNotIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeGT applies the GT predicate on the "create_time" field.
|
||||
func CreateTimeGT(v time.Time) predicate.Media {
|
||||
return predicate.Media(sql.FieldGT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeGTE applies the GTE predicate on the "create_time" field.
|
||||
func CreateTimeGTE(v time.Time) predicate.Media {
|
||||
return predicate.Media(sql.FieldGTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLT applies the LT predicate on the "create_time" field.
|
||||
func CreateTimeLT(v time.Time) predicate.Media {
|
||||
return predicate.Media(sql.FieldLT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLTE applies the LTE predicate on the "create_time" field.
|
||||
func CreateTimeLTE(v time.Time) predicate.Media {
|
||||
return predicate.Media(sql.FieldLTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeIsNil applies the IsNil predicate on the "create_time" field.
|
||||
func CreateTimeIsNil() predicate.Media {
|
||||
return predicate.Media(sql.FieldIsNull(FieldCreateTime))
|
||||
}
|
||||
|
||||
// CreateTimeNotNil applies the NotNil predicate on the "create_time" field.
|
||||
func CreateTimeNotNil() predicate.Media {
|
||||
return predicate.Media(sql.FieldNotNull(FieldCreateTime))
|
||||
}
|
||||
|
||||
// HasEpisodes applies the HasEdge predicate on the "episodes" edge.
|
||||
func HasEpisodes() predicate.Media {
|
||||
return predicate.Media(func(s *sql.Selector) {
|
||||
|
||||
@@ -190,6 +190,20 @@ func (mc *MediaCreate) SetAlternativeTitles(st []schema.AlternativeTilte) *Media
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetCreateTime sets the "create_time" field.
|
||||
func (mc *MediaCreate) SetCreateTime(t time.Time) *MediaCreate {
|
||||
mc.mutation.SetCreateTime(t)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
|
||||
func (mc *MediaCreate) SetNillableCreateTime(t *time.Time) *MediaCreate {
|
||||
if t != nil {
|
||||
mc.SetCreateTime(*t)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// AddEpisodeIDs adds the "episodes" edge to the Episode entity by IDs.
|
||||
func (mc *MediaCreate) AddEpisodeIDs(ids ...int) *MediaCreate {
|
||||
mc.mutation.AddEpisodeIDs(ids...)
|
||||
@@ -256,6 +270,10 @@ func (mc *MediaCreate) defaults() {
|
||||
v := media.DefaultDownloadHistoryEpisodes
|
||||
mc.mutation.SetDownloadHistoryEpisodes(v)
|
||||
}
|
||||
if _, ok := mc.mutation.CreateTime(); !ok {
|
||||
v := media.DefaultCreateTime()
|
||||
mc.mutation.SetCreateTime(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
@@ -387,6 +405,10 @@ func (mc *MediaCreate) createSpec() (*Media, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(media.FieldAlternativeTitles, field.TypeJSON, value)
|
||||
_node.AlternativeTitles = value
|
||||
}
|
||||
if value, ok := mc.mutation.CreateTime(); ok {
|
||||
_spec.SetField(media.FieldCreateTime, field.TypeTime, value)
|
||||
_node.CreateTime = value
|
||||
}
|
||||
if nodes := mc.mutation.EpisodesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
|
||||
@@ -484,6 +484,9 @@ func (mu *MediaUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if mu.mutation.AlternativeTitlesCleared() {
|
||||
_spec.ClearField(media.FieldAlternativeTitles, field.TypeJSON)
|
||||
}
|
||||
if mu.mutation.CreateTimeCleared() {
|
||||
_spec.ClearField(media.FieldCreateTime, field.TypeTime)
|
||||
}
|
||||
if mu.mutation.EpisodesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
@@ -1032,6 +1035,9 @@ func (muo *MediaUpdateOne) sqlSave(ctx context.Context) (_node *Media, err error
|
||||
if muo.mutation.AlternativeTitlesCleared() {
|
||||
_spec.ClearField(media.FieldAlternativeTitles, field.TypeJSON)
|
||||
}
|
||||
if muo.mutation.CreateTimeCleared() {
|
||||
_spec.ClearField(media.FieldCreateTime, field.TypeTime)
|
||||
}
|
||||
if muo.mutation.EpisodesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
|
||||
@@ -11,8 +11,11 @@ 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: "type", Type: field.TypeEnum, Enums: []string{"media", "torrent"}, Default: "torrent"},
|
||||
{Name: "torrent_hash", Type: field.TypeString, Nullable: true},
|
||||
{Name: "torrent_name", Type: field.TypeString, Nullable: true},
|
||||
{Name: "media_id", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "create_time", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "notes", Type: field.TypeString, Nullable: true},
|
||||
}
|
||||
// BlacklistsTable holds the schema information for the "blacklists" table.
|
||||
@@ -32,9 +35,11 @@ var (
|
||||
{Name: "password", Type: field.TypeString, Default: ""},
|
||||
{Name: "settings", Type: field.TypeString, Default: ""},
|
||||
{Name: "priority1", Type: field.TypeInt, Default: 1},
|
||||
{Name: "use_nat_traversal", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "remove_completed_downloads", Type: field.TypeBool, Default: true},
|
||||
{Name: "remove_failed_downloads", Type: field.TypeBool, Default: true},
|
||||
{Name: "tags", Type: field.TypeString, Default: ""},
|
||||
{Name: "create_time", Type: field.TypeTime, Nullable: true},
|
||||
}
|
||||
// DownloadClientsTable holds the schema information for the "download_clients" table.
|
||||
DownloadClientsTable = &schema.Table{
|
||||
@@ -53,6 +58,7 @@ var (
|
||||
{Name: "status", Type: field.TypeEnum, Enums: []string{"missing", "downloading", "downloaded"}, Default: "missing"},
|
||||
{Name: "monitored", Type: field.TypeBool, Default: false},
|
||||
{Name: "target_file", Type: field.TypeString, Nullable: true},
|
||||
{Name: "create_time", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "media_id", Type: field.TypeInt, Nullable: true},
|
||||
}
|
||||
// EpisodesTable holds the schema information for the "episodes" table.
|
||||
@@ -63,7 +69,7 @@ var (
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "episodes_media_episodes",
|
||||
Columns: []*schema.Column{EpisodesColumns[9]},
|
||||
Columns: []*schema.Column{EpisodesColumns[10]},
|
||||
RefColumns: []*schema.Column{MediaColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
@@ -84,6 +90,7 @@ var (
|
||||
{Name: "link", Type: field.TypeString, Nullable: true},
|
||||
{Name: "hash", Type: field.TypeString, Nullable: true},
|
||||
{Name: "status", Type: field.TypeEnum, Enums: []string{"running", "success", "fail", "uploading", "seeding", "removed"}},
|
||||
{Name: "create_time", Type: field.TypeTime, Nullable: true},
|
||||
}
|
||||
// HistoriesTable holds the schema information for the "histories" table.
|
||||
HistoriesTable = &schema.Table{
|
||||
@@ -114,7 +121,7 @@ var (
|
||||
{Name: "implementation", Type: field.TypeString},
|
||||
{Name: "settings", Type: field.TypeString, Nullable: true, Default: ""},
|
||||
{Name: "enable_rss", Type: field.TypeBool, Default: true},
|
||||
{Name: "priority", Type: field.TypeInt, Default: 50},
|
||||
{Name: "priority", Type: field.TypeInt, Default: 25},
|
||||
{Name: "seed_ratio", Type: field.TypeFloat32, Nullable: true, Default: 0},
|
||||
{Name: "disabled", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "tv_search", Type: field.TypeBool, Nullable: true, Default: true},
|
||||
@@ -122,6 +129,7 @@ var (
|
||||
{Name: "api_key", Type: field.TypeString, Nullable: true},
|
||||
{Name: "url", Type: field.TypeString, Nullable: true},
|
||||
{Name: "synced", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "create_time", Type: field.TypeTime, Nullable: true},
|
||||
}
|
||||
// IndexersTable holds the schema information for the "indexers" table.
|
||||
IndexersTable = &schema.Table{
|
||||
@@ -148,6 +156,7 @@ var (
|
||||
{Name: "limiter", Type: field.TypeJSON, Nullable: true},
|
||||
{Name: "extras", Type: field.TypeJSON, Nullable: true},
|
||||
{Name: "alternative_titles", Type: field.TypeJSON, Nullable: true},
|
||||
{Name: "create_time", Type: field.TypeTime, Nullable: true},
|
||||
}
|
||||
// MediaTable holds the schema information for the "media" table.
|
||||
MediaTable = &schema.Table{
|
||||
@@ -191,6 +200,7 @@ var (
|
||||
{Name: "settings", Type: field.TypeString, Nullable: true},
|
||||
{Name: "deleted", Type: field.TypeBool, Default: false},
|
||||
{Name: "default", Type: field.TypeBool, Default: false},
|
||||
{Name: "create_time", Type: field.TypeTime, Nullable: true},
|
||||
}
|
||||
// StoragesTable holds the schema information for the "storages" table.
|
||||
StoragesTable = &schema.Table{
|
||||
|
||||
861
ent/mutation.go
861
ent/mutation.go
File diff suppressed because it is too large
Load Diff
@@ -21,10 +21,10 @@ import (
|
||||
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)
|
||||
// blacklistDescCreateTime is the schema descriptor for create_time field.
|
||||
blacklistDescCreateTime := blacklistFields[4].Descriptor()
|
||||
// blacklist.DefaultCreateTime holds the default value on creation for the create_time field.
|
||||
blacklist.DefaultCreateTime = blacklistDescCreateTime.Default.(func() time.Time)
|
||||
downloadclientsFields := schema.DownloadClients{}.Fields()
|
||||
_ = downloadclientsFields
|
||||
// downloadclientsDescUser is the schema descriptor for user field.
|
||||
@@ -45,30 +45,46 @@ func init() {
|
||||
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)
|
||||
// downloadclientsDescUseNatTraversal is the schema descriptor for use_nat_traversal field.
|
||||
downloadclientsDescUseNatTraversal := downloadclientsFields[8].Descriptor()
|
||||
// downloadclients.DefaultUseNatTraversal holds the default value on creation for the use_nat_traversal field.
|
||||
downloadclients.DefaultUseNatTraversal = downloadclientsDescUseNatTraversal.Default.(bool)
|
||||
// downloadclientsDescRemoveCompletedDownloads is the schema descriptor for remove_completed_downloads field.
|
||||
downloadclientsDescRemoveCompletedDownloads := downloadclientsFields[8].Descriptor()
|
||||
downloadclientsDescRemoveCompletedDownloads := downloadclientsFields[9].Descriptor()
|
||||
// downloadclients.DefaultRemoveCompletedDownloads holds the default value on creation for the remove_completed_downloads field.
|
||||
downloadclients.DefaultRemoveCompletedDownloads = downloadclientsDescRemoveCompletedDownloads.Default.(bool)
|
||||
// downloadclientsDescRemoveFailedDownloads is the schema descriptor for remove_failed_downloads field.
|
||||
downloadclientsDescRemoveFailedDownloads := downloadclientsFields[9].Descriptor()
|
||||
downloadclientsDescRemoveFailedDownloads := downloadclientsFields[10].Descriptor()
|
||||
// downloadclients.DefaultRemoveFailedDownloads holds the default value on creation for the remove_failed_downloads field.
|
||||
downloadclients.DefaultRemoveFailedDownloads = downloadclientsDescRemoveFailedDownloads.Default.(bool)
|
||||
// downloadclientsDescTags is the schema descriptor for tags field.
|
||||
downloadclientsDescTags := downloadclientsFields[10].Descriptor()
|
||||
downloadclientsDescTags := downloadclientsFields[11].Descriptor()
|
||||
// downloadclients.DefaultTags holds the default value on creation for the tags field.
|
||||
downloadclients.DefaultTags = downloadclientsDescTags.Default.(string)
|
||||
// downloadclientsDescCreateTime is the schema descriptor for create_time field.
|
||||
downloadclientsDescCreateTime := downloadclientsFields[12].Descriptor()
|
||||
// downloadclients.DefaultCreateTime holds the default value on creation for the create_time field.
|
||||
downloadclients.DefaultCreateTime = downloadclientsDescCreateTime.Default.(func() time.Time)
|
||||
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)
|
||||
// episodeDescCreateTime is the schema descriptor for create_time field.
|
||||
episodeDescCreateTime := episodeFields[9].Descriptor()
|
||||
// episode.DefaultCreateTime holds the default value on creation for the create_time field.
|
||||
episode.DefaultCreateTime = episodeDescCreateTime.Default.(func() time.Time)
|
||||
historyFields := schema.History{}.Fields()
|
||||
_ = historyFields
|
||||
// historyDescSize is the schema descriptor for size field.
|
||||
historyDescSize := historyFields[6].Descriptor()
|
||||
// history.DefaultSize holds the default value on creation for the size field.
|
||||
history.DefaultSize = historyDescSize.Default.(int)
|
||||
// historyDescCreateTime is the schema descriptor for create_time field.
|
||||
historyDescCreateTime := historyFields[12].Descriptor()
|
||||
// history.DefaultCreateTime holds the default value on creation for the create_time field.
|
||||
history.DefaultCreateTime = historyDescCreateTime.Default.(func() time.Time)
|
||||
indexersFields := schema.Indexers{}.Fields()
|
||||
_ = indexersFields
|
||||
// indexersDescSettings is the schema descriptor for settings field.
|
||||
@@ -83,6 +99,8 @@ func init() {
|
||||
indexersDescPriority := indexersFields[4].Descriptor()
|
||||
// indexers.DefaultPriority holds the default value on creation for the priority field.
|
||||
indexers.DefaultPriority = indexersDescPriority.Default.(int)
|
||||
// indexers.PriorityValidator is a validator for the "priority" field. It is called by the builders before save.
|
||||
indexers.PriorityValidator = indexersDescPriority.Validators[0].(func(int) error)
|
||||
// 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.
|
||||
@@ -103,6 +121,10 @@ func init() {
|
||||
indexersDescSynced := indexersFields[11].Descriptor()
|
||||
// indexers.DefaultSynced holds the default value on creation for the synced field.
|
||||
indexers.DefaultSynced = indexersDescSynced.Default.(bool)
|
||||
// indexersDescCreateTime is the schema descriptor for create_time field.
|
||||
indexersDescCreateTime := indexersFields[12].Descriptor()
|
||||
// indexers.DefaultCreateTime holds the default value on creation for the create_time field.
|
||||
indexers.DefaultCreateTime = indexersDescCreateTime.Default.(func() time.Time)
|
||||
mediaFields := schema.Media{}.Fields()
|
||||
_ = mediaFields
|
||||
// mediaDescCreatedAt is the schema descriptor for created_at field.
|
||||
@@ -117,6 +139,10 @@ func init() {
|
||||
mediaDescDownloadHistoryEpisodes := mediaFields[12].Descriptor()
|
||||
// media.DefaultDownloadHistoryEpisodes holds the default value on creation for the download_history_episodes field.
|
||||
media.DefaultDownloadHistoryEpisodes = mediaDescDownloadHistoryEpisodes.Default.(bool)
|
||||
// mediaDescCreateTime is the schema descriptor for create_time field.
|
||||
mediaDescCreateTime := mediaFields[16].Descriptor()
|
||||
// media.DefaultCreateTime holds the default value on creation for the create_time field.
|
||||
media.DefaultCreateTime = mediaDescCreateTime.Default.(func() time.Time)
|
||||
notificationclientFields := schema.NotificationClient{}.Fields()
|
||||
_ = notificationclientFields
|
||||
// notificationclientDescEnabled is the schema descriptor for enabled field.
|
||||
@@ -133,4 +159,8 @@ func init() {
|
||||
storageDescDefault := storageFields[6].Descriptor()
|
||||
// storage.DefaultDefault holds the default value on creation for the default field.
|
||||
storage.DefaultDefault = storageDescDefault.Default.(bool)
|
||||
// storageDescCreateTime is the schema descriptor for create_time field.
|
||||
storageDescCreateTime := storageFields[7].Descriptor()
|
||||
// storage.DefaultCreateTime holds the default value on creation for the create_time field.
|
||||
storage.DefaultCreateTime = storageDescCreateTime.Default.(func() time.Time)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
@@ -13,8 +15,11 @@ type Blacklist struct {
|
||||
// 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.Enum("type").Values("media", "torrent").Default("torrent"),
|
||||
field.String("torrent_hash").Optional(),
|
||||
field.String("torrent_name").Optional(),
|
||||
field.Int("media_id").Optional(),
|
||||
field.Time("create_time").Optional().Default(time.Now).Immutable(),
|
||||
field.String("notes").Optional(),
|
||||
}
|
||||
}
|
||||
@@ -23,8 +28,3 @@ func (Blacklist) Fields() []ent.Field {
|
||||
func (Blacklist) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
||||
|
||||
type BlacklistValue struct {
|
||||
TmdbID int `json:"tmdb_id"`
|
||||
TorrentHash string `json:"torrent_hash"`
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package schema
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
@@ -31,9 +32,11 @@ func (DownloadClients) Fields() []ent.Field {
|
||||
}
|
||||
return nil
|
||||
}),
|
||||
field.Bool("use_nat_traversal").Optional().Default(false).Comment("use stun server to do nat traversal, enable download client to do uploading successfully"),
|
||||
field.Bool("remove_completed_downloads").Default(true),
|
||||
field.Bool("remove_failed_downloads").Default(true),
|
||||
field.String("tags").Default(""),
|
||||
field.Time("create_time").Optional().Default(time.Now).Immutable(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
@@ -23,6 +25,7 @@ func (Episode) Fields() []ent.Field {
|
||||
field.Enum("status").Values("missing", "downloading", "downloaded").Default("missing"),
|
||||
field.Bool("monitored").Default(false).StructTag("json:\"monitored\""), //whether this episode is monitored
|
||||
field.String("target_file").Optional(),
|
||||
field.Time("create_time").Optional().Default(time.Now).Immutable(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
@@ -23,9 +25,10 @@ func (History) Fields() []ent.Field {
|
||||
field.Int("size").Default(0),
|
||||
field.Int("download_client_id").Optional(),
|
||||
field.Int("indexer_id").Optional(),
|
||||
field.String("link").Optional().Comment("deprecated, use hash instead"), //should be magnet link
|
||||
field.String("link").Optional().Comment("torrent link"), //should be magnet link
|
||||
field.String("hash").Optional().Comment("torrent hash"),
|
||||
field.Enum("status").Values("running", "success", "fail", "uploading", "seeding", "removed"),
|
||||
field.Time("create_time").Optional().Default(time.Now).Immutable(),
|
||||
//field.String("saved").Optional().Comment("deprecated"), //deprecated
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
@@ -17,7 +20,15 @@ func (Indexers) Fields() []ent.Field {
|
||||
field.String("implementation"),
|
||||
field.String("settings").Optional().Default("").Comment("deprecated, use api_key and url"),
|
||||
field.Bool("enable_rss").Default(true),
|
||||
field.Int("priority").Default(50),
|
||||
field.Int("priority").Default(25).Validate(func(i int) error {
|
||||
if i > 50 {
|
||||
return errors.ErrUnsupported
|
||||
}
|
||||
if i <= 0 {
|
||||
return errors.ErrUnsupported
|
||||
}
|
||||
return nil
|
||||
}),
|
||||
field.Float32("seed_ratio").Optional().Default(0).Comment("minimal seed ratio requied, before removing torrent"),
|
||||
field.Bool("disabled").Optional().Default(false),
|
||||
field.Bool("tv_search").Optional().Default(true),
|
||||
@@ -25,6 +36,7 @@ func (Indexers) Fields() []ent.Field {
|
||||
field.String("api_key").Optional(),
|
||||
field.String("url").Optional(),
|
||||
field.Bool("synced").Optional().Default(false).Comment("synced from prowlarr"),
|
||||
field.Time("create_time").Optional().Default(time.Now).Immutable(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ func (Media) Fields() []ent.Field {
|
||||
field.JSON("limiter", MediaLimiter{}).Optional(),
|
||||
field.JSON("extras", MediaExtras{}).Optional(),
|
||||
field.JSON("alternative_titles", []AlternativeTilte{}).Optional(),
|
||||
field.Time("create_time").Optional().Default(time.Now).Immutable(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
@@ -20,6 +22,7 @@ func (Storage) Fields() []ent.Field {
|
||||
field.String("settings").Optional(),
|
||||
field.Bool("deleted").Default(false),
|
||||
field.Bool("default").Default(false),
|
||||
field.Time("create_time").Optional().Default(time.Now).Immutable(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"polaris/ent/storage"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
@@ -29,7 +30,9 @@ type Storage struct {
|
||||
// Deleted holds the value of the "deleted" field.
|
||||
Deleted bool `json:"deleted,omitempty"`
|
||||
// Default holds the value of the "default" field.
|
||||
Default bool `json:"default,omitempty"`
|
||||
Default bool `json:"default,omitempty"`
|
||||
// CreateTime holds the value of the "create_time" field.
|
||||
CreateTime time.Time `json:"create_time,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
@@ -44,6 +47,8 @@ func (*Storage) scanValues(columns []string) ([]any, error) {
|
||||
values[i] = new(sql.NullInt64)
|
||||
case storage.FieldName, storage.FieldImplementation, storage.FieldTvPath, storage.FieldMoviePath, storage.FieldSettings:
|
||||
values[i] = new(sql.NullString)
|
||||
case storage.FieldCreateTime:
|
||||
values[i] = new(sql.NullTime)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
@@ -107,6 +112,12 @@ func (s *Storage) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
s.Default = value.Bool
|
||||
}
|
||||
case storage.FieldCreateTime:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field create_time", values[i])
|
||||
} else if value.Valid {
|
||||
s.CreateTime = value.Time
|
||||
}
|
||||
default:
|
||||
s.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
@@ -163,6 +174,9 @@ func (s *Storage) String() string {
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("default=")
|
||||
builder.WriteString(fmt.Sprintf("%v", s.Default))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("create_time=")
|
||||
builder.WriteString(s.CreateTime.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ package storage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
@@ -27,6 +28,8 @@ const (
|
||||
FieldDeleted = "deleted"
|
||||
// FieldDefault holds the string denoting the default field in the database.
|
||||
FieldDefault = "default"
|
||||
// FieldCreateTime holds the string denoting the create_time field in the database.
|
||||
FieldCreateTime = "create_time"
|
||||
// Table holds the table name of the storage in the database.
|
||||
Table = "storages"
|
||||
)
|
||||
@@ -41,6 +44,7 @@ var Columns = []string{
|
||||
FieldSettings,
|
||||
FieldDeleted,
|
||||
FieldDefault,
|
||||
FieldCreateTime,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
@@ -58,6 +62,8 @@ var (
|
||||
DefaultDeleted bool
|
||||
// DefaultDefault holds the default value on creation for the "default" field.
|
||||
DefaultDefault bool
|
||||
// DefaultCreateTime holds the default value on creation for the "create_time" field.
|
||||
DefaultCreateTime func() time.Time
|
||||
)
|
||||
|
||||
// Implementation defines the type for the "implementation" enum field.
|
||||
@@ -126,3 +132,8 @@ func ByDeleted(opts ...sql.OrderTermOption) OrderOption {
|
||||
func ByDefault(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDefault, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreateTime orders the results by the create_time field.
|
||||
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ package storage
|
||||
|
||||
import (
|
||||
"polaris/ent/predicate"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
@@ -83,6 +84,11 @@ func Default(v bool) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldEQ(FieldDefault, v))
|
||||
}
|
||||
|
||||
// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ.
|
||||
func CreateTime(v time.Time) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// NameEQ applies the EQ predicate on the "name" field.
|
||||
func NameEQ(v string) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldEQ(FieldName, v))
|
||||
@@ -413,6 +419,56 @@ func DefaultNEQ(v bool) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldNEQ(FieldDefault, v))
|
||||
}
|
||||
|
||||
// CreateTimeEQ applies the EQ predicate on the "create_time" field.
|
||||
func CreateTimeEQ(v time.Time) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeNEQ applies the NEQ predicate on the "create_time" field.
|
||||
func CreateTimeNEQ(v time.Time) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldNEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeIn applies the In predicate on the "create_time" field.
|
||||
func CreateTimeIn(vs ...time.Time) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeNotIn applies the NotIn predicate on the "create_time" field.
|
||||
func CreateTimeNotIn(vs ...time.Time) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldNotIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeGT applies the GT predicate on the "create_time" field.
|
||||
func CreateTimeGT(v time.Time) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldGT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeGTE applies the GTE predicate on the "create_time" field.
|
||||
func CreateTimeGTE(v time.Time) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldGTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLT applies the LT predicate on the "create_time" field.
|
||||
func CreateTimeLT(v time.Time) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldLT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLTE applies the LTE predicate on the "create_time" field.
|
||||
func CreateTimeLTE(v time.Time) predicate.Storage {
|
||||
return predicate.Storage(sql.FieldLTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeIsNil applies the IsNil predicate on the "create_time" field.
|
||||
func CreateTimeIsNil() predicate.Storage {
|
||||
return predicate.Storage(sql.FieldIsNull(FieldCreateTime))
|
||||
}
|
||||
|
||||
// CreateTimeNotNil applies the NotNil predicate on the "create_time" field.
|
||||
func CreateTimeNotNil() predicate.Storage {
|
||||
return predicate.Storage(sql.FieldNotNull(FieldCreateTime))
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Storage) predicate.Storage {
|
||||
return predicate.Storage(sql.AndPredicates(predicates...))
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/storage"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
@@ -101,6 +102,20 @@ func (sc *StorageCreate) SetNillableDefault(b *bool) *StorageCreate {
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetCreateTime sets the "create_time" field.
|
||||
func (sc *StorageCreate) SetCreateTime(t time.Time) *StorageCreate {
|
||||
sc.mutation.SetCreateTime(t)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
|
||||
func (sc *StorageCreate) SetNillableCreateTime(t *time.Time) *StorageCreate {
|
||||
if t != nil {
|
||||
sc.SetCreateTime(*t)
|
||||
}
|
||||
return sc
|
||||
}
|
||||
|
||||
// Mutation returns the StorageMutation object of the builder.
|
||||
func (sc *StorageCreate) Mutation() *StorageMutation {
|
||||
return sc.mutation
|
||||
@@ -144,6 +159,10 @@ func (sc *StorageCreate) defaults() {
|
||||
v := storage.DefaultDefault
|
||||
sc.mutation.SetDefault(v)
|
||||
}
|
||||
if _, ok := sc.mutation.CreateTime(); !ok {
|
||||
v := storage.DefaultCreateTime()
|
||||
sc.mutation.SetCreateTime(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
@@ -219,6 +238,10 @@ func (sc *StorageCreate) createSpec() (*Storage, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(storage.FieldDefault, field.TypeBool, value)
|
||||
_node.Default = value
|
||||
}
|
||||
if value, ok := sc.mutation.CreateTime(); ok {
|
||||
_spec.SetField(storage.FieldCreateTime, field.TypeTime, value)
|
||||
_node.CreateTime = value
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
|
||||
@@ -227,6 +227,9 @@ func (su *StorageUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if value, ok := su.mutation.Default(); ok {
|
||||
_spec.SetField(storage.FieldDefault, field.TypeBool, value)
|
||||
}
|
||||
if su.mutation.CreateTimeCleared() {
|
||||
_spec.ClearField(storage.FieldCreateTime, field.TypeTime)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{storage.Label}
|
||||
@@ -477,6 +480,9 @@ func (suo *StorageUpdateOne) sqlSave(ctx context.Context) (_node *Storage, err e
|
||||
if value, ok := suo.mutation.Default(); ok {
|
||||
_spec.SetField(storage.FieldDefault, field.TypeBool, value)
|
||||
}
|
||||
if suo.mutation.CreateTimeCleared() {
|
||||
_spec.ClearField(storage.FieldCreateTime, field.TypeTime)
|
||||
}
|
||||
_node = &Storage{config: suo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
|
||||
36
go.mod
36
go.mod
@@ -10,7 +10,7 @@ require (
|
||||
github.com/mattn/go-sqlite3 v1.14.22 // indirect
|
||||
github.com/robfig/cron v1.2.0
|
||||
go.uber.org/zap v1.27.0
|
||||
golang.org/x/net v0.37.0
|
||||
golang.org/x/net v0.40.0
|
||||
)
|
||||
|
||||
require (
|
||||
@@ -18,14 +18,22 @@ require (
|
||||
github.com/anacrolix/torrent v1.58.1
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
|
||||
github.com/gin-contrib/zap v1.1.3
|
||||
github.com/go-kratos/kratos/v2 v2.8.4
|
||||
github.com/gocolly/colly v1.2.0
|
||||
github.com/google/wire v0.6.0
|
||||
github.com/ncruces/go-sqlite3 v0.18.4
|
||||
github.com/nikoksr/notify v1.0.0
|
||||
github.com/openai/openai-go v0.1.0-beta.10
|
||||
github.com/pion/stun/v3 v3.0.0
|
||||
github.com/stretchr/testify v1.9.0
|
||||
go.uber.org/automaxprocs v1.6.0
|
||||
golift.io/starr v1.0.0
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d
|
||||
google.golang.org/grpc v1.65.0
|
||||
)
|
||||
|
||||
require (
|
||||
dario.cat/mergo v1.0.0 // indirect
|
||||
github.com/BurntSushi/toml v1.4.0 // indirect
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.2 // indirect
|
||||
github.com/RoaringBitmap/roaring v1.2.3 // indirect
|
||||
@@ -58,16 +66,19 @@ require (
|
||||
github.com/cespare/xxhash v1.1.0 // indirect
|
||||
github.com/dustin/go-humanize v1.0.0 // indirect
|
||||
github.com/edsrzf/mmap-go v1.1.0 // indirect
|
||||
github.com/go-kratos/aegis v0.2.0 // indirect
|
||||
github.com/go-llsqlite/adapter v0.0.0-20230927005056-7f5ce7f0c916 // indirect
|
||||
github.com/go-llsqlite/crawshaw v0.5.2-0.20240425034140-f30eb7704568 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-playground/form/v4 v4.2.1 // indirect
|
||||
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible // indirect
|
||||
github.com/go-test/deep v1.0.4 // indirect
|
||||
github.com/gobwas/glob v0.2.3 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/google/btree v1.1.2 // indirect
|
||||
github.com/gorilla/mux v1.8.1 // indirect
|
||||
github.com/gorilla/websocket v1.5.3 // indirect
|
||||
github.com/gregdel/pushover v1.3.1 // indirect
|
||||
github.com/huandu/xstrings v1.3.2 // indirect
|
||||
@@ -82,7 +93,7 @@ require (
|
||||
github.com/pion/dtls/v3 v3.0.3 // indirect
|
||||
github.com/pion/ice/v4 v4.0.2 // indirect
|
||||
github.com/pion/interceptor v0.1.37 // indirect
|
||||
github.com/pion/logging v0.2.2 // indirect
|
||||
github.com/pion/logging v0.2.3 // indirect
|
||||
github.com/pion/mdns/v2 v2.0.7 // indirect
|
||||
github.com/pion/randutil v0.1.0 // indirect
|
||||
github.com/pion/rtcp v1.2.14 // indirect
|
||||
@@ -90,7 +101,6 @@ require (
|
||||
github.com/pion/sctp v1.8.33 // indirect
|
||||
github.com/pion/sdp/v3 v3.0.9 // indirect
|
||||
github.com/pion/srtp/v3 v3.0.4 // indirect
|
||||
github.com/pion/stun/v3 v3.0.0 // indirect
|
||||
github.com/pion/transport/v3 v3.0.7 // indirect
|
||||
github.com/pion/turn/v4 v4.0.0 // indirect
|
||||
github.com/pion/webrtc/v4 v4.0.0 // indirect
|
||||
@@ -105,15 +115,19 @@ require (
|
||||
github.com/temoto/robotstxt v1.1.2 // indirect
|
||||
github.com/tetratelabs/wazero v1.8.0 // indirect
|
||||
github.com/tidwall/btree v1.6.0 // indirect
|
||||
github.com/wlynxg/anet v0.0.3 // indirect
|
||||
github.com/tidwall/gjson v1.18.0 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.1 // indirect
|
||||
github.com/tidwall/sjson v1.2.5 // indirect
|
||||
github.com/wlynxg/anet v0.0.5 // indirect
|
||||
go.etcd.io/bbolt v1.3.6 // indirect
|
||||
go.opentelemetry.io/otel v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.28.0 // indirect
|
||||
golang.org/x/sync v0.12.0 // indirect
|
||||
golang.org/x/sync v0.14.0 // indirect
|
||||
golang.org/x/time v0.5.0 // indirect
|
||||
golang.org/x/tools v0.31.0 // indirect
|
||||
google.golang.org/appengine v1.6.8 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
lukechampine.com/blake3 v1.1.6 // indirect
|
||||
@@ -140,7 +154,7 @@ require (
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.20.0 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/goccy/go-json v0.10.2
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||
@@ -166,12 +180,12 @@ require (
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
github.com/zclconf/go-cty v1.8.0 // indirect
|
||||
golang.org/x/arch v0.8.0 // indirect
|
||||
golang.org/x/crypto v0.36.0
|
||||
golang.org/x/crypto v0.38.0
|
||||
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948
|
||||
golang.org/x/mod v0.24.0 // indirect
|
||||
golang.org/x/sys v0.31.0
|
||||
golang.org/x/text v0.23.0 // indirect
|
||||
google.golang.org/protobuf v1.36.5 // indirect
|
||||
golang.org/x/sys v0.33.0
|
||||
golang.org/x/text v0.25.0 // indirect
|
||||
google.golang.org/protobuf v1.36.5
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
94
go.sum
94
go.sum
@@ -1,9 +1,13 @@
|
||||
ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 h1:GwdJbXydHCYPedeeLt4x/lrlIISQ4JTH1mRWuE5ZZ14=
|
||||
ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43/go.mod h1:uj3pm+hUTVN/X5yfdBexHlZv+1Xu5u5ZbZx7+CDavNU=
|
||||
cel.dev/expr v0.15.0 h1:O1jzfJCQBfL5BFoYktaxwIhuttaQPsVWerH9/EEKx0w=
|
||||
cel.dev/expr v0.15.0/go.mod h1:TRSuuV7DlVCE/uwv5QbAiW/v8l5O8C4eEPHeu7gf7Sg=
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
crawshaw.io/iox v0.0.0-20181124134642-c51c3df30797/go.mod h1:sXBiorCo8c46JlQV3oXPKINnZ8mcqnye1EkVkqsectk=
|
||||
crawshaw.io/sqlite v0.3.2/go.mod h1:igAO5JulrQ1DbdZdtVq48mnZUBAPOeFzer7VhDWNtW4=
|
||||
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
|
||||
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
|
||||
entgo.io/ent v0.13.1 h1:uD8QwN1h6SNphdCCzmkMN3feSUzNnVvV/WIkHKMbzOE=
|
||||
entgo.io/ent v0.13.1/go.mod h1:qCEmo+biw3ccBn9OyL4ZK5dfpwg++l1Gxwac5B1206A=
|
||||
filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU=
|
||||
@@ -124,6 +128,8 @@ github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc
|
||||
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
|
||||
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
|
||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||
github.com/census-instrumentation/opencensus-proto v0.4.1 h1:iKLQ0xPNFxR/2hzXZMrBo8f1j86j5WHzznCCQxV/b8g=
|
||||
github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw=
|
||||
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
@@ -132,6 +138,8 @@ github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/
|
||||
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
|
||||
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||
github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b h1:ga8SEFjZ60pxLcmhnThWgvH2wg8376yUJmPhEH4H3kw=
|
||||
github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/cyruzin/golang-tmdb v1.6.3 h1:TKK9h+uuwiDOaFlsVispG1KxqhsSM5Y4ZELnUF3GlqU=
|
||||
github.com/cyruzin/golang-tmdb v1.6.3/go.mod h1:ZSryJLCcY+9TiKU+LbouXKns++YBrM8Tizannr05c+I=
|
||||
@@ -148,6 +156,10 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1
|
||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
||||
github.com/edsrzf/mmap-go v1.1.0 h1:6EUwBLQ/Mcr1EYLE4Tn1VdW1A4ckqCQWZBw8Hr0kjpQ=
|
||||
github.com/edsrzf/mmap-go v1.1.0/go.mod h1:19H/e8pUPLicwkyNgOykDXkJ9F0MHE+Z52B8EIth78Q=
|
||||
github.com/envoyproxy/go-control-plane v0.12.0 h1:4X+VP1GHd1Mhj6IB5mMeGbLCleqxjletLK6K0rbxyZI=
|
||||
github.com/envoyproxy/go-control-plane v0.12.0/go.mod h1:ZBTaoJ23lqITozF0M6G4/IragXCQKCnYbmlmtHvwRG0=
|
||||
github.com/envoyproxy/protoc-gen-validate v1.0.4 h1:gVPz/FMfvh57HdSJQyvBtF00j8JU4zdyUgIUNhlgg0A=
|
||||
github.com/envoyproxy/protoc-gen-validate v1.0.4/go.mod h1:qys6tmnRsYrQqIhm2bvKZH4Blx/1gTIZ2UKVY1M+Yew=
|
||||
github.com/frankban/quicktest v1.9.0/go.mod h1:ui7WezCLWMWxVWr1GETZY3smRy0G4KWq9vcPtJmFl7Y=
|
||||
github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||
@@ -173,6 +185,10 @@ github.com/glycerine/goconvey v0.0.0-20190315024820-982ee783a72e/go.mod h1:Ogl1T
|
||||
github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kratos/aegis v0.2.0 h1:dObzCDWn3XVjUkgxyBp6ZeWtx/do0DPZ7LY3yNSJLUQ=
|
||||
github.com/go-kratos/aegis v0.2.0/go.mod h1:v0R2m73WgEEYB3XYu6aE2WcMwsZkJ/Rzuf5eVccm7bI=
|
||||
github.com/go-kratos/kratos/v2 v2.8.4 h1:eIJLE9Qq9WSoKx+Buy2uPyrahtF/lPh+Xf4MTpxhmjs=
|
||||
github.com/go-kratos/kratos/v2 v2.8.4/go.mod h1:mq62W2101a5uYyRxe+7IdWubu7gZCGYqSNKwGFiiRcw=
|
||||
github.com/go-llsqlite/adapter v0.0.0-20230927005056-7f5ce7f0c916 h1:OyQmpAN302wAopDgwVjgs2HkFawP9ahIEqkUYz7V7CA=
|
||||
github.com/go-llsqlite/adapter v0.0.0-20230927005056-7f5ce7f0c916/go.mod h1:DADrR88ONKPPeSGjFp5iEN55Arx3fi2qXZeKCYDpbmU=
|
||||
github.com/go-llsqlite/crawshaw v0.5.2-0.20240425034140-f30eb7704568 h1:3EpZo8LxIzF4q3BT+vttQQlRfA6uTtTb/cxVisWa5HM=
|
||||
@@ -186,8 +202,11 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4=
|
||||
github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4=
|
||||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/form/v4 v4.2.1 h1:HjdRDKO0fftVMU5epjPW2SOREcZ6/wLUzEobqUGJuPw=
|
||||
github.com/go-playground/form/v4 v4.2.1/go.mod h1:q1a2BY+AQUUzhl6xA/6hBetay6dEIhMHjgvJiGo6K7U=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
@@ -246,14 +265,19 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/wire v0.6.0 h1:HBkoIh4BdSxoyo9PveV8giw7ZsaBOvzWKfcg/6MrVwI=
|
||||
github.com/google/wire v0.6.0/go.mod h1:F4QhpQ9EDIdJ1Mbop/NZBRB+5yrR6qg3BnctaoUk6NA=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20190309154008-847fc94819f9/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
|
||||
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/gregdel/pushover v1.3.1 h1:4bMLITOZ15+Zpi6qqoGqOPuVHCwSUvMCgVnN5Xhilfo=
|
||||
@@ -278,8 +302,6 @@ github.com/huandu/xstrings v1.3.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq
|
||||
github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
||||
github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw=
|
||||
github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible h1:jdpOPRN1zP63Td1hDQbZW73xKmzDvZHzVdNYxhnTMDA=
|
||||
github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible/go.mod h1:1c7szIrayyPPB/987hsnvNzLushdWf4o/79s3P08L8A=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
@@ -317,8 +339,6 @@ github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0V
|
||||
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
||||
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
@@ -353,11 +373,11 @@ github.com/ncruces/julianday v1.0.0 h1:fH0OKwa7NWvniGQtxdJRxAgkBMolni2BjDHaWTxqt
|
||||
github.com/ncruces/julianday v1.0.0/go.mod h1:Dusn2KvZrrovOMJuOt0TNXL6tB7U2E8kvza5fFc9G7g=
|
||||
github.com/nikoksr/notify v1.0.0 h1:qe9/6FRsWdxBgQgWcpvQ0sv8LRGJZDpRB4TkL2uNdO8=
|
||||
github.com/nikoksr/notify v1.0.0/go.mod h1:hPaaDt30d6LAA7/5nb0e48Bp/MctDfycCSs8VEgN29I=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/openai/openai-go v0.1.0-beta.10 h1:CknhGXe8aXQMRuqg255PFnWzgRY9nEryMxoNIBBM9tU=
|
||||
github.com/openai/openai-go v0.1.0-beta.10/go.mod h1:g461MYGXEXBVdV5SaR/5tNzNbSfwTBBefwc+LlDCK0Y=
|
||||
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
||||
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
||||
@@ -371,8 +391,8 @@ github.com/pion/ice/v4 v4.0.2 h1:1JhBRX8iQLi0+TfcavTjPjI6GO41MFn4CeTBX+Y9h5s=
|
||||
github.com/pion/ice/v4 v4.0.2/go.mod h1:DCdqyzgtsDNYN6/3U8044j3U7qsJ9KFJC92VnOWHvXg=
|
||||
github.com/pion/interceptor v0.1.37 h1:aRA8Zpab/wE7/c0O3fh1PqY0AJI3fCSEM5lRWJVorwI=
|
||||
github.com/pion/interceptor v0.1.37/go.mod h1:JzxbJ4umVTlZAf+/utHzNesY8tmRkM2lVmkS82TTj8Y=
|
||||
github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY=
|
||||
github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms=
|
||||
github.com/pion/logging v0.2.3 h1:gHuf0zpoh1GW67Nr6Gj4cv5Z9ZscU7g/EaoC/Ke/igI=
|
||||
github.com/pion/logging v0.2.3/go.mod h1:z8YfknkquMe1csOrxK5kc+5/ZPAzMxbKLX5aXpbpC90=
|
||||
github.com/pion/mdns/v2 v2.0.7 h1:c9kM8ewCgjslaAmicYMFQIde2H9/lrZpjBkN8VwoVtM=
|
||||
github.com/pion/mdns/v2 v2.0.7/go.mod h1:vAdSYNAT0Jy3Ru0zl2YiW3Rm/fJCwIeM0nToenfOJKA=
|
||||
github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
|
||||
@@ -403,6 +423,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
|
||||
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
@@ -459,8 +481,6 @@ github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
|
||||
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
|
||||
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
|
||||
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
||||
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
|
||||
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
|
||||
@@ -492,6 +512,16 @@ github.com/tetratelabs/wazero v1.8.0 h1:iEKu0d4c2Pd+QSRieYbnQC9yiFlMS9D+Jr0LsRmc
|
||||
github.com/tetratelabs/wazero v1.8.0/go.mod h1:yAI0XTsMBhREkM/YDAK/zNou3GoiAce1P6+rp/wQhjs=
|
||||
github.com/tidwall/btree v1.6.0 h1:LDZfKfQIBHGHWSwckhXI0RPSXzlo+KYdjK7FWSqOzzg=
|
||||
github.com/tidwall/btree v1.6.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY=
|
||||
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
|
||||
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
|
||||
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
|
||||
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
|
||||
github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
|
||||
github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
|
||||
github.com/tinylib/msgp v1.1.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
|
||||
@@ -503,8 +533,8 @@ github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+
|
||||
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
|
||||
github.com/willf/bitset v1.1.9/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
|
||||
github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
|
||||
github.com/wlynxg/anet v0.0.3 h1:PvR53psxFXstc12jelG6f1Lv4MWqE0tI76/hHGjh9rg=
|
||||
github.com/wlynxg/anet v0.0.3/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=
|
||||
github.com/wlynxg/anet v0.0.5 h1:J3VJGi1gvo0JwZ/P1/Yc/8p63SoW98B5dHkYDmpgvvU=
|
||||
github.com/wlynxg/anet v0.0.5/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=
|
||||
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/zclconf/go-cty v1.8.0 h1:s4AvqaeQzJIu3ndv4gVIhplVD0krU+bgrcLSVUnaWuA=
|
||||
@@ -518,8 +548,12 @@ go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo=
|
||||
go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4=
|
||||
go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q=
|
||||
go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s=
|
||||
go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw=
|
||||
go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg=
|
||||
go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g=
|
||||
go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI=
|
||||
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
|
||||
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
@@ -535,11 +569,12 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
||||
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
|
||||
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
|
||||
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
|
||||
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20220428152302-39d4317da171/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
|
||||
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 h1:kx6Ds3MlpiUHKj7syVnbp57++8WpuKPcR5yjLBjvLEA=
|
||||
@@ -553,6 +588,7 @@ golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57/go.mod h1:3p9vT2HGsQu2
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
|
||||
@@ -577,11 +613,12 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
|
||||
golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=
|
||||
golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
|
||||
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
|
||||
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -597,8 +634,8 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
|
||||
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
|
||||
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -623,11 +660,12 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
||||
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
|
||||
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
@@ -635,6 +673,7 @@ golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
||||
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
|
||||
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
|
||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
|
||||
@@ -651,8 +690,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
|
||||
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
|
||||
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
|
||||
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
|
||||
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
||||
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
@@ -666,11 +705,8 @@ golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023/go.mod h1:nABZi5QlRsZVlz
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
|
||||
golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
|
||||
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
|
||||
golang.org/x/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU=
|
||||
golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@@ -686,9 +722,15 @@ google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJ
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d h1:kHjw/5UfflP/L5EbledDrcG4C2597RtymmGRZvHiCuY=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d/go.mod h1:mw8MG/Qz5wfgYr6VqVCiZcHe/GJEfI+oGGDCohaVgB0=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d h1:JU0iKnSg02Gmb5ZdV8nYsKEKsP6o/FGVWTrw4i1DA9A=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
|
||||
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
|
||||
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
|
||||
1
internal/biz/README.md
Normal file
1
internal/biz/README.md
Normal file
@@ -0,0 +1 @@
|
||||
# Biz
|
||||
6
internal/biz/biz.go
Normal file
6
internal/biz/biz.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package biz
|
||||
|
||||
import "github.com/google/wire"
|
||||
|
||||
// ProviderSet is biz providers.
|
||||
var ProviderSet = wire.NewSet(NewGreeterUsecase)
|
||||
@@ -1,7 +1,7 @@
|
||||
package engine
|
||||
|
||||
import (
|
||||
"polaris/db"
|
||||
"polaris/internal/db"
|
||||
"polaris/ent"
|
||||
"polaris/ent/downloadclients"
|
||||
"polaris/log"
|
||||
@@ -16,13 +16,13 @@ import (
|
||||
"github.com/robfig/cron"
|
||||
)
|
||||
|
||||
func NewEngine(db *db.Client, language string) *Engine {
|
||||
func NewEngine(db db.Database, language string) *Engine {
|
||||
return &Engine{
|
||||
db: db,
|
||||
cron: cron.New(),
|
||||
tasks: utils.Map[int, *Task]{},
|
||||
db: db,
|
||||
cron: cron.New(),
|
||||
tasks: utils.Map[int, *Task]{},
|
||||
schedulers: utils.Map[string, scheduler]{},
|
||||
language: language,
|
||||
language: language,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,11 +31,12 @@ type scheduler struct {
|
||||
f func() error
|
||||
}
|
||||
type Engine struct {
|
||||
db *db.Client
|
||||
db db.Database
|
||||
cron *cron.Cron
|
||||
tasks utils.Map[int, *Task]
|
||||
language string
|
||||
schedulers utils.Map[string, scheduler]
|
||||
buildin *buildin.Downloader
|
||||
}
|
||||
|
||||
func (c *Engine) registerCronJob(name string, cron string, f func() error) {
|
||||
@@ -51,8 +52,12 @@ func (c *Engine) Init() {
|
||||
go c.checkW500PosterOnStartup()
|
||||
}
|
||||
|
||||
func (c *Engine) reloadUsingBuildinDownloader(h *ent.History) error{
|
||||
cl, err := buildin.NewDownloader(c.db.GetDownloadDir())
|
||||
func (c *Engine) GetTask(id int) (*Task, bool) {
|
||||
return c.tasks.Load(id)
|
||||
}
|
||||
|
||||
func (c *Engine) reloadUsingBuildinDownloader(h *ent.History) error {
|
||||
cl, err := c.buildInDownloader()
|
||||
if err != nil {
|
||||
log.Warnf("buildin downloader error: %v", err)
|
||||
}
|
||||
@@ -60,7 +65,9 @@ func (c *Engine) reloadUsingBuildinDownloader(h *ent.History) error{
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "download torrent")
|
||||
}
|
||||
c.tasks.Store(h.ID, &Task{Torrent: t})
|
||||
t.Start()
|
||||
|
||||
c.tasks.Store(h.ID, &Task{Torrent: t})
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -132,6 +139,14 @@ func (c *Engine) reloadTasks() {
|
||||
}
|
||||
c.tasks.Store(t.ID, &Task{Torrent: to})
|
||||
}
|
||||
} else if dl.Implementation == downloadclients.ImplementationBuildin {
|
||||
err := c.reloadUsingBuildinDownloader(t)
|
||||
if err != nil {
|
||||
log.Warnf("buildin downloader error: %v", err)
|
||||
} else {
|
||||
log.Infof("success reloading buildin task: %v", t.SourceTitle)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -139,8 +154,16 @@ func (c *Engine) reloadTasks() {
|
||||
}
|
||||
|
||||
func (c *Engine) buildInDownloader() (pkg.Downloader, error) {
|
||||
if c.buildin != nil {
|
||||
return c.buildin, nil
|
||||
}
|
||||
dir := c.db.GetDownloadDir()
|
||||
return buildin.NewDownloader(dir)
|
||||
d, err := buildin.NewDownloader(dir)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "buildin downloader")
|
||||
}
|
||||
c.buildin = d
|
||||
return d, nil
|
||||
}
|
||||
|
||||
func (c *Engine) GetDownloadClient() (pkg.Downloader, *ent.DownloadClients, error) {
|
||||
@@ -171,7 +194,7 @@ func (c *Engine) GetDownloadClient() (pkg.Downloader, *ent.DownloadClients, erro
|
||||
} else if d.Implementation == downloadclients.ImplementationBuildin {
|
||||
bin, err := c.buildInDownloader()
|
||||
if err != nil {
|
||||
log.Warnf("connect to download client error: %v", d.URL)
|
||||
log.Warnf("connect to download client error: %v", err)
|
||||
continue
|
||||
}
|
||||
return bin, d, nil
|
||||
@@ -210,6 +233,6 @@ func (c *Engine) RemoveTaskAndTorrent(id int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Engine) GetTasks() utils.Map[int, *Task] {
|
||||
return c.tasks
|
||||
func (c *Engine) GetTasks() *utils.Map[int, *Task] {
|
||||
return &c.tasks
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"polaris/db"
|
||||
"polaris/internal/db"
|
||||
"polaris/ent"
|
||||
"polaris/ent/episode"
|
||||
"polaris/ent/importlist"
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"path/filepath"
|
||||
"polaris/db"
|
||||
"polaris/internal/db"
|
||||
"polaris/ent/media"
|
||||
storage1 "polaris/ent/storage"
|
||||
"polaris/log"
|
||||
@@ -260,7 +260,11 @@ func (c *Engine) findEpisodeFilesPreMoving(historyId int) error {
|
||||
return err
|
||||
}
|
||||
for _, id := range episodeIds {
|
||||
ep, _ := c.db.GetEpisode(his.MediaID, his.SeasonNum, id)
|
||||
ep, err := c.db.GetEpisodeByID(id)
|
||||
if err != nil {
|
||||
log.Warnf("query episode error (%d): %v", id, err)
|
||||
continue
|
||||
}
|
||||
task.WalkFunc()(func(path string, info fs.FileInfo) error {
|
||||
if info.IsDir() {
|
||||
return nil
|
||||
@@ -16,14 +16,14 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func (c *Engine) DownloadEpisodeTorrent(r1 torznab.Result, seriesId, seasonNum int, episodeNums ...int) (*string, error) {
|
||||
func (c *Engine) DownloadEpisodeTorrent(r1 torznab.Result, op DownloadOptions) (*string, error) {
|
||||
|
||||
series, err := c.db.GetMedia(seriesId)
|
||||
series, err := c.db.GetMedia(op.MediaId)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("no tv series of id %v", seriesId)
|
||||
return nil, fmt.Errorf("no tv series of id %v", op.MediaId)
|
||||
}
|
||||
|
||||
return c.downloadTorrent(series, r1, seasonNum, episodeNums...)
|
||||
return c.downloadTorrent(series, r1, op)
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -83,9 +83,14 @@ lo:
|
||||
m.ParseExtraDescription(r.Description)
|
||||
if len(episodeNums) == 0 { //want season pack
|
||||
if m.IsSeasonPack {
|
||||
name, err := c.DownloadEpisodeTorrent(r, seriesId, seasonNum)
|
||||
name, err := c.DownloadEpisodeTorrent(r, DownloadOptions{
|
||||
SeasonNum: seasonNum,
|
||||
MediaId: seriesId,
|
||||
HashFilterFn: c.hashInBlacklist,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
log.Warnf("download season pack error, continue next item: %v", err)
|
||||
continue lo
|
||||
}
|
||||
torrentNames = append(torrentNames, *name)
|
||||
break lo
|
||||
@@ -98,9 +103,15 @@ lo:
|
||||
}
|
||||
torrentEpisodes = append(torrentEpisodes, i)
|
||||
}
|
||||
name, err := c.DownloadEpisodeTorrent(r, seriesId, seasonNum, torrentEpisodes...)
|
||||
name, err := c.DownloadEpisodeTorrent(r, DownloadOptions{
|
||||
SeasonNum: seasonNum,
|
||||
MediaId: seriesId,
|
||||
EpisodeNums: torrentEpisodes,
|
||||
HashFilterFn: c.hashInBlacklist,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
log.Warnf("download episode error, continue next item: %v", err)
|
||||
continue lo
|
||||
}
|
||||
torrentNames = append(torrentNames, *name)
|
||||
|
||||
@@ -116,10 +127,27 @@ lo:
|
||||
}
|
||||
|
||||
func (c *Engine) DownloadMovie(m *ent.Media, r1 torznab.Result) (*string, error) {
|
||||
return c.downloadTorrent(m, r1, 0)
|
||||
return c.downloadTorrent(m, r1, DownloadOptions{
|
||||
SeasonNum: 0,
|
||||
MediaId: m.ID,
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Engine) downloadTorrent(m *ent.Media, r1 torznab.Result, seasonNum int, episodeNums ...int) (*string, error) {
|
||||
func (c *Engine) hashInBlacklist(hash string) bool {
|
||||
blacklist, err := c.db.GetTorrentBlacklist()
|
||||
if err!= nil {
|
||||
log.Warnf("get torrent blacklist error: %v", err)
|
||||
return false
|
||||
}
|
||||
for _, b := range blacklist {
|
||||
if b.TorrentHash == hash {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (c *Engine) downloadTorrent(m *ent.Media, r1 torznab.Result, op DownloadOptions) (*string, error) {
|
||||
trc, dlc, err := c.GetDownloadClient()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get download client")
|
||||
@@ -137,13 +165,13 @@ func (c *Engine) downloadTorrent(m *ent.Media, r1 torznab.Result, seasonNum int,
|
||||
var name = r1.Name
|
||||
var targetDir = m.TargetDir
|
||||
if m.MediaType == media.MediaTypeTv { //tv download
|
||||
targetDir = fmt.Sprintf("%s/Season %02d/", m.TargetDir, seasonNum)
|
||||
targetDir = fmt.Sprintf("%s/Season %02d/", m.TargetDir, op.SeasonNum)
|
||||
|
||||
if len(episodeNums) > 0 {
|
||||
for _, epNum := range episodeNums {
|
||||
ep, err := c.db.GetEpisode(m.ID, seasonNum, epNum)
|
||||
if len(op.EpisodeNums) > 0 {
|
||||
for _, epNum := range op.EpisodeNums {
|
||||
ep, err := c.db.GetEpisode(m.ID, op.SeasonNum, epNum)
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("no episode of season %d episode %d", seasonNum, epNum)
|
||||
return nil, errors.Errorf("no episode of season %d episode %d", op.SeasonNum, epNum)
|
||||
|
||||
}
|
||||
if ep.Status == episode.StatusMissing {
|
||||
@@ -151,7 +179,7 @@ func (c *Engine) downloadTorrent(m *ent.Media, r1 torznab.Result, seasonNum int,
|
||||
}
|
||||
}
|
||||
buff := &bytes.Buffer{}
|
||||
for i, ep := range episodeNums {
|
||||
for i, ep := range op.EpisodeNums {
|
||||
if i != 0 {
|
||||
buff.WriteString(",")
|
||||
|
||||
@@ -162,24 +190,32 @@ func (c *Engine) downloadTorrent(m *ent.Media, r1 torznab.Result, seasonNum int,
|
||||
|
||||
} else { //season package download
|
||||
name = fmt.Sprintf("全集 (%s)", name)
|
||||
c.db.SetSeasonAllEpisodeStatus(m.ID, seasonNum, episode.StatusDownloading)
|
||||
c.db.SetSeasonAllEpisodeStatus(m.ID, op.SeasonNum, episode.StatusDownloading)
|
||||
}
|
||||
|
||||
} else {
|
||||
} else {//movie download
|
||||
ep, _ := c.db.GetMovieDummyEpisode(m.ID)
|
||||
if ep.Status == episode.StatusMissing {
|
||||
c.db.SetEpisodeStatus(ep.ID, episode.StatusDownloading)
|
||||
}
|
||||
|
||||
}
|
||||
hash, err := utils.Link2Hash(r1.Link)
|
||||
|
||||
link, hash, err := utils.GetRealLinkAndHash(r1.Link)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get hash")
|
||||
}
|
||||
|
||||
if op.HashFilterFn != nil && op.HashFilterFn(hash) {
|
||||
return nil, errors.Errorf("hash is filtered: %s", hash)
|
||||
}
|
||||
|
||||
r1.Link = link
|
||||
|
||||
history, err := c.db.SaveHistoryRecord(ent.History{
|
||||
MediaID: m.ID,
|
||||
EpisodeNums: episodeNums,
|
||||
SeasonNum: seasonNum,
|
||||
EpisodeNums: op.EpisodeNums,
|
||||
SeasonNum: op.SeasonNum,
|
||||
SourceTitle: r1.Name,
|
||||
TargetDir: targetDir,
|
||||
Status: history.StatusRunning,
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"polaris/db"
|
||||
"polaris/internal/db"
|
||||
"polaris/ent"
|
||||
"polaris/ent/episode"
|
||||
"polaris/ent/history"
|
||||
@@ -18,6 +18,13 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type DownloadOptions struct {
|
||||
HashFilterFn func(hash string) bool
|
||||
SeasonNum int
|
||||
EpisodeNums []int
|
||||
MediaId int
|
||||
}
|
||||
|
||||
func (c *Engine) addSysCron() {
|
||||
c.registerCronJob("check_running_tasks", "@every 1m", c.checkTasks)
|
||||
c.registerCronJob("check_available_medias_to_download", "0 0 * * * *", func() error {
|
||||
@@ -33,7 +40,7 @@ func (c *Engine) addSysCron() {
|
||||
return nil
|
||||
})
|
||||
c.registerCronJob("check_series_new_release", "0 0 */12 * * *", c.checkAllSeriesNewSeason)
|
||||
c.registerCronJob("update_import_lists", "0 30 * * * *", c.periodicallyUpdateImportlist)
|
||||
c.registerCronJob("update_import_lists", "0 */20 * * * *", c.periodicallyUpdateImportlist)
|
||||
|
||||
c.schedulers.Range(func(key string, value scheduler) bool {
|
||||
log.Debugf("add cron job: %v", key)
|
||||
@@ -204,35 +211,37 @@ func getSeasonNum(h *ent.History) int {
|
||||
}
|
||||
|
||||
func (c *Engine) GetEpisodeIds(r *ent.History) []int {
|
||||
var episodeIds []int
|
||||
seasonNum := getSeasonNum(r)
|
||||
|
||||
// if r.EpisodeID > 0 {
|
||||
// episodeIds = append(episodeIds, r.EpisodeID)
|
||||
// }
|
||||
series, err := c.db.GetMediaDetails(r.MediaID)
|
||||
if err != nil {
|
||||
log.Errorf("get media details error: %v", err)
|
||||
return []int{}
|
||||
}
|
||||
if series.MediaType == media.MediaTypeMovie { //movie
|
||||
ep, _ := c.db.GetMovieDummyEpisode(series.ID)
|
||||
return []int{ep.ID}
|
||||
} else { //tv
|
||||
var episodeIds []int
|
||||
seasonNum := getSeasonNum(r)
|
||||
|
||||
if len(r.EpisodeNums) > 0 {
|
||||
for _, epNum := range r.EpisodeNums {
|
||||
if len(r.EpisodeNums) > 0 {
|
||||
for _, epNum := range r.EpisodeNums {
|
||||
for _, ep := range series.Episodes {
|
||||
if ep.SeasonNumber == seasonNum && ep.EpisodeNumber == epNum {
|
||||
episodeIds = append(episodeIds, ep.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for _, ep := range series.Episodes {
|
||||
if ep.SeasonNumber == seasonNum && ep.EpisodeNumber == epNum {
|
||||
if ep.SeasonNumber == seasonNum {
|
||||
episodeIds = append(episodeIds, ep.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for _, ep := range series.Episodes {
|
||||
if ep.SeasonNumber == seasonNum {
|
||||
episodeIds = append(episodeIds, ep.ID)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return episodeIds
|
||||
}
|
||||
return episodeIds
|
||||
}
|
||||
|
||||
func (c *Engine) moveCompletedTask(id int) (err1 error) {
|
||||
@@ -492,7 +501,7 @@ func (c *Engine) downloadMovieSingleEpisode(m *ent.Media, ep *ent.Episode) (stri
|
||||
r1 := res[0]
|
||||
log.Infof("begin download torrent resource: %v", r1.Name)
|
||||
|
||||
s, err := c.downloadTorrent(m, r1, 0)
|
||||
s, err := c.downloadTorrent(m, r1, DownloadOptions{MediaId: m.ID, SeasonNum: 0, HashFilterFn: c.hashInBlacklist})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
56
internal/biz/engine/stun.go
Normal file
56
internal/biz/engine/stun.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package engine
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"polaris/ent/downloadclients"
|
||||
"polaris/log"
|
||||
"polaris/pkg/nat"
|
||||
"polaris/pkg/qbittorrent"
|
||||
|
||||
"github.com/pion/stun/v3"
|
||||
)
|
||||
|
||||
func (s *Engine) stunProxyDownloadClient() error {
|
||||
|
||||
return s.StartStunProxy("")
|
||||
}
|
||||
|
||||
|
||||
func (s *Engine) StartStunProxy(name string) error {
|
||||
downloaders := s.db.GetAllDonloadClients()
|
||||
for _, d := range downloaders {
|
||||
if !d.Enable {
|
||||
continue
|
||||
}
|
||||
if !d.UseNatTraversal {
|
||||
continue
|
||||
}
|
||||
if name != "" && d.Name != name {
|
||||
continue
|
||||
}
|
||||
|
||||
if d.Implementation != downloadclients.ImplementationQbittorrent { //TODO only support qbittorrent for now
|
||||
continue
|
||||
}
|
||||
|
||||
qbt, err := qbittorrent.NewClient(d.URL, d.User, d.Password)
|
||||
if err != nil {
|
||||
return fmt.Errorf("connect to download client error: %v", d.URL)
|
||||
}
|
||||
u, err := url.Parse(d.URL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Infof("start stun proxy for %s", d.Name)
|
||||
n, err := nat.NewNatTraversal(func(xa stun.XORMappedAddress) error {
|
||||
return qbt.SetListenPort(xa.Port)
|
||||
}, u.Hostname())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
n.StartProxy()
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package engine
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"polaris/db"
|
||||
"polaris/internal/db"
|
||||
"polaris/ent"
|
||||
"polaris/ent/media"
|
||||
"polaris/log"
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@@ -71,7 +72,27 @@ func names2Query(media *ent.Media) []string {
|
||||
return names
|
||||
}
|
||||
|
||||
func SearchTvSeries(db1 *db.Client, param *SearchParam) ([]torznab.Result, error) {
|
||||
func getSeasonReleaseYear(series *db.MediaDetails, seasonNum int) int {
|
||||
if seasonNum == 0 {
|
||||
return 0
|
||||
}
|
||||
releaseYear := 0
|
||||
for _, s := range series.Episodes {
|
||||
if s.SeasonNumber == seasonNum && s.AirDate != "" {
|
||||
ss := strings.Split(s.AirDate, "-")[0]
|
||||
y, err := strconv.Atoi(ss)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
releaseYear = y
|
||||
break
|
||||
|
||||
}
|
||||
}
|
||||
return releaseYear
|
||||
}
|
||||
|
||||
func SearchTvSeries(db1 db.Database, param *SearchParam) ([]torznab.Result, error) {
|
||||
series, err := db1.GetMediaDetails(param.MediaId)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("no tv series of id %v: %v", param.MediaId, err)
|
||||
@@ -87,6 +108,11 @@ func SearchTvSeries(db1 *db.Client, param *SearchParam) ([]torznab.Result, error
|
||||
|
||||
res := searchWithTorznab(db1, SearchTypeTv, names...)
|
||||
|
||||
ss := strings.Split(series.AirDate, "-")[0]
|
||||
releaseYear, _ := strconv.Atoi(ss)
|
||||
|
||||
seasonYear := getSeasonReleaseYear(series, param.SeasonNum)
|
||||
|
||||
var filtered []torznab.Result
|
||||
lo:
|
||||
for _, r := range res {
|
||||
@@ -102,6 +128,17 @@ lo:
|
||||
if !torrentNameOk(series, meta) {
|
||||
continue
|
||||
}
|
||||
if meta.Year > 0 && releaseYear > 0 {
|
||||
if meta.Year != releaseYear && meta.Year != releaseYear-1 && meta.Year != releaseYear+1 { //year not match
|
||||
if seasonYear > 0 { // if tv release year is not match, check season release year
|
||||
if meta.Year != seasonYear && meta.Year != seasonYear-1 && meta.Year != seasonYear+1 { //season year not match
|
||||
continue lo
|
||||
}
|
||||
} else {
|
||||
continue lo
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !isNoSeasonSeries(series) && meta.Season != param.SeasonNum { //do not check season on series that only rely on episode number
|
||||
@@ -234,7 +271,7 @@ func isNoSeasonSeries(detail *db.MediaDetails) bool {
|
||||
return hasSeason2 && !season2HasEpisode1 //only one 1st episode
|
||||
}
|
||||
|
||||
func SearchMovie(db1 *db.Client, param *SearchParam) ([]torznab.Result, error) {
|
||||
func SearchMovie(db1 db.Database, param *SearchParam) ([]torznab.Result, error) {
|
||||
movieDetail, err := db1.GetMediaDetails(param.MediaId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -310,7 +347,11 @@ const (
|
||||
SearchTypeMovie SearchType = 2
|
||||
)
|
||||
|
||||
func searchWithTorznab(db *db.Client, t SearchType, queries ...string) []torznab.Result {
|
||||
func searchWithTorznab(db db.Database, t SearchType, queries ...string) []torznab.Result {
|
||||
t1 := time.Now()
|
||||
defer func() {
|
||||
log.Infof("search with torznab took %v", time.Since(t1))
|
||||
}()
|
||||
|
||||
var res []torznab.Result
|
||||
allTorznab := db.GetAllIndexers()
|
||||
@@ -365,7 +406,7 @@ func searchWithTorznab(db *db.Client, t SearchType, queries ...string) []torznab
|
||||
sort.SliceStable(res, func(i, j int) bool { //再按优先级排序,优先级高的种子排前面
|
||||
var s1 = res[i]
|
||||
var s2 = res[j]
|
||||
return s1.Priority > s2.Priority
|
||||
return s1.Priority < s2.Priority
|
||||
})
|
||||
|
||||
//pt资源中,同一indexer内部,优先下载free的资源
|
||||
46
internal/biz/greeter.go
Normal file
46
internal/biz/greeter.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
v1 "polaris/api/helloworld/v1"
|
||||
|
||||
"github.com/go-kratos/kratos/v2/errors"
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrUserNotFound is user not found.
|
||||
ErrUserNotFound = errors.NotFound(v1.ErrorReason_USER_NOT_FOUND.String(), "user not found")
|
||||
)
|
||||
|
||||
// Greeter is a Greeter model.
|
||||
type Greeter struct {
|
||||
Hello string
|
||||
}
|
||||
|
||||
// GreeterRepo is a Greater repo.
|
||||
type GreeterRepo interface {
|
||||
Save(context.Context, *Greeter) (*Greeter, error)
|
||||
Update(context.Context, *Greeter) (*Greeter, error)
|
||||
FindByID(context.Context, int64) (*Greeter, error)
|
||||
ListByHello(context.Context, string) ([]*Greeter, error)
|
||||
ListAll(context.Context) ([]*Greeter, error)
|
||||
}
|
||||
|
||||
// GreeterUsecase is a Greeter usecase.
|
||||
type GreeterUsecase struct {
|
||||
repo GreeterRepo
|
||||
log *log.Helper
|
||||
}
|
||||
|
||||
// NewGreeterUsecase new a Greeter usecase.
|
||||
func NewGreeterUsecase(repo GreeterRepo, logger log.Logger) *GreeterUsecase {
|
||||
return &GreeterUsecase{repo: repo, log: log.NewHelper(logger)}
|
||||
}
|
||||
|
||||
// CreateGreeter creates a Greeter, and returns the new Greeter.
|
||||
func (uc *GreeterUsecase) CreateGreeter(ctx context.Context, g *Greeter) (*Greeter, error) {
|
||||
uc.log.WithContext(ctx).Infof("CreateGreeter: %v", g.Hello)
|
||||
return uc.repo.Save(ctx, g)
|
||||
}
|
||||
@@ -2,14 +2,11 @@ package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"polaris/engine"
|
||||
"polaris/internal/biz/engine"
|
||||
"polaris/ent"
|
||||
"polaris/ent/blacklist"
|
||||
"polaris/ent/episode"
|
||||
"polaris/ent/history"
|
||||
"polaris/ent/schema"
|
||||
"polaris/log"
|
||||
"polaris/pkg/utils"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -89,18 +86,28 @@ func (s *Server) RemoveActivity(c *gin.Context) (interface{}, error) {
|
||||
log.Errorf("no record of id: %d", in.ID)
|
||||
return nil, nil
|
||||
}
|
||||
if in.Add2Blacklist && his.Link != "" {
|
||||
|
||||
if err := s.core.RemoveTaskAndTorrent(his.ID); err != nil {
|
||||
return nil, errors.Wrap(err, "remove torrent")
|
||||
}
|
||||
if his.Status == history.StatusSeeding {
|
||||
//seeding, will mark as complete
|
||||
log.Infof("history is now seeding, will only mark history as success: (%d) %s", his.ID, his.SourceTitle)
|
||||
if err := s.db.SetHistoryStatus(his.ID, history.StatusSuccess); err!= nil {
|
||||
return nil, errors.Wrap(err, "set status")
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if in.Add2Blacklist {
|
||||
//should add to blacklist
|
||||
if err := s.addTorrent2Blacklist(his.Link); err != nil {
|
||||
if err := s.addTorrent2Blacklist(his); err != nil {
|
||||
return nil, errors.Errorf("add to blacklist: %v", err)
|
||||
} else {
|
||||
log.Infof("success add magnet link to blacklist: %v", his.Link)
|
||||
}
|
||||
}
|
||||
|
||||
if err := s.core.RemoveTaskAndTorrent(his.ID); err != nil {
|
||||
return nil, errors.Wrap(err, "remove torrent")
|
||||
}
|
||||
err := s.db.DeleteHistory(in.ID)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "db")
|
||||
@@ -109,9 +116,14 @@ func (s *Server) RemoveActivity(c *gin.Context) (interface{}, error) {
|
||||
episodeIds := s.core.GetEpisodeIds(his)
|
||||
|
||||
for _, id := range episodeIds {
|
||||
ep, _ := s.db.GetEpisode(his.MediaID, his.SeasonNum, id)
|
||||
ep, err := s.db.GetEpisodeByID(id)
|
||||
if err != nil {
|
||||
log.Warnf("get episode (%d) error: %v", id, err)
|
||||
continue
|
||||
}
|
||||
if !s.db.IsEpisodeDownloadingOrDownloaded(id) && ep.Status != episode.StatusDownloaded {
|
||||
//没有正在下载中或者下载完成的任务,并且episode状态不是已经下载完成
|
||||
log.Debugf("set episode (%d) status to missing", id)
|
||||
s.db.SetEpisodeStatus(id, episode.StatusMissing)
|
||||
}
|
||||
}
|
||||
@@ -120,25 +132,33 @@ func (s *Server) RemoveActivity(c *gin.Context) (interface{}, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *Server) addTorrent2Blacklist(link string) error {
|
||||
if link == "" {
|
||||
func (s *Server) addTorrent2Blacklist(h *ent.History) error {
|
||||
if h.Hash == "" { //没有hash,不添加
|
||||
return nil
|
||||
}
|
||||
if hash, err := utils.MagnetHash(link); err != nil {
|
||||
return err
|
||||
} else {
|
||||
item := ent.Blacklist{
|
||||
Type: blacklist.TypeTorrent,
|
||||
Value: schema.BlacklistValue{
|
||||
TorrentHash: hash,
|
||||
},
|
||||
}
|
||||
err := s.db.AddBlacklistItem(&item)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "add to db")
|
||||
}
|
||||
return s.db.AddTorrent2Blacklist(h.Hash, h.SourceTitle, h.MediaID)
|
||||
}
|
||||
|
||||
func (s *Server) GetAllBlacklistItems(c *gin.Context) (interface{}, error) {
|
||||
list, err := s.db.GetTorrentBlacklist()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "db")
|
||||
}
|
||||
return nil
|
||||
return list, nil
|
||||
}
|
||||
func (s *Server) RemoveBlacklistItem(c *gin.Context) (interface{}, error) {
|
||||
id := c.Param("id")
|
||||
if id == "" {
|
||||
return nil, fmt.Errorf("id is empty")
|
||||
}
|
||||
idInt, err := strconv.Atoi(id)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("id is not int: %v", id)
|
||||
}
|
||||
if err := s.db.DeleteTorrentBlacklist(idInt); err != nil {
|
||||
return nil, errors.Wrap(err, "db")
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *Server) GetMediaDownloadHistory(c *gin.Context) (interface{}, error) {
|
||||
@@ -2,7 +2,7 @@ package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"polaris/db"
|
||||
"polaris/internal/db"
|
||||
"polaris/log"
|
||||
"polaris/pkg/utils"
|
||||
"time"
|
||||
@@ -2,8 +2,8 @@ package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"polaris/db"
|
||||
"polaris/engine"
|
||||
"polaris/internal/db"
|
||||
"polaris/internal/biz/engine"
|
||||
"polaris/ent/media"
|
||||
"polaris/log"
|
||||
"polaris/pkg/torznab"
|
||||
@@ -28,7 +28,10 @@ func (s *Server) searchAndDownloadSeasonPackage(seriesId, seasonNum int) (*strin
|
||||
|
||||
r1 := res[0]
|
||||
log.Infof("found resource to download: %+v", r1)
|
||||
return s.core.DownloadEpisodeTorrent(r1, seriesId, seasonNum)
|
||||
return s.core.DownloadEpisodeTorrent(r1, engine.DownloadOptions{
|
||||
SeasonNum: seasonNum,
|
||||
MediaId: seriesId,
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -120,6 +123,9 @@ func (s *Server) SearchTvAndDownload(c *gin.Context) (interface{}, error) {
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "download")
|
||||
}
|
||||
if len(name1) == 0 {
|
||||
return nil, fmt.Errorf("no torrent found")
|
||||
}
|
||||
name = name1[0]
|
||||
}
|
||||
|
||||
@@ -154,14 +160,21 @@ func (s *Server) DownloadTorrent(c *gin.Context) (interface{}, error) {
|
||||
name = fmt.Sprintf("%v S%02d", m.OriginalName, in.Season)
|
||||
}
|
||||
res := torznab.Result{Name: name, Link: in.Link, Size: in.Size}
|
||||
return s.core.DownloadEpisodeTorrent(res, in.MediaID, in.Season)
|
||||
return s.core.DownloadEpisodeTorrent(res, engine.DownloadOptions{
|
||||
SeasonNum: in.Season,
|
||||
MediaId: in.MediaID,
|
||||
})
|
||||
}
|
||||
name := in.Name
|
||||
if name == "" {
|
||||
name = fmt.Sprintf("%v S%02dE%02d", m.OriginalName, in.Season, in.Episode)
|
||||
}
|
||||
res := torznab.Result{Name: name, Link: in.Link, Size: in.Size, IndexerId: in.IndexerId}
|
||||
return s.core.DownloadEpisodeTorrent(res, in.MediaID, in.Season, in.Episode)
|
||||
return s.core.DownloadEpisodeTorrent(res, engine.DownloadOptions{
|
||||
SeasonNum: in.Season,
|
||||
MediaId: in.MediaID,
|
||||
EpisodeNums: []int{in.Episode},
|
||||
})
|
||||
} else {
|
||||
//movie
|
||||
name := in.Name
|
||||
@@ -2,15 +2,17 @@ package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
"polaris/db"
|
||||
"polaris/engine"
|
||||
"polaris/internal/db"
|
||||
"polaris/internal/biz/engine"
|
||||
"polaris/log"
|
||||
"polaris/pkg/cache"
|
||||
"polaris/pkg/tmdb"
|
||||
"polaris/ui"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
ginzap "github.com/gin-contrib/zap"
|
||||
@@ -21,22 +23,22 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func NewServer(db *db.Client) *Server {
|
||||
r := gin.Default()
|
||||
func NewServer(db db.Database) *Server {
|
||||
s := &Server{
|
||||
r: r,
|
||||
db: db,
|
||||
srv: &http.Server{},
|
||||
language: db.GetLanguage(),
|
||||
monitorNumCache: cache.NewCache[int, int](10 * time.Minute),
|
||||
downloadNumCache: cache.NewCache[int, int](10 * time.Minute),
|
||||
}
|
||||
s.core = engine.NewEngine(db, s.language)
|
||||
s.setupRoutes()
|
||||
return s
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
r *gin.Engine
|
||||
db *db.Client
|
||||
srv *http.Server
|
||||
db db.Database
|
||||
core *engine.Engine
|
||||
language string
|
||||
jwtSerect string
|
||||
@@ -44,20 +46,21 @@ type Server struct {
|
||||
downloadNumCache *cache.Cache[int, int]
|
||||
}
|
||||
|
||||
func (s *Server) Serve() error {
|
||||
func (s *Server) setupRoutes() {
|
||||
s.core.Init()
|
||||
|
||||
r := gin.Default()
|
||||
s.jwtSerect = s.db.GetSetting(db.JwtSerectKey)
|
||||
//st, _ := fs.Sub(ui.Web, "build/web")
|
||||
s.r.Use(static.Serve("/", static.EmbedFolder(ui.Web, "build/web")))
|
||||
r.Use(static.Serve("/", static.EmbedFolder(ui.Web, "build/web")))
|
||||
//s.r.Use(ginzap.Ginzap(log.Logger().Desugar(), time.RFC3339, false))
|
||||
s.r.Use(ginzap.RecoveryWithZap(log.Logger().Desugar(), true))
|
||||
r.Use(ginzap.RecoveryWithZap(log.Logger().Desugar(), true))
|
||||
|
||||
log.SetLogLevel(s.db.GetSetting(db.SettingLogLevel)) //restore log level
|
||||
|
||||
s.r.POST("/api/login", HttpHandler(s.Login))
|
||||
r.POST("/api/login", HttpHandler(s.Login))
|
||||
|
||||
api := s.r.Group("/api/v1")
|
||||
api := r.Group("/api/v1")
|
||||
api.Use(s.authModdleware)
|
||||
api.StaticFS("/img", http.Dir(db.ImgPath))
|
||||
api.StaticFS("/logs", http.Dir(db.LogPath))
|
||||
@@ -86,6 +89,8 @@ func (s *Server) Serve() error {
|
||||
activity.GET("/", HttpHandler(s.GetAllActivities))
|
||||
activity.POST("/delete", HttpHandler(s.RemoveActivity))
|
||||
activity.GET("/media/:id", HttpHandler(s.GetMediaDownloadHistory))
|
||||
activity.GET("/blacklist", HttpHandler(s.GetAllBlacklistItems))
|
||||
activity.DELETE("/blacklist/:id", HttpHandler(s.RemoveBlacklistItem))
|
||||
//activity.GET("/torrents", HttpHandler(s.GetAllTorrents))
|
||||
}
|
||||
|
||||
@@ -96,7 +101,7 @@ func (s *Server) Serve() error {
|
||||
tv.POST("/tv/watchlist", HttpHandler(s.AddTv2Watchlist))
|
||||
tv.GET("/tv/watchlist", HttpHandler(s.GetTvWatchlist))
|
||||
tv.POST("/torrents", HttpHandler(s.SearchAvailableTorrents))
|
||||
tv.POST("/torrents/download/", HttpHandler(s.DownloadTorrent))
|
||||
tv.POST("/torrents/download", HttpHandler(s.DownloadTorrent))
|
||||
tv.POST("/movie/watchlist", HttpHandler(s.AddMovie2Watchlist))
|
||||
tv.GET("/movie/watchlist", HttpHandler(s.GetMovieWatchlist))
|
||||
tv.GET("/record/:id", HttpHandler(s.GetMediaDetails))
|
||||
@@ -140,9 +145,40 @@ func (s *Server) Serve() error {
|
||||
importlist.POST("/add", HttpHandler(s.addImportlist))
|
||||
importlist.DELETE("/delete", HttpHandler(s.deleteImportList))
|
||||
}
|
||||
log.Infof("----------- Polaris Server Successfully Started ------------")
|
||||
s.srv.Handler = r
|
||||
|
||||
return s.r.Run(":8080")
|
||||
}
|
||||
|
||||
func (s *Server) Start(addr string) (int, error) {
|
||||
if addr == "" {
|
||||
addr = "127.0.0.1:0" // 0 means any available port
|
||||
}
|
||||
ln, err := net.Listen("tcp", addr)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to listen on port: %w", err)
|
||||
}
|
||||
|
||||
_, port, _ := net.SplitHostPort(ln.Addr().String())
|
||||
|
||||
p, err := strconv.Atoi(port)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to convert port to int: %w", err)
|
||||
}
|
||||
go func() {
|
||||
defer ln.Close()
|
||||
if err := s.srv.Serve(ln); err != nil {
|
||||
log.Errorf("failed to serve: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
log.Infof("----------- Polaris Server Successfully Started on Port %d------------", p)
|
||||
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func (s *Server) Stop() error {
|
||||
log.Infof("Stopping Polaris Server...")
|
||||
return s.srv.Close()
|
||||
}
|
||||
|
||||
func (s *Server) TMDB() (*tmdb.Client, error) {
|
||||
@@ -3,7 +3,7 @@ package server
|
||||
import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"polaris/db"
|
||||
"polaris/internal/db"
|
||||
"polaris/ent"
|
||||
"polaris/ent/downloadclients"
|
||||
"polaris/log"
|
||||
@@ -190,12 +190,13 @@ func (s *Server) GetAllIndexers(c *gin.Context) (interface{}, error) {
|
||||
}
|
||||
|
||||
type downloadClientIn struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
URL string `json:"url" binding:"required"`
|
||||
User string `json:"user"`
|
||||
Password string `json:"password"`
|
||||
Implementation string `json:"implementation" binding:"required"`
|
||||
Priority int `json:"priority"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
URL string `json:"url" binding:"required"`
|
||||
User string `json:"user"`
|
||||
Password string `json:"password"`
|
||||
Implementation string `json:"implementation" binding:"required"`
|
||||
Priority int `json:"priority"`
|
||||
UseNatTraversal bool `json:"use_nat_traversal"`
|
||||
}
|
||||
|
||||
func (s *Server) AddDownloadClient(c *gin.Context) (interface{}, error) {
|
||||
@@ -225,15 +226,17 @@ func (s *Server) AddDownloadClient(c *gin.Context) (interface{}, error) {
|
||||
}
|
||||
}
|
||||
if err := s.db.SaveDownloader(&ent.DownloadClients{
|
||||
Name: in.Name,
|
||||
Implementation: downloadclients.Implementation(in.Implementation),
|
||||
Priority1: in.Priority,
|
||||
URL: in.URL,
|
||||
User: in.User,
|
||||
Password: in.Password,
|
||||
Name: in.Name,
|
||||
Implementation: downloadclients.Implementation(in.Implementation),
|
||||
Priority1: in.Priority,
|
||||
URL: in.URL,
|
||||
User: in.User,
|
||||
Password: in.Password,
|
||||
UseNatTraversal: in.UseNatTraversal,
|
||||
}); err != nil {
|
||||
return nil, errors.Wrap(err, "save downloader")
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@ package server
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"polaris/db"
|
||||
"polaris/internal/db"
|
||||
"strings"
|
||||
|
||||
"polaris/log"
|
||||
"polaris/pkg/alist"
|
||||
@@ -52,10 +53,17 @@ func (s *Server) AddStorage(c *gin.Context) (interface{}, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !strings.HasSuffix(in.TvPath, string(os.PathSeparator)) {
|
||||
in.TvPath = in.TvPath + string(os.PathSeparator)
|
||||
}
|
||||
_, err = os.Stat(in.MoviePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !strings.HasSuffix(in.MoviePath, string(os.PathSeparator)) {
|
||||
in.MoviePath = in.MoviePath + string(os.PathSeparator)
|
||||
}
|
||||
|
||||
}
|
||||
log.Infof("received add storage input: %v", in)
|
||||
err := s.db.AddStorage(&in)
|
||||
@@ -2,7 +2,7 @@ package server
|
||||
|
||||
import (
|
||||
"os"
|
||||
"polaris/db"
|
||||
"polaris/internal/db"
|
||||
"polaris/log"
|
||||
"polaris/pkg/metadata"
|
||||
"polaris/pkg/uptime"
|
||||
@@ -3,8 +3,8 @@ package server
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"polaris/db"
|
||||
"polaris/engine"
|
||||
"polaris/internal/db"
|
||||
"polaris/internal/biz/engine"
|
||||
"polaris/ent"
|
||||
"polaris/ent/episode"
|
||||
"polaris/ent/media"
|
||||
652
internal/conf/conf.pb.go
Normal file
652
internal/conf/conf.pb.go
Normal file
@@ -0,0 +1,652 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.27.1
|
||||
// protoc v3.19.3
|
||||
// source: conf/conf.proto
|
||||
|
||||
package conf
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
durationpb "google.golang.org/protobuf/types/known/durationpb"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type Bootstrap struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Server *Server `protobuf:"bytes,1,opt,name=server,proto3" json:"server,omitempty"`
|
||||
Data *Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Bootstrap) Reset() {
|
||||
*x = Bootstrap{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_conf_conf_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Bootstrap) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Bootstrap) ProtoMessage() {}
|
||||
|
||||
func (x *Bootstrap) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_conf_conf_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Bootstrap.ProtoReflect.Descriptor instead.
|
||||
func (*Bootstrap) Descriptor() ([]byte, []int) {
|
||||
return file_conf_conf_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *Bootstrap) GetServer() *Server {
|
||||
if x != nil {
|
||||
return x.Server
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Bootstrap) GetData() *Data {
|
||||
if x != nil {
|
||||
return x.Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Http *Server_HTTP `protobuf:"bytes,1,opt,name=http,proto3" json:"http,omitempty"`
|
||||
Grpc *Server_GRPC `protobuf:"bytes,2,opt,name=grpc,proto3" json:"grpc,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Server) Reset() {
|
||||
*x = Server{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_conf_conf_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Server) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Server) ProtoMessage() {}
|
||||
|
||||
func (x *Server) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_conf_conf_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Server.ProtoReflect.Descriptor instead.
|
||||
func (*Server) Descriptor() ([]byte, []int) {
|
||||
return file_conf_conf_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *Server) GetHttp() *Server_HTTP {
|
||||
if x != nil {
|
||||
return x.Http
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Server) GetGrpc() *Server_GRPC {
|
||||
if x != nil {
|
||||
return x.Grpc
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Data struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Database *Data_Database `protobuf:"bytes,1,opt,name=database,proto3" json:"database,omitempty"`
|
||||
Redis *Data_Redis `protobuf:"bytes,2,opt,name=redis,proto3" json:"redis,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Data) Reset() {
|
||||
*x = Data{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_conf_conf_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Data) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Data) ProtoMessage() {}
|
||||
|
||||
func (x *Data) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_conf_conf_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Data.ProtoReflect.Descriptor instead.
|
||||
func (*Data) Descriptor() ([]byte, []int) {
|
||||
return file_conf_conf_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *Data) GetDatabase() *Data_Database {
|
||||
if x != nil {
|
||||
return x.Database
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Data) GetRedis() *Data_Redis {
|
||||
if x != nil {
|
||||
return x.Redis
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Server_HTTP struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Network string `protobuf:"bytes,1,opt,name=network,proto3" json:"network,omitempty"`
|
||||
Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"`
|
||||
Timeout *durationpb.Duration `protobuf:"bytes,3,opt,name=timeout,proto3" json:"timeout,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Server_HTTP) Reset() {
|
||||
*x = Server_HTTP{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_conf_conf_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Server_HTTP) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Server_HTTP) ProtoMessage() {}
|
||||
|
||||
func (x *Server_HTTP) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_conf_conf_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Server_HTTP.ProtoReflect.Descriptor instead.
|
||||
func (*Server_HTTP) Descriptor() ([]byte, []int) {
|
||||
return file_conf_conf_proto_rawDescGZIP(), []int{1, 0}
|
||||
}
|
||||
|
||||
func (x *Server_HTTP) GetNetwork() string {
|
||||
if x != nil {
|
||||
return x.Network
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Server_HTTP) GetAddr() string {
|
||||
if x != nil {
|
||||
return x.Addr
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Server_HTTP) GetTimeout() *durationpb.Duration {
|
||||
if x != nil {
|
||||
return x.Timeout
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Server_GRPC struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Network string `protobuf:"bytes,1,opt,name=network,proto3" json:"network,omitempty"`
|
||||
Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"`
|
||||
Timeout *durationpb.Duration `protobuf:"bytes,3,opt,name=timeout,proto3" json:"timeout,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Server_GRPC) Reset() {
|
||||
*x = Server_GRPC{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_conf_conf_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Server_GRPC) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Server_GRPC) ProtoMessage() {}
|
||||
|
||||
func (x *Server_GRPC) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_conf_conf_proto_msgTypes[4]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Server_GRPC.ProtoReflect.Descriptor instead.
|
||||
func (*Server_GRPC) Descriptor() ([]byte, []int) {
|
||||
return file_conf_conf_proto_rawDescGZIP(), []int{1, 1}
|
||||
}
|
||||
|
||||
func (x *Server_GRPC) GetNetwork() string {
|
||||
if x != nil {
|
||||
return x.Network
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Server_GRPC) GetAddr() string {
|
||||
if x != nil {
|
||||
return x.Addr
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Server_GRPC) GetTimeout() *durationpb.Duration {
|
||||
if x != nil {
|
||||
return x.Timeout
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Data_Database struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Driver string `protobuf:"bytes,1,opt,name=driver,proto3" json:"driver,omitempty"`
|
||||
Source string `protobuf:"bytes,2,opt,name=source,proto3" json:"source,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Data_Database) Reset() {
|
||||
*x = Data_Database{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_conf_conf_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Data_Database) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Data_Database) ProtoMessage() {}
|
||||
|
||||
func (x *Data_Database) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_conf_conf_proto_msgTypes[5]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Data_Database.ProtoReflect.Descriptor instead.
|
||||
func (*Data_Database) Descriptor() ([]byte, []int) {
|
||||
return file_conf_conf_proto_rawDescGZIP(), []int{2, 0}
|
||||
}
|
||||
|
||||
func (x *Data_Database) GetDriver() string {
|
||||
if x != nil {
|
||||
return x.Driver
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Data_Database) GetSource() string {
|
||||
if x != nil {
|
||||
return x.Source
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type Data_Redis struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Network string `protobuf:"bytes,1,opt,name=network,proto3" json:"network,omitempty"`
|
||||
Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"`
|
||||
ReadTimeout *durationpb.Duration `protobuf:"bytes,3,opt,name=read_timeout,json=readTimeout,proto3" json:"read_timeout,omitempty"`
|
||||
WriteTimeout *durationpb.Duration `protobuf:"bytes,4,opt,name=write_timeout,json=writeTimeout,proto3" json:"write_timeout,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Data_Redis) Reset() {
|
||||
*x = Data_Redis{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_conf_conf_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Data_Redis) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Data_Redis) ProtoMessage() {}
|
||||
|
||||
func (x *Data_Redis) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_conf_conf_proto_msgTypes[6]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Data_Redis.ProtoReflect.Descriptor instead.
|
||||
func (*Data_Redis) Descriptor() ([]byte, []int) {
|
||||
return file_conf_conf_proto_rawDescGZIP(), []int{2, 1}
|
||||
}
|
||||
|
||||
func (x *Data_Redis) GetNetwork() string {
|
||||
if x != nil {
|
||||
return x.Network
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Data_Redis) GetAddr() string {
|
||||
if x != nil {
|
||||
return x.Addr
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Data_Redis) GetReadTimeout() *durationpb.Duration {
|
||||
if x != nil {
|
||||
return x.ReadTimeout
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Data_Redis) GetWriteTimeout() *durationpb.Duration {
|
||||
if x != nil {
|
||||
return x.WriteTimeout
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_conf_conf_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_conf_conf_proto_rawDesc = []byte{
|
||||
0x0a, 0x0f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x12, 0x0a, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x1e, 0x67,
|
||||
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64,
|
||||
0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5d, 0x0a,
|
||||
0x09, 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x65,
|
||||
0x72, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6b, 0x72, 0x61,
|
||||
0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x06,
|
||||
0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x24, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70,
|
||||
0x69, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xb8, 0x02, 0x0a,
|
||||
0x06, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x2b, 0x0a, 0x04, 0x68, 0x74, 0x74, 0x70, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61,
|
||||
0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x48, 0x54, 0x54, 0x50, 0x52, 0x04,
|
||||
0x68, 0x74, 0x74, 0x70, 0x12, 0x2b, 0x0a, 0x04, 0x67, 0x72, 0x70, 0x63, 0x18, 0x02, 0x20, 0x01,
|
||||
0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e,
|
||||
0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x47, 0x52, 0x50, 0x43, 0x52, 0x04, 0x67, 0x72, 0x70,
|
||||
0x63, 0x1a, 0x69, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x12, 0x18, 0x0a, 0x07, 0x6e, 0x65, 0x74,
|
||||
0x77, 0x6f, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77,
|
||||
0x6f, 0x72, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x04, 0x61, 0x64, 0x64, 0x72, 0x12, 0x33, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f,
|
||||
0x75, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
|
||||
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x1a, 0x69, 0x0a, 0x04,
|
||||
0x47, 0x52, 0x50, 0x43, 0x12, 0x18, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x12,
|
||||
0x0a, 0x04, 0x61, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x61, 0x64,
|
||||
0x64, 0x72, 0x12, 0x33, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x03, 0x20,
|
||||
0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07,
|
||||
0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x22, 0xdd, 0x02, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61,
|
||||
0x12, 0x35, 0x0a, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e,
|
||||
0x44, 0x61, 0x74, 0x61, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x08, 0x64,
|
||||
0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x2c, 0x0a, 0x05, 0x72, 0x65, 0x64, 0x69, 0x73,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e,
|
||||
0x61, 0x70, 0x69, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x52, 0x65, 0x64, 0x69, 0x73, 0x52, 0x05,
|
||||
0x72, 0x65, 0x64, 0x69, 0x73, 0x1a, 0x3a, 0x0a, 0x08, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73,
|
||||
0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x06, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6f, 0x75,
|
||||
0x72, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63,
|
||||
0x65, 0x1a, 0xb3, 0x01, 0x0a, 0x05, 0x52, 0x65, 0x64, 0x69, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6e,
|
||||
0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x65,
|
||||
0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x04, 0x61, 0x64, 0x64, 0x72, 0x12, 0x3c, 0x0a, 0x0c, 0x72, 0x65, 0x61,
|
||||
0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32,
|
||||
0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
|
||||
0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x72, 0x65, 0x61, 0x64,
|
||||
0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x3e, 0x0a, 0x0d, 0x77, 0x72, 0x69, 0x74, 0x65,
|
||||
0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19,
|
||||
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
|
||||
0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x77, 0x72, 0x69, 0x74, 0x65,
|
||||
0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x42, 0x37, 0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75,
|
||||
0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x2d, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2f,
|
||||
0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2d, 0x6c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x2f, 0x69, 0x6e,
|
||||
0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x3b, 0x63, 0x6f, 0x6e, 0x66,
|
||||
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_conf_conf_proto_rawDescOnce sync.Once
|
||||
file_conf_conf_proto_rawDescData = file_conf_conf_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_conf_conf_proto_rawDescGZIP() []byte {
|
||||
file_conf_conf_proto_rawDescOnce.Do(func() {
|
||||
file_conf_conf_proto_rawDescData = protoimpl.X.CompressGZIP(file_conf_conf_proto_rawDescData)
|
||||
})
|
||||
return file_conf_conf_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_conf_conf_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
|
||||
var file_conf_conf_proto_goTypes = []interface{}{
|
||||
(*Bootstrap)(nil), // 0: kratos.api.Bootstrap
|
||||
(*Server)(nil), // 1: kratos.api.Server
|
||||
(*Data)(nil), // 2: kratos.api.Data
|
||||
(*Server_HTTP)(nil), // 3: kratos.api.Server.HTTP
|
||||
(*Server_GRPC)(nil), // 4: kratos.api.Server.GRPC
|
||||
(*Data_Database)(nil), // 5: kratos.api.Data.Database
|
||||
(*Data_Redis)(nil), // 6: kratos.api.Data.Redis
|
||||
(*durationpb.Duration)(nil), // 7: google.protobuf.Duration
|
||||
}
|
||||
var file_conf_conf_proto_depIdxs = []int32{
|
||||
1, // 0: kratos.api.Bootstrap.server:type_name -> kratos.api.Server
|
||||
2, // 1: kratos.api.Bootstrap.data:type_name -> kratos.api.Data
|
||||
3, // 2: kratos.api.Server.http:type_name -> kratos.api.Server.HTTP
|
||||
4, // 3: kratos.api.Server.grpc:type_name -> kratos.api.Server.GRPC
|
||||
5, // 4: kratos.api.Data.database:type_name -> kratos.api.Data.Database
|
||||
6, // 5: kratos.api.Data.redis:type_name -> kratos.api.Data.Redis
|
||||
7, // 6: kratos.api.Server.HTTP.timeout:type_name -> google.protobuf.Duration
|
||||
7, // 7: kratos.api.Server.GRPC.timeout:type_name -> google.protobuf.Duration
|
||||
7, // 8: kratos.api.Data.Redis.read_timeout:type_name -> google.protobuf.Duration
|
||||
7, // 9: kratos.api.Data.Redis.write_timeout:type_name -> google.protobuf.Duration
|
||||
10, // [10:10] is the sub-list for method output_type
|
||||
10, // [10:10] is the sub-list for method input_type
|
||||
10, // [10:10] is the sub-list for extension type_name
|
||||
10, // [10:10] is the sub-list for extension extendee
|
||||
0, // [0:10] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_conf_conf_proto_init() }
|
||||
func file_conf_conf_proto_init() {
|
||||
if File_conf_conf_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_conf_conf_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Bootstrap); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_conf_conf_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Server); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_conf_conf_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Data); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_conf_conf_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Server_HTTP); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_conf_conf_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Server_GRPC); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_conf_conf_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Data_Database); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_conf_conf_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Data_Redis); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_conf_conf_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 7,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_conf_conf_proto_goTypes,
|
||||
DependencyIndexes: file_conf_conf_proto_depIdxs,
|
||||
MessageInfos: file_conf_conf_proto_msgTypes,
|
||||
}.Build()
|
||||
File_conf_conf_proto = out.File
|
||||
file_conf_conf_proto_rawDesc = nil
|
||||
file_conf_conf_proto_goTypes = nil
|
||||
file_conf_conf_proto_depIdxs = nil
|
||||
}
|
||||
41
internal/conf/conf.proto
Normal file
41
internal/conf/conf.proto
Normal file
@@ -0,0 +1,41 @@
|
||||
syntax = "proto3";
|
||||
package kratos.api;
|
||||
|
||||
option go_package = "polaris/internal/conf;conf";
|
||||
|
||||
import "google/protobuf/duration.proto";
|
||||
|
||||
message Bootstrap {
|
||||
Server server = 1;
|
||||
Data data = 2;
|
||||
}
|
||||
|
||||
message Server {
|
||||
message HTTP {
|
||||
string network = 1;
|
||||
string addr = 2;
|
||||
google.protobuf.Duration timeout = 3;
|
||||
}
|
||||
message GRPC {
|
||||
string network = 1;
|
||||
string addr = 2;
|
||||
google.protobuf.Duration timeout = 3;
|
||||
}
|
||||
HTTP http = 1;
|
||||
GRPC grpc = 2;
|
||||
}
|
||||
|
||||
message Data {
|
||||
message Database {
|
||||
string driver = 1;
|
||||
string source = 2;
|
||||
}
|
||||
message Redis {
|
||||
string network = 1;
|
||||
string addr = 2;
|
||||
google.protobuf.Duration read_timeout = 3;
|
||||
google.protobuf.Duration write_timeout = 4;
|
||||
}
|
||||
Database database = 1;
|
||||
Redis redis = 2;
|
||||
}
|
||||
1
internal/data/README.md
Normal file
1
internal/data/README.md
Normal file
@@ -0,0 +1 @@
|
||||
# Data
|
||||
24
internal/data/data.go
Normal file
24
internal/data/data.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package data
|
||||
|
||||
import (
|
||||
"polaris/internal/conf"
|
||||
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
"github.com/google/wire"
|
||||
)
|
||||
|
||||
// ProviderSet is data providers.
|
||||
var ProviderSet = wire.NewSet(NewData, NewGreeterRepo)
|
||||
|
||||
// Data .
|
||||
type Data struct {
|
||||
// TODO wrapped database client
|
||||
}
|
||||
|
||||
// NewData .
|
||||
func NewData(c *conf.Data, logger log.Logger) (*Data, func(), error) {
|
||||
cleanup := func() {
|
||||
log.NewHelper(logger).Info("closing the data resources")
|
||||
}
|
||||
return &Data{}, cleanup, nil
|
||||
}
|
||||
42
internal/data/greeter.go
Normal file
42
internal/data/greeter.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package data
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"polaris/internal/biz"
|
||||
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
)
|
||||
|
||||
type greeterRepo struct {
|
||||
data *Data
|
||||
log *log.Helper
|
||||
}
|
||||
|
||||
// NewGreeterRepo .
|
||||
func NewGreeterRepo(data *Data, logger log.Logger) biz.GreeterRepo {
|
||||
return &greeterRepo{
|
||||
data: data,
|
||||
log: log.NewHelper(logger),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *greeterRepo) Save(ctx context.Context, g *biz.Greeter) (*biz.Greeter, error) {
|
||||
return g, nil
|
||||
}
|
||||
|
||||
func (r *greeterRepo) Update(ctx context.Context, g *biz.Greeter) (*biz.Greeter, error) {
|
||||
return g, nil
|
||||
}
|
||||
|
||||
func (r *greeterRepo) FindByID(context.Context, int64) (*biz.Greeter, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (r *greeterRepo) ListByHello(context.Context, string) ([]*biz.Greeter, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (r *greeterRepo) ListAll(context.Context) ([]*biz.Greeter, error) {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
package db
|
||||
|
||||
import "polaris/ent/media"
|
||||
import (
|
||||
"polaris/ent/media"
|
||||
"polaris/pkg/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
Version = "undefined"
|
||||
Version = "undefined"
|
||||
DefaultTmdbApiKey = ""
|
||||
)
|
||||
|
||||
@@ -37,9 +40,12 @@ const (
|
||||
|
||||
const (
|
||||
IndexerTorznabImpl = "torznab"
|
||||
DataPath = "./data"
|
||||
ImgPath = DataPath + "/img"
|
||||
LogPath = DataPath + "/logs"
|
||||
)
|
||||
|
||||
var (
|
||||
DataPath = utils.GetUserDataDir()
|
||||
ImgPath = DataPath + "/img"
|
||||
LogPath = DataPath + "/logs"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -49,7 +55,7 @@ const (
|
||||
|
||||
const DefaultNamingFormat = "{{.NameCN}} {{.NameEN}} {{if .Year}} ({{.Year}}) {{end}}"
|
||||
|
||||
//https://en.wikipedia.org/wiki/Video_file_format
|
||||
// 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",
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"polaris/ent"
|
||||
"polaris/ent/blacklist"
|
||||
"polaris/ent/downloadclients"
|
||||
"polaris/ent/episode"
|
||||
"polaris/ent/history"
|
||||
@@ -28,19 +29,19 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
type client struct {
|
||||
ent *ent.Client
|
||||
}
|
||||
|
||||
func Open() (*Client, error) {
|
||||
func Open() (Database, error) {
|
||||
os.Mkdir(DataPath, 0777)
|
||||
client, err := ent.Open(dialect.SQLite, fmt.Sprintf("file:%v/polaris.db?cache=shared&_fk=1", DataPath))
|
||||
cl, err := ent.Open(dialect.SQLite, fmt.Sprintf("file:%v/polaris.db?cache=shared&_fk=1", DataPath))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed opening connection to sqlite")
|
||||
}
|
||||
//defer client.Close()
|
||||
c := &Client{
|
||||
ent: client,
|
||||
c := &client{
|
||||
ent: cl,
|
||||
}
|
||||
// Run the auto migration tool.
|
||||
if err := c.migrate(); err != nil {
|
||||
@@ -52,7 +53,7 @@ func Open() (*Client, error) {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (c *Client) init() {
|
||||
func (c *client) init() {
|
||||
c.generateJwtSerectIfNotExist()
|
||||
if err := c.generateDefaultLocalStorage(); err != nil {
|
||||
log.Errorf("generate default storage: %v", err)
|
||||
@@ -68,17 +69,36 @@ func (c *Client) init() {
|
||||
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",
|
||||
})
|
||||
}
|
||||
c.initBuildinClient()
|
||||
}
|
||||
|
||||
func (c *Client) generateJwtSerectIfNotExist() {
|
||||
func (c *client) initBuildinClient() {
|
||||
hasBuildin := false
|
||||
tr := c.GetAllDonloadClients()
|
||||
for _, d := range tr {
|
||||
if d.Implementation == downloadclients.ImplementationBuildin {
|
||||
hasBuildin = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !hasBuildin {
|
||||
log.Warnf("no buildin download client, set default download client")
|
||||
if err := c.SaveDownloader(&ent.DownloadClients{
|
||||
Enable: true,
|
||||
Name: "内建下载器",
|
||||
Implementation: downloadclients.ImplementationBuildin,
|
||||
URL: "buildin",
|
||||
Priority1: 50,
|
||||
RemoveCompletedDownloads: true,
|
||||
RemoveFailedDownloads: true,
|
||||
}); err != nil {
|
||||
log.Warnf("add buildin client error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (c *client) generateJwtSerectIfNotExist() {
|
||||
v := c.GetSetting(JwtSerectKey)
|
||||
if v == "" {
|
||||
log.Infof("generate jwt serect")
|
||||
@@ -87,7 +107,7 @@ func (c *Client) generateJwtSerectIfNotExist() {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) generateDefaultLocalStorage() error {
|
||||
func (c *client) generateDefaultLocalStorage() error {
|
||||
n, _ := c.ent.Storage.Query().Count(context.TODO())
|
||||
if n != 0 {
|
||||
return nil
|
||||
@@ -102,7 +122,7 @@ func (c *Client) generateDefaultLocalStorage() error {
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Client) GetSetting(key string) string {
|
||||
func (c *client) GetSetting(key string) string {
|
||||
v, err := c.ent.Settings.Query().Where(settings.Key(key)).Only(context.TODO())
|
||||
if err != nil {
|
||||
log.Debugf("get setting by key: %s error: %v", key, err)
|
||||
@@ -111,7 +131,7 @@ func (c *Client) GetSetting(key string) string {
|
||||
return v.Value
|
||||
}
|
||||
|
||||
func (c *Client) SetSetting(key, value string) error {
|
||||
func (c *client) SetSetting(key, value string) error {
|
||||
v, err := c.ent.Settings.Query().Where(settings.Key(key)).Only(context.TODO())
|
||||
if err != nil {
|
||||
log.Infof("create new setting")
|
||||
@@ -122,7 +142,7 @@ func (c *Client) SetSetting(key, value string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) GetLanguage() string {
|
||||
func (c *client) GetLanguage() string {
|
||||
lang := c.GetSetting(SettingLanguage)
|
||||
log.Infof("get application language: %s", lang)
|
||||
if lang == "" {
|
||||
@@ -131,7 +151,7 @@ func (c *Client) GetLanguage() string {
|
||||
return lang
|
||||
}
|
||||
|
||||
func (c *Client) AddMediaWatchlist(m *ent.Media, episodes []int) (*ent.Media, error) {
|
||||
func (c *client) AddMediaWatchlist(m *ent.Media, episodes []int) (*ent.Media, error) {
|
||||
count := c.ent.Media.Query().Where(media.TmdbID(m.TmdbID)).CountX(context.Background())
|
||||
if count > 0 {
|
||||
return nil, fmt.Errorf("tv series %s already in watchlist", m.NameEn)
|
||||
@@ -166,7 +186,7 @@ func (c *Client) AddMediaWatchlist(m *ent.Media, episodes []int) (*ent.Media, er
|
||||
|
||||
}
|
||||
|
||||
func (c *Client) GetMediaWatchlist(mediaType media.MediaType) []*ent.Media {
|
||||
func (c *client) GetMediaWatchlist(mediaType media.MediaType) []*ent.Media {
|
||||
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)
|
||||
@@ -175,19 +195,19 @@ func (c *Client) GetMediaWatchlist(mediaType media.MediaType) []*ent.Media {
|
||||
return list
|
||||
}
|
||||
|
||||
func (c *Client) GetEpisode(seriesId, seasonNum, episodeNum int) (*ent.Episode, error) {
|
||||
func (c *client) GetEpisode(seriesId, seasonNum, episodeNum int) (*ent.Episode, error) {
|
||||
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) {
|
||||
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 {
|
||||
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 {
|
||||
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())
|
||||
}
|
||||
|
||||
@@ -196,7 +216,7 @@ type MediaDetails struct {
|
||||
Episodes []*ent.Episode `json:"episodes"`
|
||||
}
|
||||
|
||||
func (c *Client) GetMediaDetails(id int) (*MediaDetails, error) {
|
||||
func (c *client) GetMediaDetails(id int) (*MediaDetails, error) {
|
||||
se, err := c.ent.Media.Query().Where(media.ID(id)).First(context.TODO())
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("get series %d: %v", id, err)
|
||||
@@ -214,11 +234,11 @@ func (c *Client) GetMediaDetails(id int) (*MediaDetails, error) {
|
||||
return md, nil
|
||||
}
|
||||
|
||||
func (c *Client) GetMedia(id int) (*ent.Media, error) {
|
||||
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 {
|
||||
func (c *client) DeleteMedia(id int) error {
|
||||
_, err := c.ent.Episode.Delete().Where(episode.MediaID(id)).Exec(context.TODO())
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -230,7 +250,7 @@ func (c *Client) DeleteMedia(id int) error {
|
||||
return c.CleanAllDanglingEpisodes()
|
||||
}
|
||||
|
||||
func (c *Client) SaveEposideDetail(d *ent.Episode) (int, error) {
|
||||
func (c *client) SaveEposideDetail(d *ent.Episode) (int, error) {
|
||||
ep, err := c.ent.Episode.Create().
|
||||
SetAirDate(d.AirDate).
|
||||
SetSeasonNumber(d.SeasonNumber).
|
||||
@@ -244,7 +264,7 @@ func (c *Client) SaveEposideDetail(d *ent.Episode) (int, error) {
|
||||
return ep.ID, nil
|
||||
}
|
||||
|
||||
func (c *Client) SaveEposideDetail2(d *ent.Episode) (int, error) {
|
||||
func (c *client) SaveEposideDetail2(d *ent.Episode) (int, error) {
|
||||
ep, err := c.ent.Episode.Create().
|
||||
SetAirDate(d.AirDate).
|
||||
SetSeasonNumber(d.SeasonNumber).
|
||||
@@ -263,13 +283,13 @@ type TorznabSetting struct {
|
||||
ApiKey string `json:"api_key"`
|
||||
}
|
||||
|
||||
func (c *Client) SaveIndexer(in *ent.Indexers) error {
|
||||
func (c *client) SaveIndexer(in *ent.Indexers) error {
|
||||
|
||||
count := c.ent.Indexers.Query().Where(indexers.Name(in.Name)).CountX(context.TODO())
|
||||
|
||||
if count > 0 || in.ID != 0 {
|
||||
if count > 0 {
|
||||
//update setting
|
||||
return c.ent.Indexers.Update().Where(indexers.ID(in.ID)).SetName(in.Name).SetImplementation(in.Implementation).
|
||||
return c.ent.Indexers.Update().Where(indexers.Name(in.Name)).SetName(in.Name).SetImplementation(in.Implementation).
|
||||
SetPriority(in.Priority).SetSeedRatio(in.SeedRatio).SetDisabled(in.Disabled).
|
||||
SetTvSearch(in.TvSearch).SetMovieSearch(in.MovieSearch).SetSettings("").SetSynced(in.Synced).
|
||||
SetAPIKey(in.APIKey).SetURL(in.URL).
|
||||
@@ -288,11 +308,11 @@ func (c *Client) SaveIndexer(in *ent.Indexers) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) DeleteIndexer(id int) {
|
||||
func (c *client) DeleteIndexer(id int) {
|
||||
c.ent.Indexers.Delete().Where(indexers.ID(id)).Exec(context.TODO())
|
||||
}
|
||||
|
||||
func (c *Client) GetIndexer(id int) (*ent.Indexers, error) {
|
||||
func (c *client) GetIndexer(id int) (*ent.Indexers, error) {
|
||||
res, err := c.ent.Indexers.Query().Where(indexers.ID(id)).First(context.TODO())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -300,41 +320,35 @@ func (c *Client) GetIndexer(id int) (*ent.Indexers, error) {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (c *Client) GetAllIndexers() []*ent.Indexers {
|
||||
func (c *client) GetAllIndexers() []*ent.Indexers {
|
||||
res := c.ent.Indexers.Query().Where(indexers.Implementation(IndexerTorznabImpl)).Order(ent.Asc(indexers.FieldID)).AllX(context.TODO())
|
||||
return res
|
||||
}
|
||||
|
||||
func (c *Client) SaveDownloader(downloader *ent.DownloadClients) error {
|
||||
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(downloader.Name)).SetImplementation(downloader.Implementation).
|
||||
SetURL(downloader.URL).SetUser(downloader.User).SetPassword(downloader.Password).SetPriority1(downloader.Priority1).Exec(context.TODO())
|
||||
SetURL(downloader.URL).SetUser(downloader.User).SetUseNatTraversal(downloader.UseNatTraversal).SetPassword(downloader.Password).SetPriority1(downloader.Priority1).Exec(context.TODO())
|
||||
return err
|
||||
}
|
||||
|
||||
_, err := c.ent.DownloadClients.Create().SetEnable(true).SetImplementation(downloader.Implementation).
|
||||
_, err := c.ent.DownloadClients.Create().SetEnable(true).SetImplementation(downloader.Implementation).SetUseNatTraversal(downloader.UseNatTraversal).
|
||||
SetName(downloader.Name).SetURL(downloader.URL).SetUser(downloader.User).SetPriority1(downloader.Priority1).SetPassword(downloader.Password).Save(context.TODO())
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) GetAllDonloadClients() []*ent.DownloadClients {
|
||||
func (c *client) GetAllDonloadClients() []*ent.DownloadClients {
|
||||
cc, err := c.ent.DownloadClients.Query().Order(ent.Asc(downloadclients.FieldPriority1)).All(context.TODO())
|
||||
if err != nil {
|
||||
log.Errorf("no download client")
|
||||
return nil
|
||||
}
|
||||
cc = append(cc, &ent.DownloadClients{
|
||||
Implementation: downloadclients.ImplementationBuildin,
|
||||
Name: "内建下载器",
|
||||
Priority1: 9999,
|
||||
Enable: true,
|
||||
})
|
||||
return cc
|
||||
}
|
||||
|
||||
func (c *Client) DeleteDownloadCLient(id int) {
|
||||
c.ent.DownloadClients.Delete().Where(downloadclients.ID(id)).Exec(context.TODO())
|
||||
func (c *client) DeleteDownloadCLient(id int) { //not delete buildin client
|
||||
c.ent.DownloadClients.Delete().Where(downloadclients.ID(id), downloadclients.ImplementationNEQ(downloadclients.ImplementationBuildin)).Exec(context.TODO())
|
||||
}
|
||||
|
||||
// Storage is the model entity for the Storage schema.
|
||||
@@ -375,12 +389,14 @@ type WebdavSetting struct {
|
||||
ChangeFileHash string `json:"change_file_hash"`
|
||||
}
|
||||
|
||||
func (c *Client) AddStorage(st *StorageInfo) error {
|
||||
if !strings.HasSuffix(st.TvPath, "/") {
|
||||
st.TvPath += "/"
|
||||
}
|
||||
if !strings.HasSuffix(st.MoviePath, "/") {
|
||||
st.MoviePath += "/"
|
||||
func (c *client) AddStorage(st *StorageInfo) error {
|
||||
if st.Implementation != storage.ImplementationLocal.String() { //add seperator if not local storage
|
||||
if !strings.HasSuffix(st.TvPath, "/") {
|
||||
st.TvPath += "/"
|
||||
}
|
||||
if !strings.HasSuffix(st.MoviePath, "/") {
|
||||
st.MoviePath += "/"
|
||||
}
|
||||
}
|
||||
if st.Settings == nil {
|
||||
st.Settings = map[string]string{}
|
||||
@@ -412,7 +428,7 @@ func (c *Client) AddStorage(st *StorageInfo) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) GetAllStorage() []*ent.Storage {
|
||||
func (c *client) GetAllStorage() []*ent.Storage {
|
||||
data, err := c.ent.Storage.Query().Where(storage.Deleted(false)).All(context.TODO())
|
||||
if err != nil {
|
||||
log.Errorf("get storage: %v", err)
|
||||
@@ -434,7 +450,7 @@ func (s *Storage) ToWebDavSetting() WebdavSetting {
|
||||
return webdavSetting
|
||||
}
|
||||
|
||||
func (c *Client) GetStorage(id int) *Storage {
|
||||
func (c *client) GetStorage(id int) *Storage {
|
||||
r, err := c.ent.Storage.Query().Where(storage.ID(id)).First(context.TODO())
|
||||
if err != nil {
|
||||
//use default storage
|
||||
@@ -444,11 +460,11 @@ func (c *Client) GetStorage(id int) *Storage {
|
||||
return &Storage{*r}
|
||||
}
|
||||
|
||||
func (c *Client) DeleteStorage(id int) error {
|
||||
func (c *client) DeleteStorage(id int) error {
|
||||
return c.ent.Storage.Update().Where(storage.ID(id)).SetDeleted(true).Exec(context.TODO())
|
||||
}
|
||||
|
||||
func (c *Client) SetDefaultStorage(id int) error {
|
||||
func (c *client) SetDefaultStorage(id int) error {
|
||||
err := c.ent.Storage.Update().Where(storage.ID(id)).SetDefault(true).Exec(context.TODO())
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -457,7 +473,7 @@ func (c *Client) SetDefaultStorage(id int) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) SetDefaultStorageByName(name string) error {
|
||||
func (c *client) SetDefaultStorageByName(name string) error {
|
||||
err := c.ent.Storage.Update().Where(storage.Name(name)).SetDefault(true).Exec(context.TODO())
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -466,18 +482,18 @@ func (c *Client) SetDefaultStorageByName(name string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) SaveHistoryRecord(h ent.History) (*ent.History, error) {
|
||||
func (c *client) SaveHistoryRecord(h ent.History) (*ent.History, error) {
|
||||
return c.ent.History.Create().SetMediaID(h.MediaID).SetDate(time.Now()).
|
||||
SetStatus(h.Status).SetTargetDir(h.TargetDir).SetSourceTitle(h.SourceTitle).SetIndexerID(h.IndexerID).
|
||||
SetDownloadClientID(h.DownloadClientID).SetSize(h.Size).SetSeasonNum(h.SeasonNum).
|
||||
SetEpisodeNums(h.EpisodeNums).SetHash(h.Hash).SetLink(h.Link).Save(context.TODO())
|
||||
}
|
||||
|
||||
func (c *Client) SetHistoryStatus(id int, status history.Status) error {
|
||||
func (c *client) SetHistoryStatus(id int, status history.Status) error {
|
||||
return c.ent.History.Update().Where(history.ID(id)).SetStatus(status).Exec(context.TODO())
|
||||
}
|
||||
|
||||
func (c *Client) GetHistories() ent.Histories {
|
||||
func (c *client) GetHistories() ent.Histories {
|
||||
h, err := c.ent.History.Query().Order(history.ByID(sql.OrderDesc())).All(context.TODO())
|
||||
if err != nil {
|
||||
return nil
|
||||
@@ -485,7 +501,7 @@ func (c *Client) GetHistories() ent.Histories {
|
||||
return h
|
||||
}
|
||||
|
||||
func (c *Client) GetRunningHistories() 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), history.StatusEQ(history.StatusSeeding))).All(context.TODO())
|
||||
if err != nil {
|
||||
@@ -494,16 +510,16 @@ func (c *Client) GetRunningHistories() ent.Histories {
|
||||
return h
|
||||
}
|
||||
|
||||
func (c *Client) GetHistory(id int) *ent.History {
|
||||
func (c *client) GetHistory(id int) *ent.History {
|
||||
return c.ent.History.Query().Where(history.ID(id)).FirstX(context.TODO())
|
||||
}
|
||||
|
||||
func (c *Client) DeleteHistory(id int) error {
|
||||
err := c.ent.History.Update().Where(history.ID(id)).SetStatus(history.StatusRemoved).Exec(context.Background())
|
||||
func (c *client) DeleteHistory(id int) error {
|
||||
err := c.ent.History.Update().Where(history.ID(id)).SetStatus(history.StatusRemoved).Exec(context.Background())
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) GetDownloadDir() string {
|
||||
func (c *client) GetDownloadDir() string {
|
||||
r, err := c.ent.Settings.Query().Where(settings.Key(SettingDownloadDir)).First(context.TODO())
|
||||
if err != nil {
|
||||
return "/downloads"
|
||||
@@ -511,7 +527,7 @@ func (c *Client) GetDownloadDir() string {
|
||||
return r.Value
|
||||
}
|
||||
|
||||
func (c *Client) UpdateEpisodeStatus(mediaID int, seasonNum, episodeNum int) 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 {
|
||||
@@ -520,37 +536,37 @@ func (c *Client) UpdateEpisodeStatus(mediaID int, seasonNum, episodeNum int) err
|
||||
return ep.Update().SetStatus(episode.StatusDownloaded).Exec(context.TODO())
|
||||
}
|
||||
|
||||
func (c *Client) SetEpisodeStatus(id int, status episode.Status) error {
|
||||
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 {
|
||||
func (c *client) IsEpisodeDownloadingOrDownloaded(id int) bool {
|
||||
ep, _ := c.GetEpisodeByID(id)
|
||||
his := c.ent.History.Query().Where(history.EpisodeNumsNotNil()).AllX(context.Background())
|
||||
his := c.ent.History.Query().Where(history.MediaID(ep.MediaID), history.SeasonNum(ep.SeasonNumber), history.StatusNEQ(history.StatusRemoved), history.StatusNEQ(history.StatusFail)).AllX(context.Background())
|
||||
for _, h := range his {
|
||||
if !slices.Contains(h.EpisodeNums, ep.EpisodeNumber) {
|
||||
continue
|
||||
if len(h.EpisodeNums) == 0 { //season pack download
|
||||
return true
|
||||
}
|
||||
if h.Status != history.StatusFail {
|
||||
if slices.Contains(h.EpisodeNums, ep.EpisodeNumber) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (c *Client) SetSeasonAllEpisodeStatus(mediaID, seasonNum int, status episode.Status) error {
|
||||
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())
|
||||
}
|
||||
|
||||
func (c *Client) TmdbIdInWatchlist(tmdb_id int) bool {
|
||||
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) {
|
||||
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) {
|
||||
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")
|
||||
@@ -562,11 +578,11 @@ func (c *Client) GetMovieDummyEpisode(movieId int) (*ent.Episode, error) {
|
||||
return ep, nil
|
||||
}
|
||||
|
||||
func (c *Client) GetDownloadClient(id int) (*ent.DownloadClients, error) {
|
||||
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 {
|
||||
func (c *client) SetEpisodeMonitoring(id int, b bool) error {
|
||||
return c.ent.Episode.Update().Where(episode.ID(id)).SetMonitored(b).Exec(context.Background())
|
||||
}
|
||||
|
||||
@@ -577,24 +593,24 @@ type EditMediaData struct {
|
||||
Limiter schema.MediaLimiter `json:"limiter"`
|
||||
}
|
||||
|
||||
func (c *Client) EditMediaMetadata(in EditMediaData) error {
|
||||
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 {
|
||||
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) {
|
||||
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) {
|
||||
func (c *client) GetAllImportLists() ([]*ent.ImportList, error) {
|
||||
return c.ent.ImportList.Query().All(context.Background())
|
||||
}
|
||||
|
||||
func (c *Client) AddImportlist(il *ent.ImportList) error {
|
||||
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
|
||||
@@ -608,11 +624,11 @@ func (c *Client) AddImportlist(il *ent.ImportList) error {
|
||||
SetType(il.Type).Exec(context.Background())
|
||||
}
|
||||
|
||||
func (c *Client) DeleteImportlist(id int) error {
|
||||
func (c *client) DeleteImportlist(id int) error {
|
||||
return c.ent.ImportList.DeleteOneID(id).Exec(context.TODO())
|
||||
}
|
||||
|
||||
func (c *Client) GetSizeLimiter(mediaType string) (*MediaSizeLimiter, error) {
|
||||
func (c *client) GetSizeLimiter(mediaType string) (*MediaSizeLimiter, error) {
|
||||
var v string
|
||||
if mediaType == "tv" {
|
||||
v = c.GetSetting(SettingTvSizeLimiter)
|
||||
@@ -631,7 +647,7 @@ func (c *Client) GetSizeLimiter(mediaType string) (*MediaSizeLimiter, error) {
|
||||
return &limiter, err
|
||||
}
|
||||
|
||||
func (c *Client) SetSizeLimiter(mediaType string, limiter *MediaSizeLimiter) error {
|
||||
func (c *client) SetSizeLimiter(mediaType string, limiter *MediaSizeLimiter) error {
|
||||
data, err := json.Marshal(limiter)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -646,7 +662,7 @@ func (c *Client) SetSizeLimiter(mediaType string, limiter *MediaSizeLimiter) err
|
||||
|
||||
}
|
||||
|
||||
func (c *Client) GetTvNamingFormat() string {
|
||||
func (c *client) GetTvNamingFormat() string {
|
||||
s := c.GetSetting(SettingTvNamingFormat)
|
||||
if s == "" {
|
||||
return DefaultNamingFormat
|
||||
@@ -654,7 +670,7 @@ func (c *Client) GetTvNamingFormat() string {
|
||||
return s
|
||||
}
|
||||
|
||||
func (c *Client) GetMovingNamingFormat() string {
|
||||
func (c *client) GetMovingNamingFormat() string {
|
||||
s := c.GetSetting(SettingMovieNamingFormat)
|
||||
if s == "" {
|
||||
return DefaultNamingFormat
|
||||
@@ -662,16 +678,11 @@ func (c *Client) GetMovingNamingFormat() string {
|
||||
return s
|
||||
}
|
||||
|
||||
func (c *Client) CleanAllDanglingEpisodes() error {
|
||||
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) {
|
||||
func (c *client) GetProwlarrSetting() (*ProwlarrSetting, error) {
|
||||
s := c.GetSetting(SettingProwlarrInfo)
|
||||
if s == "" {
|
||||
return nil, errors.New("prowlarr setting not set")
|
||||
@@ -683,7 +694,7 @@ func (c *Client) GetProwlarrSetting() (*ProwlarrSetting, error) {
|
||||
return &se, nil
|
||||
}
|
||||
|
||||
func (c *Client) SaveProwlarrSetting(se *ProwlarrSetting) error {
|
||||
func (c *client) SaveProwlarrSetting(se *ProwlarrSetting) error {
|
||||
data, err := json.Marshal(se)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -691,7 +702,7 @@ func (c *Client) SaveProwlarrSetting(se *ProwlarrSetting) error {
|
||||
return c.SetSetting(SettingProwlarrInfo, string(data))
|
||||
}
|
||||
|
||||
func (c *Client) getAcceptedFormats(key string) ([]string, error) {
|
||||
func (c *client) getAcceptedFormats(key string) ([]string, error) {
|
||||
v := c.GetSetting(key)
|
||||
if v == "" {
|
||||
return nil, nil
|
||||
@@ -702,7 +713,7 @@ func (c *Client) getAcceptedFormats(key string) ([]string, error) {
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (c *Client) setAcceptedFormats(key string, v []string) error {
|
||||
func (c *client) setAcceptedFormats(key string, v []string) error {
|
||||
data, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -710,7 +721,7 @@ func (c *Client) setAcceptedFormats(key string, v []string) error {
|
||||
return c.SetSetting(key, string(data))
|
||||
}
|
||||
|
||||
func (c *Client) GetAcceptedVideoFormats() ([]string, error) {
|
||||
func (c *client) GetAcceptedVideoFormats() ([]string, error) {
|
||||
res, err := c.getAcceptedFormats(SettingAcceptedVideoFormats)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -721,11 +732,11 @@ func (c *Client) GetAcceptedVideoFormats() ([]string, error) {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (c *Client) SetAcceptedVideoFormats(key string, v []string) error {
|
||||
func (c *client) SetAcceptedVideoFormats(key string, v []string) error {
|
||||
return c.setAcceptedFormats(SettingAcceptedVideoFormats, v)
|
||||
}
|
||||
|
||||
func (c *Client) GetAcceptedSubtitleFormats() ([]string, error) {
|
||||
func (c *client) GetAcceptedSubtitleFormats() ([]string, error) {
|
||||
res, err := c.getAcceptedFormats(SettingAcceptedSubtitleFormats)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -736,14 +747,30 @@ func (c *Client) GetAcceptedSubtitleFormats() ([]string, error) {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (c *Client) SetAcceptedSubtitleFormats(key string, v []string) error {
|
||||
func (c *client) SetAcceptedSubtitleFormats(key string, v []string) error {
|
||||
return c.setAcceptedFormats(SettingAcceptedSubtitleFormats, v)
|
||||
}
|
||||
|
||||
func (c *Client) GetTmdbApiKey() string {
|
||||
func (c *client) GetTmdbApiKey() string {
|
||||
k := c.GetSetting(SettingTmdbApiKey)
|
||||
if k == "" {
|
||||
return DefaultTmdbApiKey
|
||||
}
|
||||
return k
|
||||
}
|
||||
|
||||
func (c *client) AddTorrent2Blacklist(hash, name string, mediaId int) error {
|
||||
count := c.ent.Blacklist.Query().Where(blacklist.TorrentHash(hash), blacklist.MediaID(mediaId)).CountX(context.TODO())
|
||||
if count > 0 { //already exist
|
||||
log.Infof("torrent %s already in blacklist", hash)
|
||||
return nil
|
||||
}
|
||||
return c.ent.Blacklist.Create().SetType(blacklist.TypeTorrent).SetTorrentHash(hash).SetTorrentName(name).SetMediaID(mediaId).Exec(context.Background())
|
||||
}
|
||||
|
||||
func (c *client) GetTorrentBlacklist() (ent.Blacklists, error) {
|
||||
return c.ent.Blacklist.Query().Where(blacklist.TypeEQ(blacklist.TypeTorrent)).All(context.Background())
|
||||
}
|
||||
func (c *client) DeleteTorrentBlacklist(id int) error {
|
||||
return c.ent.Blacklist.DeleteOneID(id).Exec(context.Background())
|
||||
}
|
||||
112
internal/db/interface.go
Normal file
112
internal/db/interface.go
Normal file
@@ -0,0 +1,112 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"polaris/ent"
|
||||
"polaris/ent/episode"
|
||||
"polaris/ent/history"
|
||||
"polaris/ent/media"
|
||||
)
|
||||
|
||||
type Database interface {
|
||||
Settings
|
||||
|
||||
MediaApis
|
||||
|
||||
EpisodeApis
|
||||
|
||||
IndexerApis
|
||||
|
||||
HistoryApis
|
||||
|
||||
SaveDownloader(downloader *ent.DownloadClients) error
|
||||
GetAllDonloadClients() []*ent.DownloadClients
|
||||
DeleteDownloadCLient(id int)
|
||||
GetDownloadClient(id int) (*ent.DownloadClients, error)
|
||||
|
||||
AddStorage(st *StorageInfo) error
|
||||
GetAllStorage() []*ent.Storage
|
||||
GetStorage(id int) *Storage
|
||||
DeleteStorage(id int) error
|
||||
SetDefaultStorage(id int) error
|
||||
SetDefaultStorageByName(name string) error
|
||||
|
||||
GetAllImportLists() ([]*ent.ImportList, error)
|
||||
AddImportlist(il *ent.ImportList) error
|
||||
DeleteImportlist(id int) error
|
||||
|
||||
GetAllNotificationClients2() ([]*ent.NotificationClient, error)
|
||||
GetAllNotificationClients() ([]*NotificationClient, error)
|
||||
AddNotificationClient(name, service string, setting string, enabled bool) error
|
||||
DeleteNotificationClient(id int) error
|
||||
GetNotificationClient(id int) (*NotificationClient, error)
|
||||
|
||||
AddTorrent2Blacklist(hash, name string, mediaId int) error
|
||||
GetTorrentBlacklist() (ent.Blacklists, error)
|
||||
DeleteTorrentBlacklist(id int) error
|
||||
}
|
||||
|
||||
type Settings interface {
|
||||
GetSetting(key string) string
|
||||
SetSetting(key, value string) error
|
||||
GetLanguage() string
|
||||
GetDownloadDir() string
|
||||
GetTvNamingFormat() string
|
||||
GetMovingNamingFormat() string
|
||||
GetProwlarrSetting() (*ProwlarrSetting, error)
|
||||
SaveProwlarrSetting(se *ProwlarrSetting) error
|
||||
GetAcceptedVideoFormats() ([]string, error)
|
||||
SetAcceptedVideoFormats(key string, v []string) error
|
||||
GetAcceptedSubtitleFormats() ([]string, error)
|
||||
SetAcceptedSubtitleFormats(key string, v []string) error
|
||||
GetTmdbApiKey() string
|
||||
|
||||
}
|
||||
|
||||
type MediaApis interface {
|
||||
AddMediaWatchlist(m *ent.Media, episodes []int) (*ent.Media, error)
|
||||
GetMediaWatchlist(mediaType media.MediaType) []*ent.Media
|
||||
GetMediaDetails(id int) (*MediaDetails, error)
|
||||
GetMedia(id int) (*ent.Media, error)
|
||||
DeleteMedia(id int) error
|
||||
TmdbIdInWatchlist(tmdb_id int) bool
|
||||
EditMediaMetadata(in EditMediaData) error
|
||||
GetSizeLimiter(mediaType string) (*MediaSizeLimiter, error)
|
||||
SetSizeLimiter(mediaType string, limiter *MediaSizeLimiter) error
|
||||
}
|
||||
|
||||
type EpisodeApis interface {
|
||||
GetEpisode(seriesId, seasonNum, episodeNum int) (*ent.Episode, error)
|
||||
GetEpisodeByID(epID int) (*ent.Episode, error)
|
||||
UpdateEpiode(episodeId int, name, overview string) error
|
||||
UpdateEpiode2(episodeId int, name, overview, airdate string) error
|
||||
SaveEposideDetail(d *ent.Episode) (int, error)
|
||||
SaveEposideDetail2(d *ent.Episode) (int, error)
|
||||
UpdateEpisodeStatus(mediaID int, seasonNum, episodeNum int) error
|
||||
SetEpisodeStatus(id int, status episode.Status) error
|
||||
IsEpisodeDownloadingOrDownloaded(id int) bool
|
||||
SetSeasonAllEpisodeStatus(mediaID, seasonNum int, status episode.Status) error
|
||||
SetEpisodeMonitoring(id int, b bool) error
|
||||
UpdateEpisodeTargetFile(id int, filename string) error
|
||||
GetSeasonEpisodes(mediaId, seasonNum int) ([]*ent.Episode, error)
|
||||
CleanAllDanglingEpisodes() error
|
||||
|
||||
}
|
||||
|
||||
type IndexerApis interface {
|
||||
SaveIndexer(in *ent.Indexers) error
|
||||
DeleteIndexer(id int)
|
||||
GetIndexer(id int) (*ent.Indexers, error)
|
||||
GetAllIndexers() []*ent.Indexers
|
||||
|
||||
}
|
||||
|
||||
type HistoryApis interface {
|
||||
SaveHistoryRecord(h ent.History) (*ent.History, error)
|
||||
SetHistoryStatus(id int, status history.Status) error
|
||||
GetRunningHistories() ent.Histories
|
||||
GetHistory(id int) *ent.History
|
||||
GetHistories() ent.Histories
|
||||
DeleteHistory(id int) error
|
||||
GetDownloadHistory(mediaID int) ([]*ent.History, error)
|
||||
GetMovieDummyEpisode(movieId int) (*ent.Episode, error)
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user