init: create project
This commit is contained in:
commit
a970ad7653
12
.gitignore
vendored
Normal file
12
.gitignore
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
.idea
|
||||
.vscode
|
||||
|
||||
/website/node_modules
|
||||
/website/.eslintcache
|
||||
/website/build
|
||||
/website/.DS_Store
|
||||
/website/.env.local
|
||||
/website/.env.development.local
|
||||
/website/.env.test.local
|
||||
/website/.env.production.local
|
||||
|
22
LICENSE
Normal file
22
LICENSE
Normal file
@ -0,0 +1,22 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 KallyDev
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
166
README.md
Normal file
166
README.md
Normal file
@ -0,0 +1,166 @@
|
||||
# Privacy
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
个人数据泄漏检测网站,适用于近期流传的 40GB+ 数据。
|
||||
|
||||
## 示例截图
|
||||
|
||||

|
||||
|
||||
可以前往预览 [示例网站](https://privacy.kallydev.com/)(暂未部署最新版本)。
|
||||
|
||||
## 使用方法
|
||||
|
||||
### 导入数据
|
||||
|
||||
数据来源于近期流传的 40GB+ 的压缩包,目前已支持 QQ / JD / SF 的多表查询。
|
||||
|
||||
1. 创建 SQLite 数据库
|
||||
|
||||
```bash
|
||||
sqlite3 database.db
|
||||
```
|
||||
|
||||
分别执行以下 SQL 语句,用于创建 QQ / 京东 / 顺丰数据表。
|
||||
|
||||
```sql
|
||||
CREATE TABLE IF NOT EXISTS qq
|
||||
(
|
||||
id BIGINT,
|
||||
qq_number BIGINT,
|
||||
phone_number INT
|
||||
);
|
||||
```
|
||||
|
||||
```sql
|
||||
CREATE TABLE IF NOT EXISTS jd
|
||||
(
|
||||
id BIGINT,
|
||||
name TEXT,
|
||||
nickname TEXT,
|
||||
password TEXT,
|
||||
email TEXT,
|
||||
id_number TEXT,
|
||||
phone_number INT
|
||||
);
|
||||
```
|
||||
|
||||
```sql
|
||||
CREATE TABLE IF NOT EXISTS sf
|
||||
(
|
||||
id BIGINT,
|
||||
name TEXT,
|
||||
phone_number INT,
|
||||
address TEXT
|
||||
);
|
||||
```
|
||||
|
||||
2. 导入 QQ 库
|
||||
|
||||
把 `6.9更新总库.txt` 文件放到 `database` 目录下,然后执行 `qq.py`。
|
||||
|
||||
3.导入京东库
|
||||
|
||||
把 `www_jd_com_12g.txt` 文件放到 `database` 目录下,然后执行 `jd.py`。
|
||||
|
||||
- 创建索引
|
||||
|
||||
```bash
|
||||
sqlite3 database.db
|
||||
```
|
||||
|
||||
```sql
|
||||
CREATE INDEX index_qq ON qq (qq, phone);
|
||||
CREATE INDEX index_jd ON jd (email, id_number, phone_number, phone_number);
|
||||
```
|
||||
|
||||
4. 导入顺丰库
|
||||
|
||||
还没来得及写,欢迎 PR 或者等我明天再写。
|
||||
|
||||
### 编译代码
|
||||
|
||||
1. 安装 Yarn
|
||||
|
||||
```bash
|
||||
npm install -g yarn
|
||||
```
|
||||
|
||||
2. 安装 Golang
|
||||
|
||||
```bash
|
||||
sudo apt install -y snap
|
||||
sudo snap install golang --classic
|
||||
```
|
||||
|
||||
3. 下载源代码
|
||||
|
||||
```bash
|
||||
git clone http://github.com/kallydev/privacy
|
||||
```
|
||||
|
||||
4. 编译前端
|
||||
|
||||
```bash
|
||||
cd privacy
|
||||
yarn install
|
||||
yarn build
|
||||
```
|
||||
|
||||
5. 编译后端
|
||||
|
||||
```bash
|
||||
cd ../server
|
||||
go build -o app main/main.go
|
||||
```
|
||||
|
||||
### 运行
|
||||
|
||||
修改 `config.yaml` 配置文件,然后直接运行后端。
|
||||
|
||||
```bash
|
||||
./app --config config.yaml
|
||||
```
|
||||
|
||||
## TODO
|
||||
|
||||
- [ ] 编译 Docker 镜像
|
||||
- [ ] 取模分表
|
||||
- [ ] 微博账号和手机号关联查询
|
||||
- [ ] 重构所有导入脚本以及编写微博和顺丰的导入脚本
|
||||
- [ ] 自动加载支持的数据表
|
||||
- [ ] 示例网站支持以上新的功能
|
||||
|
||||
## Q&A
|
||||
|
||||
### 1. 为什么代码和文档都写的这么生草?
|
||||
|
||||
我当时只是随口说了一个时间,结果才发现时间安排得有亿点紧,于是就放飞自我了。之后会逐步进行重构,**同时也欢迎发起 PR**。
|
||||
|
||||
### 2. 部署或使用遇到问题如何解决?
|
||||
|
||||
1. 在这个 Repo 发起 Issues,空余时间我会协助你解决。
|
||||
2. 把错误信息粘贴到 `https://stackoverflow.com/search?q=` 这个链接后面,然后浏览器打开。
|
||||
3. 因为个人并不喜欢回复 PM,所以 Telegram 之类问我问题的不太可能会回复。
|
||||
4. 通往罗马的道路千万条慢,自己努力吧少年。
|
||||
|
||||
### 3. 为什么示例网站只支持 QQ 和手机号关系查询?
|
||||
|
||||
示例服务器的硬盘不够,而且这些大文件传输特别麻烦,先搁置一段时间。
|
||||
|
||||
### 4. 为什么导入脚本会提示出现无效数据?
|
||||
|
||||
因为源数据的格式实在是太乱了,存在大量错排。脚本会自动忽略这些解析失败的数据。
|
||||
|
||||
### 5. 为什么不提供数据库文件?
|
||||
|
||||
众所周知传播这些数据属于违法行为,所以这个项目不提供相关数据。
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) KallyDev. All rights reserved.
|
||||
|
||||
Licensed under the [MIT](LICENSE).
|
16
config.yaml
Normal file
16
config.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
database:
|
||||
path: ../database/database.db
|
||||
tables:
|
||||
qq: true
|
||||
jd: true
|
||||
sf: false # Not support
|
||||
wb: false # Not support
|
||||
|
||||
http:
|
||||
host: 0.0.0.0
|
||||
port: 80
|
||||
# tls:
|
||||
# cert_path: server.crt
|
||||
# key_path: server.key
|
||||
|
||||
mask: true
|
BIN
screenshot/screenshot.png
Normal file
BIN
screenshot/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 59 KiB |
25
scripts/database/create_database.sql
Normal file
25
scripts/database/create_database.sql
Normal file
@ -0,0 +1,25 @@
|
||||
CREATE TABLE IF NOT EXISTS qq
|
||||
(
|
||||
id BIGINT,
|
||||
qq_number BIGINT,
|
||||
phone_number INT
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS jd
|
||||
(
|
||||
id BIGINT,
|
||||
name TEXT,
|
||||
nickname TEXT,
|
||||
password TEXT,
|
||||
email TEXT,
|
||||
id_number TEXT,
|
||||
phone_number INT
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS sf
|
||||
(
|
||||
id BIGINT,
|
||||
name TEXT,
|
||||
phone_number INT,
|
||||
address TEXT
|
||||
);
|
3
scripts/database/create_index.sql
Normal file
3
scripts/database/create_index.sql
Normal file
@ -0,0 +1,3 @@
|
||||
CREATE INDEX index_qq ON qq (qq, phone);
|
||||
CREATE INDEX index_jd ON jd (email, id_number, phone_number, phone_number);
|
||||
CREATE INDEX index_sf ON sf (phone_number);
|
111
scripts/jd.py
Normal file
111
scripts/jd.py
Normal file
@ -0,0 +1,111 @@
|
||||
import logging
|
||||
import sqlite3
|
||||
import threading
|
||||
import time
|
||||
|
||||
|
||||
class Converter(object):
|
||||
def __init__(self, database_path, file_path):
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG,
|
||||
format="%(asctime)s %(levelname)s %(message)s",
|
||||
datefmt='%Y-%m-%d %H:%M:%S',
|
||||
)
|
||||
self.logger = logging.getLogger()
|
||||
self.database_connection = None
|
||||
self.database_path = database_path
|
||||
self.file_path = file_path
|
||||
self.file_rows = 0
|
||||
self.handle_total = 0
|
||||
self.handle_invalid = 0
|
||||
self.handle_queue = 0
|
||||
self.cancel_print_insertion_speed = None
|
||||
|
||||
def connect_database(self):
|
||||
self.database_connection = sqlite3.connect(self.database_path)
|
||||
|
||||
def close_database(self):
|
||||
self.database_connection.close()
|
||||
|
||||
def insert(self, id, name, nickname, password, email, id_number, phone_number):
|
||||
cursor = self.database_connection.cursor()
|
||||
try:
|
||||
cursor.execute(
|
||||
"INSERT INTO jd VALUES (?, ?, ?, ?, ?, ?, ?);",
|
||||
(id, name, nickname, password, email, id_number, phone_number)
|
||||
)
|
||||
except sqlite3.IntegrityError:
|
||||
self.handle_invalid += 1
|
||||
finally:
|
||||
self.handle_total += 1
|
||||
self.handle_queue += 1
|
||||
pass
|
||||
|
||||
def start_insertion_speed(self):
|
||||
event = threading.Event()
|
||||
|
||||
def print_insertion_speed():
|
||||
handle_total = self.handle_total
|
||||
while not event.wait(1):
|
||||
if self.handle_total - handle_total == 0:
|
||||
continue
|
||||
self.logger.info("{}/s, {}/{} progress, {} rows are invalid, {} seconds left".format(
|
||||
self.handle_total - handle_total,
|
||||
self.handle_total,
|
||||
self.file_rows,
|
||||
self.handle_invalid,
|
||||
(self.file_rows - self.handle_total) / (self.handle_total - handle_total),
|
||||
))
|
||||
handle_total = self.handle_total
|
||||
|
||||
threading.Thread(target=print_insertion_speed).start()
|
||||
return event.set
|
||||
|
||||
def start(self):
|
||||
# Get the number of file rows
|
||||
self.logger.info("start scanning file lines")
|
||||
start_time = time.time()
|
||||
with open(self.file_path) as file:
|
||||
self.file_rows = 0
|
||||
for _ in file:
|
||||
self.file_rows += 1
|
||||
end_time = time.time()
|
||||
self.logger.info("scan completed, there are a total of {} lines, and it taken {} seconds".format(
|
||||
self.file_rows,
|
||||
end_time - start_time,
|
||||
))
|
||||
# Insert QQ and phone numbers
|
||||
self.connect_database()
|
||||
self.cancel_print_insertion_speed = self.start_insertion_speed()
|
||||
with open(self.file_path) as file:
|
||||
for line in file:
|
||||
try:
|
||||
dataset = line.strip().split("---")
|
||||
name = dataset[0]
|
||||
nickname = dataset[1]
|
||||
password = dataset[2]
|
||||
email = dataset[3]
|
||||
id_number = dataset[4]
|
||||
phone_number = dataset[5]
|
||||
except IndexError:
|
||||
self.handle_invalid += 1
|
||||
pass
|
||||
finally:
|
||||
self.handle_total += 1
|
||||
self.insert(self.handle_total, name, nickname, password, email, id_number, phone_number)
|
||||
if self.handle_queue >= 400000:
|
||||
self.database_connection.commit()
|
||||
self.handle_queue = 0
|
||||
self.database_connection.commit()
|
||||
self.cancel_print_insertion_speed()
|
||||
self.close_database()
|
||||
self.logger.info("completed, insert {} rows, {} rows of invalid data".format(
|
||||
self.handle_total,
|
||||
self.handle_invalid,
|
||||
))
|
||||
exit()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
converter = Converter("database/database.db", "www_jd_com_12g.txt")
|
||||
converter.start()
|
103
scripts/qq.py
Normal file
103
scripts/qq.py
Normal file
@ -0,0 +1,103 @@
|
||||
import logging
|
||||
import sqlite3
|
||||
import threading
|
||||
import time
|
||||
|
||||
|
||||
class Scanner:
|
||||
|
||||
def __init__(self, database_name, file_name):
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG,
|
||||
format="%(asctime)s %(levelname)s %(message)s",
|
||||
datefmt='%Y-%m-%d %H:%M:%S',
|
||||
)
|
||||
self.logger = logging.getLogger()
|
||||
self.database_connection = None
|
||||
self.database_name = database_name
|
||||
self.file_name = file_name
|
||||
self.file_rows = 0
|
||||
self.handle_total = 0
|
||||
self.handle_invalid = 0
|
||||
self.handle_queue = 0
|
||||
self.cancel_print_insertion_speed = None
|
||||
|
||||
def connect_database(self):
|
||||
self.database_connection = sqlite3.connect(self.database_name)
|
||||
|
||||
def close_database(self):
|
||||
self.database_connection.close()
|
||||
|
||||
def insert_qq_and_phone(self, id, qq, phone):
|
||||
cursor = self.database_connection.cursor()
|
||||
try:
|
||||
cursor.execute("INSERT INTO qq VALUES (?, ?, ?);", (id, qq, phone))
|
||||
except sqlite3.IntegrityError:
|
||||
self.handle_invalid += 1
|
||||
finally:
|
||||
self.handle_total += 1
|
||||
self.handle_queue += 1
|
||||
|
||||
def start_insertion_speed(self):
|
||||
event = threading.Event()
|
||||
|
||||
def print_insertion_speed():
|
||||
handle_total = self.handle_total
|
||||
while not event.wait(1):
|
||||
if self.handle_total - handle_total == 0:
|
||||
continue
|
||||
self.logger.info("{}/s, {}/{} progress, {} rows are invalid, {} seconds left".format(
|
||||
self.handle_total - handle_total,
|
||||
self.handle_total,
|
||||
self.file_rows,
|
||||
self.handle_invalid,
|
||||
(self.file_rows - self.handle_total) / (self.handle_total - handle_total),
|
||||
))
|
||||
handle_total = self.handle_total
|
||||
|
||||
threading.Thread(target=print_insertion_speed).start()
|
||||
return event.set
|
||||
|
||||
def start(self):
|
||||
# Get the number of file rows
|
||||
self.logger.info("start scanning file lines")
|
||||
start_time = time.time()
|
||||
with open(self.file_name) as file:
|
||||
self.file_rows = 0
|
||||
for _ in file:
|
||||
self.file_rows += 1
|
||||
end_time = time.time()
|
||||
self.logger.info("scan completed, there are a total of {} lines, and it taken {} seconds".format(
|
||||
self.file_rows,
|
||||
end_time - start_time,
|
||||
))
|
||||
# Insert QQ and phone numbers
|
||||
self.connect_database()
|
||||
self.cancel_print_insertion_speed = self.start_insertion_speed()
|
||||
with open(self.file_name) as file:
|
||||
for line in file:
|
||||
line = line.strip()
|
||||
data = line.split("----")
|
||||
if len(data) < 2:
|
||||
self.handle_invalid += 1
|
||||
self.handle_total += 1
|
||||
continue
|
||||
phone = data[-1]
|
||||
for qq in data[:-1]:
|
||||
self.insert_qq_and_phone(self.handle_total, qq, phone)
|
||||
if self.handle_queue >= 400000:
|
||||
self.database_connection.commit()
|
||||
self.handle_queue = 0
|
||||
self.database_connection.commit()
|
||||
self.cancel_print_insertion_speed()
|
||||
self.close_database()
|
||||
self.logger.info("completed, insert {} rows, {} rows of invalid data".format(
|
||||
self.handle_total,
|
||||
self.handle_invalid,
|
||||
))
|
||||
exit()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
scanner = Scanner("8E.db", "6.9更新总库.txt")
|
||||
scanner.start()
|
48
server/config/config.go
Normal file
48
server/config/config.go
Normal file
@ -0,0 +1,48 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"gopkg.in/yaml.v3"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Database *DatabaseConfig `yaml:"database"`
|
||||
HttpConfig *HttpConfig `yaml:"http"`
|
||||
Mask bool `yaml:"mask"`
|
||||
}
|
||||
|
||||
type DatabaseConfig struct {
|
||||
Path string `yaml:"path"`
|
||||
Tables *TablesConfig `yaml:"tables"`
|
||||
}
|
||||
|
||||
type TablesConfig struct {
|
||||
QQ bool `yaml:"qq"`
|
||||
JD bool `yaml:"jd"`
|
||||
SF bool `yaml:"sf"`
|
||||
}
|
||||
|
||||
type HttpConfig struct {
|
||||
Host string `yaml:"host"`
|
||||
Port uint16 `yaml:"port"`
|
||||
TLS *TLSConfig `yaml:"tls"`
|
||||
}
|
||||
|
||||
type TLSConfig struct {
|
||||
CertPath string `yaml:"cert_path"`
|
||||
KeyPath string `yaml:"key_path"`
|
||||
}
|
||||
|
||||
func NewConfig(configPath string) (*Config, error) {
|
||||
data, err := ioutil.ReadFile(configPath)
|
||||
if err != nil {
|
||||
return nil, errors.New(fmt.Sprintf("failed to read config file: %s", err))
|
||||
}
|
||||
config := new(Config)
|
||||
if err = yaml.Unmarshal(data, config); err != nil {
|
||||
return nil, errors.New(fmt.Sprintf("failed to parse config file: %s", err))
|
||||
}
|
||||
return config, nil
|
||||
}
|
21
server/database/database.go
Normal file
21
server/database/database.go
Normal file
@ -0,0 +1,21 @@
|
||||
package database
|
||||
|
||||
import "context"
|
||||
|
||||
type Database interface {
|
||||
QueryByQQNumber(ctx context.Context, qqNumber int64) ([]Model, error)
|
||||
QueryByEmail(ctx context.Context, email string) ([]Model, error)
|
||||
QueryByIDNumber(ctx context.Context, idNumber string) ([]Model, error)
|
||||
QueryByPhoneNumber(ctx context.Context, phoneNumber int64) ([]Model, error)
|
||||
}
|
||||
|
||||
type Model interface {
|
||||
GetName() (name string, valid bool)
|
||||
GetNickname() (nickname string, valid bool)
|
||||
GetPassword() (password string, valid bool)
|
||||
GetEmail() (email string, valid bool)
|
||||
GetQQNumber() (qqNumber int64, valid bool)
|
||||
GetIDNumber() (idNumber string, valid bool)
|
||||
GetPhoneNumber() (phoneNumber int64, valid bool)
|
||||
GetAddress() (address string, valid bool)
|
||||
}
|
129
server/database/table/jd.go
Normal file
129
server/database/table/jd.go
Normal file
@ -0,0 +1,129 @@
|
||||
package table
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"github.com/kallydev/privacy/database"
|
||||
"github.com/kallydev/privacy/ent"
|
||||
"github.com/kallydev/privacy/ent/jdmodel"
|
||||
)
|
||||
|
||||
var (
|
||||
_ database.Database = &JDDatabase{}
|
||||
_ database.Model = &JDModel{}
|
||||
)
|
||||
|
||||
type JDDatabase struct {
|
||||
Client *ent.Client
|
||||
}
|
||||
|
||||
func (db *JDDatabase) QueryByQQNumber(ctx context.Context, qqNumber int64) ([]database.Model, error) {
|
||||
return []database.Model{}, nil
|
||||
}
|
||||
|
||||
func (db *JDDatabase) QueryByEmail(ctx context.Context, email string) ([]database.Model, error) {
|
||||
models, err := db.Client.JDModel.
|
||||
Query().
|
||||
Where(jdmodel.EmailEQ(email)).
|
||||
All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return entModelsToJDModels(models), nil
|
||||
}
|
||||
|
||||
func (db *JDDatabase) QueryByIDNumber(ctx context.Context, idNumber string) ([]database.Model, error) {
|
||||
models, err := db.Client.JDModel.
|
||||
Query().
|
||||
Where(jdmodel.IDNumberEQ(idNumber)).
|
||||
All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return entModelsToJDModels(models), nil
|
||||
}
|
||||
|
||||
func (db *JDDatabase) QueryByPhoneNumber(ctx context.Context, phoneNumber int64) ([]database.Model, error) {
|
||||
models, err := db.Client.JDModel.
|
||||
Query().
|
||||
Where(jdmodel.PhoneNumberEQ(phoneNumber)).
|
||||
All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return entModelsToJDModels(models), nil
|
||||
}
|
||||
|
||||
type JDModel struct {
|
||||
Name sql.NullString
|
||||
Nickname sql.NullString
|
||||
Password sql.NullString
|
||||
Email sql.NullString
|
||||
IDNumber sql.NullString
|
||||
PhoneNumber sql.NullInt64
|
||||
}
|
||||
|
||||
func (model *JDModel) GetName() (name string, valid bool) {
|
||||
return model.Name.String, model.Name.Valid
|
||||
}
|
||||
|
||||
func (model *JDModel) GetNickname() (nickname string, valid bool) {
|
||||
return model.Nickname.String, model.Nickname.Valid
|
||||
}
|
||||
|
||||
func (model *JDModel) GetPassword() (password string, valid bool) {
|
||||
return model.Password.String, model.Password.Valid
|
||||
}
|
||||
|
||||
func (model *JDModel) GetEmail() (email string, valid bool) {
|
||||
return model.Email.String, model.Email.Valid
|
||||
}
|
||||
|
||||
func (model *JDModel) GetQQNumber() (qqNumber int64, valid bool) {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
func (model *JDModel) GetIDNumber() (idNumber string, valid bool) {
|
||||
return model.IDNumber.String, model.IDNumber.Valid
|
||||
}
|
||||
|
||||
func (model *JDModel) GetPhoneNumber() (phoneNumber int64, valid bool) {
|
||||
return model.PhoneNumber.Int64, model.PhoneNumber.Valid
|
||||
}
|
||||
|
||||
func (model *JDModel) GetAddress() (address string, valid bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
func entModelsToJDModels(endModels []*ent.JDModel) []database.Model {
|
||||
models := make([]database.Model, len(endModels))
|
||||
for i, model := range endModels {
|
||||
models[i] = &JDModel{
|
||||
Name: sql.NullString{
|
||||
String: model.Name,
|
||||
Valid: model.Name != "",
|
||||
},
|
||||
Nickname: sql.NullString{
|
||||
String: model.Nickname,
|
||||
Valid: model.Nickname != "",
|
||||
},
|
||||
Password: sql.NullString{
|
||||
String: model.Password,
|
||||
Valid: model.Password != "",
|
||||
},
|
||||
Email: sql.NullString{
|
||||
String: model.Email,
|
||||
Valid: model.Email != "",
|
||||
},
|
||||
IDNumber: sql.NullString{
|
||||
String: model.IDNumber,
|
||||
Valid: model.IDNumber != "",
|
||||
},
|
||||
PhoneNumber: sql.NullInt64{
|
||||
Int64: model.PhoneNumber,
|
||||
Valid: model.PhoneNumber != 0,
|
||||
},
|
||||
}
|
||||
}
|
||||
return models
|
||||
}
|
102
server/database/table/qq.go
Normal file
102
server/database/table/qq.go
Normal file
@ -0,0 +1,102 @@
|
||||
package table
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"github.com/kallydev/privacy/database"
|
||||
"github.com/kallydev/privacy/ent"
|
||||
"github.com/kallydev/privacy/ent/qqmodel"
|
||||
)
|
||||
|
||||
var (
|
||||
_ database.Database = &QQDatabase{}
|
||||
_ database.Model = &QQModel{}
|
||||
)
|
||||
|
||||
type QQDatabase struct {
|
||||
Client *ent.Client
|
||||
}
|
||||
|
||||
func (db *QQDatabase) QueryByQQNumber(ctx context.Context, qqNumber int64) ([]database.Model, error) {
|
||||
models, err := db.Client.QQModel.
|
||||
Query().
|
||||
Where(qqmodel.QqNumberEQ(qqNumber)).
|
||||
All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return entModelsToQQModels(models), nil
|
||||
}
|
||||
|
||||
func (db *QQDatabase) QueryByEmail(ctx context.Context, email string) ([]database.Model, error) {
|
||||
return []database.Model{}, nil
|
||||
}
|
||||
|
||||
func (db *QQDatabase) QueryByIDNumber(ctx context.Context, idNumber string) ([]database.Model, error) {
|
||||
return []database.Model{}, nil
|
||||
}
|
||||
|
||||
func (db *QQDatabase) QueryByPhoneNumber(ctx context.Context, phoneNumber int64) ([]database.Model, error) {
|
||||
models, err := db.Client.QQModel.
|
||||
Query().
|
||||
Where(qqmodel.PhoneNumberEQ(phoneNumber)).
|
||||
All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return entModelsToQQModels(models), nil
|
||||
}
|
||||
|
||||
type QQModel struct {
|
||||
QQNumber sql.NullInt64
|
||||
PhoneNumber sql.NullInt64
|
||||
}
|
||||
|
||||
func (model *QQModel) GetName() (name string, valid bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
func (model *QQModel) GetNickname() (nickname string, valid bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
func (model *QQModel) GetPassword() (password string, valid bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
func (model *QQModel) GetEmail() (email string, valid bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
func (model *QQModel) GetQQNumber() (qqNumber int64, valid bool) {
|
||||
return model.QQNumber.Int64, model.QQNumber.Valid
|
||||
}
|
||||
|
||||
func (model *QQModel) GetIDNumber() (idNumber string, valid bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
func (model *QQModel) GetPhoneNumber() (phoneNumber int64, valid bool) {
|
||||
return model.PhoneNumber.Int64, model.PhoneNumber.Valid
|
||||
}
|
||||
|
||||
func (model *QQModel) GetAddress() (address string, valid bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
func entModelsToQQModels(endModels []*ent.QQModel) []database.Model {
|
||||
models := make([]database.Model, len(endModels))
|
||||
for i, model := range endModels {
|
||||
models[i] = &QQModel{
|
||||
QQNumber: sql.NullInt64{
|
||||
Int64: model.QqNumber,
|
||||
Valid: model.QqNumber != 0,
|
||||
},
|
||||
PhoneNumber: sql.NullInt64{
|
||||
Int64: model.PhoneNumber,
|
||||
Valid: model.PhoneNumber != 0,
|
||||
},
|
||||
}
|
||||
}
|
||||
return models
|
||||
}
|
100
server/database/table/sf.go
Normal file
100
server/database/table/sf.go
Normal file
@ -0,0 +1,100 @@
|
||||
package table
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"github.com/kallydev/privacy/database"
|
||||
"github.com/kallydev/privacy/ent"
|
||||
"github.com/kallydev/privacy/ent/sfmodel"
|
||||
)
|
||||
|
||||
var (
|
||||
_ database.Database = &SFDatabase{}
|
||||
_ database.Model = &SFModel{}
|
||||
)
|
||||
|
||||
type SFDatabase struct {
|
||||
Client *ent.Client
|
||||
}
|
||||
|
||||
func (db *SFDatabase) QueryByQQNumber(ctx context.Context, qqNumber int64) ([]database.Model, error) {
|
||||
return []database.Model{}, nil
|
||||
}
|
||||
|
||||
func (db *SFDatabase) QueryByEmail(ctx context.Context, email string) ([]database.Model, error) {
|
||||
return []database.Model{}, nil
|
||||
}
|
||||
|
||||
func (db *SFDatabase) QueryByIDNumber(ctx context.Context, idNumber string) ([]database.Model, error) {
|
||||
return []database.Model{}, nil
|
||||
}
|
||||
|
||||
func (db *SFDatabase) QueryByPhoneNumber(ctx context.Context, phoneNumber int64) ([]database.Model, error) {
|
||||
models, err := db.Client.SFModel.
|
||||
Query().
|
||||
Where(sfmodel.PhoneNumberEQ(phoneNumber)).
|
||||
All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return entModelsToSFModels(models), nil
|
||||
}
|
||||
|
||||
type SFModel struct {
|
||||
Name sql.NullString
|
||||
PhoneNumber sql.NullInt64
|
||||
Address sql.NullString
|
||||
}
|
||||
|
||||
func (model *SFModel) GetName() (name string, valid bool) {
|
||||
return model.Name.String, model.Name.Valid
|
||||
}
|
||||
|
||||
func (model *SFModel) GetNickname() (nickname string, valid bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
func (model *SFModel) GetPassword() (password string, valid bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
func (model *SFModel) GetEmail() (email string, valid bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
func (model *SFModel) GetQQNumber() (qqNumber int64, valid bool) {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
func (model *SFModel) GetIDNumber() (idNumber string, valid bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
func (model *SFModel) GetPhoneNumber() (phoneNumber int64, valid bool) {
|
||||
return model.PhoneNumber.Int64, model.PhoneNumber.Valid
|
||||
}
|
||||
|
||||
func (model *SFModel) GetAddress() (address string, valid bool) {
|
||||
return model.Address.String, model.Address.Valid
|
||||
}
|
||||
|
||||
func entModelsToSFModels(endModels []*ent.SFModel) []database.Model {
|
||||
models := make([]database.Model, len(endModels))
|
||||
for i, model := range endModels {
|
||||
models[i] = &SFModel{
|
||||
Name: sql.NullString{
|
||||
String: model.Name,
|
||||
Valid: model.Name != "",
|
||||
},
|
||||
PhoneNumber: sql.NullInt64{
|
||||
Int64: model.PhoneNumber,
|
||||
Valid: model.PhoneNumber != 0,
|
||||
},
|
||||
Address: sql.NullString{
|
||||
String: model.Address,
|
||||
Valid: model.Name != "",
|
||||
},
|
||||
}
|
||||
}
|
||||
return models
|
||||
}
|
395
server/ent/client.go
Normal file
395
server/ent/client.go
Normal file
@ -0,0 +1,395 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/kallydev/privacy/ent/migrate"
|
||||
|
||||
"github.com/kallydev/privacy/ent/jdmodel"
|
||||
"github.com/kallydev/privacy/ent/qqmodel"
|
||||
"github.com/kallydev/privacy/ent/sfmodel"
|
||||
|
||||
"github.com/facebook/ent/dialect"
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// Client is the client that holds all ent builders.
|
||||
type Client struct {
|
||||
config
|
||||
// Schema is the client for creating, migrating and dropping schema.
|
||||
Schema *migrate.Schema
|
||||
// JDModel is the client for interacting with the JDModel builders.
|
||||
JDModel *JDModelClient
|
||||
// QQModel is the client for interacting with the QQModel builders.
|
||||
QQModel *QQModelClient
|
||||
// SFModel is the client for interacting with the SFModel builders.
|
||||
SFModel *SFModelClient
|
||||
}
|
||||
|
||||
// NewClient creates a new client configured with the given options.
|
||||
func NewClient(opts ...Option) *Client {
|
||||
cfg := config{log: log.Println, hooks: &hooks{}}
|
||||
cfg.options(opts...)
|
||||
client := &Client{config: cfg}
|
||||
client.init()
|
||||
return client
|
||||
}
|
||||
|
||||
func (c *Client) init() {
|
||||
c.Schema = migrate.NewSchema(c.driver)
|
||||
c.JDModel = NewJDModelClient(c.config)
|
||||
c.QQModel = NewQQModelClient(c.config)
|
||||
c.SFModel = NewSFModelClient(c.config)
|
||||
}
|
||||
|
||||
// Open opens a database/sql.DB specified by the driver name and
|
||||
// the data source name, and returns a new client attached to it.
|
||||
// Optional parameters can be added for configuring the client.
|
||||
func Open(driverName, dataSourceName string, options ...Option) (*Client, error) {
|
||||
switch driverName {
|
||||
case dialect.MySQL, dialect.Postgres, dialect.SQLite:
|
||||
drv, err := sql.Open(driverName, dataSourceName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewClient(append(options, Driver(drv))...), nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported driver: %q", driverName)
|
||||
}
|
||||
}
|
||||
|
||||
// Tx returns a new transactional client. The provided context
|
||||
// is used until the transaction is committed or rolled back.
|
||||
func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
||||
if _, ok := c.driver.(*txDriver); ok {
|
||||
return nil, fmt.Errorf("ent: cannot start a transaction within a transaction")
|
||||
}
|
||||
tx, err := newTx(ctx, c.driver)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("ent: starting a transaction: %v", err)
|
||||
}
|
||||
cfg := config{driver: tx, log: c.log, debug: c.debug, hooks: c.hooks}
|
||||
return &Tx{
|
||||
ctx: ctx,
|
||||
config: cfg,
|
||||
JDModel: NewJDModelClient(cfg),
|
||||
QQModel: NewQQModelClient(cfg),
|
||||
SFModel: NewSFModelClient(cfg),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// BeginTx returns a transactional client with options.
|
||||
func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
|
||||
if _, ok := c.driver.(*txDriver); ok {
|
||||
return nil, fmt.Errorf("ent: cannot start a transaction within a transaction")
|
||||
}
|
||||
tx, err := c.driver.(*sql.Driver).BeginTx(ctx, opts)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("ent: starting a transaction: %v", err)
|
||||
}
|
||||
cfg := config{driver: &txDriver{tx: tx, drv: c.driver}, log: c.log, debug: c.debug, hooks: c.hooks}
|
||||
return &Tx{
|
||||
config: cfg,
|
||||
JDModel: NewJDModelClient(cfg),
|
||||
QQModel: NewQQModelClient(cfg),
|
||||
SFModel: NewSFModelClient(cfg),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Debug returns a new debug-client. It's used to get verbose logging on specific operations.
|
||||
//
|
||||
// client.Debug().
|
||||
// JDModel.
|
||||
// Query().
|
||||
// Count(ctx)
|
||||
//
|
||||
func (c *Client) Debug() *Client {
|
||||
if c.debug {
|
||||
return c
|
||||
}
|
||||
cfg := config{driver: dialect.Debug(c.driver, c.log), log: c.log, debug: true, hooks: c.hooks}
|
||||
client := &Client{config: cfg}
|
||||
client.init()
|
||||
return client
|
||||
}
|
||||
|
||||
// Close closes the database connection and prevents new queries from starting.
|
||||
func (c *Client) Close() error {
|
||||
return c.driver.Close()
|
||||
}
|
||||
|
||||
// Use adds the mutation hooks to all the entity clients.
|
||||
// In order to add hooks to a specific client, call: `client.Node.Use(...)`.
|
||||
func (c *Client) Use(hooks ...Hook) {
|
||||
c.JDModel.Use(hooks...)
|
||||
c.QQModel.Use(hooks...)
|
||||
c.SFModel.Use(hooks...)
|
||||
}
|
||||
|
||||
// JDModelClient is a client for the JDModel schema.
|
||||
type JDModelClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewJDModelClient returns a client for the JDModel from the given config.
|
||||
func NewJDModelClient(c config) *JDModelClient {
|
||||
return &JDModelClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `jdmodel.Hooks(f(g(h())))`.
|
||||
func (c *JDModelClient) Use(hooks ...Hook) {
|
||||
c.hooks.JDModel = append(c.hooks.JDModel, hooks...)
|
||||
}
|
||||
|
||||
// Create returns a create builder for JDModel.
|
||||
func (c *JDModelClient) Create() *JDModelCreate {
|
||||
mutation := newJDModelMutation(c.config, OpCreate)
|
||||
return &JDModelCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// BulkCreate returns a builder for creating a bulk of JDModel entities.
|
||||
func (c *JDModelClient) CreateBulk(builders ...*JDModelCreate) *JDModelCreateBulk {
|
||||
return &JDModelCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for JDModel.
|
||||
func (c *JDModelClient) Update() *JDModelUpdate {
|
||||
mutation := newJDModelMutation(c.config, OpUpdate)
|
||||
return &JDModelUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *JDModelClient) UpdateOne(jm *JDModel) *JDModelUpdateOne {
|
||||
mutation := newJDModelMutation(c.config, OpUpdateOne, withJDModel(jm))
|
||||
return &JDModelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *JDModelClient) UpdateOneID(id int) *JDModelUpdateOne {
|
||||
mutation := newJDModelMutation(c.config, OpUpdateOne, withJDModelID(id))
|
||||
return &JDModelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for JDModel.
|
||||
func (c *JDModelClient) Delete() *JDModelDelete {
|
||||
mutation := newJDModelMutation(c.config, OpDelete)
|
||||
return &JDModelDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a delete builder for the given entity.
|
||||
func (c *JDModelClient) DeleteOne(jm *JDModel) *JDModelDeleteOne {
|
||||
return c.DeleteOneID(jm.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a delete builder for the given id.
|
||||
func (c *JDModelClient) DeleteOneID(id int) *JDModelDeleteOne {
|
||||
builder := c.Delete().Where(jdmodel.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &JDModelDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for JDModel.
|
||||
func (c *JDModelClient) Query() *JDModelQuery {
|
||||
return &JDModelQuery{config: c.config}
|
||||
}
|
||||
|
||||
// Get returns a JDModel entity by its id.
|
||||
func (c *JDModelClient) Get(ctx context.Context, id int) (*JDModel, error) {
|
||||
return c.Query().Where(jdmodel.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *JDModelClient) GetX(ctx context.Context, id int) *JDModel {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *JDModelClient) Hooks() []Hook {
|
||||
return c.hooks.JDModel
|
||||
}
|
||||
|
||||
// QQModelClient is a client for the QQModel schema.
|
||||
type QQModelClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewQQModelClient returns a client for the QQModel from the given config.
|
||||
func NewQQModelClient(c config) *QQModelClient {
|
||||
return &QQModelClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `qqmodel.Hooks(f(g(h())))`.
|
||||
func (c *QQModelClient) Use(hooks ...Hook) {
|
||||
c.hooks.QQModel = append(c.hooks.QQModel, hooks...)
|
||||
}
|
||||
|
||||
// Create returns a create builder for QQModel.
|
||||
func (c *QQModelClient) Create() *QQModelCreate {
|
||||
mutation := newQQModelMutation(c.config, OpCreate)
|
||||
return &QQModelCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// BulkCreate returns a builder for creating a bulk of QQModel entities.
|
||||
func (c *QQModelClient) CreateBulk(builders ...*QQModelCreate) *QQModelCreateBulk {
|
||||
return &QQModelCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for QQModel.
|
||||
func (c *QQModelClient) Update() *QQModelUpdate {
|
||||
mutation := newQQModelMutation(c.config, OpUpdate)
|
||||
return &QQModelUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *QQModelClient) UpdateOne(qm *QQModel) *QQModelUpdateOne {
|
||||
mutation := newQQModelMutation(c.config, OpUpdateOne, withQQModel(qm))
|
||||
return &QQModelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *QQModelClient) UpdateOneID(id int) *QQModelUpdateOne {
|
||||
mutation := newQQModelMutation(c.config, OpUpdateOne, withQQModelID(id))
|
||||
return &QQModelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for QQModel.
|
||||
func (c *QQModelClient) Delete() *QQModelDelete {
|
||||
mutation := newQQModelMutation(c.config, OpDelete)
|
||||
return &QQModelDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a delete builder for the given entity.
|
||||
func (c *QQModelClient) DeleteOne(qm *QQModel) *QQModelDeleteOne {
|
||||
return c.DeleteOneID(qm.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a delete builder for the given id.
|
||||
func (c *QQModelClient) DeleteOneID(id int) *QQModelDeleteOne {
|
||||
builder := c.Delete().Where(qqmodel.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &QQModelDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for QQModel.
|
||||
func (c *QQModelClient) Query() *QQModelQuery {
|
||||
return &QQModelQuery{config: c.config}
|
||||
}
|
||||
|
||||
// Get returns a QQModel entity by its id.
|
||||
func (c *QQModelClient) Get(ctx context.Context, id int) (*QQModel, error) {
|
||||
return c.Query().Where(qqmodel.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *QQModelClient) GetX(ctx context.Context, id int) *QQModel {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *QQModelClient) Hooks() []Hook {
|
||||
return c.hooks.QQModel
|
||||
}
|
||||
|
||||
// SFModelClient is a client for the SFModel schema.
|
||||
type SFModelClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewSFModelClient returns a client for the SFModel from the given config.
|
||||
func NewSFModelClient(c config) *SFModelClient {
|
||||
return &SFModelClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `sfmodel.Hooks(f(g(h())))`.
|
||||
func (c *SFModelClient) Use(hooks ...Hook) {
|
||||
c.hooks.SFModel = append(c.hooks.SFModel, hooks...)
|
||||
}
|
||||
|
||||
// Create returns a create builder for SFModel.
|
||||
func (c *SFModelClient) Create() *SFModelCreate {
|
||||
mutation := newSFModelMutation(c.config, OpCreate)
|
||||
return &SFModelCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// BulkCreate returns a builder for creating a bulk of SFModel entities.
|
||||
func (c *SFModelClient) CreateBulk(builders ...*SFModelCreate) *SFModelCreateBulk {
|
||||
return &SFModelCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for SFModel.
|
||||
func (c *SFModelClient) Update() *SFModelUpdate {
|
||||
mutation := newSFModelMutation(c.config, OpUpdate)
|
||||
return &SFModelUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *SFModelClient) UpdateOne(sm *SFModel) *SFModelUpdateOne {
|
||||
mutation := newSFModelMutation(c.config, OpUpdateOne, withSFModel(sm))
|
||||
return &SFModelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *SFModelClient) UpdateOneID(id int) *SFModelUpdateOne {
|
||||
mutation := newSFModelMutation(c.config, OpUpdateOne, withSFModelID(id))
|
||||
return &SFModelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for SFModel.
|
||||
func (c *SFModelClient) Delete() *SFModelDelete {
|
||||
mutation := newSFModelMutation(c.config, OpDelete)
|
||||
return &SFModelDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a delete builder for the given entity.
|
||||
func (c *SFModelClient) DeleteOne(sm *SFModel) *SFModelDeleteOne {
|
||||
return c.DeleteOneID(sm.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a delete builder for the given id.
|
||||
func (c *SFModelClient) DeleteOneID(id int) *SFModelDeleteOne {
|
||||
builder := c.Delete().Where(sfmodel.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &SFModelDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for SFModel.
|
||||
func (c *SFModelClient) Query() *SFModelQuery {
|
||||
return &SFModelQuery{config: c.config}
|
||||
}
|
||||
|
||||
// Get returns a SFModel entity by its id.
|
||||
func (c *SFModelClient) Get(ctx context.Context, id int) (*SFModel, error) {
|
||||
return c.Query().Where(sfmodel.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *SFModelClient) GetX(ctx context.Context, id int) *SFModel {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *SFModelClient) Hooks() []Hook {
|
||||
return c.hooks.SFModel
|
||||
}
|
61
server/ent/config.go
Normal file
61
server/ent/config.go
Normal file
@ -0,0 +1,61 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"github.com/facebook/ent"
|
||||
"github.com/facebook/ent/dialect"
|
||||
)
|
||||
|
||||
// Option function to configure the client.
|
||||
type Option func(*config)
|
||||
|
||||
// Config is the configuration for the client and its builder.
|
||||
type config struct {
|
||||
// driver used for executing database requests.
|
||||
driver dialect.Driver
|
||||
// debug enable a debug logging.
|
||||
debug bool
|
||||
// log used for logging on debug mode.
|
||||
log func(...interface{})
|
||||
// hooks to execute on mutations.
|
||||
hooks *hooks
|
||||
}
|
||||
|
||||
// hooks per client, for fast access.
|
||||
type hooks struct {
|
||||
JDModel []ent.Hook
|
||||
QQModel []ent.Hook
|
||||
SFModel []ent.Hook
|
||||
}
|
||||
|
||||
// Options applies the options on the config object.
|
||||
func (c *config) options(opts ...Option) {
|
||||
for _, opt := range opts {
|
||||
opt(c)
|
||||
}
|
||||
if c.debug {
|
||||
c.driver = dialect.Debug(c.driver, c.log)
|
||||
}
|
||||
}
|
||||
|
||||
// Debug enables debug logging on the ent.Driver.
|
||||
func Debug() Option {
|
||||
return func(c *config) {
|
||||
c.debug = true
|
||||
}
|
||||
}
|
||||
|
||||
// Log sets the logging function for debug mode.
|
||||
func Log(fn func(...interface{})) Option {
|
||||
return func(c *config) {
|
||||
c.log = fn
|
||||
}
|
||||
}
|
||||
|
||||
// Driver configures the client driver.
|
||||
func Driver(driver dialect.Driver) Option {
|
||||
return func(c *config) {
|
||||
c.driver = driver
|
||||
}
|
||||
}
|
33
server/ent/context.go
Normal file
33
server/ent/context.go
Normal file
@ -0,0 +1,33 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type clientCtxKey struct{}
|
||||
|
||||
// FromContext returns the Client stored in a context, or nil if there isn't one.
|
||||
func FromContext(ctx context.Context) *Client {
|
||||
c, _ := ctx.Value(clientCtxKey{}).(*Client)
|
||||
return c
|
||||
}
|
||||
|
||||
// NewContext returns a new context with the given Client attached.
|
||||
func NewContext(parent context.Context, c *Client) context.Context {
|
||||
return context.WithValue(parent, clientCtxKey{}, c)
|
||||
}
|
||||
|
||||
type txCtxKey struct{}
|
||||
|
||||
// TxFromContext returns the Tx stored in a context, or nil if there isn't one.
|
||||
func TxFromContext(ctx context.Context) *Tx {
|
||||
tx, _ := ctx.Value(txCtxKey{}).(*Tx)
|
||||
return tx
|
||||
}
|
||||
|
||||
// NewTxContext returns a new context with the given Client attached.
|
||||
func NewTxContext(parent context.Context, tx *Tx) context.Context {
|
||||
return context.WithValue(parent, txCtxKey{}, tx)
|
||||
}
|
270
server/ent/ent.go
Normal file
270
server/ent/ent.go
Normal file
@ -0,0 +1,270 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/facebook/ent"
|
||||
"github.com/facebook/ent/dialect"
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
// ent aliases to avoid import conflict in user's code.
|
||||
type (
|
||||
Op = ent.Op
|
||||
Hook = ent.Hook
|
||||
Value = ent.Value
|
||||
Query = ent.Query
|
||||
Policy = ent.Policy
|
||||
Mutator = ent.Mutator
|
||||
Mutation = ent.Mutation
|
||||
MutateFunc = ent.MutateFunc
|
||||
)
|
||||
|
||||
// OrderFunc applies an ordering on the sql selector.
|
||||
type OrderFunc func(*sql.Selector, func(string) bool)
|
||||
|
||||
// Asc applies the given fields in ASC order.
|
||||
func Asc(fields ...string) OrderFunc {
|
||||
return func(s *sql.Selector, check func(string) bool) {
|
||||
for _, f := range fields {
|
||||
if check(f) {
|
||||
s.OrderBy(sql.Asc(f))
|
||||
} else {
|
||||
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("invalid field %q for ordering", f)})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Desc applies the given fields in DESC order.
|
||||
func Desc(fields ...string) OrderFunc {
|
||||
return func(s *sql.Selector, check func(string) bool) {
|
||||
for _, f := range fields {
|
||||
if check(f) {
|
||||
s.OrderBy(sql.Desc(f))
|
||||
} else {
|
||||
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("invalid field %q for ordering", f)})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AggregateFunc applies an aggregation step on the group-by traversal/selector.
|
||||
type AggregateFunc func(*sql.Selector, func(string) bool) string
|
||||
|
||||
// As is a pseudo aggregation function for renaming another other functions with custom names. For example:
|
||||
//
|
||||
// GroupBy(field1, field2).
|
||||
// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func As(fn AggregateFunc, end string) AggregateFunc {
|
||||
return func(s *sql.Selector, check func(string) bool) string {
|
||||
return sql.As(fn(s, check), end)
|
||||
}
|
||||
}
|
||||
|
||||
// Count applies the "count" aggregation function on each group.
|
||||
func Count() AggregateFunc {
|
||||
return func(s *sql.Selector, _ func(string) bool) string {
|
||||
return sql.Count("*")
|
||||
}
|
||||
}
|
||||
|
||||
// Max applies the "max" aggregation function on the given field of each group.
|
||||
func Max(field string) AggregateFunc {
|
||||
return func(s *sql.Selector, check func(string) bool) string {
|
||||
if !check(field) {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("invalid field %q for grouping", field)})
|
||||
return ""
|
||||
}
|
||||
return sql.Max(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// Mean applies the "mean" aggregation function on the given field of each group.
|
||||
func Mean(field string) AggregateFunc {
|
||||
return func(s *sql.Selector, check func(string) bool) string {
|
||||
if !check(field) {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("invalid field %q for grouping", field)})
|
||||
return ""
|
||||
}
|
||||
return sql.Avg(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// Min applies the "min" aggregation function on the given field of each group.
|
||||
func Min(field string) AggregateFunc {
|
||||
return func(s *sql.Selector, check func(string) bool) string {
|
||||
if !check(field) {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("invalid field %q for grouping", field)})
|
||||
return ""
|
||||
}
|
||||
return sql.Min(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// Sum applies the "sum" aggregation function on the given field of each group.
|
||||
func Sum(field string) AggregateFunc {
|
||||
return func(s *sql.Selector, check func(string) bool) string {
|
||||
if !check(field) {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("invalid field %q for grouping", field)})
|
||||
return ""
|
||||
}
|
||||
return sql.Sum(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// ValidationError returns when validating a field fails.
|
||||
type ValidationError struct {
|
||||
Name string // Field or edge name.
|
||||
err error
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e *ValidationError) Error() string {
|
||||
return e.err.Error()
|
||||
}
|
||||
|
||||
// Unwrap implements the errors.Wrapper interface.
|
||||
func (e *ValidationError) Unwrap() error {
|
||||
return e.err
|
||||
}
|
||||
|
||||
// IsValidationError returns a boolean indicating whether the error is a validaton error.
|
||||
func IsValidationError(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *ValidationError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// NotFoundError returns when trying to fetch a specific entity and it was not found in the database.
|
||||
type NotFoundError struct {
|
||||
label string
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e *NotFoundError) Error() string {
|
||||
return "ent: " + e.label + " not found"
|
||||
}
|
||||
|
||||
// IsNotFound returns a boolean indicating whether the error is a not found error.
|
||||
func IsNotFound(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *NotFoundError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// MaskNotFound masks not found error.
|
||||
func MaskNotFound(err error) error {
|
||||
if IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// NotSingularError returns when trying to fetch a singular entity and more then one was found in the database.
|
||||
type NotSingularError struct {
|
||||
label string
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e *NotSingularError) Error() string {
|
||||
return "ent: " + e.label + " not singular"
|
||||
}
|
||||
|
||||
// IsNotSingular returns a boolean indicating whether the error is a not singular error.
|
||||
func IsNotSingular(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *NotSingularError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// NotLoadedError returns when trying to get a node that was not loaded by the query.
|
||||
type NotLoadedError struct {
|
||||
edge string
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e *NotLoadedError) Error() string {
|
||||
return "ent: " + e.edge + " edge was not loaded"
|
||||
}
|
||||
|
||||
// IsNotLoaded returns a boolean indicating whether the error is a not loaded error.
|
||||
func IsNotLoaded(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *NotLoadedError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// ConstraintError returns when trying to create/update one or more entities and
|
||||
// one or more of their constraints failed. For example, violation of edge or
|
||||
// field uniqueness.
|
||||
type ConstraintError struct {
|
||||
msg string
|
||||
wrap error
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e ConstraintError) Error() string {
|
||||
return "ent: constraint failed: " + e.msg
|
||||
}
|
||||
|
||||
// Unwrap implements the errors.Wrapper interface.
|
||||
func (e *ConstraintError) Unwrap() error {
|
||||
return e.wrap
|
||||
}
|
||||
|
||||
// IsConstraintError returns a boolean indicating whether the error is a constraint failure.
|
||||
func IsConstraintError(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *ConstraintError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
func isSQLConstraintError(err error) (*ConstraintError, bool) {
|
||||
var (
|
||||
msg = err.Error()
|
||||
// error format per dialect.
|
||||
errors = [...]string{
|
||||
"Error 1062", // MySQL 1062 error (ER_DUP_ENTRY).
|
||||
"UNIQUE constraint failed", // SQLite.
|
||||
"duplicate key value violates unique constraint", // PostgreSQL.
|
||||
}
|
||||
)
|
||||
if _, ok := err.(*sqlgraph.ConstraintError); ok {
|
||||
return &ConstraintError{msg, err}, true
|
||||
}
|
||||
for i := range errors {
|
||||
if strings.Contains(msg, errors[i]) {
|
||||
return &ConstraintError{msg, err}, true
|
||||
}
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// rollback calls to tx.Rollback and wraps the given error with the rollback error if occurred.
|
||||
func rollback(tx dialect.Tx, err error) error {
|
||||
if rerr := tx.Rollback(); rerr != nil {
|
||||
err = fmt.Errorf("%s: %v", err.Error(), rerr)
|
||||
}
|
||||
if err, ok := isSQLConstraintError(err); ok {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
78
server/ent/enttest/enttest.go
Normal file
78
server/ent/enttest/enttest.go
Normal file
@ -0,0 +1,78 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package enttest
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/kallydev/privacy/ent"
|
||||
// required by schema hooks.
|
||||
_ "github.com/kallydev/privacy/ent/runtime"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql/schema"
|
||||
)
|
||||
|
||||
type (
|
||||
// TestingT is the interface that is shared between
|
||||
// testing.T and testing.B and used by enttest.
|
||||
TestingT interface {
|
||||
FailNow()
|
||||
Error(...interface{})
|
||||
}
|
||||
|
||||
// Option configures client creation.
|
||||
Option func(*options)
|
||||
|
||||
options struct {
|
||||
opts []ent.Option
|
||||
migrateOpts []schema.MigrateOption
|
||||
}
|
||||
)
|
||||
|
||||
// WithOptions forwards options to client creation.
|
||||
func WithOptions(opts ...ent.Option) Option {
|
||||
return func(o *options) {
|
||||
o.opts = append(o.opts, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// WithMigrateOptions forwards options to auto migration.
|
||||
func WithMigrateOptions(opts ...schema.MigrateOption) Option {
|
||||
return func(o *options) {
|
||||
o.migrateOpts = append(o.migrateOpts, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
func newOptions(opts []Option) *options {
|
||||
o := &options{}
|
||||
for _, opt := range opts {
|
||||
opt(o)
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// Open calls ent.Open and auto-run migration.
|
||||
func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client {
|
||||
o := newOptions(opts)
|
||||
c, err := ent.Open(driverName, dataSourceName, o.opts...)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.FailNow()
|
||||
}
|
||||
if err := c.Schema.Create(context.Background(), o.migrateOpts...); err != nil {
|
||||
t.Error(err)
|
||||
t.FailNow()
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
// NewClient calls ent.NewClient and auto-run migration.
|
||||
func NewClient(t TestingT, opts ...Option) *ent.Client {
|
||||
o := newOptions(opts)
|
||||
c := ent.NewClient(o.opts...)
|
||||
if err := c.Schema.Create(context.Background(), o.migrateOpts...); err != nil {
|
||||
t.Error(err)
|
||||
t.FailNow()
|
||||
}
|
||||
return c
|
||||
}
|
3
server/ent/generate.go
Normal file
3
server/ent/generate.go
Normal file
@ -0,0 +1,3 @@
|
||||
package ent
|
||||
|
||||
//go:generate go run github.com/facebook/ent/cmd/entc generate ./schema
|
230
server/ent/hook/hook.go
Normal file
230
server/ent/hook/hook.go
Normal file
@ -0,0 +1,230 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package hook
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/kallydev/privacy/ent"
|
||||
)
|
||||
|
||||
// The JDModelFunc type is an adapter to allow the use of ordinary
|
||||
// function as JDModel mutator.
|
||||
type JDModelFunc func(context.Context, *ent.JDModelMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f JDModelFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
mv, ok := m.(*ent.JDModelMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.JDModelMutation", m)
|
||||
}
|
||||
return f(ctx, mv)
|
||||
}
|
||||
|
||||
// The QQModelFunc type is an adapter to allow the use of ordinary
|
||||
// function as QQModel mutator.
|
||||
type QQModelFunc func(context.Context, *ent.QQModelMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f QQModelFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
mv, ok := m.(*ent.QQModelMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.QQModelMutation", m)
|
||||
}
|
||||
return f(ctx, mv)
|
||||
}
|
||||
|
||||
// The SFModelFunc type is an adapter to allow the use of ordinary
|
||||
// function as SFModel mutator.
|
||||
type SFModelFunc func(context.Context, *ent.SFModelMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f SFModelFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
mv, ok := m.(*ent.SFModelMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SFModelMutation", m)
|
||||
}
|
||||
return f(ctx, mv)
|
||||
}
|
||||
|
||||
// Condition is a hook condition function.
|
||||
type Condition func(context.Context, ent.Mutation) bool
|
||||
|
||||
// And groups conditions with the AND operator.
|
||||
func And(first, second Condition, rest ...Condition) Condition {
|
||||
return func(ctx context.Context, m ent.Mutation) bool {
|
||||
if !first(ctx, m) || !second(ctx, m) {
|
||||
return false
|
||||
}
|
||||
for _, cond := range rest {
|
||||
if !cond(ctx, m) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// Or groups conditions with the OR operator.
|
||||
func Or(first, second Condition, rest ...Condition) Condition {
|
||||
return func(ctx context.Context, m ent.Mutation) bool {
|
||||
if first(ctx, m) || second(ctx, m) {
|
||||
return true
|
||||
}
|
||||
for _, cond := range rest {
|
||||
if cond(ctx, m) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Not negates a given condition.
|
||||
func Not(cond Condition) Condition {
|
||||
return func(ctx context.Context, m ent.Mutation) bool {
|
||||
return !cond(ctx, m)
|
||||
}
|
||||
}
|
||||
|
||||
// HasOp is a condition testing mutation operation.
|
||||
func HasOp(op ent.Op) Condition {
|
||||
return func(_ context.Context, m ent.Mutation) bool {
|
||||
return m.Op().Is(op)
|
||||
}
|
||||
}
|
||||
|
||||
// HasAddedFields is a condition validating `.AddedField` on fields.
|
||||
func HasAddedFields(field string, fields ...string) Condition {
|
||||
return func(_ context.Context, m ent.Mutation) bool {
|
||||
if _, exists := m.AddedField(field); !exists {
|
||||
return false
|
||||
}
|
||||
for _, field := range fields {
|
||||
if _, exists := m.AddedField(field); !exists {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// HasClearedFields is a condition validating `.FieldCleared` on fields.
|
||||
func HasClearedFields(field string, fields ...string) Condition {
|
||||
return func(_ context.Context, m ent.Mutation) bool {
|
||||
if exists := m.FieldCleared(field); !exists {
|
||||
return false
|
||||
}
|
||||
for _, field := range fields {
|
||||
if exists := m.FieldCleared(field); !exists {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// HasFields is a condition validating `.Field` on fields.
|
||||
func HasFields(field string, fields ...string) Condition {
|
||||
return func(_ context.Context, m ent.Mutation) bool {
|
||||
if _, exists := m.Field(field); !exists {
|
||||
return false
|
||||
}
|
||||
for _, field := range fields {
|
||||
if _, exists := m.Field(field); !exists {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// If executes the given hook under condition.
|
||||
//
|
||||
// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))
|
||||
//
|
||||
func If(hk ent.Hook, cond Condition) ent.Hook {
|
||||
return func(next ent.Mutator) ent.Mutator {
|
||||
return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if cond(ctx, m) {
|
||||
return hk(next).Mutate(ctx, m)
|
||||
}
|
||||
return next.Mutate(ctx, m)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// On executes the given hook only for the given operation.
|
||||
//
|
||||
// hook.On(Log, ent.Delete|ent.Create)
|
||||
//
|
||||
func On(hk ent.Hook, op ent.Op) ent.Hook {
|
||||
return If(hk, HasOp(op))
|
||||
}
|
||||
|
||||
// Unless skips the given hook only for the given operation.
|
||||
//
|
||||
// hook.Unless(Log, ent.Update|ent.UpdateOne)
|
||||
//
|
||||
func Unless(hk ent.Hook, op ent.Op) ent.Hook {
|
||||
return If(hk, Not(HasOp(op)))
|
||||
}
|
||||
|
||||
// FixedError is a hook returning a fixed error.
|
||||
func FixedError(err error) ent.Hook {
|
||||
return func(ent.Mutator) ent.Mutator {
|
||||
return ent.MutateFunc(func(context.Context, ent.Mutation) (ent.Value, error) {
|
||||
return nil, err
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Reject returns a hook that rejects all operations that match op.
|
||||
//
|
||||
// func (T) Hooks() []ent.Hook {
|
||||
// return []ent.Hook{
|
||||
// Reject(ent.Delete|ent.Update),
|
||||
// }
|
||||
// }
|
||||
//
|
||||
func Reject(op ent.Op) ent.Hook {
|
||||
hk := FixedError(fmt.Errorf("%s operation is not allowed", op))
|
||||
return On(hk, op)
|
||||
}
|
||||
|
||||
// Chain acts as a list of hooks and is effectively immutable.
|
||||
// Once created, it will always hold the same set of hooks in the same order.
|
||||
type Chain struct {
|
||||
hooks []ent.Hook
|
||||
}
|
||||
|
||||
// NewChain creates a new chain of hooks.
|
||||
func NewChain(hooks ...ent.Hook) Chain {
|
||||
return Chain{append([]ent.Hook(nil), hooks...)}
|
||||
}
|
||||
|
||||
// Hook chains the list of hooks and returns the final hook.
|
||||
func (c Chain) Hook() ent.Hook {
|
||||
return func(mutator ent.Mutator) ent.Mutator {
|
||||
for i := len(c.hooks) - 1; i >= 0; i-- {
|
||||
mutator = c.hooks[i](mutator)
|
||||
}
|
||||
return mutator
|
||||
}
|
||||
}
|
||||
|
||||
// Append extends a chain, adding the specified hook
|
||||
// as the last ones in the mutation flow.
|
||||
func (c Chain) Append(hooks ...ent.Hook) Chain {
|
||||
newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks))
|
||||
newHooks = append(newHooks, c.hooks...)
|
||||
newHooks = append(newHooks, hooks...)
|
||||
return Chain{newHooks}
|
||||
}
|
||||
|
||||
// Extend extends a chain, adding the specified chain
|
||||
// as the last ones in the mutation flow.
|
||||
func (c Chain) Extend(chain Chain) Chain {
|
||||
return c.Append(chain.hooks...)
|
||||
}
|
136
server/ent/jdmodel.go
Normal file
136
server/ent/jdmodel.go
Normal file
@ -0,0 +1,136 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/kallydev/privacy/ent/jdmodel"
|
||||
)
|
||||
|
||||
// JDModel is the model entity for the JDModel schema.
|
||||
type JDModel struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// Name holds the value of the "name" field.
|
||||
Name string `json:"name,omitempty"`
|
||||
// Nickname holds the value of the "nickname" field.
|
||||
Nickname string `json:"nickname,omitempty"`
|
||||
// Password holds the value of the "password" field.
|
||||
Password string `json:"password,omitempty"`
|
||||
// Email holds the value of the "email" field.
|
||||
Email string `json:"email,omitempty"`
|
||||
// IDNumber holds the value of the "id_number" field.
|
||||
IDNumber string `json:"id_number,omitempty"`
|
||||
// PhoneNumber holds the value of the "phone_number" field.
|
||||
PhoneNumber int64 `json:"phone_number,omitempty"`
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*JDModel) scanValues() []interface{} {
|
||||
return []interface{}{
|
||||
&sql.NullInt64{}, // id
|
||||
&sql.NullString{}, // name
|
||||
&sql.NullString{}, // nickname
|
||||
&sql.NullString{}, // password
|
||||
&sql.NullString{}, // email
|
||||
&sql.NullString{}, // id_number
|
||||
&sql.NullInt64{}, // phone_number
|
||||
}
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the JDModel fields.
|
||||
func (jm *JDModel) assignValues(values ...interface{}) error {
|
||||
if m, n := len(values), len(jdmodel.Columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
value, ok := values[0].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
jm.ID = int(value.Int64)
|
||||
values = values[1:]
|
||||
if value, ok := values[0].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[0])
|
||||
} else if value.Valid {
|
||||
jm.Name = value.String
|
||||
}
|
||||
if value, ok := values[1].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field nickname", values[1])
|
||||
} else if value.Valid {
|
||||
jm.Nickname = value.String
|
||||
}
|
||||
if value, ok := values[2].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field password", values[2])
|
||||
} else if value.Valid {
|
||||
jm.Password = value.String
|
||||
}
|
||||
if value, ok := values[3].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field email", values[3])
|
||||
} else if value.Valid {
|
||||
jm.Email = value.String
|
||||
}
|
||||
if value, ok := values[4].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id_number", values[4])
|
||||
} else if value.Valid {
|
||||
jm.IDNumber = value.String
|
||||
}
|
||||
if value, ok := values[5].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field phone_number", values[5])
|
||||
} else if value.Valid {
|
||||
jm.PhoneNumber = value.Int64
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this JDModel.
|
||||
// Note that, you need to call JDModel.Unwrap() before calling this method, if this JDModel
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (jm *JDModel) Update() *JDModelUpdateOne {
|
||||
return (&JDModelClient{config: jm.config}).UpdateOne(jm)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the entity that was returned from a transaction after it was closed,
|
||||
// so that all next queries will be executed through the driver which created the transaction.
|
||||
func (jm *JDModel) Unwrap() *JDModel {
|
||||
tx, ok := jm.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: JDModel is not a transactional entity")
|
||||
}
|
||||
jm.config.driver = tx.drv
|
||||
return jm
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (jm *JDModel) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("JDModel(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v", jm.ID))
|
||||
builder.WriteString(", name=")
|
||||
builder.WriteString(jm.Name)
|
||||
builder.WriteString(", nickname=")
|
||||
builder.WriteString(jm.Nickname)
|
||||
builder.WriteString(", password=")
|
||||
builder.WriteString(jm.Password)
|
||||
builder.WriteString(", email=")
|
||||
builder.WriteString(jm.Email)
|
||||
builder.WriteString(", id_number=")
|
||||
builder.WriteString(jm.IDNumber)
|
||||
builder.WriteString(", phone_number=")
|
||||
builder.WriteString(fmt.Sprintf("%v", jm.PhoneNumber))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// JDModels is a parsable slice of JDModel.
|
||||
type JDModels []*JDModel
|
||||
|
||||
func (jm JDModels) config(cfg config) {
|
||||
for _i := range jm {
|
||||
jm[_i].config = cfg
|
||||
}
|
||||
}
|
46
server/ent/jdmodel/jdmodel.go
Normal file
46
server/ent/jdmodel/jdmodel.go
Normal file
@ -0,0 +1,46 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package jdmodel
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the jdmodel type in the database.
|
||||
Label = "jd_model"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldName holds the string denoting the name field in the database.
|
||||
FieldName = "name"
|
||||
// FieldNickname holds the string denoting the nickname field in the database.
|
||||
FieldNickname = "nickname"
|
||||
// FieldPassword holds the string denoting the password field in the database.
|
||||
FieldPassword = "password"
|
||||
// FieldEmail holds the string denoting the email field in the database.
|
||||
FieldEmail = "email"
|
||||
// FieldIDNumber holds the string denoting the id_number field in the database.
|
||||
FieldIDNumber = "id_number"
|
||||
// FieldPhoneNumber holds the string denoting the phone_number field in the database.
|
||||
FieldPhoneNumber = "phone_number"
|
||||
|
||||
// Table holds the table name of the jdmodel in the database.
|
||||
Table = "jd"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for jdmodel fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldName,
|
||||
FieldNickname,
|
||||
FieldPassword,
|
||||
FieldEmail,
|
||||
FieldIDNumber,
|
||||
FieldPhoneNumber,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
796
server/ent/jdmodel/where.go
Normal file
796
server/ent/jdmodel/where.go
Normal file
@ -0,0 +1,796 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package jdmodel
|
||||
|
||||
import (
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/kallydev/privacy/ent/predicate"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their identifier.
|
||||
func ID(id int) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
|
||||
func Name(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// Nickname applies equality check predicate on the "nickname" field. It's identical to NicknameEQ.
|
||||
func Nickname(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldNickname), v))
|
||||
})
|
||||
}
|
||||
|
||||
// Password applies equality check predicate on the "password" field. It's identical to PasswordEQ.
|
||||
func Password(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldPassword), v))
|
||||
})
|
||||
}
|
||||
|
||||
// Email applies equality check predicate on the "email" field. It's identical to EmailEQ.
|
||||
func Email(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldEmail), v))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNumber applies equality check predicate on the "id_number" field. It's identical to IDNumberEQ.
|
||||
func IDNumber(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldIDNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumber applies equality check predicate on the "phone_number" field. It's identical to PhoneNumberEQ.
|
||||
func PhoneNumber(v int64) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldPhoneNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameEQ applies the EQ predicate on the "name" field.
|
||||
func NameEQ(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameNEQ applies the NEQ predicate on the "name" field.
|
||||
func NameNEQ(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameIn applies the In predicate on the "name" field.
|
||||
func NameIn(vs ...string) predicate.JDModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldName), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// NameNotIn applies the NotIn predicate on the "name" field.
|
||||
func NameNotIn(vs ...string) predicate.JDModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldName), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// NameGT applies the GT predicate on the "name" field.
|
||||
func NameGT(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameGTE applies the GTE predicate on the "name" field.
|
||||
func NameGTE(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameLT applies the LT predicate on the "name" field.
|
||||
func NameLT(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameLTE applies the LTE predicate on the "name" field.
|
||||
func NameLTE(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameContains applies the Contains predicate on the "name" field.
|
||||
func NameContains(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.Contains(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
|
||||
func NameHasPrefix(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.HasPrefix(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
|
||||
func NameHasSuffix(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.HasSuffix(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameEqualFold applies the EqualFold predicate on the "name" field.
|
||||
func NameEqualFold(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EqualFold(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameContainsFold applies the ContainsFold predicate on the "name" field.
|
||||
func NameContainsFold(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.ContainsFold(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NicknameEQ applies the EQ predicate on the "nickname" field.
|
||||
func NicknameEQ(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldNickname), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NicknameNEQ applies the NEQ predicate on the "nickname" field.
|
||||
func NicknameNEQ(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldNickname), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NicknameIn applies the In predicate on the "nickname" field.
|
||||
func NicknameIn(vs ...string) predicate.JDModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldNickname), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// NicknameNotIn applies the NotIn predicate on the "nickname" field.
|
||||
func NicknameNotIn(vs ...string) predicate.JDModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldNickname), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// NicknameGT applies the GT predicate on the "nickname" field.
|
||||
func NicknameGT(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldNickname), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NicknameGTE applies the GTE predicate on the "nickname" field.
|
||||
func NicknameGTE(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldNickname), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NicknameLT applies the LT predicate on the "nickname" field.
|
||||
func NicknameLT(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldNickname), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NicknameLTE applies the LTE predicate on the "nickname" field.
|
||||
func NicknameLTE(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldNickname), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NicknameContains applies the Contains predicate on the "nickname" field.
|
||||
func NicknameContains(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.Contains(s.C(FieldNickname), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NicknameHasPrefix applies the HasPrefix predicate on the "nickname" field.
|
||||
func NicknameHasPrefix(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.HasPrefix(s.C(FieldNickname), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NicknameHasSuffix applies the HasSuffix predicate on the "nickname" field.
|
||||
func NicknameHasSuffix(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.HasSuffix(s.C(FieldNickname), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NicknameEqualFold applies the EqualFold predicate on the "nickname" field.
|
||||
func NicknameEqualFold(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EqualFold(s.C(FieldNickname), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NicknameContainsFold applies the ContainsFold predicate on the "nickname" field.
|
||||
func NicknameContainsFold(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.ContainsFold(s.C(FieldNickname), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PasswordEQ applies the EQ predicate on the "password" field.
|
||||
func PasswordEQ(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldPassword), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PasswordNEQ applies the NEQ predicate on the "password" field.
|
||||
func PasswordNEQ(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldPassword), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PasswordIn applies the In predicate on the "password" field.
|
||||
func PasswordIn(vs ...string) predicate.JDModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldPassword), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// PasswordNotIn applies the NotIn predicate on the "password" field.
|
||||
func PasswordNotIn(vs ...string) predicate.JDModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldPassword), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// PasswordGT applies the GT predicate on the "password" field.
|
||||
func PasswordGT(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldPassword), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PasswordGTE applies the GTE predicate on the "password" field.
|
||||
func PasswordGTE(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldPassword), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PasswordLT applies the LT predicate on the "password" field.
|
||||
func PasswordLT(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldPassword), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PasswordLTE applies the LTE predicate on the "password" field.
|
||||
func PasswordLTE(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldPassword), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PasswordContains applies the Contains predicate on the "password" field.
|
||||
func PasswordContains(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.Contains(s.C(FieldPassword), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PasswordHasPrefix applies the HasPrefix predicate on the "password" field.
|
||||
func PasswordHasPrefix(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.HasPrefix(s.C(FieldPassword), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PasswordHasSuffix applies the HasSuffix predicate on the "password" field.
|
||||
func PasswordHasSuffix(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.HasSuffix(s.C(FieldPassword), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PasswordEqualFold applies the EqualFold predicate on the "password" field.
|
||||
func PasswordEqualFold(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EqualFold(s.C(FieldPassword), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PasswordContainsFold applies the ContainsFold predicate on the "password" field.
|
||||
func PasswordContainsFold(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.ContainsFold(s.C(FieldPassword), v))
|
||||
})
|
||||
}
|
||||
|
||||
// EmailEQ applies the EQ predicate on the "email" field.
|
||||
func EmailEQ(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldEmail), v))
|
||||
})
|
||||
}
|
||||
|
||||
// EmailNEQ applies the NEQ predicate on the "email" field.
|
||||
func EmailNEQ(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldEmail), v))
|
||||
})
|
||||
}
|
||||
|
||||
// EmailIn applies the In predicate on the "email" field.
|
||||
func EmailIn(vs ...string) predicate.JDModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldEmail), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// EmailNotIn applies the NotIn predicate on the "email" field.
|
||||
func EmailNotIn(vs ...string) predicate.JDModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldEmail), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// EmailGT applies the GT predicate on the "email" field.
|
||||
func EmailGT(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldEmail), v))
|
||||
})
|
||||
}
|
||||
|
||||
// EmailGTE applies the GTE predicate on the "email" field.
|
||||
func EmailGTE(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldEmail), v))
|
||||
})
|
||||
}
|
||||
|
||||
// EmailLT applies the LT predicate on the "email" field.
|
||||
func EmailLT(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldEmail), v))
|
||||
})
|
||||
}
|
||||
|
||||
// EmailLTE applies the LTE predicate on the "email" field.
|
||||
func EmailLTE(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldEmail), v))
|
||||
})
|
||||
}
|
||||
|
||||
// EmailContains applies the Contains predicate on the "email" field.
|
||||
func EmailContains(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.Contains(s.C(FieldEmail), v))
|
||||
})
|
||||
}
|
||||
|
||||
// EmailHasPrefix applies the HasPrefix predicate on the "email" field.
|
||||
func EmailHasPrefix(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.HasPrefix(s.C(FieldEmail), v))
|
||||
})
|
||||
}
|
||||
|
||||
// EmailHasSuffix applies the HasSuffix predicate on the "email" field.
|
||||
func EmailHasSuffix(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.HasSuffix(s.C(FieldEmail), v))
|
||||
})
|
||||
}
|
||||
|
||||
// EmailEqualFold applies the EqualFold predicate on the "email" field.
|
||||
func EmailEqualFold(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EqualFold(s.C(FieldEmail), v))
|
||||
})
|
||||
}
|
||||
|
||||
// EmailContainsFold applies the ContainsFold predicate on the "email" field.
|
||||
func EmailContainsFold(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.ContainsFold(s.C(FieldEmail), v))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNumberEQ applies the EQ predicate on the "id_number" field.
|
||||
func IDNumberEQ(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldIDNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNumberNEQ applies the NEQ predicate on the "id_number" field.
|
||||
func IDNumberNEQ(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldIDNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNumberIn applies the In predicate on the "id_number" field.
|
||||
func IDNumberIn(vs ...string) predicate.JDModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldIDNumber), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNumberNotIn applies the NotIn predicate on the "id_number" field.
|
||||
func IDNumberNotIn(vs ...string) predicate.JDModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldIDNumber), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNumberGT applies the GT predicate on the "id_number" field.
|
||||
func IDNumberGT(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldIDNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNumberGTE applies the GTE predicate on the "id_number" field.
|
||||
func IDNumberGTE(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldIDNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNumberLT applies the LT predicate on the "id_number" field.
|
||||
func IDNumberLT(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldIDNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNumberLTE applies the LTE predicate on the "id_number" field.
|
||||
func IDNumberLTE(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldIDNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNumberContains applies the Contains predicate on the "id_number" field.
|
||||
func IDNumberContains(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.Contains(s.C(FieldIDNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNumberHasPrefix applies the HasPrefix predicate on the "id_number" field.
|
||||
func IDNumberHasPrefix(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.HasPrefix(s.C(FieldIDNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNumberHasSuffix applies the HasSuffix predicate on the "id_number" field.
|
||||
func IDNumberHasSuffix(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.HasSuffix(s.C(FieldIDNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNumberEqualFold applies the EqualFold predicate on the "id_number" field.
|
||||
func IDNumberEqualFold(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EqualFold(s.C(FieldIDNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNumberContainsFold applies the ContainsFold predicate on the "id_number" field.
|
||||
func IDNumberContainsFold(v string) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.ContainsFold(s.C(FieldIDNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberEQ applies the EQ predicate on the "phone_number" field.
|
||||
func PhoneNumberEQ(v int64) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldPhoneNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberNEQ applies the NEQ predicate on the "phone_number" field.
|
||||
func PhoneNumberNEQ(v int64) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldPhoneNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberIn applies the In predicate on the "phone_number" field.
|
||||
func PhoneNumberIn(vs ...int64) predicate.JDModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldPhoneNumber), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberNotIn applies the NotIn predicate on the "phone_number" field.
|
||||
func PhoneNumberNotIn(vs ...int64) predicate.JDModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldPhoneNumber), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberGT applies the GT predicate on the "phone_number" field.
|
||||
func PhoneNumberGT(v int64) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldPhoneNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberGTE applies the GTE predicate on the "phone_number" field.
|
||||
func PhoneNumberGTE(v int64) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldPhoneNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberLT applies the LT predicate on the "phone_number" field.
|
||||
func PhoneNumberLT(v int64) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldPhoneNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberLTE applies the LTE predicate on the "phone_number" field.
|
||||
func PhoneNumberLTE(v int64) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldPhoneNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// And groups list of predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.JDModel) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for _, p := range predicates {
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
}
|
||||
|
||||
// Or groups list of predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.JDModel) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for i, p := range predicates {
|
||||
if i > 0 {
|
||||
s1.Or()
|
||||
}
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.JDModel) predicate.JDModel {
|
||||
return predicate.JDModel(func(s *sql.Selector) {
|
||||
p(s.Not())
|
||||
})
|
||||
}
|
269
server/ent/jdmodel_create.go
Normal file
269
server/ent/jdmodel_create.go
Normal file
@ -0,0 +1,269 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/kallydev/privacy/ent/jdmodel"
|
||||
)
|
||||
|
||||
// JDModelCreate is the builder for creating a JDModel entity.
|
||||
type JDModelCreate struct {
|
||||
config
|
||||
mutation *JDModelMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetName sets the name field.
|
||||
func (jmc *JDModelCreate) SetName(s string) *JDModelCreate {
|
||||
jmc.mutation.SetName(s)
|
||||
return jmc
|
||||
}
|
||||
|
||||
// SetNickname sets the nickname field.
|
||||
func (jmc *JDModelCreate) SetNickname(s string) *JDModelCreate {
|
||||
jmc.mutation.SetNickname(s)
|
||||
return jmc
|
||||
}
|
||||
|
||||
// SetPassword sets the password field.
|
||||
func (jmc *JDModelCreate) SetPassword(s string) *JDModelCreate {
|
||||
jmc.mutation.SetPassword(s)
|
||||
return jmc
|
||||
}
|
||||
|
||||
// SetEmail sets the email field.
|
||||
func (jmc *JDModelCreate) SetEmail(s string) *JDModelCreate {
|
||||
jmc.mutation.SetEmail(s)
|
||||
return jmc
|
||||
}
|
||||
|
||||
// SetIDNumber sets the id_number field.
|
||||
func (jmc *JDModelCreate) SetIDNumber(s string) *JDModelCreate {
|
||||
jmc.mutation.SetIDNumber(s)
|
||||
return jmc
|
||||
}
|
||||
|
||||
// SetPhoneNumber sets the phone_number field.
|
||||
func (jmc *JDModelCreate) SetPhoneNumber(i int64) *JDModelCreate {
|
||||
jmc.mutation.SetPhoneNumber(i)
|
||||
return jmc
|
||||
}
|
||||
|
||||
// Mutation returns the JDModelMutation object of the builder.
|
||||
func (jmc *JDModelCreate) Mutation() *JDModelMutation {
|
||||
return jmc.mutation
|
||||
}
|
||||
|
||||
// Save creates the JDModel in the database.
|
||||
func (jmc *JDModelCreate) Save(ctx context.Context) (*JDModel, error) {
|
||||
var (
|
||||
err error
|
||||
node *JDModel
|
||||
)
|
||||
if len(jmc.hooks) == 0 {
|
||||
if err = jmc.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
node, err = jmc.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*JDModelMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err = jmc.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
jmc.mutation = mutation
|
||||
node, err = jmc.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(jmc.hooks) - 1; i >= 0; i-- {
|
||||
mut = jmc.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, jmc.mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return node, err
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (jmc *JDModelCreate) SaveX(ctx context.Context) *JDModel {
|
||||
v, err := jmc.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (jmc *JDModelCreate) check() error {
|
||||
if _, ok := jmc.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New("ent: missing required field \"name\"")}
|
||||
}
|
||||
if _, ok := jmc.mutation.Nickname(); !ok {
|
||||
return &ValidationError{Name: "nickname", err: errors.New("ent: missing required field \"nickname\"")}
|
||||
}
|
||||
if _, ok := jmc.mutation.Password(); !ok {
|
||||
return &ValidationError{Name: "password", err: errors.New("ent: missing required field \"password\"")}
|
||||
}
|
||||
if _, ok := jmc.mutation.Email(); !ok {
|
||||
return &ValidationError{Name: "email", err: errors.New("ent: missing required field \"email\"")}
|
||||
}
|
||||
if _, ok := jmc.mutation.IDNumber(); !ok {
|
||||
return &ValidationError{Name: "id_number", err: errors.New("ent: missing required field \"id_number\"")}
|
||||
}
|
||||
if _, ok := jmc.mutation.PhoneNumber(); !ok {
|
||||
return &ValidationError{Name: "phone_number", err: errors.New("ent: missing required field \"phone_number\"")}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (jmc *JDModelCreate) sqlSave(ctx context.Context) (*JDModel, error) {
|
||||
_node, _spec := jmc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, jmc.driver, _spec); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = int(id)
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (jmc *JDModelCreate) createSpec() (*JDModel, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &JDModel{config: jmc.config}
|
||||
_spec = &sqlgraph.CreateSpec{
|
||||
Table: jdmodel.Table,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: jdmodel.FieldID,
|
||||
},
|
||||
}
|
||||
)
|
||||
if value, ok := jmc.mutation.Name(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: jdmodel.FieldName,
|
||||
})
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := jmc.mutation.Nickname(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: jdmodel.FieldNickname,
|
||||
})
|
||||
_node.Nickname = value
|
||||
}
|
||||
if value, ok := jmc.mutation.Password(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: jdmodel.FieldPassword,
|
||||
})
|
||||
_node.Password = value
|
||||
}
|
||||
if value, ok := jmc.mutation.Email(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: jdmodel.FieldEmail,
|
||||
})
|
||||
_node.Email = value
|
||||
}
|
||||
if value, ok := jmc.mutation.IDNumber(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: jdmodel.FieldIDNumber,
|
||||
})
|
||||
_node.IDNumber = value
|
||||
}
|
||||
if value, ok := jmc.mutation.PhoneNumber(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt64,
|
||||
Value: value,
|
||||
Column: jdmodel.FieldPhoneNumber,
|
||||
})
|
||||
_node.PhoneNumber = value
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// JDModelCreateBulk is the builder for creating a bulk of JDModel entities.
|
||||
type JDModelCreateBulk struct {
|
||||
config
|
||||
builders []*JDModelCreate
|
||||
}
|
||||
|
||||
// Save creates the JDModel entities in the database.
|
||||
func (jmcb *JDModelCreateBulk) Save(ctx context.Context) ([]*JDModel, error) {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(jmcb.builders))
|
||||
nodes := make([]*JDModel, len(jmcb.builders))
|
||||
mutators := make([]Mutator, len(jmcb.builders))
|
||||
for i := range jmcb.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := jmcb.builders[i]
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*JDModelMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err := builder.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
var err error
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, jmcb.builders[i+1].mutation)
|
||||
} else {
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, jmcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
}
|
||||
}
|
||||
mutation.done = true
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
id := specs[i].ID.Value.(int64)
|
||||
nodes[i].ID = int(id)
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
mut = builder.hooks[i](mut)
|
||||
}
|
||||
mutators[i] = mut
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, jmcb.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (jmcb *JDModelCreateBulk) SaveX(ctx context.Context) []*JDModel {
|
||||
v, err := jmcb.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
108
server/ent/jdmodel_delete.go
Normal file
108
server/ent/jdmodel_delete.go
Normal file
@ -0,0 +1,108 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/kallydev/privacy/ent/jdmodel"
|
||||
"github.com/kallydev/privacy/ent/predicate"
|
||||
)
|
||||
|
||||
// JDModelDelete is the builder for deleting a JDModel entity.
|
||||
type JDModelDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *JDModelMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate to the delete builder.
|
||||
func (jmd *JDModelDelete) Where(ps ...predicate.JDModel) *JDModelDelete {
|
||||
jmd.mutation.predicates = append(jmd.mutation.predicates, ps...)
|
||||
return jmd
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (jmd *JDModelDelete) Exec(ctx context.Context) (int, error) {
|
||||
var (
|
||||
err error
|
||||
affected int
|
||||
)
|
||||
if len(jmd.hooks) == 0 {
|
||||
affected, err = jmd.sqlExec(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*JDModelMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
jmd.mutation = mutation
|
||||
affected, err = jmd.sqlExec(ctx)
|
||||
mutation.done = true
|
||||
return affected, err
|
||||
})
|
||||
for i := len(jmd.hooks) - 1; i >= 0; i-- {
|
||||
mut = jmd.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, jmd.mutation); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (jmd *JDModelDelete) ExecX(ctx context.Context) int {
|
||||
n, err := jmd.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (jmd *JDModelDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := &sqlgraph.DeleteSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: jdmodel.Table,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: jdmodel.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := jmd.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return sqlgraph.DeleteNodes(ctx, jmd.driver, _spec)
|
||||
}
|
||||
|
||||
// JDModelDeleteOne is the builder for deleting a single JDModel entity.
|
||||
type JDModelDeleteOne struct {
|
||||
jmd *JDModelDelete
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (jmdo *JDModelDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := jmdo.jmd.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{jdmodel.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (jmdo *JDModelDeleteOne) ExecX(ctx context.Context) {
|
||||
jmdo.jmd.ExecX(ctx)
|
||||
}
|
883
server/ent/jdmodel_query.go
Normal file
883
server/ent/jdmodel_query.go
Normal file
@ -0,0 +1,883 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/kallydev/privacy/ent/jdmodel"
|
||||
"github.com/kallydev/privacy/ent/predicate"
|
||||
)
|
||||
|
||||
// JDModelQuery is the builder for querying JDModel entities.
|
||||
type JDModelQuery struct {
|
||||
config
|
||||
limit *int
|
||||
offset *int
|
||||
order []OrderFunc
|
||||
unique []string
|
||||
predicates []predicate.JDModel
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the builder.
|
||||
func (jmq *JDModelQuery) Where(ps ...predicate.JDModel) *JDModelQuery {
|
||||
jmq.predicates = append(jmq.predicates, ps...)
|
||||
return jmq
|
||||
}
|
||||
|
||||
// Limit adds a limit step to the query.
|
||||
func (jmq *JDModelQuery) Limit(limit int) *JDModelQuery {
|
||||
jmq.limit = &limit
|
||||
return jmq
|
||||
}
|
||||
|
||||
// Offset adds an offset step to the query.
|
||||
func (jmq *JDModelQuery) Offset(offset int) *JDModelQuery {
|
||||
jmq.offset = &offset
|
||||
return jmq
|
||||
}
|
||||
|
||||
// Order adds an order step to the query.
|
||||
func (jmq *JDModelQuery) Order(o ...OrderFunc) *JDModelQuery {
|
||||
jmq.order = append(jmq.order, o...)
|
||||
return jmq
|
||||
}
|
||||
|
||||
// First returns the first JDModel entity in the query. Returns *NotFoundError when no jdmodel was found.
|
||||
func (jmq *JDModelQuery) First(ctx context.Context) (*JDModel, error) {
|
||||
nodes, err := jmq.Limit(1).All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{jdmodel.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (jmq *JDModelQuery) FirstX(ctx context.Context) *JDModel {
|
||||
node, err := jmq.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first JDModel id in the query. Returns *NotFoundError when no id was found.
|
||||
func (jmq *JDModelQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = jmq.Limit(1).IDs(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{jdmodel.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (jmq *JDModelQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := jmq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns the only JDModel entity in the query, returns an error if not exactly one entity was returned.
|
||||
func (jmq *JDModelQuery) Only(ctx context.Context) (*JDModel, error) {
|
||||
nodes, err := jmq.Limit(2).All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{jdmodel.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{jdmodel.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (jmq *JDModelQuery) OnlyX(ctx context.Context) *JDModel {
|
||||
node, err := jmq.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID returns the only JDModel id in the query, returns an error if not exactly one id was returned.
|
||||
func (jmq *JDModelQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = jmq.Limit(2).IDs(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{jdmodel.Label}
|
||||
default:
|
||||
err = &NotSingularError{jdmodel.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (jmq *JDModelQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := jmq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of JDModels.
|
||||
func (jmq *JDModelQuery) All(ctx context.Context) ([]*JDModel, error) {
|
||||
if err := jmq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return jmq.sqlAll(ctx)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (jmq *JDModelQuery) AllX(ctx context.Context) []*JDModel {
|
||||
nodes, err := jmq.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of JDModel ids.
|
||||
func (jmq *JDModelQuery) IDs(ctx context.Context) ([]int, error) {
|
||||
var ids []int
|
||||
if err := jmq.Select(jdmodel.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (jmq *JDModelQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := jmq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (jmq *JDModelQuery) Count(ctx context.Context) (int, error) {
|
||||
if err := jmq.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return jmq.sqlCount(ctx)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (jmq *JDModelQuery) CountX(ctx context.Context) int {
|
||||
count, err := jmq.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (jmq *JDModelQuery) Exist(ctx context.Context) (bool, error) {
|
||||
if err := jmq.prepareQuery(ctx); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return jmq.sqlExist(ctx)
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (jmq *JDModelQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := jmq.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the query builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (jmq *JDModelQuery) Clone() *JDModelQuery {
|
||||
if jmq == nil {
|
||||
return nil
|
||||
}
|
||||
return &JDModelQuery{
|
||||
config: jmq.config,
|
||||
limit: jmq.limit,
|
||||
offset: jmq.offset,
|
||||
order: append([]OrderFunc{}, jmq.order...),
|
||||
unique: append([]string{}, jmq.unique...),
|
||||
predicates: append([]predicate.JDModel{}, jmq.predicates...),
|
||||
// clone intermediate query.
|
||||
sql: jmq.sql.Clone(),
|
||||
path: jmq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// GroupBy used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Name string `json:"name,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.JDModel.Query().
|
||||
// GroupBy(jdmodel.FieldName).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func (jmq *JDModelQuery) GroupBy(field string, fields ...string) *JDModelGroupBy {
|
||||
group := &JDModelGroupBy{config: jmq.config}
|
||||
group.fields = append([]string{field}, fields...)
|
||||
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
||||
if err := jmq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return jmq.sqlQuery(), nil
|
||||
}
|
||||
return group
|
||||
}
|
||||
|
||||
// Select one or more fields from the given query.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Name string `json:"name,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.JDModel.Query().
|
||||
// Select(jdmodel.FieldName).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func (jmq *JDModelQuery) Select(field string, fields ...string) *JDModelSelect {
|
||||
selector := &JDModelSelect{config: jmq.config}
|
||||
selector.fields = append([]string{field}, fields...)
|
||||
selector.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
||||
if err := jmq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return jmq.sqlQuery(), nil
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
func (jmq *JDModelQuery) prepareQuery(ctx context.Context) error {
|
||||
if jmq.path != nil {
|
||||
prev, err := jmq.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
jmq.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (jmq *JDModelQuery) sqlAll(ctx context.Context) ([]*JDModel, error) {
|
||||
var (
|
||||
nodes = []*JDModel{}
|
||||
_spec = jmq.querySpec()
|
||||
)
|
||||
_spec.ScanValues = func() []interface{} {
|
||||
node := &JDModel{config: jmq.config}
|
||||
nodes = append(nodes, node)
|
||||
values := node.scanValues()
|
||||
return values
|
||||
}
|
||||
_spec.Assign = func(values ...interface{}) error {
|
||||
if len(nodes) == 0 {
|
||||
return fmt.Errorf("ent: Assign called without calling ScanValues")
|
||||
}
|
||||
node := nodes[len(nodes)-1]
|
||||
return node.assignValues(values...)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, jmq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (jmq *JDModelQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := jmq.querySpec()
|
||||
return sqlgraph.CountNodes(ctx, jmq.driver, _spec)
|
||||
}
|
||||
|
||||
func (jmq *JDModelQuery) sqlExist(ctx context.Context) (bool, error) {
|
||||
n, err := jmq.sqlCount(ctx)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("ent: check existence: %v", err)
|
||||
}
|
||||
return n > 0, nil
|
||||
}
|
||||
|
||||
func (jmq *JDModelQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := &sqlgraph.QuerySpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: jdmodel.Table,
|
||||
Columns: jdmodel.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: jdmodel.FieldID,
|
||||
},
|
||||
},
|
||||
From: jmq.sql,
|
||||
Unique: true,
|
||||
}
|
||||
if ps := jmq.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := jmq.limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := jmq.offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := jmq.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector, jdmodel.ValidColumn)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (jmq *JDModelQuery) sqlQuery() *sql.Selector {
|
||||
builder := sql.Dialect(jmq.driver.Dialect())
|
||||
t1 := builder.Table(jdmodel.Table)
|
||||
selector := builder.Select(t1.Columns(jdmodel.Columns...)...).From(t1)
|
||||
if jmq.sql != nil {
|
||||
selector = jmq.sql
|
||||
selector.Select(selector.Columns(jdmodel.Columns...)...)
|
||||
}
|
||||
for _, p := range jmq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range jmq.order {
|
||||
p(selector, jdmodel.ValidColumn)
|
||||
}
|
||||
if offset := jmq.offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := jmq.limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// JDModelGroupBy is the builder for group-by JDModel entities.
|
||||
type JDModelGroupBy struct {
|
||||
config
|
||||
fields []string
|
||||
fns []AggregateFunc
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (jmgb *JDModelGroupBy) Aggregate(fns ...AggregateFunc) *JDModelGroupBy {
|
||||
jmgb.fns = append(jmgb.fns, fns...)
|
||||
return jmgb
|
||||
}
|
||||
|
||||
// Scan applies the group-by query and scan the result into the given value.
|
||||
func (jmgb *JDModelGroupBy) Scan(ctx context.Context, v interface{}) error {
|
||||
query, err := jmgb.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
jmgb.sql = query
|
||||
return jmgb.sqlScan(ctx, v)
|
||||
}
|
||||
|
||||
// ScanX is like Scan, but panics if an error occurs.
|
||||
func (jmgb *JDModelGroupBy) ScanX(ctx context.Context, v interface{}) {
|
||||
if err := jmgb.Scan(ctx, v); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Strings returns list of strings from group-by. It is only allowed when querying group-by with one field.
|
||||
func (jmgb *JDModelGroupBy) Strings(ctx context.Context) ([]string, error) {
|
||||
if len(jmgb.fields) > 1 {
|
||||
return nil, errors.New("ent: JDModelGroupBy.Strings is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []string
|
||||
if err := jmgb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// StringsX is like Strings, but panics if an error occurs.
|
||||
func (jmgb *JDModelGroupBy) StringsX(ctx context.Context) []string {
|
||||
v, err := jmgb.Strings(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// String returns a single string from group-by. It is only allowed when querying group-by with one field.
|
||||
func (jmgb *JDModelGroupBy) String(ctx context.Context) (_ string, err error) {
|
||||
var v []string
|
||||
if v, err = jmgb.Strings(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{jdmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: JDModelGroupBy.Strings returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// StringX is like String, but panics if an error occurs.
|
||||
func (jmgb *JDModelGroupBy) StringX(ctx context.Context) string {
|
||||
v, err := jmgb.String(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Ints returns list of ints from group-by. It is only allowed when querying group-by with one field.
|
||||
func (jmgb *JDModelGroupBy) Ints(ctx context.Context) ([]int, error) {
|
||||
if len(jmgb.fields) > 1 {
|
||||
return nil, errors.New("ent: JDModelGroupBy.Ints is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []int
|
||||
if err := jmgb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// IntsX is like Ints, but panics if an error occurs.
|
||||
func (jmgb *JDModelGroupBy) IntsX(ctx context.Context) []int {
|
||||
v, err := jmgb.Ints(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Int returns a single int from group-by. It is only allowed when querying group-by with one field.
|
||||
func (jmgb *JDModelGroupBy) Int(ctx context.Context) (_ int, err error) {
|
||||
var v []int
|
||||
if v, err = jmgb.Ints(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{jdmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: JDModelGroupBy.Ints returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// IntX is like Int, but panics if an error occurs.
|
||||
func (jmgb *JDModelGroupBy) IntX(ctx context.Context) int {
|
||||
v, err := jmgb.Int(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64s returns list of float64s from group-by. It is only allowed when querying group-by with one field.
|
||||
func (jmgb *JDModelGroupBy) Float64s(ctx context.Context) ([]float64, error) {
|
||||
if len(jmgb.fields) > 1 {
|
||||
return nil, errors.New("ent: JDModelGroupBy.Float64s is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []float64
|
||||
if err := jmgb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Float64sX is like Float64s, but panics if an error occurs.
|
||||
func (jmgb *JDModelGroupBy) Float64sX(ctx context.Context) []float64 {
|
||||
v, err := jmgb.Float64s(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64 returns a single float64 from group-by. It is only allowed when querying group-by with one field.
|
||||
func (jmgb *JDModelGroupBy) Float64(ctx context.Context) (_ float64, err error) {
|
||||
var v []float64
|
||||
if v, err = jmgb.Float64s(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{jdmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: JDModelGroupBy.Float64s returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Float64X is like Float64, but panics if an error occurs.
|
||||
func (jmgb *JDModelGroupBy) Float64X(ctx context.Context) float64 {
|
||||
v, err := jmgb.Float64(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bools returns list of bools from group-by. It is only allowed when querying group-by with one field.
|
||||
func (jmgb *JDModelGroupBy) Bools(ctx context.Context) ([]bool, error) {
|
||||
if len(jmgb.fields) > 1 {
|
||||
return nil, errors.New("ent: JDModelGroupBy.Bools is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []bool
|
||||
if err := jmgb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// BoolsX is like Bools, but panics if an error occurs.
|
||||
func (jmgb *JDModelGroupBy) BoolsX(ctx context.Context) []bool {
|
||||
v, err := jmgb.Bools(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bool returns a single bool from group-by. It is only allowed when querying group-by with one field.
|
||||
func (jmgb *JDModelGroupBy) Bool(ctx context.Context) (_ bool, err error) {
|
||||
var v []bool
|
||||
if v, err = jmgb.Bools(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{jdmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: JDModelGroupBy.Bools returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// BoolX is like Bool, but panics if an error occurs.
|
||||
func (jmgb *JDModelGroupBy) BoolX(ctx context.Context) bool {
|
||||
v, err := jmgb.Bool(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func (jmgb *JDModelGroupBy) sqlScan(ctx context.Context, v interface{}) error {
|
||||
for _, f := range jmgb.fields {
|
||||
if !jdmodel.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
|
||||
}
|
||||
}
|
||||
selector := jmgb.sqlQuery()
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := jmgb.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
func (jmgb *JDModelGroupBy) sqlQuery() *sql.Selector {
|
||||
selector := jmgb.sql
|
||||
columns := make([]string, 0, len(jmgb.fields)+len(jmgb.fns))
|
||||
columns = append(columns, jmgb.fields...)
|
||||
for _, fn := range jmgb.fns {
|
||||
columns = append(columns, fn(selector, jdmodel.ValidColumn))
|
||||
}
|
||||
return selector.Select(columns...).GroupBy(jmgb.fields...)
|
||||
}
|
||||
|
||||
// JDModelSelect is the builder for select fields of JDModel entities.
|
||||
type JDModelSelect struct {
|
||||
config
|
||||
fields []string
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scan the result into the given value.
|
||||
func (jms *JDModelSelect) Scan(ctx context.Context, v interface{}) error {
|
||||
query, err := jms.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
jms.sql = query
|
||||
return jms.sqlScan(ctx, v)
|
||||
}
|
||||
|
||||
// ScanX is like Scan, but panics if an error occurs.
|
||||
func (jms *JDModelSelect) ScanX(ctx context.Context, v interface{}) {
|
||||
if err := jms.Scan(ctx, v); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Strings returns list of strings from selector. It is only allowed when selecting one field.
|
||||
func (jms *JDModelSelect) Strings(ctx context.Context) ([]string, error) {
|
||||
if len(jms.fields) > 1 {
|
||||
return nil, errors.New("ent: JDModelSelect.Strings is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []string
|
||||
if err := jms.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// StringsX is like Strings, but panics if an error occurs.
|
||||
func (jms *JDModelSelect) StringsX(ctx context.Context) []string {
|
||||
v, err := jms.Strings(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// String returns a single string from selector. It is only allowed when selecting one field.
|
||||
func (jms *JDModelSelect) String(ctx context.Context) (_ string, err error) {
|
||||
var v []string
|
||||
if v, err = jms.Strings(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{jdmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: JDModelSelect.Strings returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// StringX is like String, but panics if an error occurs.
|
||||
func (jms *JDModelSelect) StringX(ctx context.Context) string {
|
||||
v, err := jms.String(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Ints returns list of ints from selector. It is only allowed when selecting one field.
|
||||
func (jms *JDModelSelect) Ints(ctx context.Context) ([]int, error) {
|
||||
if len(jms.fields) > 1 {
|
||||
return nil, errors.New("ent: JDModelSelect.Ints is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []int
|
||||
if err := jms.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// IntsX is like Ints, but panics if an error occurs.
|
||||
func (jms *JDModelSelect) IntsX(ctx context.Context) []int {
|
||||
v, err := jms.Ints(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Int returns a single int from selector. It is only allowed when selecting one field.
|
||||
func (jms *JDModelSelect) Int(ctx context.Context) (_ int, err error) {
|
||||
var v []int
|
||||
if v, err = jms.Ints(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{jdmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: JDModelSelect.Ints returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// IntX is like Int, but panics if an error occurs.
|
||||
func (jms *JDModelSelect) IntX(ctx context.Context) int {
|
||||
v, err := jms.Int(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64s returns list of float64s from selector. It is only allowed when selecting one field.
|
||||
func (jms *JDModelSelect) Float64s(ctx context.Context) ([]float64, error) {
|
||||
if len(jms.fields) > 1 {
|
||||
return nil, errors.New("ent: JDModelSelect.Float64s is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []float64
|
||||
if err := jms.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Float64sX is like Float64s, but panics if an error occurs.
|
||||
func (jms *JDModelSelect) Float64sX(ctx context.Context) []float64 {
|
||||
v, err := jms.Float64s(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64 returns a single float64 from selector. It is only allowed when selecting one field.
|
||||
func (jms *JDModelSelect) Float64(ctx context.Context) (_ float64, err error) {
|
||||
var v []float64
|
||||
if v, err = jms.Float64s(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{jdmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: JDModelSelect.Float64s returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Float64X is like Float64, but panics if an error occurs.
|
||||
func (jms *JDModelSelect) Float64X(ctx context.Context) float64 {
|
||||
v, err := jms.Float64(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bools returns list of bools from selector. It is only allowed when selecting one field.
|
||||
func (jms *JDModelSelect) Bools(ctx context.Context) ([]bool, error) {
|
||||
if len(jms.fields) > 1 {
|
||||
return nil, errors.New("ent: JDModelSelect.Bools is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []bool
|
||||
if err := jms.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// BoolsX is like Bools, but panics if an error occurs.
|
||||
func (jms *JDModelSelect) BoolsX(ctx context.Context) []bool {
|
||||
v, err := jms.Bools(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bool returns a single bool from selector. It is only allowed when selecting one field.
|
||||
func (jms *JDModelSelect) Bool(ctx context.Context) (_ bool, err error) {
|
||||
var v []bool
|
||||
if v, err = jms.Bools(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{jdmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: JDModelSelect.Bools returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// BoolX is like Bool, but panics if an error occurs.
|
||||
func (jms *JDModelSelect) BoolX(ctx context.Context) bool {
|
||||
v, err := jms.Bool(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func (jms *JDModelSelect) sqlScan(ctx context.Context, v interface{}) error {
|
||||
for _, f := range jms.fields {
|
||||
if !jdmodel.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for selection", f)}
|
||||
}
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := jms.sqlQuery().Query()
|
||||
if err := jms.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
func (jms *JDModelSelect) sqlQuery() sql.Querier {
|
||||
selector := jms.sql
|
||||
selector.Select(selector.Columns(jms.fields...)...)
|
||||
return selector
|
||||
}
|
389
server/ent/jdmodel_update.go
Normal file
389
server/ent/jdmodel_update.go
Normal file
@ -0,0 +1,389 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/kallydev/privacy/ent/jdmodel"
|
||||
"github.com/kallydev/privacy/ent/predicate"
|
||||
)
|
||||
|
||||
// JDModelUpdate is the builder for updating JDModel entities.
|
||||
type JDModelUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *JDModelMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the builder.
|
||||
func (jmu *JDModelUpdate) Where(ps ...predicate.JDModel) *JDModelUpdate {
|
||||
jmu.mutation.predicates = append(jmu.mutation.predicates, ps...)
|
||||
return jmu
|
||||
}
|
||||
|
||||
// SetName sets the name field.
|
||||
func (jmu *JDModelUpdate) SetName(s string) *JDModelUpdate {
|
||||
jmu.mutation.SetName(s)
|
||||
return jmu
|
||||
}
|
||||
|
||||
// SetNickname sets the nickname field.
|
||||
func (jmu *JDModelUpdate) SetNickname(s string) *JDModelUpdate {
|
||||
jmu.mutation.SetNickname(s)
|
||||
return jmu
|
||||
}
|
||||
|
||||
// SetPassword sets the password field.
|
||||
func (jmu *JDModelUpdate) SetPassword(s string) *JDModelUpdate {
|
||||
jmu.mutation.SetPassword(s)
|
||||
return jmu
|
||||
}
|
||||
|
||||
// SetEmail sets the email field.
|
||||
func (jmu *JDModelUpdate) SetEmail(s string) *JDModelUpdate {
|
||||
jmu.mutation.SetEmail(s)
|
||||
return jmu
|
||||
}
|
||||
|
||||
// SetIDNumber sets the id_number field.
|
||||
func (jmu *JDModelUpdate) SetIDNumber(s string) *JDModelUpdate {
|
||||
jmu.mutation.SetIDNumber(s)
|
||||
return jmu
|
||||
}
|
||||
|
||||
// SetPhoneNumber sets the phone_number field.
|
||||
func (jmu *JDModelUpdate) SetPhoneNumber(i int64) *JDModelUpdate {
|
||||
jmu.mutation.ResetPhoneNumber()
|
||||
jmu.mutation.SetPhoneNumber(i)
|
||||
return jmu
|
||||
}
|
||||
|
||||
// AddPhoneNumber adds i to phone_number.
|
||||
func (jmu *JDModelUpdate) AddPhoneNumber(i int64) *JDModelUpdate {
|
||||
jmu.mutation.AddPhoneNumber(i)
|
||||
return jmu
|
||||
}
|
||||
|
||||
// Mutation returns the JDModelMutation object of the builder.
|
||||
func (jmu *JDModelUpdate) Mutation() *JDModelMutation {
|
||||
return jmu.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of rows/vertices matched by this operation.
|
||||
func (jmu *JDModelUpdate) Save(ctx context.Context) (int, error) {
|
||||
var (
|
||||
err error
|
||||
affected int
|
||||
)
|
||||
if len(jmu.hooks) == 0 {
|
||||
affected, err = jmu.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*JDModelMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
jmu.mutation = mutation
|
||||
affected, err = jmu.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return affected, err
|
||||
})
|
||||
for i := len(jmu.hooks) - 1; i >= 0; i-- {
|
||||
mut = jmu.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, jmu.mutation); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (jmu *JDModelUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := jmu.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (jmu *JDModelUpdate) Exec(ctx context.Context) error {
|
||||
_, err := jmu.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (jmu *JDModelUpdate) ExecX(ctx context.Context) {
|
||||
if err := jmu.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (jmu *JDModelUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
_spec := &sqlgraph.UpdateSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: jdmodel.Table,
|
||||
Columns: jdmodel.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: jdmodel.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := jmu.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := jmu.mutation.Name(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: jdmodel.FieldName,
|
||||
})
|
||||
}
|
||||
if value, ok := jmu.mutation.Nickname(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: jdmodel.FieldNickname,
|
||||
})
|
||||
}
|
||||
if value, ok := jmu.mutation.Password(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: jdmodel.FieldPassword,
|
||||
})
|
||||
}
|
||||
if value, ok := jmu.mutation.Email(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: jdmodel.FieldEmail,
|
||||
})
|
||||
}
|
||||
if value, ok := jmu.mutation.IDNumber(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: jdmodel.FieldIDNumber,
|
||||
})
|
||||
}
|
||||
if value, ok := jmu.mutation.PhoneNumber(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt64,
|
||||
Value: value,
|
||||
Column: jdmodel.FieldPhoneNumber,
|
||||
})
|
||||
}
|
||||
if value, ok := jmu.mutation.AddedPhoneNumber(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt64,
|
||||
Value: value,
|
||||
Column: jdmodel.FieldPhoneNumber,
|
||||
})
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, jmu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{jdmodel.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// JDModelUpdateOne is the builder for updating a single JDModel entity.
|
||||
type JDModelUpdateOne struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *JDModelMutation
|
||||
}
|
||||
|
||||
// SetName sets the name field.
|
||||
func (jmuo *JDModelUpdateOne) SetName(s string) *JDModelUpdateOne {
|
||||
jmuo.mutation.SetName(s)
|
||||
return jmuo
|
||||
}
|
||||
|
||||
// SetNickname sets the nickname field.
|
||||
func (jmuo *JDModelUpdateOne) SetNickname(s string) *JDModelUpdateOne {
|
||||
jmuo.mutation.SetNickname(s)
|
||||
return jmuo
|
||||
}
|
||||
|
||||
// SetPassword sets the password field.
|
||||
func (jmuo *JDModelUpdateOne) SetPassword(s string) *JDModelUpdateOne {
|
||||
jmuo.mutation.SetPassword(s)
|
||||
return jmuo
|
||||
}
|
||||
|
||||
// SetEmail sets the email field.
|
||||
func (jmuo *JDModelUpdateOne) SetEmail(s string) *JDModelUpdateOne {
|
||||
jmuo.mutation.SetEmail(s)
|
||||
return jmuo
|
||||
}
|
||||
|
||||
// SetIDNumber sets the id_number field.
|
||||
func (jmuo *JDModelUpdateOne) SetIDNumber(s string) *JDModelUpdateOne {
|
||||
jmuo.mutation.SetIDNumber(s)
|
||||
return jmuo
|
||||
}
|
||||
|
||||
// SetPhoneNumber sets the phone_number field.
|
||||
func (jmuo *JDModelUpdateOne) SetPhoneNumber(i int64) *JDModelUpdateOne {
|
||||
jmuo.mutation.ResetPhoneNumber()
|
||||
jmuo.mutation.SetPhoneNumber(i)
|
||||
return jmuo
|
||||
}
|
||||
|
||||
// AddPhoneNumber adds i to phone_number.
|
||||
func (jmuo *JDModelUpdateOne) AddPhoneNumber(i int64) *JDModelUpdateOne {
|
||||
jmuo.mutation.AddPhoneNumber(i)
|
||||
return jmuo
|
||||
}
|
||||
|
||||
// Mutation returns the JDModelMutation object of the builder.
|
||||
func (jmuo *JDModelUpdateOne) Mutation() *JDModelMutation {
|
||||
return jmuo.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated entity.
|
||||
func (jmuo *JDModelUpdateOne) Save(ctx context.Context) (*JDModel, error) {
|
||||
var (
|
||||
err error
|
||||
node *JDModel
|
||||
)
|
||||
if len(jmuo.hooks) == 0 {
|
||||
node, err = jmuo.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*JDModelMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
jmuo.mutation = mutation
|
||||
node, err = jmuo.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(jmuo.hooks) - 1; i >= 0; i-- {
|
||||
mut = jmuo.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, jmuo.mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return node, err
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (jmuo *JDModelUpdateOne) SaveX(ctx context.Context) *JDModel {
|
||||
node, err := jmuo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (jmuo *JDModelUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := jmuo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (jmuo *JDModelUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := jmuo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (jmuo *JDModelUpdateOne) sqlSave(ctx context.Context) (_node *JDModel, err error) {
|
||||
_spec := &sqlgraph.UpdateSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: jdmodel.Table,
|
||||
Columns: jdmodel.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: jdmodel.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
id, ok := jmuo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing JDModel.ID for update")}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if value, ok := jmuo.mutation.Name(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: jdmodel.FieldName,
|
||||
})
|
||||
}
|
||||
if value, ok := jmuo.mutation.Nickname(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: jdmodel.FieldNickname,
|
||||
})
|
||||
}
|
||||
if value, ok := jmuo.mutation.Password(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: jdmodel.FieldPassword,
|
||||
})
|
||||
}
|
||||
if value, ok := jmuo.mutation.Email(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: jdmodel.FieldEmail,
|
||||
})
|
||||
}
|
||||
if value, ok := jmuo.mutation.IDNumber(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: jdmodel.FieldIDNumber,
|
||||
})
|
||||
}
|
||||
if value, ok := jmuo.mutation.PhoneNumber(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt64,
|
||||
Value: value,
|
||||
Column: jdmodel.FieldPhoneNumber,
|
||||
})
|
||||
}
|
||||
if value, ok := jmuo.mutation.AddedPhoneNumber(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt64,
|
||||
Value: value,
|
||||
Column: jdmodel.FieldPhoneNumber,
|
||||
})
|
||||
}
|
||||
_node = &JDModel{config: jmuo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues()
|
||||
if err = sqlgraph.UpdateNode(ctx, jmuo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{jdmodel.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return _node, nil
|
||||
}
|
72
server/ent/migrate/migrate.go
Normal file
72
server/ent/migrate/migrate.go
Normal file
@ -0,0 +1,72 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package migrate
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/facebook/ent/dialect"
|
||||
"github.com/facebook/ent/dialect/sql/schema"
|
||||
)
|
||||
|
||||
var (
|
||||
// WithGlobalUniqueID sets the universal ids options to the migration.
|
||||
// If this option is enabled, ent migration will allocate a 1<<32 range
|
||||
// for the ids of each entity (table).
|
||||
// Note that this option cannot be applied on tables that already exist.
|
||||
WithGlobalUniqueID = schema.WithGlobalUniqueID
|
||||
// WithDropColumn sets the drop column option to the migration.
|
||||
// If this option is enabled, ent migration will drop old columns
|
||||
// that were used for both fields and edges. This defaults to false.
|
||||
WithDropColumn = schema.WithDropColumn
|
||||
// WithDropIndex sets the drop index option to the migration.
|
||||
// If this option is enabled, ent migration will drop old indexes
|
||||
// that were defined in the schema. This defaults to false.
|
||||
// Note that unique constraints are defined using `UNIQUE INDEX`,
|
||||
// and therefore, it's recommended to enable this option to get more
|
||||
// flexibility in the schema changes.
|
||||
WithDropIndex = schema.WithDropIndex
|
||||
// WithFixture sets the foreign-key renaming option to the migration when upgrading
|
||||
// ent from v0.1.0 (issue-#285). Defaults to false.
|
||||
WithFixture = schema.WithFixture
|
||||
// WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true.
|
||||
WithForeignKeys = schema.WithForeignKeys
|
||||
)
|
||||
|
||||
// Schema is the API for creating, migrating and dropping a schema.
|
||||
type Schema struct {
|
||||
drv dialect.Driver
|
||||
universalID bool
|
||||
}
|
||||
|
||||
// NewSchema creates a new schema client.
|
||||
func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} }
|
||||
|
||||
// Create creates all schema resources.
|
||||
func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error {
|
||||
migrate, err := schema.NewMigrate(s.drv, opts...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("ent/migrate: %v", err)
|
||||
}
|
||||
return migrate.Create(ctx, Tables...)
|
||||
}
|
||||
|
||||
// WriteTo writes the schema changes to w instead of running them against the database.
|
||||
//
|
||||
// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
//
|
||||
func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error {
|
||||
drv := &schema.WriteDriver{
|
||||
Writer: w,
|
||||
Driver: s.drv,
|
||||
}
|
||||
migrate, err := schema.NewMigrate(drv, opts...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("ent/migrate: %v", err)
|
||||
}
|
||||
return migrate.Create(ctx, Tables...)
|
||||
}
|
64
server/ent/migrate/schema.go
Normal file
64
server/ent/migrate/schema.go
Normal file
@ -0,0 +1,64 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package migrate
|
||||
|
||||
import (
|
||||
"github.com/facebook/ent/dialect/sql/schema"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
)
|
||||
|
||||
var (
|
||||
// JdColumns holds the columns for the "jd" table.
|
||||
JdColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "name", Type: field.TypeString},
|
||||
{Name: "nickname", Type: field.TypeString},
|
||||
{Name: "password", Type: field.TypeString},
|
||||
{Name: "email", Type: field.TypeString},
|
||||
{Name: "id_number", Type: field.TypeString},
|
||||
{Name: "phone_number", Type: field.TypeInt64},
|
||||
}
|
||||
// JdTable holds the schema information for the "jd" table.
|
||||
JdTable = &schema.Table{
|
||||
Name: "jd",
|
||||
Columns: JdColumns,
|
||||
PrimaryKey: []*schema.Column{JdColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{},
|
||||
}
|
||||
// QqColumns holds the columns for the "qq" table.
|
||||
QqColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "qq_number", Type: field.TypeInt64},
|
||||
{Name: "phone_number", Type: field.TypeInt64},
|
||||
}
|
||||
// QqTable holds the schema information for the "qq" table.
|
||||
QqTable = &schema.Table{
|
||||
Name: "qq",
|
||||
Columns: QqColumns,
|
||||
PrimaryKey: []*schema.Column{QqColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{},
|
||||
}
|
||||
// SfColumns holds the columns for the "sf" table.
|
||||
SfColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "name", Type: field.TypeString},
|
||||
{Name: "phone_number", Type: field.TypeInt64},
|
||||
{Name: "address", Type: field.TypeString},
|
||||
}
|
||||
// SfTable holds the schema information for the "sf" table.
|
||||
SfTable = &schema.Table{
|
||||
Name: "sf",
|
||||
Columns: SfColumns,
|
||||
PrimaryKey: []*schema.Column{SfColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{},
|
||||
}
|
||||
// Tables holds all the tables in the schema.
|
||||
Tables = []*schema.Table{
|
||||
JdTable,
|
||||
QqTable,
|
||||
SfTable,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
}
|
1493
server/ent/mutation.go
Normal file
1493
server/ent/mutation.go
Normal file
File diff suppressed because it is too large
Load Diff
16
server/ent/predicate/predicate.go
Normal file
16
server/ent/predicate/predicate.go
Normal file
@ -0,0 +1,16 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package predicate
|
||||
|
||||
import (
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// JDModel is the predicate function for jdmodel builders.
|
||||
type JDModel func(*sql.Selector)
|
||||
|
||||
// QQModel is the predicate function for qqmodel builders.
|
||||
type QQModel func(*sql.Selector)
|
||||
|
||||
// SFModel is the predicate function for sfmodel builders.
|
||||
type SFModel func(*sql.Selector)
|
96
server/ent/qqmodel.go
Normal file
96
server/ent/qqmodel.go
Normal file
@ -0,0 +1,96 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/kallydev/privacy/ent/qqmodel"
|
||||
)
|
||||
|
||||
// QQModel is the model entity for the QQModel schema.
|
||||
type QQModel struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// QqNumber holds the value of the "qq_number" field.
|
||||
QqNumber int64 `json:"qq_number,omitempty"`
|
||||
// PhoneNumber holds the value of the "phone_number" field.
|
||||
PhoneNumber int64 `json:"phone_number,omitempty"`
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*QQModel) scanValues() []interface{} {
|
||||
return []interface{}{
|
||||
&sql.NullInt64{}, // id
|
||||
&sql.NullInt64{}, // qq_number
|
||||
&sql.NullInt64{}, // phone_number
|
||||
}
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the QQModel fields.
|
||||
func (qm *QQModel) assignValues(values ...interface{}) error {
|
||||
if m, n := len(values), len(qqmodel.Columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
value, ok := values[0].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
qm.ID = int(value.Int64)
|
||||
values = values[1:]
|
||||
if value, ok := values[0].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field qq_number", values[0])
|
||||
} else if value.Valid {
|
||||
qm.QqNumber = value.Int64
|
||||
}
|
||||
if value, ok := values[1].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field phone_number", values[1])
|
||||
} else if value.Valid {
|
||||
qm.PhoneNumber = value.Int64
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this QQModel.
|
||||
// Note that, you need to call QQModel.Unwrap() before calling this method, if this QQModel
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (qm *QQModel) Update() *QQModelUpdateOne {
|
||||
return (&QQModelClient{config: qm.config}).UpdateOne(qm)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the entity that was returned from a transaction after it was closed,
|
||||
// so that all next queries will be executed through the driver which created the transaction.
|
||||
func (qm *QQModel) Unwrap() *QQModel {
|
||||
tx, ok := qm.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: QQModel is not a transactional entity")
|
||||
}
|
||||
qm.config.driver = tx.drv
|
||||
return qm
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (qm *QQModel) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("QQModel(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v", qm.ID))
|
||||
builder.WriteString(", qq_number=")
|
||||
builder.WriteString(fmt.Sprintf("%v", qm.QqNumber))
|
||||
builder.WriteString(", phone_number=")
|
||||
builder.WriteString(fmt.Sprintf("%v", qm.PhoneNumber))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// QQModels is a parsable slice of QQModel.
|
||||
type QQModels []*QQModel
|
||||
|
||||
func (qm QQModels) config(cfg config) {
|
||||
for _i := range qm {
|
||||
qm[_i].config = cfg
|
||||
}
|
||||
}
|
34
server/ent/qqmodel/qqmodel.go
Normal file
34
server/ent/qqmodel/qqmodel.go
Normal file
@ -0,0 +1,34 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package qqmodel
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the qqmodel type in the database.
|
||||
Label = "qq_model"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldQqNumber holds the string denoting the qq_number field in the database.
|
||||
FieldQqNumber = "qq_number"
|
||||
// FieldPhoneNumber holds the string denoting the phone_number field in the database.
|
||||
FieldPhoneNumber = "phone_number"
|
||||
|
||||
// Table holds the table name of the qqmodel in the database.
|
||||
Table = "qq"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for qqmodel fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldQqNumber,
|
||||
FieldPhoneNumber,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
289
server/ent/qqmodel/where.go
Normal file
289
server/ent/qqmodel/where.go
Normal file
@ -0,0 +1,289 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package qqmodel
|
||||
|
||||
import (
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/kallydev/privacy/ent/predicate"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their identifier.
|
||||
func ID(id int) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// QqNumber applies equality check predicate on the "qq_number" field. It's identical to QqNumberEQ.
|
||||
func QqNumber(v int64) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldQqNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumber applies equality check predicate on the "phone_number" field. It's identical to PhoneNumberEQ.
|
||||
func PhoneNumber(v int64) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldPhoneNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// QqNumberEQ applies the EQ predicate on the "qq_number" field.
|
||||
func QqNumberEQ(v int64) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldQqNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// QqNumberNEQ applies the NEQ predicate on the "qq_number" field.
|
||||
func QqNumberNEQ(v int64) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldQqNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// QqNumberIn applies the In predicate on the "qq_number" field.
|
||||
func QqNumberIn(vs ...int64) predicate.QQModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldQqNumber), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// QqNumberNotIn applies the NotIn predicate on the "qq_number" field.
|
||||
func QqNumberNotIn(vs ...int64) predicate.QQModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldQqNumber), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// QqNumberGT applies the GT predicate on the "qq_number" field.
|
||||
func QqNumberGT(v int64) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldQqNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// QqNumberGTE applies the GTE predicate on the "qq_number" field.
|
||||
func QqNumberGTE(v int64) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldQqNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// QqNumberLT applies the LT predicate on the "qq_number" field.
|
||||
func QqNumberLT(v int64) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldQqNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// QqNumberLTE applies the LTE predicate on the "qq_number" field.
|
||||
func QqNumberLTE(v int64) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldQqNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberEQ applies the EQ predicate on the "phone_number" field.
|
||||
func PhoneNumberEQ(v int64) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldPhoneNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberNEQ applies the NEQ predicate on the "phone_number" field.
|
||||
func PhoneNumberNEQ(v int64) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldPhoneNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberIn applies the In predicate on the "phone_number" field.
|
||||
func PhoneNumberIn(vs ...int64) predicate.QQModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldPhoneNumber), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberNotIn applies the NotIn predicate on the "phone_number" field.
|
||||
func PhoneNumberNotIn(vs ...int64) predicate.QQModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldPhoneNumber), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberGT applies the GT predicate on the "phone_number" field.
|
||||
func PhoneNumberGT(v int64) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldPhoneNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberGTE applies the GTE predicate on the "phone_number" field.
|
||||
func PhoneNumberGTE(v int64) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldPhoneNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberLT applies the LT predicate on the "phone_number" field.
|
||||
func PhoneNumberLT(v int64) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldPhoneNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberLTE applies the LTE predicate on the "phone_number" field.
|
||||
func PhoneNumberLTE(v int64) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldPhoneNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// And groups list of predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.QQModel) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for _, p := range predicates {
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
}
|
||||
|
||||
// Or groups list of predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.QQModel) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for i, p := range predicates {
|
||||
if i > 0 {
|
||||
s1.Or()
|
||||
}
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.QQModel) predicate.QQModel {
|
||||
return predicate.QQModel(func(s *sql.Selector) {
|
||||
p(s.Not())
|
||||
})
|
||||
}
|
201
server/ent/qqmodel_create.go
Normal file
201
server/ent/qqmodel_create.go
Normal file
@ -0,0 +1,201 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/kallydev/privacy/ent/qqmodel"
|
||||
)
|
||||
|
||||
// QQModelCreate is the builder for creating a QQModel entity.
|
||||
type QQModelCreate struct {
|
||||
config
|
||||
mutation *QQModelMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetQqNumber sets the qq_number field.
|
||||
func (qmc *QQModelCreate) SetQqNumber(i int64) *QQModelCreate {
|
||||
qmc.mutation.SetQqNumber(i)
|
||||
return qmc
|
||||
}
|
||||
|
||||
// SetPhoneNumber sets the phone_number field.
|
||||
func (qmc *QQModelCreate) SetPhoneNumber(i int64) *QQModelCreate {
|
||||
qmc.mutation.SetPhoneNumber(i)
|
||||
return qmc
|
||||
}
|
||||
|
||||
// Mutation returns the QQModelMutation object of the builder.
|
||||
func (qmc *QQModelCreate) Mutation() *QQModelMutation {
|
||||
return qmc.mutation
|
||||
}
|
||||
|
||||
// Save creates the QQModel in the database.
|
||||
func (qmc *QQModelCreate) Save(ctx context.Context) (*QQModel, error) {
|
||||
var (
|
||||
err error
|
||||
node *QQModel
|
||||
)
|
||||
if len(qmc.hooks) == 0 {
|
||||
if err = qmc.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
node, err = qmc.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*QQModelMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err = qmc.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qmc.mutation = mutation
|
||||
node, err = qmc.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(qmc.hooks) - 1; i >= 0; i-- {
|
||||
mut = qmc.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, qmc.mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return node, err
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (qmc *QQModelCreate) SaveX(ctx context.Context) *QQModel {
|
||||
v, err := qmc.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (qmc *QQModelCreate) check() error {
|
||||
if _, ok := qmc.mutation.QqNumber(); !ok {
|
||||
return &ValidationError{Name: "qq_number", err: errors.New("ent: missing required field \"qq_number\"")}
|
||||
}
|
||||
if _, ok := qmc.mutation.PhoneNumber(); !ok {
|
||||
return &ValidationError{Name: "phone_number", err: errors.New("ent: missing required field \"phone_number\"")}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (qmc *QQModelCreate) sqlSave(ctx context.Context) (*QQModel, error) {
|
||||
_node, _spec := qmc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, qmc.driver, _spec); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = int(id)
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (qmc *QQModelCreate) createSpec() (*QQModel, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &QQModel{config: qmc.config}
|
||||
_spec = &sqlgraph.CreateSpec{
|
||||
Table: qqmodel.Table,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: qqmodel.FieldID,
|
||||
},
|
||||
}
|
||||
)
|
||||
if value, ok := qmc.mutation.QqNumber(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt64,
|
||||
Value: value,
|
||||
Column: qqmodel.FieldQqNumber,
|
||||
})
|
||||
_node.QqNumber = value
|
||||
}
|
||||
if value, ok := qmc.mutation.PhoneNumber(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt64,
|
||||
Value: value,
|
||||
Column: qqmodel.FieldPhoneNumber,
|
||||
})
|
||||
_node.PhoneNumber = value
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// QQModelCreateBulk is the builder for creating a bulk of QQModel entities.
|
||||
type QQModelCreateBulk struct {
|
||||
config
|
||||
builders []*QQModelCreate
|
||||
}
|
||||
|
||||
// Save creates the QQModel entities in the database.
|
||||
func (qmcb *QQModelCreateBulk) Save(ctx context.Context) ([]*QQModel, error) {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(qmcb.builders))
|
||||
nodes := make([]*QQModel, len(qmcb.builders))
|
||||
mutators := make([]Mutator, len(qmcb.builders))
|
||||
for i := range qmcb.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := qmcb.builders[i]
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*QQModelMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err := builder.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
var err error
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, qmcb.builders[i+1].mutation)
|
||||
} else {
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, qmcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
}
|
||||
}
|
||||
mutation.done = true
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
id := specs[i].ID.Value.(int64)
|
||||
nodes[i].ID = int(id)
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
mut = builder.hooks[i](mut)
|
||||
}
|
||||
mutators[i] = mut
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, qmcb.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (qmcb *QQModelCreateBulk) SaveX(ctx context.Context) []*QQModel {
|
||||
v, err := qmcb.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
108
server/ent/qqmodel_delete.go
Normal file
108
server/ent/qqmodel_delete.go
Normal file
@ -0,0 +1,108 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/kallydev/privacy/ent/predicate"
|
||||
"github.com/kallydev/privacy/ent/qqmodel"
|
||||
)
|
||||
|
||||
// QQModelDelete is the builder for deleting a QQModel entity.
|
||||
type QQModelDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *QQModelMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate to the delete builder.
|
||||
func (qmd *QQModelDelete) Where(ps ...predicate.QQModel) *QQModelDelete {
|
||||
qmd.mutation.predicates = append(qmd.mutation.predicates, ps...)
|
||||
return qmd
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (qmd *QQModelDelete) Exec(ctx context.Context) (int, error) {
|
||||
var (
|
||||
err error
|
||||
affected int
|
||||
)
|
||||
if len(qmd.hooks) == 0 {
|
||||
affected, err = qmd.sqlExec(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*QQModelMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
qmd.mutation = mutation
|
||||
affected, err = qmd.sqlExec(ctx)
|
||||
mutation.done = true
|
||||
return affected, err
|
||||
})
|
||||
for i := len(qmd.hooks) - 1; i >= 0; i-- {
|
||||
mut = qmd.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, qmd.mutation); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (qmd *QQModelDelete) ExecX(ctx context.Context) int {
|
||||
n, err := qmd.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (qmd *QQModelDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := &sqlgraph.DeleteSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: qqmodel.Table,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: qqmodel.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := qmd.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return sqlgraph.DeleteNodes(ctx, qmd.driver, _spec)
|
||||
}
|
||||
|
||||
// QQModelDeleteOne is the builder for deleting a single QQModel entity.
|
||||
type QQModelDeleteOne struct {
|
||||
qmd *QQModelDelete
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (qmdo *QQModelDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := qmdo.qmd.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{qqmodel.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (qmdo *QQModelDeleteOne) ExecX(ctx context.Context) {
|
||||
qmdo.qmd.ExecX(ctx)
|
||||
}
|
883
server/ent/qqmodel_query.go
Normal file
883
server/ent/qqmodel_query.go
Normal file
@ -0,0 +1,883 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/kallydev/privacy/ent/predicate"
|
||||
"github.com/kallydev/privacy/ent/qqmodel"
|
||||
)
|
||||
|
||||
// QQModelQuery is the builder for querying QQModel entities.
|
||||
type QQModelQuery struct {
|
||||
config
|
||||
limit *int
|
||||
offset *int
|
||||
order []OrderFunc
|
||||
unique []string
|
||||
predicates []predicate.QQModel
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the builder.
|
||||
func (qmq *QQModelQuery) Where(ps ...predicate.QQModel) *QQModelQuery {
|
||||
qmq.predicates = append(qmq.predicates, ps...)
|
||||
return qmq
|
||||
}
|
||||
|
||||
// Limit adds a limit step to the query.
|
||||
func (qmq *QQModelQuery) Limit(limit int) *QQModelQuery {
|
||||
qmq.limit = &limit
|
||||
return qmq
|
||||
}
|
||||
|
||||
// Offset adds an offset step to the query.
|
||||
func (qmq *QQModelQuery) Offset(offset int) *QQModelQuery {
|
||||
qmq.offset = &offset
|
||||
return qmq
|
||||
}
|
||||
|
||||
// Order adds an order step to the query.
|
||||
func (qmq *QQModelQuery) Order(o ...OrderFunc) *QQModelQuery {
|
||||
qmq.order = append(qmq.order, o...)
|
||||
return qmq
|
||||
}
|
||||
|
||||
// First returns the first QQModel entity in the query. Returns *NotFoundError when no qqmodel was found.
|
||||
func (qmq *QQModelQuery) First(ctx context.Context) (*QQModel, error) {
|
||||
nodes, err := qmq.Limit(1).All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{qqmodel.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (qmq *QQModelQuery) FirstX(ctx context.Context) *QQModel {
|
||||
node, err := qmq.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first QQModel id in the query. Returns *NotFoundError when no id was found.
|
||||
func (qmq *QQModelQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = qmq.Limit(1).IDs(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{qqmodel.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (qmq *QQModelQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := qmq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns the only QQModel entity in the query, returns an error if not exactly one entity was returned.
|
||||
func (qmq *QQModelQuery) Only(ctx context.Context) (*QQModel, error) {
|
||||
nodes, err := qmq.Limit(2).All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{qqmodel.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{qqmodel.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (qmq *QQModelQuery) OnlyX(ctx context.Context) *QQModel {
|
||||
node, err := qmq.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID returns the only QQModel id in the query, returns an error if not exactly one id was returned.
|
||||
func (qmq *QQModelQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = qmq.Limit(2).IDs(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{qqmodel.Label}
|
||||
default:
|
||||
err = &NotSingularError{qqmodel.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (qmq *QQModelQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := qmq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of QQModels.
|
||||
func (qmq *QQModelQuery) All(ctx context.Context) ([]*QQModel, error) {
|
||||
if err := qmq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return qmq.sqlAll(ctx)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (qmq *QQModelQuery) AllX(ctx context.Context) []*QQModel {
|
||||
nodes, err := qmq.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of QQModel ids.
|
||||
func (qmq *QQModelQuery) IDs(ctx context.Context) ([]int, error) {
|
||||
var ids []int
|
||||
if err := qmq.Select(qqmodel.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (qmq *QQModelQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := qmq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (qmq *QQModelQuery) Count(ctx context.Context) (int, error) {
|
||||
if err := qmq.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return qmq.sqlCount(ctx)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (qmq *QQModelQuery) CountX(ctx context.Context) int {
|
||||
count, err := qmq.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (qmq *QQModelQuery) Exist(ctx context.Context) (bool, error) {
|
||||
if err := qmq.prepareQuery(ctx); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return qmq.sqlExist(ctx)
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (qmq *QQModelQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := qmq.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the query builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (qmq *QQModelQuery) Clone() *QQModelQuery {
|
||||
if qmq == nil {
|
||||
return nil
|
||||
}
|
||||
return &QQModelQuery{
|
||||
config: qmq.config,
|
||||
limit: qmq.limit,
|
||||
offset: qmq.offset,
|
||||
order: append([]OrderFunc{}, qmq.order...),
|
||||
unique: append([]string{}, qmq.unique...),
|
||||
predicates: append([]predicate.QQModel{}, qmq.predicates...),
|
||||
// clone intermediate query.
|
||||
sql: qmq.sql.Clone(),
|
||||
path: qmq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// GroupBy used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// QqNumber int64 `json:"qq_number,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.QQModel.Query().
|
||||
// GroupBy(qqmodel.FieldQqNumber).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func (qmq *QQModelQuery) GroupBy(field string, fields ...string) *QQModelGroupBy {
|
||||
group := &QQModelGroupBy{config: qmq.config}
|
||||
group.fields = append([]string{field}, fields...)
|
||||
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
||||
if err := qmq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return qmq.sqlQuery(), nil
|
||||
}
|
||||
return group
|
||||
}
|
||||
|
||||
// Select one or more fields from the given query.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// QqNumber int64 `json:"qq_number,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.QQModel.Query().
|
||||
// Select(qqmodel.FieldQqNumber).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func (qmq *QQModelQuery) Select(field string, fields ...string) *QQModelSelect {
|
||||
selector := &QQModelSelect{config: qmq.config}
|
||||
selector.fields = append([]string{field}, fields...)
|
||||
selector.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
||||
if err := qmq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return qmq.sqlQuery(), nil
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
func (qmq *QQModelQuery) prepareQuery(ctx context.Context) error {
|
||||
if qmq.path != nil {
|
||||
prev, err := qmq.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
qmq.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (qmq *QQModelQuery) sqlAll(ctx context.Context) ([]*QQModel, error) {
|
||||
var (
|
||||
nodes = []*QQModel{}
|
||||
_spec = qmq.querySpec()
|
||||
)
|
||||
_spec.ScanValues = func() []interface{} {
|
||||
node := &QQModel{config: qmq.config}
|
||||
nodes = append(nodes, node)
|
||||
values := node.scanValues()
|
||||
return values
|
||||
}
|
||||
_spec.Assign = func(values ...interface{}) error {
|
||||
if len(nodes) == 0 {
|
||||
return fmt.Errorf("ent: Assign called without calling ScanValues")
|
||||
}
|
||||
node := nodes[len(nodes)-1]
|
||||
return node.assignValues(values...)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, qmq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (qmq *QQModelQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := qmq.querySpec()
|
||||
return sqlgraph.CountNodes(ctx, qmq.driver, _spec)
|
||||
}
|
||||
|
||||
func (qmq *QQModelQuery) sqlExist(ctx context.Context) (bool, error) {
|
||||
n, err := qmq.sqlCount(ctx)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("ent: check existence: %v", err)
|
||||
}
|
||||
return n > 0, nil
|
||||
}
|
||||
|
||||
func (qmq *QQModelQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := &sqlgraph.QuerySpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: qqmodel.Table,
|
||||
Columns: qqmodel.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: qqmodel.FieldID,
|
||||
},
|
||||
},
|
||||
From: qmq.sql,
|
||||
Unique: true,
|
||||
}
|
||||
if ps := qmq.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := qmq.limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := qmq.offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := qmq.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector, qqmodel.ValidColumn)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (qmq *QQModelQuery) sqlQuery() *sql.Selector {
|
||||
builder := sql.Dialect(qmq.driver.Dialect())
|
||||
t1 := builder.Table(qqmodel.Table)
|
||||
selector := builder.Select(t1.Columns(qqmodel.Columns...)...).From(t1)
|
||||
if qmq.sql != nil {
|
||||
selector = qmq.sql
|
||||
selector.Select(selector.Columns(qqmodel.Columns...)...)
|
||||
}
|
||||
for _, p := range qmq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range qmq.order {
|
||||
p(selector, qqmodel.ValidColumn)
|
||||
}
|
||||
if offset := qmq.offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := qmq.limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// QQModelGroupBy is the builder for group-by QQModel entities.
|
||||
type QQModelGroupBy struct {
|
||||
config
|
||||
fields []string
|
||||
fns []AggregateFunc
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (qmgb *QQModelGroupBy) Aggregate(fns ...AggregateFunc) *QQModelGroupBy {
|
||||
qmgb.fns = append(qmgb.fns, fns...)
|
||||
return qmgb
|
||||
}
|
||||
|
||||
// Scan applies the group-by query and scan the result into the given value.
|
||||
func (qmgb *QQModelGroupBy) Scan(ctx context.Context, v interface{}) error {
|
||||
query, err := qmgb.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
qmgb.sql = query
|
||||
return qmgb.sqlScan(ctx, v)
|
||||
}
|
||||
|
||||
// ScanX is like Scan, but panics if an error occurs.
|
||||
func (qmgb *QQModelGroupBy) ScanX(ctx context.Context, v interface{}) {
|
||||
if err := qmgb.Scan(ctx, v); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Strings returns list of strings from group-by. It is only allowed when querying group-by with one field.
|
||||
func (qmgb *QQModelGroupBy) Strings(ctx context.Context) ([]string, error) {
|
||||
if len(qmgb.fields) > 1 {
|
||||
return nil, errors.New("ent: QQModelGroupBy.Strings is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []string
|
||||
if err := qmgb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// StringsX is like Strings, but panics if an error occurs.
|
||||
func (qmgb *QQModelGroupBy) StringsX(ctx context.Context) []string {
|
||||
v, err := qmgb.Strings(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// String returns a single string from group-by. It is only allowed when querying group-by with one field.
|
||||
func (qmgb *QQModelGroupBy) String(ctx context.Context) (_ string, err error) {
|
||||
var v []string
|
||||
if v, err = qmgb.Strings(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{qqmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: QQModelGroupBy.Strings returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// StringX is like String, but panics if an error occurs.
|
||||
func (qmgb *QQModelGroupBy) StringX(ctx context.Context) string {
|
||||
v, err := qmgb.String(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Ints returns list of ints from group-by. It is only allowed when querying group-by with one field.
|
||||
func (qmgb *QQModelGroupBy) Ints(ctx context.Context) ([]int, error) {
|
||||
if len(qmgb.fields) > 1 {
|
||||
return nil, errors.New("ent: QQModelGroupBy.Ints is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []int
|
||||
if err := qmgb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// IntsX is like Ints, but panics if an error occurs.
|
||||
func (qmgb *QQModelGroupBy) IntsX(ctx context.Context) []int {
|
||||
v, err := qmgb.Ints(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Int returns a single int from group-by. It is only allowed when querying group-by with one field.
|
||||
func (qmgb *QQModelGroupBy) Int(ctx context.Context) (_ int, err error) {
|
||||
var v []int
|
||||
if v, err = qmgb.Ints(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{qqmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: QQModelGroupBy.Ints returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// IntX is like Int, but panics if an error occurs.
|
||||
func (qmgb *QQModelGroupBy) IntX(ctx context.Context) int {
|
||||
v, err := qmgb.Int(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64s returns list of float64s from group-by. It is only allowed when querying group-by with one field.
|
||||
func (qmgb *QQModelGroupBy) Float64s(ctx context.Context) ([]float64, error) {
|
||||
if len(qmgb.fields) > 1 {
|
||||
return nil, errors.New("ent: QQModelGroupBy.Float64s is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []float64
|
||||
if err := qmgb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Float64sX is like Float64s, but panics if an error occurs.
|
||||
func (qmgb *QQModelGroupBy) Float64sX(ctx context.Context) []float64 {
|
||||
v, err := qmgb.Float64s(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64 returns a single float64 from group-by. It is only allowed when querying group-by with one field.
|
||||
func (qmgb *QQModelGroupBy) Float64(ctx context.Context) (_ float64, err error) {
|
||||
var v []float64
|
||||
if v, err = qmgb.Float64s(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{qqmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: QQModelGroupBy.Float64s returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Float64X is like Float64, but panics if an error occurs.
|
||||
func (qmgb *QQModelGroupBy) Float64X(ctx context.Context) float64 {
|
||||
v, err := qmgb.Float64(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bools returns list of bools from group-by. It is only allowed when querying group-by with one field.
|
||||
func (qmgb *QQModelGroupBy) Bools(ctx context.Context) ([]bool, error) {
|
||||
if len(qmgb.fields) > 1 {
|
||||
return nil, errors.New("ent: QQModelGroupBy.Bools is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []bool
|
||||
if err := qmgb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// BoolsX is like Bools, but panics if an error occurs.
|
||||
func (qmgb *QQModelGroupBy) BoolsX(ctx context.Context) []bool {
|
||||
v, err := qmgb.Bools(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bool returns a single bool from group-by. It is only allowed when querying group-by with one field.
|
||||
func (qmgb *QQModelGroupBy) Bool(ctx context.Context) (_ bool, err error) {
|
||||
var v []bool
|
||||
if v, err = qmgb.Bools(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{qqmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: QQModelGroupBy.Bools returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// BoolX is like Bool, but panics if an error occurs.
|
||||
func (qmgb *QQModelGroupBy) BoolX(ctx context.Context) bool {
|
||||
v, err := qmgb.Bool(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func (qmgb *QQModelGroupBy) sqlScan(ctx context.Context, v interface{}) error {
|
||||
for _, f := range qmgb.fields {
|
||||
if !qqmodel.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
|
||||
}
|
||||
}
|
||||
selector := qmgb.sqlQuery()
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := qmgb.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
func (qmgb *QQModelGroupBy) sqlQuery() *sql.Selector {
|
||||
selector := qmgb.sql
|
||||
columns := make([]string, 0, len(qmgb.fields)+len(qmgb.fns))
|
||||
columns = append(columns, qmgb.fields...)
|
||||
for _, fn := range qmgb.fns {
|
||||
columns = append(columns, fn(selector, qqmodel.ValidColumn))
|
||||
}
|
||||
return selector.Select(columns...).GroupBy(qmgb.fields...)
|
||||
}
|
||||
|
||||
// QQModelSelect is the builder for select fields of QQModel entities.
|
||||
type QQModelSelect struct {
|
||||
config
|
||||
fields []string
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scan the result into the given value.
|
||||
func (qms *QQModelSelect) Scan(ctx context.Context, v interface{}) error {
|
||||
query, err := qms.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
qms.sql = query
|
||||
return qms.sqlScan(ctx, v)
|
||||
}
|
||||
|
||||
// ScanX is like Scan, but panics if an error occurs.
|
||||
func (qms *QQModelSelect) ScanX(ctx context.Context, v interface{}) {
|
||||
if err := qms.Scan(ctx, v); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Strings returns list of strings from selector. It is only allowed when selecting one field.
|
||||
func (qms *QQModelSelect) Strings(ctx context.Context) ([]string, error) {
|
||||
if len(qms.fields) > 1 {
|
||||
return nil, errors.New("ent: QQModelSelect.Strings is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []string
|
||||
if err := qms.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// StringsX is like Strings, but panics if an error occurs.
|
||||
func (qms *QQModelSelect) StringsX(ctx context.Context) []string {
|
||||
v, err := qms.Strings(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// String returns a single string from selector. It is only allowed when selecting one field.
|
||||
func (qms *QQModelSelect) String(ctx context.Context) (_ string, err error) {
|
||||
var v []string
|
||||
if v, err = qms.Strings(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{qqmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: QQModelSelect.Strings returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// StringX is like String, but panics if an error occurs.
|
||||
func (qms *QQModelSelect) StringX(ctx context.Context) string {
|
||||
v, err := qms.String(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Ints returns list of ints from selector. It is only allowed when selecting one field.
|
||||
func (qms *QQModelSelect) Ints(ctx context.Context) ([]int, error) {
|
||||
if len(qms.fields) > 1 {
|
||||
return nil, errors.New("ent: QQModelSelect.Ints is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []int
|
||||
if err := qms.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// IntsX is like Ints, but panics if an error occurs.
|
||||
func (qms *QQModelSelect) IntsX(ctx context.Context) []int {
|
||||
v, err := qms.Ints(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Int returns a single int from selector. It is only allowed when selecting one field.
|
||||
func (qms *QQModelSelect) Int(ctx context.Context) (_ int, err error) {
|
||||
var v []int
|
||||
if v, err = qms.Ints(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{qqmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: QQModelSelect.Ints returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// IntX is like Int, but panics if an error occurs.
|
||||
func (qms *QQModelSelect) IntX(ctx context.Context) int {
|
||||
v, err := qms.Int(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64s returns list of float64s from selector. It is only allowed when selecting one field.
|
||||
func (qms *QQModelSelect) Float64s(ctx context.Context) ([]float64, error) {
|
||||
if len(qms.fields) > 1 {
|
||||
return nil, errors.New("ent: QQModelSelect.Float64s is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []float64
|
||||
if err := qms.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Float64sX is like Float64s, but panics if an error occurs.
|
||||
func (qms *QQModelSelect) Float64sX(ctx context.Context) []float64 {
|
||||
v, err := qms.Float64s(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64 returns a single float64 from selector. It is only allowed when selecting one field.
|
||||
func (qms *QQModelSelect) Float64(ctx context.Context) (_ float64, err error) {
|
||||
var v []float64
|
||||
if v, err = qms.Float64s(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{qqmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: QQModelSelect.Float64s returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Float64X is like Float64, but panics if an error occurs.
|
||||
func (qms *QQModelSelect) Float64X(ctx context.Context) float64 {
|
||||
v, err := qms.Float64(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bools returns list of bools from selector. It is only allowed when selecting one field.
|
||||
func (qms *QQModelSelect) Bools(ctx context.Context) ([]bool, error) {
|
||||
if len(qms.fields) > 1 {
|
||||
return nil, errors.New("ent: QQModelSelect.Bools is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []bool
|
||||
if err := qms.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// BoolsX is like Bools, but panics if an error occurs.
|
||||
func (qms *QQModelSelect) BoolsX(ctx context.Context) []bool {
|
||||
v, err := qms.Bools(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bool returns a single bool from selector. It is only allowed when selecting one field.
|
||||
func (qms *QQModelSelect) Bool(ctx context.Context) (_ bool, err error) {
|
||||
var v []bool
|
||||
if v, err = qms.Bools(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{qqmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: QQModelSelect.Bools returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// BoolX is like Bool, but panics if an error occurs.
|
||||
func (qms *QQModelSelect) BoolX(ctx context.Context) bool {
|
||||
v, err := qms.Bool(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func (qms *QQModelSelect) sqlScan(ctx context.Context, v interface{}) error {
|
||||
for _, f := range qms.fields {
|
||||
if !qqmodel.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for selection", f)}
|
||||
}
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := qms.sqlQuery().Query()
|
||||
if err := qms.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
func (qms *QQModelSelect) sqlQuery() sql.Querier {
|
||||
selector := qms.sql
|
||||
selector.Select(selector.Columns(qms.fields...)...)
|
||||
return selector
|
||||
}
|
313
server/ent/qqmodel_update.go
Normal file
313
server/ent/qqmodel_update.go
Normal file
@ -0,0 +1,313 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/kallydev/privacy/ent/predicate"
|
||||
"github.com/kallydev/privacy/ent/qqmodel"
|
||||
)
|
||||
|
||||
// QQModelUpdate is the builder for updating QQModel entities.
|
||||
type QQModelUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *QQModelMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the builder.
|
||||
func (qmu *QQModelUpdate) Where(ps ...predicate.QQModel) *QQModelUpdate {
|
||||
qmu.mutation.predicates = append(qmu.mutation.predicates, ps...)
|
||||
return qmu
|
||||
}
|
||||
|
||||
// SetQqNumber sets the qq_number field.
|
||||
func (qmu *QQModelUpdate) SetQqNumber(i int64) *QQModelUpdate {
|
||||
qmu.mutation.ResetQqNumber()
|
||||
qmu.mutation.SetQqNumber(i)
|
||||
return qmu
|
||||
}
|
||||
|
||||
// AddQqNumber adds i to qq_number.
|
||||
func (qmu *QQModelUpdate) AddQqNumber(i int64) *QQModelUpdate {
|
||||
qmu.mutation.AddQqNumber(i)
|
||||
return qmu
|
||||
}
|
||||
|
||||
// SetPhoneNumber sets the phone_number field.
|
||||
func (qmu *QQModelUpdate) SetPhoneNumber(i int64) *QQModelUpdate {
|
||||
qmu.mutation.ResetPhoneNumber()
|
||||
qmu.mutation.SetPhoneNumber(i)
|
||||
return qmu
|
||||
}
|
||||
|
||||
// AddPhoneNumber adds i to phone_number.
|
||||
func (qmu *QQModelUpdate) AddPhoneNumber(i int64) *QQModelUpdate {
|
||||
qmu.mutation.AddPhoneNumber(i)
|
||||
return qmu
|
||||
}
|
||||
|
||||
// Mutation returns the QQModelMutation object of the builder.
|
||||
func (qmu *QQModelUpdate) Mutation() *QQModelMutation {
|
||||
return qmu.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of rows/vertices matched by this operation.
|
||||
func (qmu *QQModelUpdate) Save(ctx context.Context) (int, error) {
|
||||
var (
|
||||
err error
|
||||
affected int
|
||||
)
|
||||
if len(qmu.hooks) == 0 {
|
||||
affected, err = qmu.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*QQModelMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
qmu.mutation = mutation
|
||||
affected, err = qmu.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return affected, err
|
||||
})
|
||||
for i := len(qmu.hooks) - 1; i >= 0; i-- {
|
||||
mut = qmu.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, qmu.mutation); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (qmu *QQModelUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := qmu.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (qmu *QQModelUpdate) Exec(ctx context.Context) error {
|
||||
_, err := qmu.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (qmu *QQModelUpdate) ExecX(ctx context.Context) {
|
||||
if err := qmu.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (qmu *QQModelUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
_spec := &sqlgraph.UpdateSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: qqmodel.Table,
|
||||
Columns: qqmodel.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: qqmodel.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := qmu.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := qmu.mutation.QqNumber(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt64,
|
||||
Value: value,
|
||||
Column: qqmodel.FieldQqNumber,
|
||||
})
|
||||
}
|
||||
if value, ok := qmu.mutation.AddedQqNumber(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt64,
|
||||
Value: value,
|
||||
Column: qqmodel.FieldQqNumber,
|
||||
})
|
||||
}
|
||||
if value, ok := qmu.mutation.PhoneNumber(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt64,
|
||||
Value: value,
|
||||
Column: qqmodel.FieldPhoneNumber,
|
||||
})
|
||||
}
|
||||
if value, ok := qmu.mutation.AddedPhoneNumber(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt64,
|
||||
Value: value,
|
||||
Column: qqmodel.FieldPhoneNumber,
|
||||
})
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, qmu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{qqmodel.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// QQModelUpdateOne is the builder for updating a single QQModel entity.
|
||||
type QQModelUpdateOne struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *QQModelMutation
|
||||
}
|
||||
|
||||
// SetQqNumber sets the qq_number field.
|
||||
func (qmuo *QQModelUpdateOne) SetQqNumber(i int64) *QQModelUpdateOne {
|
||||
qmuo.mutation.ResetQqNumber()
|
||||
qmuo.mutation.SetQqNumber(i)
|
||||
return qmuo
|
||||
}
|
||||
|
||||
// AddQqNumber adds i to qq_number.
|
||||
func (qmuo *QQModelUpdateOne) AddQqNumber(i int64) *QQModelUpdateOne {
|
||||
qmuo.mutation.AddQqNumber(i)
|
||||
return qmuo
|
||||
}
|
||||
|
||||
// SetPhoneNumber sets the phone_number field.
|
||||
func (qmuo *QQModelUpdateOne) SetPhoneNumber(i int64) *QQModelUpdateOne {
|
||||
qmuo.mutation.ResetPhoneNumber()
|
||||
qmuo.mutation.SetPhoneNumber(i)
|
||||
return qmuo
|
||||
}
|
||||
|
||||
// AddPhoneNumber adds i to phone_number.
|
||||
func (qmuo *QQModelUpdateOne) AddPhoneNumber(i int64) *QQModelUpdateOne {
|
||||
qmuo.mutation.AddPhoneNumber(i)
|
||||
return qmuo
|
||||
}
|
||||
|
||||
// Mutation returns the QQModelMutation object of the builder.
|
||||
func (qmuo *QQModelUpdateOne) Mutation() *QQModelMutation {
|
||||
return qmuo.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated entity.
|
||||
func (qmuo *QQModelUpdateOne) Save(ctx context.Context) (*QQModel, error) {
|
||||
var (
|
||||
err error
|
||||
node *QQModel
|
||||
)
|
||||
if len(qmuo.hooks) == 0 {
|
||||
node, err = qmuo.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*QQModelMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
qmuo.mutation = mutation
|
||||
node, err = qmuo.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(qmuo.hooks) - 1; i >= 0; i-- {
|
||||
mut = qmuo.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, qmuo.mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return node, err
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (qmuo *QQModelUpdateOne) SaveX(ctx context.Context) *QQModel {
|
||||
node, err := qmuo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (qmuo *QQModelUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := qmuo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (qmuo *QQModelUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := qmuo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (qmuo *QQModelUpdateOne) sqlSave(ctx context.Context) (_node *QQModel, err error) {
|
||||
_spec := &sqlgraph.UpdateSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: qqmodel.Table,
|
||||
Columns: qqmodel.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: qqmodel.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
id, ok := qmuo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing QQModel.ID for update")}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if value, ok := qmuo.mutation.QqNumber(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt64,
|
||||
Value: value,
|
||||
Column: qqmodel.FieldQqNumber,
|
||||
})
|
||||
}
|
||||
if value, ok := qmuo.mutation.AddedQqNumber(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt64,
|
||||
Value: value,
|
||||
Column: qqmodel.FieldQqNumber,
|
||||
})
|
||||
}
|
||||
if value, ok := qmuo.mutation.PhoneNumber(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt64,
|
||||
Value: value,
|
||||
Column: qqmodel.FieldPhoneNumber,
|
||||
})
|
||||
}
|
||||
if value, ok := qmuo.mutation.AddedPhoneNumber(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt64,
|
||||
Value: value,
|
||||
Column: qqmodel.FieldPhoneNumber,
|
||||
})
|
||||
}
|
||||
_node = &QQModel{config: qmuo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues()
|
||||
if err = sqlgraph.UpdateNode(ctx, qmuo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{qqmodel.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return _node, nil
|
||||
}
|
9
server/ent/runtime.go
Normal file
9
server/ent/runtime.go
Normal file
@ -0,0 +1,9 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
// The init function reads all schema descriptors with runtime code
|
||||
// (default values, validators, hooks and policies) and stitches it
|
||||
// to their package variables.
|
||||
func init() {
|
||||
}
|
10
server/ent/runtime/runtime.go
Normal file
10
server/ent/runtime/runtime.go
Normal file
@ -0,0 +1,10 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package runtime
|
||||
|
||||
// The schema-stitching logic is generated in github.com/kallydev/privacy/ent/runtime.go
|
||||
|
||||
const (
|
||||
Version = "v0.5.0" // Version of ent codegen.
|
||||
Sum = "h1:NlDQDxJi1X6+20CCjRQgu8UqvRhQNm5ocPBCQYdxC/8=" // Sum of ent codegen.
|
||||
)
|
37
server/ent/schema/jdmodel.go
Normal file
37
server/ent/schema/jdmodel.go
Normal file
@ -0,0 +1,37 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"github.com/facebook/ent"
|
||||
"github.com/facebook/ent/dialect/entsql"
|
||||
"github.com/facebook/ent/schema"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
)
|
||||
|
||||
// JDModel holds the schema definition for the JDModel entity.
|
||||
type JDModel struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Annotations of the JDModel.
|
||||
func (JDModel) Annotations() []schema.Annotation {
|
||||
return []schema.Annotation{
|
||||
entsql.Annotation{Table: "jd"},
|
||||
}
|
||||
}
|
||||
|
||||
// Fields of the JDModel.
|
||||
func (JDModel) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("name"),
|
||||
field.String("nickname"),
|
||||
field.String("password"),
|
||||
field.String("email"),
|
||||
field.String("id_number"),
|
||||
field.Int64("phone_number"),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the JDModel.
|
||||
func (JDModel) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
33
server/ent/schema/qqmodel.go
Normal file
33
server/ent/schema/qqmodel.go
Normal file
@ -0,0 +1,33 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"github.com/facebook/ent"
|
||||
"github.com/facebook/ent/dialect/entsql"
|
||||
"github.com/facebook/ent/schema"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
)
|
||||
|
||||
// QQModel holds the schema definition for the QQModel entity.
|
||||
type QQModel struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Annotations of the QQModel.
|
||||
func (QQModel) Annotations() []schema.Annotation {
|
||||
return []schema.Annotation{
|
||||
entsql.Annotation{Table: "qq"},
|
||||
}
|
||||
}
|
||||
|
||||
// Fields of the QQModel.
|
||||
func (QQModel) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int64("qq_number"),
|
||||
field.Int64("phone_number"),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the QQModel.
|
||||
func (QQModel) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
34
server/ent/schema/sfmodel.go
Normal file
34
server/ent/schema/sfmodel.go
Normal file
@ -0,0 +1,34 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"github.com/facebook/ent"
|
||||
"github.com/facebook/ent/dialect/entsql"
|
||||
"github.com/facebook/ent/schema"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
)
|
||||
|
||||
// SFModel holds the schema definition for the SFModel entity.
|
||||
type SFModel struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Annotations of the SFModel.
|
||||
func (SFModel) Annotations() []schema.Annotation {
|
||||
return []schema.Annotation{
|
||||
entsql.Annotation{Table: "sf"},
|
||||
}
|
||||
}
|
||||
|
||||
// Fields of the SFModel.
|
||||
func (SFModel) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("name"),
|
||||
field.Int64("phone_number"),
|
||||
field.String("address"),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the SFModel.
|
||||
func (SFModel) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
106
server/ent/sfmodel.go
Normal file
106
server/ent/sfmodel.go
Normal file
@ -0,0 +1,106 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/kallydev/privacy/ent/sfmodel"
|
||||
)
|
||||
|
||||
// SFModel is the model entity for the SFModel schema.
|
||||
type SFModel struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// Name holds the value of the "name" field.
|
||||
Name string `json:"name,omitempty"`
|
||||
// PhoneNumber holds the value of the "phone_number" field.
|
||||
PhoneNumber int64 `json:"phone_number,omitempty"`
|
||||
// Address holds the value of the "address" field.
|
||||
Address string `json:"address,omitempty"`
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*SFModel) scanValues() []interface{} {
|
||||
return []interface{}{
|
||||
&sql.NullInt64{}, // id
|
||||
&sql.NullString{}, // name
|
||||
&sql.NullInt64{}, // phone_number
|
||||
&sql.NullString{}, // address
|
||||
}
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the SFModel fields.
|
||||
func (sm *SFModel) assignValues(values ...interface{}) error {
|
||||
if m, n := len(values), len(sfmodel.Columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
value, ok := values[0].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
sm.ID = int(value.Int64)
|
||||
values = values[1:]
|
||||
if value, ok := values[0].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[0])
|
||||
} else if value.Valid {
|
||||
sm.Name = value.String
|
||||
}
|
||||
if value, ok := values[1].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field phone_number", values[1])
|
||||
} else if value.Valid {
|
||||
sm.PhoneNumber = value.Int64
|
||||
}
|
||||
if value, ok := values[2].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field address", values[2])
|
||||
} else if value.Valid {
|
||||
sm.Address = value.String
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this SFModel.
|
||||
// Note that, you need to call SFModel.Unwrap() before calling this method, if this SFModel
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (sm *SFModel) Update() *SFModelUpdateOne {
|
||||
return (&SFModelClient{config: sm.config}).UpdateOne(sm)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the entity that was returned from a transaction after it was closed,
|
||||
// so that all next queries will be executed through the driver which created the transaction.
|
||||
func (sm *SFModel) Unwrap() *SFModel {
|
||||
tx, ok := sm.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: SFModel is not a transactional entity")
|
||||
}
|
||||
sm.config.driver = tx.drv
|
||||
return sm
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (sm *SFModel) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("SFModel(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v", sm.ID))
|
||||
builder.WriteString(", name=")
|
||||
builder.WriteString(sm.Name)
|
||||
builder.WriteString(", phone_number=")
|
||||
builder.WriteString(fmt.Sprintf("%v", sm.PhoneNumber))
|
||||
builder.WriteString(", address=")
|
||||
builder.WriteString(sm.Address)
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// SFModels is a parsable slice of SFModel.
|
||||
type SFModels []*SFModel
|
||||
|
||||
func (sm SFModels) config(cfg config) {
|
||||
for _i := range sm {
|
||||
sm[_i].config = cfg
|
||||
}
|
||||
}
|
37
server/ent/sfmodel/sfmodel.go
Normal file
37
server/ent/sfmodel/sfmodel.go
Normal file
@ -0,0 +1,37 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package sfmodel
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the sfmodel type in the database.
|
||||
Label = "sf_model"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldName holds the string denoting the name field in the database.
|
||||
FieldName = "name"
|
||||
// FieldPhoneNumber holds the string denoting the phone_number field in the database.
|
||||
FieldPhoneNumber = "phone_number"
|
||||
// FieldAddress holds the string denoting the address field in the database.
|
||||
FieldAddress = "address"
|
||||
|
||||
// Table holds the table name of the sfmodel in the database.
|
||||
Table = "sf"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for sfmodel fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldName,
|
||||
FieldPhoneNumber,
|
||||
FieldAddress,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
442
server/ent/sfmodel/where.go
Normal file
442
server/ent/sfmodel/where.go
Normal file
@ -0,0 +1,442 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package sfmodel
|
||||
|
||||
import (
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/kallydev/privacy/ent/predicate"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their identifier.
|
||||
func ID(id int) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
|
||||
func Name(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumber applies equality check predicate on the "phone_number" field. It's identical to PhoneNumberEQ.
|
||||
func PhoneNumber(v int64) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldPhoneNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// Address applies equality check predicate on the "address" field. It's identical to AddressEQ.
|
||||
func Address(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldAddress), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameEQ applies the EQ predicate on the "name" field.
|
||||
func NameEQ(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameNEQ applies the NEQ predicate on the "name" field.
|
||||
func NameNEQ(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameIn applies the In predicate on the "name" field.
|
||||
func NameIn(vs ...string) predicate.SFModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldName), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// NameNotIn applies the NotIn predicate on the "name" field.
|
||||
func NameNotIn(vs ...string) predicate.SFModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldName), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// NameGT applies the GT predicate on the "name" field.
|
||||
func NameGT(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameGTE applies the GTE predicate on the "name" field.
|
||||
func NameGTE(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameLT applies the LT predicate on the "name" field.
|
||||
func NameLT(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameLTE applies the LTE predicate on the "name" field.
|
||||
func NameLTE(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameContains applies the Contains predicate on the "name" field.
|
||||
func NameContains(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.Contains(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
|
||||
func NameHasPrefix(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.HasPrefix(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
|
||||
func NameHasSuffix(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.HasSuffix(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameEqualFold applies the EqualFold predicate on the "name" field.
|
||||
func NameEqualFold(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EqualFold(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameContainsFold applies the ContainsFold predicate on the "name" field.
|
||||
func NameContainsFold(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.ContainsFold(s.C(FieldName), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberEQ applies the EQ predicate on the "phone_number" field.
|
||||
func PhoneNumberEQ(v int64) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldPhoneNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberNEQ applies the NEQ predicate on the "phone_number" field.
|
||||
func PhoneNumberNEQ(v int64) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldPhoneNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberIn applies the In predicate on the "phone_number" field.
|
||||
func PhoneNumberIn(vs ...int64) predicate.SFModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldPhoneNumber), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberNotIn applies the NotIn predicate on the "phone_number" field.
|
||||
func PhoneNumberNotIn(vs ...int64) predicate.SFModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldPhoneNumber), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberGT applies the GT predicate on the "phone_number" field.
|
||||
func PhoneNumberGT(v int64) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldPhoneNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberGTE applies the GTE predicate on the "phone_number" field.
|
||||
func PhoneNumberGTE(v int64) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldPhoneNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberLT applies the LT predicate on the "phone_number" field.
|
||||
func PhoneNumberLT(v int64) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldPhoneNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PhoneNumberLTE applies the LTE predicate on the "phone_number" field.
|
||||
func PhoneNumberLTE(v int64) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldPhoneNumber), v))
|
||||
})
|
||||
}
|
||||
|
||||
// AddressEQ applies the EQ predicate on the "address" field.
|
||||
func AddressEQ(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldAddress), v))
|
||||
})
|
||||
}
|
||||
|
||||
// AddressNEQ applies the NEQ predicate on the "address" field.
|
||||
func AddressNEQ(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldAddress), v))
|
||||
})
|
||||
}
|
||||
|
||||
// AddressIn applies the In predicate on the "address" field.
|
||||
func AddressIn(vs ...string) predicate.SFModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldAddress), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// AddressNotIn applies the NotIn predicate on the "address" field.
|
||||
func AddressNotIn(vs ...string) predicate.SFModel {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldAddress), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// AddressGT applies the GT predicate on the "address" field.
|
||||
func AddressGT(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldAddress), v))
|
||||
})
|
||||
}
|
||||
|
||||
// AddressGTE applies the GTE predicate on the "address" field.
|
||||
func AddressGTE(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldAddress), v))
|
||||
})
|
||||
}
|
||||
|
||||
// AddressLT applies the LT predicate on the "address" field.
|
||||
func AddressLT(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldAddress), v))
|
||||
})
|
||||
}
|
||||
|
||||
// AddressLTE applies the LTE predicate on the "address" field.
|
||||
func AddressLTE(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldAddress), v))
|
||||
})
|
||||
}
|
||||
|
||||
// AddressContains applies the Contains predicate on the "address" field.
|
||||
func AddressContains(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.Contains(s.C(FieldAddress), v))
|
||||
})
|
||||
}
|
||||
|
||||
// AddressHasPrefix applies the HasPrefix predicate on the "address" field.
|
||||
func AddressHasPrefix(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.HasPrefix(s.C(FieldAddress), v))
|
||||
})
|
||||
}
|
||||
|
||||
// AddressHasSuffix applies the HasSuffix predicate on the "address" field.
|
||||
func AddressHasSuffix(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.HasSuffix(s.C(FieldAddress), v))
|
||||
})
|
||||
}
|
||||
|
||||
// AddressEqualFold applies the EqualFold predicate on the "address" field.
|
||||
func AddressEqualFold(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.EqualFold(s.C(FieldAddress), v))
|
||||
})
|
||||
}
|
||||
|
||||
// AddressContainsFold applies the ContainsFold predicate on the "address" field.
|
||||
func AddressContainsFold(v string) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s.Where(sql.ContainsFold(s.C(FieldAddress), v))
|
||||
})
|
||||
}
|
||||
|
||||
// And groups list of predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.SFModel) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for _, p := range predicates {
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
}
|
||||
|
||||
// Or groups list of predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.SFModel) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for i, p := range predicates {
|
||||
if i > 0 {
|
||||
s1.Or()
|
||||
}
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.SFModel) predicate.SFModel {
|
||||
return predicate.SFModel(func(s *sql.Selector) {
|
||||
p(s.Not())
|
||||
})
|
||||
}
|
218
server/ent/sfmodel_create.go
Normal file
218
server/ent/sfmodel_create.go
Normal file
@ -0,0 +1,218 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/kallydev/privacy/ent/sfmodel"
|
||||
)
|
||||
|
||||
// SFModelCreate is the builder for creating a SFModel entity.
|
||||
type SFModelCreate struct {
|
||||
config
|
||||
mutation *SFModelMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetName sets the name field.
|
||||
func (smc *SFModelCreate) SetName(s string) *SFModelCreate {
|
||||
smc.mutation.SetName(s)
|
||||
return smc
|
||||
}
|
||||
|
||||
// SetPhoneNumber sets the phone_number field.
|
||||
func (smc *SFModelCreate) SetPhoneNumber(i int64) *SFModelCreate {
|
||||
smc.mutation.SetPhoneNumber(i)
|
||||
return smc
|
||||
}
|
||||
|
||||
// SetAddress sets the address field.
|
||||
func (smc *SFModelCreate) SetAddress(s string) *SFModelCreate {
|
||||
smc.mutation.SetAddress(s)
|
||||
return smc
|
||||
}
|
||||
|
||||
// Mutation returns the SFModelMutation object of the builder.
|
||||
func (smc *SFModelCreate) Mutation() *SFModelMutation {
|
||||
return smc.mutation
|
||||
}
|
||||
|
||||
// Save creates the SFModel in the database.
|
||||
func (smc *SFModelCreate) Save(ctx context.Context) (*SFModel, error) {
|
||||
var (
|
||||
err error
|
||||
node *SFModel
|
||||
)
|
||||
if len(smc.hooks) == 0 {
|
||||
if err = smc.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
node, err = smc.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*SFModelMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err = smc.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
smc.mutation = mutation
|
||||
node, err = smc.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(smc.hooks) - 1; i >= 0; i-- {
|
||||
mut = smc.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, smc.mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return node, err
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (smc *SFModelCreate) SaveX(ctx context.Context) *SFModel {
|
||||
v, err := smc.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (smc *SFModelCreate) check() error {
|
||||
if _, ok := smc.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New("ent: missing required field \"name\"")}
|
||||
}
|
||||
if _, ok := smc.mutation.PhoneNumber(); !ok {
|
||||
return &ValidationError{Name: "phone_number", err: errors.New("ent: missing required field \"phone_number\"")}
|
||||
}
|
||||
if _, ok := smc.mutation.Address(); !ok {
|
||||
return &ValidationError{Name: "address", err: errors.New("ent: missing required field \"address\"")}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (smc *SFModelCreate) sqlSave(ctx context.Context) (*SFModel, error) {
|
||||
_node, _spec := smc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, smc.driver, _spec); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = int(id)
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (smc *SFModelCreate) createSpec() (*SFModel, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &SFModel{config: smc.config}
|
||||
_spec = &sqlgraph.CreateSpec{
|
||||
Table: sfmodel.Table,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: sfmodel.FieldID,
|
||||
},
|
||||
}
|
||||
)
|
||||
if value, ok := smc.mutation.Name(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: sfmodel.FieldName,
|
||||
})
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := smc.mutation.PhoneNumber(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt64,
|
||||
Value: value,
|
||||
Column: sfmodel.FieldPhoneNumber,
|
||||
})
|
||||
_node.PhoneNumber = value
|
||||
}
|
||||
if value, ok := smc.mutation.Address(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: sfmodel.FieldAddress,
|
||||
})
|
||||
_node.Address = value
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// SFModelCreateBulk is the builder for creating a bulk of SFModel entities.
|
||||
type SFModelCreateBulk struct {
|
||||
config
|
||||
builders []*SFModelCreate
|
||||
}
|
||||
|
||||
// Save creates the SFModel entities in the database.
|
||||
func (smcb *SFModelCreateBulk) Save(ctx context.Context) ([]*SFModel, error) {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(smcb.builders))
|
||||
nodes := make([]*SFModel, len(smcb.builders))
|
||||
mutators := make([]Mutator, len(smcb.builders))
|
||||
for i := range smcb.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := smcb.builders[i]
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*SFModelMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err := builder.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
var err error
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, smcb.builders[i+1].mutation)
|
||||
} else {
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, smcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
}
|
||||
}
|
||||
mutation.done = true
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
id := specs[i].ID.Value.(int64)
|
||||
nodes[i].ID = int(id)
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
mut = builder.hooks[i](mut)
|
||||
}
|
||||
mutators[i] = mut
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, smcb.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (smcb *SFModelCreateBulk) SaveX(ctx context.Context) []*SFModel {
|
||||
v, err := smcb.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
108
server/ent/sfmodel_delete.go
Normal file
108
server/ent/sfmodel_delete.go
Normal file
@ -0,0 +1,108 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/kallydev/privacy/ent/predicate"
|
||||
"github.com/kallydev/privacy/ent/sfmodel"
|
||||
)
|
||||
|
||||
// SFModelDelete is the builder for deleting a SFModel entity.
|
||||
type SFModelDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *SFModelMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate to the delete builder.
|
||||
func (smd *SFModelDelete) Where(ps ...predicate.SFModel) *SFModelDelete {
|
||||
smd.mutation.predicates = append(smd.mutation.predicates, ps...)
|
||||
return smd
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (smd *SFModelDelete) Exec(ctx context.Context) (int, error) {
|
||||
var (
|
||||
err error
|
||||
affected int
|
||||
)
|
||||
if len(smd.hooks) == 0 {
|
||||
affected, err = smd.sqlExec(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*SFModelMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
smd.mutation = mutation
|
||||
affected, err = smd.sqlExec(ctx)
|
||||
mutation.done = true
|
||||
return affected, err
|
||||
})
|
||||
for i := len(smd.hooks) - 1; i >= 0; i-- {
|
||||
mut = smd.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, smd.mutation); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (smd *SFModelDelete) ExecX(ctx context.Context) int {
|
||||
n, err := smd.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (smd *SFModelDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := &sqlgraph.DeleteSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: sfmodel.Table,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: sfmodel.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := smd.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return sqlgraph.DeleteNodes(ctx, smd.driver, _spec)
|
||||
}
|
||||
|
||||
// SFModelDeleteOne is the builder for deleting a single SFModel entity.
|
||||
type SFModelDeleteOne struct {
|
||||
smd *SFModelDelete
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (smdo *SFModelDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := smdo.smd.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{sfmodel.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (smdo *SFModelDeleteOne) ExecX(ctx context.Context) {
|
||||
smdo.smd.ExecX(ctx)
|
||||
}
|
883
server/ent/sfmodel_query.go
Normal file
883
server/ent/sfmodel_query.go
Normal file
@ -0,0 +1,883 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/kallydev/privacy/ent/predicate"
|
||||
"github.com/kallydev/privacy/ent/sfmodel"
|
||||
)
|
||||
|
||||
// SFModelQuery is the builder for querying SFModel entities.
|
||||
type SFModelQuery struct {
|
||||
config
|
||||
limit *int
|
||||
offset *int
|
||||
order []OrderFunc
|
||||
unique []string
|
||||
predicates []predicate.SFModel
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the builder.
|
||||
func (smq *SFModelQuery) Where(ps ...predicate.SFModel) *SFModelQuery {
|
||||
smq.predicates = append(smq.predicates, ps...)
|
||||
return smq
|
||||
}
|
||||
|
||||
// Limit adds a limit step to the query.
|
||||
func (smq *SFModelQuery) Limit(limit int) *SFModelQuery {
|
||||
smq.limit = &limit
|
||||
return smq
|
||||
}
|
||||
|
||||
// Offset adds an offset step to the query.
|
||||
func (smq *SFModelQuery) Offset(offset int) *SFModelQuery {
|
||||
smq.offset = &offset
|
||||
return smq
|
||||
}
|
||||
|
||||
// Order adds an order step to the query.
|
||||
func (smq *SFModelQuery) Order(o ...OrderFunc) *SFModelQuery {
|
||||
smq.order = append(smq.order, o...)
|
||||
return smq
|
||||
}
|
||||
|
||||
// First returns the first SFModel entity in the query. Returns *NotFoundError when no sfmodel was found.
|
||||
func (smq *SFModelQuery) First(ctx context.Context) (*SFModel, error) {
|
||||
nodes, err := smq.Limit(1).All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{sfmodel.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (smq *SFModelQuery) FirstX(ctx context.Context) *SFModel {
|
||||
node, err := smq.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first SFModel id in the query. Returns *NotFoundError when no id was found.
|
||||
func (smq *SFModelQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = smq.Limit(1).IDs(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{sfmodel.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (smq *SFModelQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := smq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns the only SFModel entity in the query, returns an error if not exactly one entity was returned.
|
||||
func (smq *SFModelQuery) Only(ctx context.Context) (*SFModel, error) {
|
||||
nodes, err := smq.Limit(2).All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{sfmodel.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{sfmodel.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (smq *SFModelQuery) OnlyX(ctx context.Context) *SFModel {
|
||||
node, err := smq.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID returns the only SFModel id in the query, returns an error if not exactly one id was returned.
|
||||
func (smq *SFModelQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = smq.Limit(2).IDs(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{sfmodel.Label}
|
||||
default:
|
||||
err = &NotSingularError{sfmodel.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (smq *SFModelQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := smq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of SFModels.
|
||||
func (smq *SFModelQuery) All(ctx context.Context) ([]*SFModel, error) {
|
||||
if err := smq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return smq.sqlAll(ctx)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (smq *SFModelQuery) AllX(ctx context.Context) []*SFModel {
|
||||
nodes, err := smq.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of SFModel ids.
|
||||
func (smq *SFModelQuery) IDs(ctx context.Context) ([]int, error) {
|
||||
var ids []int
|
||||
if err := smq.Select(sfmodel.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (smq *SFModelQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := smq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (smq *SFModelQuery) Count(ctx context.Context) (int, error) {
|
||||
if err := smq.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return smq.sqlCount(ctx)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (smq *SFModelQuery) CountX(ctx context.Context) int {
|
||||
count, err := smq.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (smq *SFModelQuery) Exist(ctx context.Context) (bool, error) {
|
||||
if err := smq.prepareQuery(ctx); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return smq.sqlExist(ctx)
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (smq *SFModelQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := smq.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the query builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (smq *SFModelQuery) Clone() *SFModelQuery {
|
||||
if smq == nil {
|
||||
return nil
|
||||
}
|
||||
return &SFModelQuery{
|
||||
config: smq.config,
|
||||
limit: smq.limit,
|
||||
offset: smq.offset,
|
||||
order: append([]OrderFunc{}, smq.order...),
|
||||
unique: append([]string{}, smq.unique...),
|
||||
predicates: append([]predicate.SFModel{}, smq.predicates...),
|
||||
// clone intermediate query.
|
||||
sql: smq.sql.Clone(),
|
||||
path: smq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// GroupBy used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Name string `json:"name,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.SFModel.Query().
|
||||
// GroupBy(sfmodel.FieldName).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func (smq *SFModelQuery) GroupBy(field string, fields ...string) *SFModelGroupBy {
|
||||
group := &SFModelGroupBy{config: smq.config}
|
||||
group.fields = append([]string{field}, fields...)
|
||||
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
||||
if err := smq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return smq.sqlQuery(), nil
|
||||
}
|
||||
return group
|
||||
}
|
||||
|
||||
// Select one or more fields from the given query.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Name string `json:"name,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.SFModel.Query().
|
||||
// Select(sfmodel.FieldName).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func (smq *SFModelQuery) Select(field string, fields ...string) *SFModelSelect {
|
||||
selector := &SFModelSelect{config: smq.config}
|
||||
selector.fields = append([]string{field}, fields...)
|
||||
selector.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
||||
if err := smq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return smq.sqlQuery(), nil
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
func (smq *SFModelQuery) prepareQuery(ctx context.Context) error {
|
||||
if smq.path != nil {
|
||||
prev, err := smq.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
smq.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (smq *SFModelQuery) sqlAll(ctx context.Context) ([]*SFModel, error) {
|
||||
var (
|
||||
nodes = []*SFModel{}
|
||||
_spec = smq.querySpec()
|
||||
)
|
||||
_spec.ScanValues = func() []interface{} {
|
||||
node := &SFModel{config: smq.config}
|
||||
nodes = append(nodes, node)
|
||||
values := node.scanValues()
|
||||
return values
|
||||
}
|
||||
_spec.Assign = func(values ...interface{}) error {
|
||||
if len(nodes) == 0 {
|
||||
return fmt.Errorf("ent: Assign called without calling ScanValues")
|
||||
}
|
||||
node := nodes[len(nodes)-1]
|
||||
return node.assignValues(values...)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, smq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (smq *SFModelQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := smq.querySpec()
|
||||
return sqlgraph.CountNodes(ctx, smq.driver, _spec)
|
||||
}
|
||||
|
||||
func (smq *SFModelQuery) sqlExist(ctx context.Context) (bool, error) {
|
||||
n, err := smq.sqlCount(ctx)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("ent: check existence: %v", err)
|
||||
}
|
||||
return n > 0, nil
|
||||
}
|
||||
|
||||
func (smq *SFModelQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := &sqlgraph.QuerySpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: sfmodel.Table,
|
||||
Columns: sfmodel.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: sfmodel.FieldID,
|
||||
},
|
||||
},
|
||||
From: smq.sql,
|
||||
Unique: true,
|
||||
}
|
||||
if ps := smq.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := smq.limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := smq.offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := smq.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector, sfmodel.ValidColumn)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (smq *SFModelQuery) sqlQuery() *sql.Selector {
|
||||
builder := sql.Dialect(smq.driver.Dialect())
|
||||
t1 := builder.Table(sfmodel.Table)
|
||||
selector := builder.Select(t1.Columns(sfmodel.Columns...)...).From(t1)
|
||||
if smq.sql != nil {
|
||||
selector = smq.sql
|
||||
selector.Select(selector.Columns(sfmodel.Columns...)...)
|
||||
}
|
||||
for _, p := range smq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range smq.order {
|
||||
p(selector, sfmodel.ValidColumn)
|
||||
}
|
||||
if offset := smq.offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := smq.limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// SFModelGroupBy is the builder for group-by SFModel entities.
|
||||
type SFModelGroupBy struct {
|
||||
config
|
||||
fields []string
|
||||
fns []AggregateFunc
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (smgb *SFModelGroupBy) Aggregate(fns ...AggregateFunc) *SFModelGroupBy {
|
||||
smgb.fns = append(smgb.fns, fns...)
|
||||
return smgb
|
||||
}
|
||||
|
||||
// Scan applies the group-by query and scan the result into the given value.
|
||||
func (smgb *SFModelGroupBy) Scan(ctx context.Context, v interface{}) error {
|
||||
query, err := smgb.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
smgb.sql = query
|
||||
return smgb.sqlScan(ctx, v)
|
||||
}
|
||||
|
||||
// ScanX is like Scan, but panics if an error occurs.
|
||||
func (smgb *SFModelGroupBy) ScanX(ctx context.Context, v interface{}) {
|
||||
if err := smgb.Scan(ctx, v); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Strings returns list of strings from group-by. It is only allowed when querying group-by with one field.
|
||||
func (smgb *SFModelGroupBy) Strings(ctx context.Context) ([]string, error) {
|
||||
if len(smgb.fields) > 1 {
|
||||
return nil, errors.New("ent: SFModelGroupBy.Strings is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []string
|
||||
if err := smgb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// StringsX is like Strings, but panics if an error occurs.
|
||||
func (smgb *SFModelGroupBy) StringsX(ctx context.Context) []string {
|
||||
v, err := smgb.Strings(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// String returns a single string from group-by. It is only allowed when querying group-by with one field.
|
||||
func (smgb *SFModelGroupBy) String(ctx context.Context) (_ string, err error) {
|
||||
var v []string
|
||||
if v, err = smgb.Strings(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{sfmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: SFModelGroupBy.Strings returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// StringX is like String, but panics if an error occurs.
|
||||
func (smgb *SFModelGroupBy) StringX(ctx context.Context) string {
|
||||
v, err := smgb.String(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Ints returns list of ints from group-by. It is only allowed when querying group-by with one field.
|
||||
func (smgb *SFModelGroupBy) Ints(ctx context.Context) ([]int, error) {
|
||||
if len(smgb.fields) > 1 {
|
||||
return nil, errors.New("ent: SFModelGroupBy.Ints is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []int
|
||||
if err := smgb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// IntsX is like Ints, but panics if an error occurs.
|
||||
func (smgb *SFModelGroupBy) IntsX(ctx context.Context) []int {
|
||||
v, err := smgb.Ints(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Int returns a single int from group-by. It is only allowed when querying group-by with one field.
|
||||
func (smgb *SFModelGroupBy) Int(ctx context.Context) (_ int, err error) {
|
||||
var v []int
|
||||
if v, err = smgb.Ints(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{sfmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: SFModelGroupBy.Ints returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// IntX is like Int, but panics if an error occurs.
|
||||
func (smgb *SFModelGroupBy) IntX(ctx context.Context) int {
|
||||
v, err := smgb.Int(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64s returns list of float64s from group-by. It is only allowed when querying group-by with one field.
|
||||
func (smgb *SFModelGroupBy) Float64s(ctx context.Context) ([]float64, error) {
|
||||
if len(smgb.fields) > 1 {
|
||||
return nil, errors.New("ent: SFModelGroupBy.Float64s is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []float64
|
||||
if err := smgb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Float64sX is like Float64s, but panics if an error occurs.
|
||||
func (smgb *SFModelGroupBy) Float64sX(ctx context.Context) []float64 {
|
||||
v, err := smgb.Float64s(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64 returns a single float64 from group-by. It is only allowed when querying group-by with one field.
|
||||
func (smgb *SFModelGroupBy) Float64(ctx context.Context) (_ float64, err error) {
|
||||
var v []float64
|
||||
if v, err = smgb.Float64s(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{sfmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: SFModelGroupBy.Float64s returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Float64X is like Float64, but panics if an error occurs.
|
||||
func (smgb *SFModelGroupBy) Float64X(ctx context.Context) float64 {
|
||||
v, err := smgb.Float64(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bools returns list of bools from group-by. It is only allowed when querying group-by with one field.
|
||||
func (smgb *SFModelGroupBy) Bools(ctx context.Context) ([]bool, error) {
|
||||
if len(smgb.fields) > 1 {
|
||||
return nil, errors.New("ent: SFModelGroupBy.Bools is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []bool
|
||||
if err := smgb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// BoolsX is like Bools, but panics if an error occurs.
|
||||
func (smgb *SFModelGroupBy) BoolsX(ctx context.Context) []bool {
|
||||
v, err := smgb.Bools(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bool returns a single bool from group-by. It is only allowed when querying group-by with one field.
|
||||
func (smgb *SFModelGroupBy) Bool(ctx context.Context) (_ bool, err error) {
|
||||
var v []bool
|
||||
if v, err = smgb.Bools(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{sfmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: SFModelGroupBy.Bools returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// BoolX is like Bool, but panics if an error occurs.
|
||||
func (smgb *SFModelGroupBy) BoolX(ctx context.Context) bool {
|
||||
v, err := smgb.Bool(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func (smgb *SFModelGroupBy) sqlScan(ctx context.Context, v interface{}) error {
|
||||
for _, f := range smgb.fields {
|
||||
if !sfmodel.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
|
||||
}
|
||||
}
|
||||
selector := smgb.sqlQuery()
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := smgb.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
func (smgb *SFModelGroupBy) sqlQuery() *sql.Selector {
|
||||
selector := smgb.sql
|
||||
columns := make([]string, 0, len(smgb.fields)+len(smgb.fns))
|
||||
columns = append(columns, smgb.fields...)
|
||||
for _, fn := range smgb.fns {
|
||||
columns = append(columns, fn(selector, sfmodel.ValidColumn))
|
||||
}
|
||||
return selector.Select(columns...).GroupBy(smgb.fields...)
|
||||
}
|
||||
|
||||
// SFModelSelect is the builder for select fields of SFModel entities.
|
||||
type SFModelSelect struct {
|
||||
config
|
||||
fields []string
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scan the result into the given value.
|
||||
func (sms *SFModelSelect) Scan(ctx context.Context, v interface{}) error {
|
||||
query, err := sms.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sms.sql = query
|
||||
return sms.sqlScan(ctx, v)
|
||||
}
|
||||
|
||||
// ScanX is like Scan, but panics if an error occurs.
|
||||
func (sms *SFModelSelect) ScanX(ctx context.Context, v interface{}) {
|
||||
if err := sms.Scan(ctx, v); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Strings returns list of strings from selector. It is only allowed when selecting one field.
|
||||
func (sms *SFModelSelect) Strings(ctx context.Context) ([]string, error) {
|
||||
if len(sms.fields) > 1 {
|
||||
return nil, errors.New("ent: SFModelSelect.Strings is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []string
|
||||
if err := sms.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// StringsX is like Strings, but panics if an error occurs.
|
||||
func (sms *SFModelSelect) StringsX(ctx context.Context) []string {
|
||||
v, err := sms.Strings(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// String returns a single string from selector. It is only allowed when selecting one field.
|
||||
func (sms *SFModelSelect) String(ctx context.Context) (_ string, err error) {
|
||||
var v []string
|
||||
if v, err = sms.Strings(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{sfmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: SFModelSelect.Strings returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// StringX is like String, but panics if an error occurs.
|
||||
func (sms *SFModelSelect) StringX(ctx context.Context) string {
|
||||
v, err := sms.String(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Ints returns list of ints from selector. It is only allowed when selecting one field.
|
||||
func (sms *SFModelSelect) Ints(ctx context.Context) ([]int, error) {
|
||||
if len(sms.fields) > 1 {
|
||||
return nil, errors.New("ent: SFModelSelect.Ints is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []int
|
||||
if err := sms.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// IntsX is like Ints, but panics if an error occurs.
|
||||
func (sms *SFModelSelect) IntsX(ctx context.Context) []int {
|
||||
v, err := sms.Ints(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Int returns a single int from selector. It is only allowed when selecting one field.
|
||||
func (sms *SFModelSelect) Int(ctx context.Context) (_ int, err error) {
|
||||
var v []int
|
||||
if v, err = sms.Ints(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{sfmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: SFModelSelect.Ints returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// IntX is like Int, but panics if an error occurs.
|
||||
func (sms *SFModelSelect) IntX(ctx context.Context) int {
|
||||
v, err := sms.Int(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64s returns list of float64s from selector. It is only allowed when selecting one field.
|
||||
func (sms *SFModelSelect) Float64s(ctx context.Context) ([]float64, error) {
|
||||
if len(sms.fields) > 1 {
|
||||
return nil, errors.New("ent: SFModelSelect.Float64s is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []float64
|
||||
if err := sms.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Float64sX is like Float64s, but panics if an error occurs.
|
||||
func (sms *SFModelSelect) Float64sX(ctx context.Context) []float64 {
|
||||
v, err := sms.Float64s(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64 returns a single float64 from selector. It is only allowed when selecting one field.
|
||||
func (sms *SFModelSelect) Float64(ctx context.Context) (_ float64, err error) {
|
||||
var v []float64
|
||||
if v, err = sms.Float64s(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{sfmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: SFModelSelect.Float64s returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Float64X is like Float64, but panics if an error occurs.
|
||||
func (sms *SFModelSelect) Float64X(ctx context.Context) float64 {
|
||||
v, err := sms.Float64(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bools returns list of bools from selector. It is only allowed when selecting one field.
|
||||
func (sms *SFModelSelect) Bools(ctx context.Context) ([]bool, error) {
|
||||
if len(sms.fields) > 1 {
|
||||
return nil, errors.New("ent: SFModelSelect.Bools is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []bool
|
||||
if err := sms.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// BoolsX is like Bools, but panics if an error occurs.
|
||||
func (sms *SFModelSelect) BoolsX(ctx context.Context) []bool {
|
||||
v, err := sms.Bools(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bool returns a single bool from selector. It is only allowed when selecting one field.
|
||||
func (sms *SFModelSelect) Bool(ctx context.Context) (_ bool, err error) {
|
||||
var v []bool
|
||||
if v, err = sms.Bools(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{sfmodel.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: SFModelSelect.Bools returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// BoolX is like Bool, but panics if an error occurs.
|
||||
func (sms *SFModelSelect) BoolX(ctx context.Context) bool {
|
||||
v, err := sms.Bool(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func (sms *SFModelSelect) sqlScan(ctx context.Context, v interface{}) error {
|
||||
for _, f := range sms.fields {
|
||||
if !sfmodel.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for selection", f)}
|
||||
}
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := sms.sqlQuery().Query()
|
||||
if err := sms.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
func (sms *SFModelSelect) sqlQuery() sql.Querier {
|
||||
selector := sms.sql
|
||||
selector.Select(selector.Columns(sms.fields...)...)
|
||||
return selector
|
||||
}
|
311
server/ent/sfmodel_update.go
Normal file
311
server/ent/sfmodel_update.go
Normal file
@ -0,0 +1,311 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/kallydev/privacy/ent/predicate"
|
||||
"github.com/kallydev/privacy/ent/sfmodel"
|
||||
)
|
||||
|
||||
// SFModelUpdate is the builder for updating SFModel entities.
|
||||
type SFModelUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *SFModelMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the builder.
|
||||
func (smu *SFModelUpdate) Where(ps ...predicate.SFModel) *SFModelUpdate {
|
||||
smu.mutation.predicates = append(smu.mutation.predicates, ps...)
|
||||
return smu
|
||||
}
|
||||
|
||||
// SetName sets the name field.
|
||||
func (smu *SFModelUpdate) SetName(s string) *SFModelUpdate {
|
||||
smu.mutation.SetName(s)
|
||||
return smu
|
||||
}
|
||||
|
||||
// SetPhoneNumber sets the phone_number field.
|
||||
func (smu *SFModelUpdate) SetPhoneNumber(i int64) *SFModelUpdate {
|
||||
smu.mutation.ResetPhoneNumber()
|
||||
smu.mutation.SetPhoneNumber(i)
|
||||
return smu
|
||||
}
|
||||
|
||||
// AddPhoneNumber adds i to phone_number.
|
||||
func (smu *SFModelUpdate) AddPhoneNumber(i int64) *SFModelUpdate {
|
||||
smu.mutation.AddPhoneNumber(i)
|
||||
return smu
|
||||
}
|
||||
|
||||
// SetAddress sets the address field.
|
||||
func (smu *SFModelUpdate) SetAddress(s string) *SFModelUpdate {
|
||||
smu.mutation.SetAddress(s)
|
||||
return smu
|
||||
}
|
||||
|
||||
// Mutation returns the SFModelMutation object of the builder.
|
||||
func (smu *SFModelUpdate) Mutation() *SFModelMutation {
|
||||
return smu.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of rows/vertices matched by this operation.
|
||||
func (smu *SFModelUpdate) Save(ctx context.Context) (int, error) {
|
||||
var (
|
||||
err error
|
||||
affected int
|
||||
)
|
||||
if len(smu.hooks) == 0 {
|
||||
affected, err = smu.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*SFModelMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
smu.mutation = mutation
|
||||
affected, err = smu.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return affected, err
|
||||
})
|
||||
for i := len(smu.hooks) - 1; i >= 0; i-- {
|
||||
mut = smu.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, smu.mutation); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (smu *SFModelUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := smu.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (smu *SFModelUpdate) Exec(ctx context.Context) error {
|
||||
_, err := smu.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (smu *SFModelUpdate) ExecX(ctx context.Context) {
|
||||
if err := smu.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (smu *SFModelUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
_spec := &sqlgraph.UpdateSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: sfmodel.Table,
|
||||
Columns: sfmodel.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: sfmodel.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := smu.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := smu.mutation.Name(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: sfmodel.FieldName,
|
||||
})
|
||||
}
|
||||
if value, ok := smu.mutation.PhoneNumber(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt64,
|
||||
Value: value,
|
||||
Column: sfmodel.FieldPhoneNumber,
|
||||
})
|
||||
}
|
||||
if value, ok := smu.mutation.AddedPhoneNumber(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt64,
|
||||
Value: value,
|
||||
Column: sfmodel.FieldPhoneNumber,
|
||||
})
|
||||
}
|
||||
if value, ok := smu.mutation.Address(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: sfmodel.FieldAddress,
|
||||
})
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, smu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{sfmodel.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// SFModelUpdateOne is the builder for updating a single SFModel entity.
|
||||
type SFModelUpdateOne struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *SFModelMutation
|
||||
}
|
||||
|
||||
// SetName sets the name field.
|
||||
func (smuo *SFModelUpdateOne) SetName(s string) *SFModelUpdateOne {
|
||||
smuo.mutation.SetName(s)
|
||||
return smuo
|
||||
}
|
||||
|
||||
// SetPhoneNumber sets the phone_number field.
|
||||
func (smuo *SFModelUpdateOne) SetPhoneNumber(i int64) *SFModelUpdateOne {
|
||||
smuo.mutation.ResetPhoneNumber()
|
||||
smuo.mutation.SetPhoneNumber(i)
|
||||
return smuo
|
||||
}
|
||||
|
||||
// AddPhoneNumber adds i to phone_number.
|
||||
func (smuo *SFModelUpdateOne) AddPhoneNumber(i int64) *SFModelUpdateOne {
|
||||
smuo.mutation.AddPhoneNumber(i)
|
||||
return smuo
|
||||
}
|
||||
|
||||
// SetAddress sets the address field.
|
||||
func (smuo *SFModelUpdateOne) SetAddress(s string) *SFModelUpdateOne {
|
||||
smuo.mutation.SetAddress(s)
|
||||
return smuo
|
||||
}
|
||||
|
||||
// Mutation returns the SFModelMutation object of the builder.
|
||||
func (smuo *SFModelUpdateOne) Mutation() *SFModelMutation {
|
||||
return smuo.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated entity.
|
||||
func (smuo *SFModelUpdateOne) Save(ctx context.Context) (*SFModel, error) {
|
||||
var (
|
||||
err error
|
||||
node *SFModel
|
||||
)
|
||||
if len(smuo.hooks) == 0 {
|
||||
node, err = smuo.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*SFModelMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
smuo.mutation = mutation
|
||||
node, err = smuo.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(smuo.hooks) - 1; i >= 0; i-- {
|
||||
mut = smuo.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, smuo.mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return node, err
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (smuo *SFModelUpdateOne) SaveX(ctx context.Context) *SFModel {
|
||||
node, err := smuo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (smuo *SFModelUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := smuo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (smuo *SFModelUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := smuo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (smuo *SFModelUpdateOne) sqlSave(ctx context.Context) (_node *SFModel, err error) {
|
||||
_spec := &sqlgraph.UpdateSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: sfmodel.Table,
|
||||
Columns: sfmodel.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: sfmodel.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
id, ok := smuo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing SFModel.ID for update")}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if value, ok := smuo.mutation.Name(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: sfmodel.FieldName,
|
||||
})
|
||||
}
|
||||
if value, ok := smuo.mutation.PhoneNumber(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt64,
|
||||
Value: value,
|
||||
Column: sfmodel.FieldPhoneNumber,
|
||||
})
|
||||
}
|
||||
if value, ok := smuo.mutation.AddedPhoneNumber(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt64,
|
||||
Value: value,
|
||||
Column: sfmodel.FieldPhoneNumber,
|
||||
})
|
||||
}
|
||||
if value, ok := smuo.mutation.Address(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: sfmodel.FieldAddress,
|
||||
})
|
||||
}
|
||||
_node = &SFModel{config: smuo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues()
|
||||
if err = sqlgraph.UpdateNode(ctx, smuo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{sfmodel.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return _node, nil
|
||||
}
|
216
server/ent/tx.go
Normal file
216
server/ent/tx.go
Normal file
@ -0,0 +1,216 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/facebook/ent/dialect"
|
||||
)
|
||||
|
||||
// Tx is a transactional client that is created by calling Client.Tx().
|
||||
type Tx struct {
|
||||
config
|
||||
// JDModel is the client for interacting with the JDModel builders.
|
||||
JDModel *JDModelClient
|
||||
// QQModel is the client for interacting with the QQModel builders.
|
||||
QQModel *QQModelClient
|
||||
// SFModel is the client for interacting with the SFModel builders.
|
||||
SFModel *SFModelClient
|
||||
|
||||
// lazily loaded.
|
||||
client *Client
|
||||
clientOnce sync.Once
|
||||
|
||||
// completion callbacks.
|
||||
mu sync.Mutex
|
||||
onCommit []CommitHook
|
||||
onRollback []RollbackHook
|
||||
|
||||
// ctx lives for the life of the transaction. It is
|
||||
// the same context used by the underlying connection.
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
type (
|
||||
// Committer is the interface that wraps the Committer method.
|
||||
Committer interface {
|
||||
Commit(context.Context, *Tx) error
|
||||
}
|
||||
|
||||
// The CommitFunc type is an adapter to allow the use of ordinary
|
||||
// function as a Committer. If f is a function with the appropriate
|
||||
// signature, CommitFunc(f) is a Committer that calls f.
|
||||
CommitFunc func(context.Context, *Tx) error
|
||||
|
||||
// CommitHook defines the "commit middleware". A function that gets a Committer
|
||||
// and returns a Committer. For example:
|
||||
//
|
||||
// hook := func(next ent.Committer) ent.Committer {
|
||||
// return ent.CommitFunc(func(context.Context, tx *ent.Tx) error {
|
||||
// // Do some stuff before.
|
||||
// if err := next.Commit(ctx, tx); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// // Do some stuff after.
|
||||
// return nil
|
||||
// })
|
||||
// }
|
||||
//
|
||||
CommitHook func(Committer) Committer
|
||||
)
|
||||
|
||||
// Commit calls f(ctx, m).
|
||||
func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error {
|
||||
return f(ctx, tx)
|
||||
}
|
||||
|
||||
// Commit commits the transaction.
|
||||
func (tx *Tx) Commit() error {
|
||||
txDriver := tx.config.driver.(*txDriver)
|
||||
var fn Committer = CommitFunc(func(context.Context, *Tx) error {
|
||||
return txDriver.tx.Commit()
|
||||
})
|
||||
tx.mu.Lock()
|
||||
hooks := append([]CommitHook(nil), tx.onCommit...)
|
||||
tx.mu.Unlock()
|
||||
for i := len(hooks) - 1; i >= 0; i-- {
|
||||
fn = hooks[i](fn)
|
||||
}
|
||||
return fn.Commit(tx.ctx, tx)
|
||||
}
|
||||
|
||||
// OnCommit adds a hook to call on commit.
|
||||
func (tx *Tx) OnCommit(f CommitHook) {
|
||||
tx.mu.Lock()
|
||||
defer tx.mu.Unlock()
|
||||
tx.onCommit = append(tx.onCommit, f)
|
||||
}
|
||||
|
||||
type (
|
||||
// Rollbacker is the interface that wraps the Rollbacker method.
|
||||
Rollbacker interface {
|
||||
Rollback(context.Context, *Tx) error
|
||||
}
|
||||
|
||||
// The RollbackFunc type is an adapter to allow the use of ordinary
|
||||
// function as a Rollbacker. If f is a function with the appropriate
|
||||
// signature, RollbackFunc(f) is a Rollbacker that calls f.
|
||||
RollbackFunc func(context.Context, *Tx) error
|
||||
|
||||
// RollbackHook defines the "rollback middleware". A function that gets a Rollbacker
|
||||
// and returns a Rollbacker. For example:
|
||||
//
|
||||
// hook := func(next ent.Rollbacker) ent.Rollbacker {
|
||||
// return ent.RollbackFunc(func(context.Context, tx *ent.Tx) error {
|
||||
// // Do some stuff before.
|
||||
// if err := next.Rollback(ctx, tx); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// // Do some stuff after.
|
||||
// return nil
|
||||
// })
|
||||
// }
|
||||
//
|
||||
RollbackHook func(Rollbacker) Rollbacker
|
||||
)
|
||||
|
||||
// Rollback calls f(ctx, m).
|
||||
func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error {
|
||||
return f(ctx, tx)
|
||||
}
|
||||
|
||||
// Rollback rollbacks the transaction.
|
||||
func (tx *Tx) Rollback() error {
|
||||
txDriver := tx.config.driver.(*txDriver)
|
||||
var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error {
|
||||
return txDriver.tx.Rollback()
|
||||
})
|
||||
tx.mu.Lock()
|
||||
hooks := append([]RollbackHook(nil), tx.onRollback...)
|
||||
tx.mu.Unlock()
|
||||
for i := len(hooks) - 1; i >= 0; i-- {
|
||||
fn = hooks[i](fn)
|
||||
}
|
||||
return fn.Rollback(tx.ctx, tx)
|
||||
}
|
||||
|
||||
// OnRollback adds a hook to call on rollback.
|
||||
func (tx *Tx) OnRollback(f RollbackHook) {
|
||||
tx.mu.Lock()
|
||||
defer tx.mu.Unlock()
|
||||
tx.onRollback = append(tx.onRollback, f)
|
||||
}
|
||||
|
||||
// Client returns a Client that binds to current transaction.
|
||||
func (tx *Tx) Client() *Client {
|
||||
tx.clientOnce.Do(func() {
|
||||
tx.client = &Client{config: tx.config}
|
||||
tx.client.init()
|
||||
})
|
||||
return tx.client
|
||||
}
|
||||
|
||||
func (tx *Tx) init() {
|
||||
tx.JDModel = NewJDModelClient(tx.config)
|
||||
tx.QQModel = NewQQModelClient(tx.config)
|
||||
tx.SFModel = NewSFModelClient(tx.config)
|
||||
}
|
||||
|
||||
// txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation.
|
||||
// The idea is to support transactions without adding any extra code to the builders.
|
||||
// When a builder calls to driver.Tx(), it gets the same dialect.Tx instance.
|
||||
// Commit and Rollback are nop for the internal builders and the user must call one
|
||||
// of them in order to commit or rollback the transaction.
|
||||
//
|
||||
// If a closed transaction is embedded in one of the generated entities, and the entity
|
||||
// applies a query, for example: JDModel.QueryXXX(), the query will be executed
|
||||
// through the driver which created this transaction.
|
||||
//
|
||||
// Note that txDriver is not goroutine safe.
|
||||
type txDriver struct {
|
||||
// the driver we started the transaction from.
|
||||
drv dialect.Driver
|
||||
// tx is the underlying transaction.
|
||||
tx dialect.Tx
|
||||
}
|
||||
|
||||
// newTx creates a new transactional driver.
|
||||
func newTx(ctx context.Context, drv dialect.Driver) (*txDriver, error) {
|
||||
tx, err := drv.Tx(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &txDriver{tx: tx, drv: drv}, nil
|
||||
}
|
||||
|
||||
// Tx returns the transaction wrapper (txDriver) to avoid Commit or Rollback calls
|
||||
// from the internal builders. Should be called only by the internal builders.
|
||||
func (tx *txDriver) Tx(context.Context) (dialect.Tx, error) { return tx, nil }
|
||||
|
||||
// Dialect returns the dialect of the driver we started the transaction from.
|
||||
func (tx *txDriver) Dialect() string { return tx.drv.Dialect() }
|
||||
|
||||
// Close is a nop close.
|
||||
func (*txDriver) Close() error { return nil }
|
||||
|
||||
// Commit is a nop commit for the internal builders.
|
||||
// User must call `Tx.Commit` in order to commit the transaction.
|
||||
func (*txDriver) Commit() error { return nil }
|
||||
|
||||
// Rollback is a nop rollback for the internal builders.
|
||||
// User must call `Tx.Rollback` in order to rollback the transaction.
|
||||
func (*txDriver) Rollback() error { return nil }
|
||||
|
||||
// Exec calls tx.Exec.
|
||||
func (tx *txDriver) Exec(ctx context.Context, query string, args, v interface{}) error {
|
||||
return tx.tx.Exec(ctx, query, args, v)
|
||||
}
|
||||
|
||||
// Query calls tx.Query.
|
||||
func (tx *txDriver) Query(ctx context.Context, query string, args, v interface{}) error {
|
||||
return tx.tx.Query(ctx, query, args, v)
|
||||
}
|
||||
|
||||
var _ dialect.Driver = (*txDriver)(nil)
|
11
server/go.mod
Normal file
11
server/go.mod
Normal file
@ -0,0 +1,11 @@
|
||||
module github.com/kallydev/privacy
|
||||
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
github.com/facebook/ent v0.5.0
|
||||
github.com/go-pg/pg/v10 v10.7.3
|
||||
github.com/labstack/echo/v4 v4.1.17
|
||||
github.com/mattn/go-sqlite3 v1.14.5
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
|
||||
)
|
473
server/go.sum
Normal file
473
server/go.sum
Normal file
@ -0,0 +1,473 @@
|
||||
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=
|
||||
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
||||
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
|
||||
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
|
||||
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
|
||||
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
|
||||
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
|
||||
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
|
||||
cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk=
|
||||
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
|
||||
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
||||
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
|
||||
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/facebook/ent v0.5.0 h1:NlDQDxJi1X6+20CCjRQgu8UqvRhQNm5ocPBCQYdxC/8=
|
||||
github.com/facebook/ent v0.5.0/go.mod h1:HrrMNGsvgZoGQ74PGBQJ9r9WNOVMqKQefcOJFXuOUlw=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/go-bindata/go-bindata v1.0.1-0.20190711162640-ee3c2418e368 h1:WNHfSP1q2vuAa9vF54RrhCl4nqxCjVcXhlbsRXbGOSY=
|
||||
github.com/go-bindata/go-bindata v1.0.1-0.20190711162640-ee3c2418e368/go.mod h1:7xCgX1lzlrXPHkfvn3EhumqHkmSlzt8at9q7v0ax19c=
|
||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
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-pg/pg/v10 v10.7.3 h1:oL/Hz5MJie/9epmwxlZjfReO+2wlLPOK6BeGb9I+XHk=
|
||||
github.com/go-pg/pg/v10 v10.7.3/go.mod h1:UsDYtA+ihbBNX1OeIvDejxkL4RXzL3wsZYoEv5NUEqM=
|
||||
github.com/go-pg/zerochecker v0.2.0 h1:pp7f72c3DobMWOb2ErtZsnrPaSvHd2W4o9//8HtF4mU=
|
||||
github.com/go-pg/zerochecker v0.2.0/go.mod h1:NJZ4wKL0NmTtz0GKCoJ8kym6Xn/EQzXRl2OnAe7MmDo=
|
||||
github.com/go-sql-driver/mysql v1.5.1-0.20200311113236-681ffa848bae/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.3 h1:x95R7cp+rSeeqAMI2knLtQ0DKlaBhv2NrtrOvafPHRo=
|
||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
|
||||
github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
|
||||
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
|
||||
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
|
||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
|
||||
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
|
||||
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
|
||||
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
||||
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
|
||||
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
|
||||
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/labstack/echo/v4 v4.1.17 h1:PQIBaRplyRy3OjwILGkPg89JRtH2x5bssi59G2EL3fo=
|
||||
github.com/labstack/echo/v4 v4.1.17/go.mod h1:Tn2yRQL/UclUalpb5rPdXDevbkJ+lp/2svdyFBg6CHQ=
|
||||
github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0=
|
||||
github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k=
|
||||
github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw=
|
||||
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
|
||||
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
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.4/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI=
|
||||
github.com/mattn/go-sqlite3 v1.14.5 h1:1IdxlwTNazvbKJQSxoJ5/9ECbEeaTTyeU7sEAZ5KKTQ=
|
||||
github.com/mattn/go-sqlite3 v1.14.5/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
|
||||
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
|
||||
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
|
||||
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
||||
github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8=
|
||||
github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.14.2 h1:8mVmC9kjFFmA8H4pKMUhcblgifdkOIXPvbhN1T36q1M=
|
||||
github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.10.3 h1:gph6h/qe9GSUw1NhH1gp+qb+h8rXD8Cy60Z32Qw3ELA=
|
||||
github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc=
|
||||
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
|
||||
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cobra v1.1.1 h1:KfztREH0tPxJJ+geloSLaAkaPkr4ki2Er5quFV1TDo4=
|
||||
github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI=
|
||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
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.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo=
|
||||
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc/go.mod h1:bciPuU6GHm1iF1pBvUfxfsH0Wmnc2VbpgvbI9ZWuIRs=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
|
||||
github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4=
|
||||
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||
github.com/vmihailenco/bufpool v0.1.11 h1:gOq2WmBrq0i2yW5QJ16ykccQ4wH9UyEsgLm6czKAd94=
|
||||
github.com/vmihailenco/bufpool v0.1.11/go.mod h1:AFf/MOy3l2CFTKbxwt0mp2MwnqjNEs5H/UxrkA5jxTQ=
|
||||
github.com/vmihailenco/msgpack/v4 v4.3.11/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
|
||||
github.com/vmihailenco/msgpack/v5 v5.0.0 h1:nCaMMPEyfgwkGc/Y0GreJPhuvzqCqW+Ufq5lY7zLO2c=
|
||||
github.com/vmihailenco/msgpack/v5 v5.0.0/go.mod h1:HVxBVPUK/+fZMonk4bi1islLa8V3cfnBug0+4dykPzo=
|
||||
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
|
||||
github.com/vmihailenco/tagparser v0.1.2 h1:gnjoVuB/kljJ5wICEEOpx98oXMWPLj22G67Vbd1qPqc=
|
||||
github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
|
||||
go.opentelemetry.io/otel v0.14.0 h1:YFBEfjCk9MTjaytCNSUkp9Q8lF7QJezA06T71FbQxLQ=
|
||||
go.opentelemetry.io/otel v0.14.0/go.mod h1:vH5xEuwy7Rts0GNtsCW3HYQoZDY+OmBJ6t1bFGGlxgw=
|
||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM=
|
||||
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9 h1:phUcVbl53swtrUN8kQEXFhUxPlIlWyBfKmidCu7P95o=
|
||||
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
|
||||
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
||||
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
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/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
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=
|
||||
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6 h1:DvY3Zkh7KabQE/kfzMvYvKirSiguP9Q/veMtkYyf0o8=
|
||||
golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200904185747-39188db58858 h1:xLt+iB5ksWcZVxqc+g9K41ZHy+6MKWfXCDsjSThnsPA=
|
||||
golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE=
|
||||
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 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
|
||||
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||
google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
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-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
|
||||
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
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.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
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=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
mellium.im/sasl v0.2.1 h1:nspKSRg7/SyO0cRGY71OkfHab8tf9kCts6a6oTDut0w=
|
||||
mellium.im/sasl v0.2.1/go.mod h1:ROaEDLQNuf9vjKqE1SrAfnsobm2YKXT1gnN1uDp1PjQ=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
21
server/main/main.go
Normal file
21
server/main/main.go
Normal file
@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"github.com/kallydev/privacy/service"
|
||||
"log"
|
||||
)
|
||||
|
||||
var configPath string
|
||||
|
||||
func init() {
|
||||
flag.Parse()
|
||||
flag.StringVar(&configPath, "config", "../config.yaml", "config file path")
|
||||
}
|
||||
|
||||
func main() {
|
||||
svc := service.NewService(configPath)
|
||||
if err := svc.Start(); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
139
server/service/data.go
Normal file
139
server/service/data.go
Normal file
@ -0,0 +1,139 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Data interface {
|
||||
String() string
|
||||
Masking() string
|
||||
}
|
||||
|
||||
var (
|
||||
_ Data = Address("")
|
||||
_ Data = Nickname("")
|
||||
_ Data = PhoneNumber(0)
|
||||
_ Data = IDNumber("")
|
||||
_ Data = QQNumber(0)
|
||||
_ Data = Password("")
|
||||
_ Data = Email("")
|
||||
_ Data = Address("")
|
||||
)
|
||||
|
||||
type (
|
||||
Name string
|
||||
Nickname string
|
||||
PhoneNumber int64
|
||||
IDNumber string
|
||||
QQNumber int64
|
||||
Password string
|
||||
Email string
|
||||
Address string
|
||||
)
|
||||
|
||||
func (address Address) Masking() string {
|
||||
return maskLeft(string(address), 1)
|
||||
}
|
||||
|
||||
func (address Address) String() string {
|
||||
return string(address)
|
||||
}
|
||||
|
||||
func (email Email) Masking() string {
|
||||
return maskLeft(email.String(), len(strings.Split(string(email), "@")[0])+1)
|
||||
}
|
||||
|
||||
func (email Email) String() string {
|
||||
return string(email)
|
||||
}
|
||||
|
||||
func (password Password) Masking() string {
|
||||
return maskLeft(password.String(), 4)
|
||||
}
|
||||
|
||||
func (password Password) String() string {
|
||||
return string(password)
|
||||
}
|
||||
|
||||
func (qqNumber QQNumber) Masking() string {
|
||||
return maskLeft(qqNumber.String(), 3)
|
||||
}
|
||||
|
||||
func (qqNumber QQNumber) String() string {
|
||||
return strconv.Itoa(int(qqNumber))
|
||||
}
|
||||
|
||||
func (idNumber IDNumber) Masking() string {
|
||||
return mask(maskLeft(idNumber.String(), 3), 16, 16)
|
||||
}
|
||||
|
||||
func (idNumber IDNumber) String() string {
|
||||
return string(idNumber)
|
||||
}
|
||||
|
||||
func (phoneNumber PhoneNumber) Masking() string {
|
||||
return mask(phoneNumber.String(), 3, 6)
|
||||
}
|
||||
|
||||
func (phoneNumber PhoneNumber) String() string {
|
||||
return strconv.Itoa(int(phoneNumber))
|
||||
}
|
||||
|
||||
func (nickname Nickname) Masking() string {
|
||||
return maskLeft(nickname.String(), 1)
|
||||
}
|
||||
|
||||
func (nickname Nickname) String() string {
|
||||
return string(nickname)
|
||||
}
|
||||
|
||||
func (name Name) Masking() string {
|
||||
return maskLeft(name.String(), 1)
|
||||
}
|
||||
|
||||
func (name Name) String() string {
|
||||
return string(name)
|
||||
}
|
||||
|
||||
func isPhoneNumber(number int) bool {
|
||||
numberStr := strconv.Itoa(number)
|
||||
if len(numberStr) != 11 {
|
||||
return false
|
||||
}
|
||||
// https://www.miit.gov.cn/n1146295/n1652858/n1652930/n3757020/c5623267/part/5623278.doc
|
||||
s := []int{
|
||||
130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
|
||||
145, 146, 147, 148, 148,
|
||||
150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
|
||||
161, 162, 164, 165, 167,
|
||||
170, 172, 173, 175, 176, 177, 178, 179,
|
||||
181, 182, 183, 184, 185, 186, 187, 188, 189,
|
||||
190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
|
||||
}
|
||||
header, _ := strconv.Atoi(numberStr[:3])
|
||||
for _, num := range s {
|
||||
if num == header {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func whatType(value string) (result []interface{}) {
|
||||
if number, err := strconv.ParseInt(value, 10, 64); err == nil {
|
||||
if number <= 19999999999 && isPhoneNumber(int(number)) {
|
||||
result = append(result, PhoneNumber(number))
|
||||
}
|
||||
if number <= 99999999999 && len(strconv.Itoa(int(number))) >= 5 {
|
||||
result = append(result, QQNumber(number))
|
||||
}
|
||||
}
|
||||
if len(value) == 18 {
|
||||
result = append(result, IDNumber(value))
|
||||
}
|
||||
if strings.Contains(value, "@") {
|
||||
result = append(result, Email(value))
|
||||
}
|
||||
return result
|
||||
}
|
42
server/service/errors.go
Normal file
42
server/service/errors.go
Normal file
@ -0,0 +1,42 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/labstack/echo/v4"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
OK = errors.New("ok")
|
||||
UnknownError = errors.New("unknown error")
|
||||
InvalidParameterError = errors.New("invalid parameter error")
|
||||
)
|
||||
|
||||
var errorMap = map[error]int{
|
||||
OK: 0,
|
||||
UnknownError: 10001,
|
||||
InvalidParameterError: 10002,
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
func NewResponse(ctx echo.Context, err error, data interface{}) error {
|
||||
if err == nil {
|
||||
err = OK
|
||||
}
|
||||
code, ok := errorMap[err]
|
||||
if !ok {
|
||||
err = UnknownError
|
||||
code = errorMap[err]
|
||||
}
|
||||
return ctx.JSONPretty(http.StatusOK, &Response{
|
||||
Code: code,
|
||||
Message: strings.ToLower(err.Error()),
|
||||
Data: data,
|
||||
}, "\x20\x20")
|
||||
}
|
87
server/service/handler.go
Normal file
87
server/service/handler.go
Normal file
@ -0,0 +1,87 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
type QueryResponse struct {
|
||||
Names []string `json:"names"`
|
||||
Nicknames []string `json:"nicknames"`
|
||||
PhoneNumbers []string `json:"phone_numbers"`
|
||||
IDNumbers []string `json:"id_numbers"`
|
||||
QQNumbers []string `json:"qq_numbers"`
|
||||
Passwords []string `json:"passwords"`
|
||||
Emails []string `json:"emails"`
|
||||
Addresses []string `json:"addresses"`
|
||||
}
|
||||
|
||||
func NewQueryResponse() *QueryResponse {
|
||||
return &QueryResponse{
|
||||
Names: make([]string, 0),
|
||||
Nicknames: make([]string, 0),
|
||||
PhoneNumbers: make([]string, 0),
|
||||
IDNumbers: make([]string, 0),
|
||||
QQNumbers: make([]string, 0),
|
||||
Passwords: make([]string, 0),
|
||||
Emails: make([]string, 0),
|
||||
Addresses: make([]string, 0),
|
||||
}
|
||||
}
|
||||
|
||||
func (svc *Service) queryHandlerFunc(ctx echo.Context) error {
|
||||
value := ctx.QueryParam("value")
|
||||
if value == "" {
|
||||
return InvalidParameterError
|
||||
}
|
||||
result := NewQueryResult()
|
||||
types := whatType(value)
|
||||
for _, t := range types {
|
||||
switch value := t.(type) {
|
||||
case QQNumber:
|
||||
result.addQQNumber(int64(value))
|
||||
case PhoneNumber:
|
||||
result.addPhoneNumber(int64(value))
|
||||
case Email:
|
||||
result.addEmail(string(value))
|
||||
case IDNumber:
|
||||
result.addIDNumber(string(value))
|
||||
}
|
||||
}
|
||||
ok := false
|
||||
for !ok {
|
||||
for qqNumber, checked := range result.QQNumbers {
|
||||
if !checked {
|
||||
if err := result.queryQQNumber(svc.databases, int64(qqNumber)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
for phoneNumber, checked := range result.PhoneNumbers {
|
||||
if !checked {
|
||||
if err := result.queryPhoneNumber(svc.databases, int64(phoneNumber)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
for idNumber, checked := range result.IDNumbers {
|
||||
if !checked {
|
||||
if err := result.queryIDNumber(svc.databases, string(idNumber)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
for email, checked := range result.Emails {
|
||||
if !checked {
|
||||
if err := result.queryEmail(svc.databases, string(email)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
ok = true
|
||||
}
|
||||
return NewResponse(ctx, nil, result.Build(svc.config.Mask))
|
||||
}
|
36
server/service/mask.go
Normal file
36
server/service/mask.go
Normal file
@ -0,0 +1,36 @@
|
||||
package service
|
||||
|
||||
func mask(str string, start, end int) string {
|
||||
maskLen := end - start
|
||||
if maskLen < 0 {
|
||||
panic("end cannot be greater than start")
|
||||
}
|
||||
var maskStr string
|
||||
for i := 0; i <= maskLen; i++ {
|
||||
maskStr += "*"
|
||||
}
|
||||
runes := []rune(str)
|
||||
return string(append(runes[:start], append([]rune(maskStr), runes[end+1:]...)...))
|
||||
}
|
||||
|
||||
func maskLeft(str string, reserve int) string {
|
||||
runes := []rune(str)
|
||||
if len(runes)-reserve < 0 {
|
||||
panic("length of reserved string is out of range")
|
||||
}
|
||||
for i := 0; i < len(runes)-reserve; i++ {
|
||||
runes[i] = '*'
|
||||
}
|
||||
return string(runes)
|
||||
}
|
||||
|
||||
func maskRight(str string, reserve int) string {
|
||||
runes := []rune(str)
|
||||
if len(runes)-reserve < 0 {
|
||||
panic("length of reserved string is out of range")
|
||||
}
|
||||
for i := len(runes) - 1; i > len(runes)-reserve; i-- {
|
||||
runes[i] = '*'
|
||||
}
|
||||
return string(runes)
|
||||
}
|
274
server/service/result.go
Normal file
274
server/service/result.go
Normal file
@ -0,0 +1,274 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/kallydev/privacy/database"
|
||||
)
|
||||
|
||||
type Result interface {
|
||||
queryPhoneNumber(databases []database.Database, phoneNumber int64) error
|
||||
queryIDNumber(databases []database.Database, idNumber string) error
|
||||
queryQQNumber(databases []database.Database, qqNumber int64) error
|
||||
queryEmail(databases []database.Database, email string) error
|
||||
|
||||
addName(name string)
|
||||
addNickname(nickname string)
|
||||
addPhoneNumber(phoneNumber int64)
|
||||
addIDNumber(idNumber string)
|
||||
addQQNumber(qqNumber int64)
|
||||
addPassword(password string)
|
||||
addEmail(email string)
|
||||
addAddress(address string)
|
||||
}
|
||||
|
||||
var (
|
||||
_ Result = &QueryResult{}
|
||||
)
|
||||
|
||||
type QueryResult struct {
|
||||
Names map[Name]bool `json:"names"`
|
||||
Nicknames map[Nickname]bool `json:"nicknames"`
|
||||
PhoneNumbers map[PhoneNumber]bool `json:"phone_numbers"`
|
||||
IDNumbers map[IDNumber]bool `json:"id_numbers"`
|
||||
QQNumbers map[QQNumber]bool `json:"qq_numbers"`
|
||||
Passwords map[Password]bool `json:"passwords"`
|
||||
Emails map[Email]bool `json:"emails"`
|
||||
Addresses map[Address]bool `json:"addresses"`
|
||||
}
|
||||
|
||||
func NewQueryResult() *QueryResult {
|
||||
return &QueryResult{
|
||||
Names: make(map[Name]bool),
|
||||
Nicknames: make(map[Nickname]bool),
|
||||
PhoneNumbers: make(map[PhoneNumber]bool),
|
||||
IDNumbers: make(map[IDNumber]bool),
|
||||
QQNumbers: make(map[QQNumber]bool),
|
||||
Passwords: make(map[Password]bool),
|
||||
Emails: make(map[Email]bool),
|
||||
Addresses: make(map[Address]bool),
|
||||
}
|
||||
}
|
||||
|
||||
func (result *QueryResult) addModel(model database.Model) {
|
||||
if name, valid := model.GetName(); valid {
|
||||
result.addName(name)
|
||||
}
|
||||
if nickname, valid := model.GetNickname(); valid {
|
||||
result.addNickname(nickname)
|
||||
}
|
||||
if phoneNumber, valid := model.GetPhoneNumber(); valid {
|
||||
result.addPhoneNumber(phoneNumber)
|
||||
}
|
||||
if idNumber, valid := model.GetIDNumber(); valid {
|
||||
result.addIDNumber(idNumber)
|
||||
}
|
||||
if qqNumber, valid := model.GetQQNumber(); valid {
|
||||
result.addQQNumber(qqNumber)
|
||||
}
|
||||
if password, valid := model.GetPassword(); valid {
|
||||
result.addPassword(password)
|
||||
}
|
||||
if email, valid := model.GetEmail(); valid {
|
||||
result.addEmail(email)
|
||||
}
|
||||
if address, valid := model.GetAddress(); valid {
|
||||
result.addAddress(address)
|
||||
}
|
||||
}
|
||||
|
||||
func (result *QueryResult) queryPhoneNumber(databases []database.Database, phoneNumber int64) error {
|
||||
for _, db := range databases {
|
||||
models, err := db.QueryByPhoneNumber(context.Background(), phoneNumber)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, model := range models {
|
||||
result.addModel(model)
|
||||
}
|
||||
}
|
||||
result.PhoneNumbers[PhoneNumber(phoneNumber)] = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (result *QueryResult) queryIDNumber(databases []database.Database, idNumber string) error {
|
||||
for _, db := range databases {
|
||||
models, err := db.QueryByIDNumber(context.Background(), idNumber)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, model := range models {
|
||||
result.addModel(model)
|
||||
}
|
||||
}
|
||||
result.IDNumbers[IDNumber(idNumber)] = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (result *QueryResult) queryQQNumber(databases []database.Database, qqNumber int64) error {
|
||||
for _, db := range databases {
|
||||
models, err := db.QueryByQQNumber(context.Background(), qqNumber)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, model := range models {
|
||||
result.addModel(model)
|
||||
}
|
||||
}
|
||||
result.QQNumbers[QQNumber(qqNumber)] = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (result *QueryResult) queryEmail(databases []database.Database, email string) error {
|
||||
for _, db := range databases {
|
||||
models, err := db.QueryByEmail(context.Background(), email)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, model := range models {
|
||||
result.addModel(model)
|
||||
}
|
||||
}
|
||||
result.Emails[Email(email)] = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (result *QueryResult) addName(value string) {
|
||||
if value == "" {
|
||||
return
|
||||
}
|
||||
name := Name(value)
|
||||
if _, ok := result.Names[name]; !ok {
|
||||
result.Names[name] = false
|
||||
}
|
||||
}
|
||||
|
||||
func (result *QueryResult) addNickname(value string) {
|
||||
if value == "" {
|
||||
return
|
||||
}
|
||||
nickname := Nickname(value)
|
||||
if _, ok := result.Nicknames[nickname]; !ok {
|
||||
result.Nicknames[nickname] = false
|
||||
}
|
||||
}
|
||||
|
||||
func (result *QueryResult) addPhoneNumber(value int64) {
|
||||
if value == 0 {
|
||||
return
|
||||
}
|
||||
phoneNumber := PhoneNumber(value)
|
||||
if _, ok := result.PhoneNumbers[phoneNumber]; !ok {
|
||||
result.PhoneNumbers[phoneNumber] = false
|
||||
}
|
||||
}
|
||||
|
||||
func (result *QueryResult) addIDNumber(value string) {
|
||||
if value == "" {
|
||||
return
|
||||
}
|
||||
idNumber := IDNumber(value)
|
||||
if _, ok := result.IDNumbers[idNumber]; !ok {
|
||||
result.IDNumbers[idNumber] = false
|
||||
}
|
||||
}
|
||||
|
||||
func (result *QueryResult) addQQNumber(value int64) {
|
||||
if value == 0 {
|
||||
return
|
||||
}
|
||||
qqNumber := QQNumber(value)
|
||||
if _, ok := result.QQNumbers[qqNumber]; !ok {
|
||||
result.QQNumbers[qqNumber] = false
|
||||
}
|
||||
}
|
||||
|
||||
func (result *QueryResult) addPassword(value string) {
|
||||
if value == "" {
|
||||
return
|
||||
}
|
||||
password := Password(value)
|
||||
if _, ok := result.Passwords[password]; !ok {
|
||||
result.Passwords[password] = false
|
||||
}
|
||||
}
|
||||
|
||||
func (result *QueryResult) addEmail(value string) {
|
||||
if value == "" {
|
||||
return
|
||||
}
|
||||
email := Email(value)
|
||||
if _, ok := result.Emails[email]; !ok {
|
||||
result.Emails[email] = false
|
||||
}
|
||||
}
|
||||
|
||||
func (result *QueryResult) addAddress(value string) {
|
||||
if value == "" {
|
||||
return
|
||||
}
|
||||
address := Address(value)
|
||||
if _, ok := result.Addresses[address]; !ok {
|
||||
result.Addresses[address] = false
|
||||
}
|
||||
}
|
||||
|
||||
func (result *QueryResult) Build(mask bool) *QueryResponse {
|
||||
response := NewQueryResponse()
|
||||
for name := range result.Names {
|
||||
result := name.String()
|
||||
if mask {
|
||||
result = name.Masking()
|
||||
}
|
||||
response.Names = append(response.Names, result)
|
||||
}
|
||||
for nickname := range result.Nicknames {
|
||||
result := nickname.String()
|
||||
if mask {
|
||||
result = nickname.Masking()
|
||||
}
|
||||
response.Nicknames = append(response.Nicknames, result)
|
||||
}
|
||||
for phoneNumber := range result.PhoneNumbers {
|
||||
result := phoneNumber.String()
|
||||
if mask {
|
||||
result = phoneNumber.Masking()
|
||||
}
|
||||
response.PhoneNumbers = append(response.PhoneNumbers, result)
|
||||
}
|
||||
for idNumber := range result.IDNumbers {
|
||||
result := idNumber.String()
|
||||
if mask {
|
||||
result = idNumber.Masking()
|
||||
}
|
||||
response.IDNumbers = append(response.IDNumbers, result)
|
||||
}
|
||||
for qqNumber := range result.QQNumbers {
|
||||
result := qqNumber.String()
|
||||
if mask {
|
||||
result = qqNumber.Masking()
|
||||
}
|
||||
response.QQNumbers = append(response.QQNumbers, result)
|
||||
}
|
||||
for password := range result.Passwords {
|
||||
result := password.String()
|
||||
if mask {
|
||||
result = password.Masking()
|
||||
}
|
||||
response.Passwords = append(response.Passwords, result)
|
||||
}
|
||||
for email := range result.Emails {
|
||||
result := email.String()
|
||||
if mask {
|
||||
result = email.Masking()
|
||||
}
|
||||
response.Emails = append(response.Emails, result)
|
||||
}
|
||||
for address := range result.Addresses {
|
||||
result := address.String()
|
||||
if mask {
|
||||
result = address.Masking()
|
||||
}
|
||||
response.Addresses = append(response.Addresses, result)
|
||||
}
|
||||
return response
|
||||
}
|
87
server/service/service.go
Normal file
87
server/service/service.go
Normal file
@ -0,0 +1,87 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/kallydev/privacy/config"
|
||||
"github.com/kallydev/privacy/database"
|
||||
"github.com/kallydev/privacy/database/table"
|
||||
"github.com/kallydev/privacy/ent"
|
||||
"github.com/labstack/echo/v4"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"log"
|
||||
"net"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
client *ent.Client
|
||||
databases []database.Database
|
||||
config *config.Config
|
||||
instance *echo.Echo
|
||||
}
|
||||
|
||||
func NewService(configPath string) *Service {
|
||||
conf, err := config.NewConfig(configPath)
|
||||
if err != nil {
|
||||
log.Panicln("failed to load config file")
|
||||
}
|
||||
instance := echo.New()
|
||||
instance.HidePort = true
|
||||
instance.HideBanner = true
|
||||
return &Service{
|
||||
config: conf,
|
||||
instance: instance,
|
||||
}
|
||||
}
|
||||
|
||||
func (svc *Service) loadRouter() {
|
||||
instance := svc.instance
|
||||
instance.HTTPErrorHandler = func(err error, ctx echo.Context) {
|
||||
_ = NewResponse(ctx, UnknownError, err)
|
||||
}
|
||||
instance.Static("/", "../website/build")
|
||||
apiGroup := instance.Group("/api")
|
||||
{
|
||||
apiGroup.GET("/query", svc.queryHandlerFunc)
|
||||
}
|
||||
}
|
||||
|
||||
func (svc *Service) LoadDatabase() (err error) {
|
||||
svc.client, err = ent.Open("sqlite3", fmt.Sprintf("file:%s", svc.config.Database.Path))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tablesConfig := svc.config.Database.Tables
|
||||
if tablesConfig.QQ {
|
||||
svc.databases = append(svc.databases, &table.QQDatabase{
|
||||
Client: svc.client,
|
||||
})
|
||||
}
|
||||
if tablesConfig.JD {
|
||||
svc.databases = append(svc.databases, &table.JDDatabase{
|
||||
Client: svc.client,
|
||||
})
|
||||
}
|
||||
if tablesConfig.SF {
|
||||
svc.databases = append(svc.databases, &table.SFDatabase{
|
||||
Client: svc.client,
|
||||
})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (svc *Service) Start() (err error) {
|
||||
if err := svc.LoadDatabase(); err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
_ = svc.client.Close()
|
||||
}()
|
||||
svc.loadRouter()
|
||||
httpConfig := svc.config.HttpConfig
|
||||
address := net.JoinHostPort(httpConfig.Host, strconv.Itoa(int(httpConfig.Port)))
|
||||
if httpConfig.TLS != nil {
|
||||
return svc.instance.StartTLS(address, httpConfig.TLS.CertPath, httpConfig.TLS.KeyPath)
|
||||
}
|
||||
return svc.instance.Start(address)
|
||||
}
|
46
website/README.md
Normal file
46
website/README.md
Normal file
@ -0,0 +1,46 @@
|
||||
# Getting Started with Create React App
|
||||
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||
|
||||
## Available Scripts
|
||||
|
||||
In the project directory, you can run:
|
||||
|
||||
### `yarn start`
|
||||
|
||||
Runs the app in the development mode.\
|
||||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
||||
|
||||
The page will reload if you make edits.\
|
||||
You will also see any lint errors in the console.
|
||||
|
||||
### `yarn test`
|
||||
|
||||
Launches the test runner in the interactive watch mode.\
|
||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||
|
||||
### `yarn build`
|
||||
|
||||
Builds the app for production to the `build` folder.\
|
||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||
|
||||
The build is minified and the filenames include the hashes.\
|
||||
Your app is ready to be deployed!
|
||||
|
||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||
|
||||
### `yarn eject`
|
||||
|
||||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
||||
|
||||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
||||
|
||||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
|
||||
|
||||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
|
||||
|
||||
## Learn More
|
||||
|
||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||
|
||||
To learn React, check out the [React documentation](https://reactjs.org/).
|
49
website/package.json
Normal file
49
website/package.json
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"name": "privacy",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@material-ui/core": "^4.11.1",
|
||||
"@material-ui/icons": "^4.9.1",
|
||||
"@material-ui/lab": "^4.0.0-alpha.56",
|
||||
"@mdi/js": "^5.8.55",
|
||||
"@testing-library/jest-dom": "^5.11.4",
|
||||
"@testing-library/react": "^11.1.0",
|
||||
"@testing-library/user-event": "^12.1.10",
|
||||
"@types/jest": "^26.0.15",
|
||||
"@types/node": "^12.0.0",
|
||||
"@types/react": "^16.9.53",
|
||||
"@types/react-dom": "^16.9.8",
|
||||
"fontsource-roboto": "^3.0.3",
|
||||
"react": "^17.0.1",
|
||||
"react-dom": "^17.0.1",
|
||||
"react-router-dom": "^5.2.0",
|
||||
"react-scripts": "4.0.1",
|
||||
"typescript": "^4.0.3",
|
||||
"web-vitals": "^0.2.4"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest"
|
||||
]
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
}
|
||||
}
|
BIN
website/public/favicon.ico
Normal file
BIN
website/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
46
website/public/index.html
Normal file
46
website/public/index.html
Normal file
@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<meta name="theme-color" content="#000000"/>
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png"/>
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json"/>
|
||||
<link rel="stylesheet" href="https://fonts.loli.net/css?family=Roboto:300,400,500,700&display=swap"/>
|
||||
<link rel="stylesheet" href="https://fonts.loli.net/icon?family=Material+Icons"/>
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>Privacy | 个人数据泄漏检测</title>
|
||||
<meta name="description" content="个人数据泄漏检测">
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
BIN
website/public/logo192.png
Normal file
BIN
website/public/logo192.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
BIN
website/public/logo512.png
Normal file
BIN
website/public/logo512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
25
website/public/manifest.json
Normal file
25
website/public/manifest.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"short_name": "Privacy",
|
||||
"name": "个人数据泄漏检测",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon"
|
||||
},
|
||||
{
|
||||
"src": "logo192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "logo512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
3
website/public/robots.txt
Normal file
3
website/public/robots.txt
Normal file
@ -0,0 +1,3 @@
|
||||
# https://www.robotstxt.org/robotstxt.html
|
||||
User-agent: *
|
||||
Disallow:
|
0
website/src/App.css
Normal file
0
website/src/App.css
Normal file
9
website/src/App.test.tsx
Normal file
9
website/src/App.test.tsx
Normal file
@ -0,0 +1,9 @@
|
||||
import React from 'react';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import App from './App';
|
||||
|
||||
test('renders learn react link', () => {
|
||||
render(<App />);
|
||||
const linkElement = screen.getByText(/learn react/i);
|
||||
expect(linkElement).toBeInTheDocument();
|
||||
});
|
146
website/src/App.tsx
Normal file
146
website/src/App.tsx
Normal file
@ -0,0 +1,146 @@
|
||||
import React from 'react';
|
||||
import 'fontsource-roboto';
|
||||
import './App.css';
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import Button from '@material-ui/core/Button';
|
||||
import makeStyles from '@material-ui/core/styles/makeStyles';
|
||||
import CssBaseline from '@material-ui/core/CssBaseline';
|
||||
import Container from '@material-ui/core/Container';
|
||||
import Box from '@material-ui/core/Box';
|
||||
import TextField from "@material-ui/core/TextField";
|
||||
import FormControl from '@material-ui/core/FormControl';
|
||||
import Result from "./components/ResultList";
|
||||
import AppBar from "./components/AppBar";
|
||||
import Footer from "./components/Footer";
|
||||
import Alert from '@material-ui/lab/Alert';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
main: {
|
||||
flex: 1,
|
||||
padding: theme.spacing(2),
|
||||
},
|
||||
heroContent: {
|
||||
padding: theme.spacing(4, 2),
|
||||
},
|
||||
}));
|
||||
|
||||
interface Response {
|
||||
code: number;
|
||||
message: string;
|
||||
data: any;
|
||||
}
|
||||
|
||||
export interface QueryResult {
|
||||
names: string[];
|
||||
nicknames: string[];
|
||||
phone_numbers: string[];
|
||||
id_numbers: string[];
|
||||
qq_numbers: string[];
|
||||
passwords: string[];
|
||||
emails: string[];
|
||||
addresses: string[];
|
||||
}
|
||||
|
||||
export enum State {
|
||||
Normal,
|
||||
Succeeded,
|
||||
Failed,
|
||||
}
|
||||
|
||||
function App() {
|
||||
const classes = useStyles();
|
||||
|
||||
const [value, setValue] = React.useState('');
|
||||
const [state, setState] = React.useState(State.Normal);
|
||||
const [error, setError] = React.useState('');
|
||||
const [result, setResult] = React.useState({
|
||||
names: [],
|
||||
nicknames: [],
|
||||
phone_numbers: [],
|
||||
id_numbers: [],
|
||||
qq_numbers: [],
|
||||
passwords: [],
|
||||
emails: [],
|
||||
addresses: [],
|
||||
} as QueryResult);
|
||||
|
||||
const closeResult = () => {
|
||||
setState(State.Normal);
|
||||
}
|
||||
|
||||
const query = async () => {
|
||||
setState(State.Normal);
|
||||
if (value.length === 0) {
|
||||
return;
|
||||
}
|
||||
let url = new URL(document.baseURI + 'api/query');
|
||||
url.search = new URLSearchParams({'value': value}).toString();
|
||||
fetch(url.toString(), {})
|
||||
.then(response => response.json())
|
||||
.then((response: Response) => {
|
||||
if (response.code !== 0) {
|
||||
setState(State.Failed);
|
||||
setError(response.message)
|
||||
return;
|
||||
}
|
||||
setResult(response.data as QueryResult);
|
||||
setState(State.Succeeded);
|
||||
})
|
||||
.catch((error) => {
|
||||
setState(State.Failed);
|
||||
setError(error)
|
||||
console.log('error: ' + error);
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<CssBaseline/>
|
||||
<AppBar/>
|
||||
<Container maxWidth="sm" component="main" className={classes.main}>
|
||||
{
|
||||
state === State.Failed &&
|
||||
<Alert variant="filled" severity="error">
|
||||
{error}
|
||||
</Alert>
|
||||
}
|
||||
<Box mt={2}>
|
||||
<Typography component="h1" variant="h2" align="center" color="textPrimary" gutterBottom>
|
||||
Privacy
|
||||
</Typography>
|
||||
<Typography component="p" variant="h5" align="center" color="textSecondary">
|
||||
「 is dead, get over it. 」
|
||||
</Typography>
|
||||
</Box>
|
||||
<Box mt={4}>
|
||||
<FormControl fullWidth component="fieldset">
|
||||
<TextField
|
||||
fullWidth
|
||||
id="filled-basic"
|
||||
label="QQ / 手机号 / 身份证号 / 邮箱"
|
||||
variant="outlined"
|
||||
type="number"
|
||||
onChange={event => {
|
||||
setValue(event.target.value)
|
||||
}}
|
||||
color="secondary"/>
|
||||
<Box mt={2}>
|
||||
<Button fullWidth size="large" variant="contained" color="secondary" onClick={query}>
|
||||
检测隐私状态
|
||||
</Button>
|
||||
</Box>
|
||||
</FormControl>
|
||||
</Box>
|
||||
{
|
||||
result !== null &&
|
||||
<Box mt={4}>
|
||||
<Result state={state} closeResult={closeResult} result={result}/>
|
||||
</Box>
|
||||
}
|
||||
</Container>
|
||||
<Footer/>
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
50
website/src/components/AppBar.tsx
Normal file
50
website/src/components/AppBar.tsx
Normal file
@ -0,0 +1,50 @@
|
||||
import React from 'react';
|
||||
import Container from "@material-ui/core/Container";
|
||||
import Toolbar from "@material-ui/core/Toolbar";
|
||||
import IconButton from "@material-ui/core/IconButton";
|
||||
import LockOpenIcon from "@material-ui/icons/LockOpen";
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import {Link} from "@material-ui/core";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import makeStyles from "@material-ui/core/styles/makeStyles";
|
||||
import {AppBar as MaterialAppBar} from '@material-ui/core';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
header: {
|
||||
flex: 0,
|
||||
},
|
||||
menuButton: {
|
||||
marginRight: theme.spacing(2),
|
||||
},
|
||||
title: {
|
||||
flexGrow: 1,
|
||||
},
|
||||
}));
|
||||
|
||||
function AppBar() {
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Container maxWidth={false} disableGutters className={classes.header}>
|
||||
<MaterialAppBar position="static">
|
||||
<Container maxWidth="sm" disableGutters>
|
||||
<Toolbar>
|
||||
<IconButton edge="start" className={classes.menuButton} color="inherit"
|
||||
aria-label="menu">
|
||||
<LockOpenIcon/>
|
||||
</IconButton>
|
||||
<Typography variant="h6" className={classes.title}>
|
||||
Privacy
|
||||
</Typography>
|
||||
<Link href="https://github.com/kallydev/privacy" underline="none" target="_blank"
|
||||
component={Button}
|
||||
color="inherit">GitHub</Link>
|
||||
</Toolbar>
|
||||
</Container>
|
||||
</MaterialAppBar>
|
||||
</Container>
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
export default AppBar;
|
50
website/src/components/Footer.tsx
Normal file
50
website/src/components/Footer.tsx
Normal file
@ -0,0 +1,50 @@
|
||||
import React from 'react';
|
||||
import Box from "@material-ui/core/Box";
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import FavoriteIcon from "@material-ui/icons/Favorite";
|
||||
import {Link} from "@material-ui/core";
|
||||
import Container from "@material-ui/core/Container";
|
||||
import makeStyles from "@material-ui/core/styles/makeStyles";
|
||||
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
footer: {
|
||||
flex: 0,
|
||||
textAlign: "center",
|
||||
padding: theme.spacing(2),
|
||||
},
|
||||
link: {
|
||||
padding: theme.spacing(0, 0.5),
|
||||
},
|
||||
temp: {
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
},
|
||||
}));
|
||||
|
||||
function Footer() {
|
||||
const classes = useStyles();
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Container className={classes.footer} component="footer">
|
||||
<Box>
|
||||
<Typography variant="caption">
|
||||
技术栈 React + Golang + SQLite,将于 11 月 28 日开源。
|
||||
</Typography>
|
||||
</Box>
|
||||
<Box mt={2} className={classes.temp}>
|
||||
<Typography display="inline">Developed with</Typography>
|
||||
<FavoriteIcon color="error" fontSize="default" className={classes.link}/>
|
||||
<Typography display="inline">by</Typography>
|
||||
<Link color="secondary" href="https://github.com/kallydev" target="_blank"
|
||||
className={classes.link}>KallyDev</Link>
|
||||
<Typography display="inline">.</Typography>
|
||||
</Box>
|
||||
</Container>
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
export default Footer;
|
173
website/src/components/ResultList.tsx
Normal file
173
website/src/components/ResultList.tsx
Normal file
@ -0,0 +1,173 @@
|
||||
import Box from '@material-ui/core/Box';
|
||||
import Paper from '@material-ui/core/Paper';
|
||||
import React from 'react';
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import IconButton from "@material-ui/core/IconButton";
|
||||
import CloseIcon from "@material-ui/icons/Close";
|
||||
import {List, ListItem, ListItemIcon, ListItemText, SvgIcon} from "@material-ui/core";
|
||||
import PhoneIcon from "@material-ui/icons/Phone";
|
||||
import {QueryResult, State} from '../App';
|
||||
import FaceIcon from '@material-ui/icons/Face';
|
||||
import DoneIcon from '@material-ui/icons/Done';
|
||||
import AccountCircleIcon from '@material-ui/icons/AccountCircle';
|
||||
import EmailIcon from '@material-ui/icons/Email';
|
||||
import BusinessIcon from '@material-ui/icons/Business';
|
||||
import VpnKeyIcon from '@material-ui/icons/VpnKey';
|
||||
|
||||
interface ResultProps {
|
||||
state: State;
|
||||
closeResult: () => void;
|
||||
result: QueryResult;
|
||||
}
|
||||
|
||||
function Result(props: ResultProps) {
|
||||
return (
|
||||
<React.Fragment>
|
||||
{
|
||||
props.state === State.Succeeded &&
|
||||
<Paper>
|
||||
<Box pt={2} px={2} pb={1}>
|
||||
<Box display="flex" flexDirection="row" justifyContent="center">
|
||||
<Box flexGrow={1}>
|
||||
<Typography component="h5" variant="h5">检测结果</Typography>
|
||||
</Box>
|
||||
<IconButton size="small">
|
||||
<CloseIcon onClick={() => {
|
||||
props.closeResult();
|
||||
}}/>
|
||||
</IconButton>
|
||||
</Box>
|
||||
<Box mt={1}>
|
||||
<List disablePadding component="nav" aria-label="main mailbox folders">
|
||||
{
|
||||
(
|
||||
props.result.names.length === 0 &&
|
||||
props.result.nicknames.length === 0 &&
|
||||
props.result.phone_numbers.length === 0 &&
|
||||
props.result.id_numbers.length === 0 &&
|
||||
props.result.qq_numbers.length === 0 &&
|
||||
props.result.passwords.length === 0 &&
|
||||
props.result.emails.length === 0 &&
|
||||
props.result.addresses.length === 0
|
||||
) && <ListItem disableGutters>
|
||||
<ListItem>
|
||||
<ListItemIcon>
|
||||
<DoneIcon/>
|
||||
</ListItemIcon>
|
||||
<ListItemText primary="未查询到任何结果"/>
|
||||
</ListItem>
|
||||
</ListItem>
|
||||
}
|
||||
{
|
||||
props.result.names.map((name, index) =>
|
||||
<ListItem disableGutters key={index}>
|
||||
<ListItem>
|
||||
<ListItemIcon>
|
||||
<FaceIcon/>
|
||||
</ListItemIcon>
|
||||
<ListItemText primary={name}/>
|
||||
</ListItem>
|
||||
</ListItem>
|
||||
)
|
||||
}
|
||||
{
|
||||
props.result.nicknames.map((nickname, index) =>
|
||||
<ListItem disableGutters key={index}>
|
||||
<ListItem>
|
||||
<ListItemIcon>
|
||||
<AccountCircleIcon/>
|
||||
</ListItemIcon>
|
||||
<ListItemText primary={nickname}/>
|
||||
</ListItem>
|
||||
</ListItem>
|
||||
)
|
||||
}
|
||||
{
|
||||
props.result.phone_numbers.map((phoneNumber, index) =>
|
||||
<ListItem disableGutters key={index}>
|
||||
<ListItem>
|
||||
<ListItemIcon>
|
||||
<PhoneIcon/>
|
||||
</ListItemIcon>
|
||||
<ListItemText primary={phoneNumber}/>
|
||||
</ListItem>
|
||||
</ListItem>
|
||||
)
|
||||
}
|
||||
{
|
||||
props.result.id_numbers.map((idNumber, index) =>
|
||||
<ListItem disableGutters key={index}>
|
||||
<ListItem>
|
||||
<ListItemIcon>
|
||||
<SvgIcon>
|
||||
<path fill="currentColor"
|
||||
d="M2,3H22C23.05,3 24,3.95 24,5V19C24,20.05 23.05,21 22,21H2C0.95,21 0,20.05 0,19V5C0,3.95 0.95,3 2,3M14,6V7H22V6H14M14,8V9H21.5L22,9V8H14M14,10V11H21V10H14M8,13.91C6,13.91 2,15 2,17V18H14V17C14,15 10,13.91 8,13.91M8,6A3,3 0 0,0 5,9A3,3 0 0,0 8,12A3,3 0 0,0 11,9A3,3 0 0,0 8,6Z"/>
|
||||
</SvgIcon>
|
||||
</ListItemIcon>
|
||||
<ListItemText primary={idNumber}/>
|
||||
</ListItem>
|
||||
</ListItem>
|
||||
)
|
||||
}
|
||||
{
|
||||
props.result.qq_numbers.map((qqNumber, index) =>
|
||||
<ListItem disableGutters key={index}>
|
||||
<ListItem>
|
||||
<ListItemIcon>
|
||||
<SvgIcon>
|
||||
<path fill="currentColor"
|
||||
d="M3.18,13.54C3.76,12.16 4.57,11.14 5.17,10.92C5.16,10.12 5.31,9.62 5.56,9.22C5.56,9.19 5.5,8.86 5.72,8.45C5.87,4.85 8.21,2 12,2C15.79,2 18.13,4.85 18.28,8.45C18.5,8.86 18.44,9.19 18.44,9.22C18.69,9.62 18.84,10.12 18.83,10.92C19.43,11.14 20.24,12.16 20.82,13.55C21.57,15.31 21.69,17 21.09,17.3C20.68,17.5 20.03,17 19.42,16.12C19.18,17.1 18.58,18 17.73,18.71C18.63,19.04 19.21,19.58 19.21,20.19C19.21,21.19 17.63,22 15.69,22C13.93,22 12.5,21.34 12.21,20.5H11.79C11.5,21.34 10.07,22 8.31,22C6.37,22 4.79,21.19 4.79,20.19C4.79,19.58 5.37,19.04 6.27,18.71C5.42,18 4.82,17.1 4.58,16.12C3.97,17 3.32,17.5 2.91,17.3C2.31,17 2.43,15.31 3.18,13.54Z"/>
|
||||
</SvgIcon>
|
||||
</ListItemIcon>
|
||||
<ListItemText primary={qqNumber}/>
|
||||
</ListItem>
|
||||
</ListItem>
|
||||
)
|
||||
}
|
||||
{
|
||||
props.result.passwords.map((qqNumber, index) =>
|
||||
<ListItem disableGutters key={index}>
|
||||
<ListItem>
|
||||
<ListItemIcon>
|
||||
<VpnKeyIcon/>
|
||||
</ListItemIcon>
|
||||
<ListItemText primaryTypographyProps={{style: {wordWrap: "break-word"}}}
|
||||
primary={qqNumber}/>
|
||||
</ListItem>
|
||||
</ListItem>
|
||||
)
|
||||
}
|
||||
{
|
||||
props.result.emails.map((email, index) =>
|
||||
<ListItem disableGutters key={index}>
|
||||
<ListItem>
|
||||
<ListItemIcon>
|
||||
<EmailIcon/>
|
||||
</ListItemIcon>
|
||||
<ListItemText primary={email}/>
|
||||
</ListItem>
|
||||
</ListItem>
|
||||
)
|
||||
}
|
||||
{
|
||||
props.result.addresses.map((address, index) =>
|
||||
<ListItem disableGutters key={index}>
|
||||
<ListItem>
|
||||
<ListItemIcon>
|
||||
<BusinessIcon/>
|
||||
</ListItemIcon>
|
||||
<ListItemText primary={address}/>
|
||||
</ListItem>
|
||||
</ListItem>
|
||||
)
|
||||
}
|
||||
</List>
|
||||
</Box>
|
||||
</Box>
|
||||
</Paper>
|
||||
}
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
export default Result;
|
19
website/src/index.css
Normal file
19
website/src/index.css
Normal file
@ -0,0 +1,19 @@
|
||||
html, body, #root {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||
sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
||||
monospace;
|
||||
}
|
33
website/src/index.tsx
Normal file
33
website/src/index.tsx
Normal file
@ -0,0 +1,33 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import './index.css';
|
||||
import App from './App';
|
||||
import reportWebVitals from './reportWebVitals';
|
||||
import createMuiTheme from "@material-ui/core/styles/createMuiTheme";
|
||||
import {grey, pink} from "@material-ui/core/colors";
|
||||
import {ThemeProvider} from '@material-ui/core/styles';
|
||||
|
||||
const theme = createMuiTheme({
|
||||
palette: {
|
||||
primary: {
|
||||
main: grey[50],
|
||||
},
|
||||
secondary: {
|
||||
main: pink["A200"],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
ReactDOM.render(
|
||||
<React.StrictMode>
|
||||
<ThemeProvider theme={theme}>
|
||||
<App/>
|
||||
</ThemeProvider>
|
||||
</React.StrictMode>,
|
||||
document.getElementById('root')
|
||||
);
|
||||
|
||||
// If you want to start measuring performance in your app, pass a function
|
||||
// to log results (for example: reportWebVitals(console.log))
|
||||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
||||
reportWebVitals();
|
1
website/src/logo.svg
Normal file
1
website/src/logo.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
|
After Width: | Height: | Size: 2.6 KiB |
1
website/src/react-app-env.d.ts
vendored
Normal file
1
website/src/react-app-env.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
/// <reference types="react-scripts" />
|
15
website/src/reportWebVitals.ts
Normal file
15
website/src/reportWebVitals.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { ReportHandler } from 'web-vitals';
|
||||
|
||||
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
|
||||
if (onPerfEntry && onPerfEntry instanceof Function) {
|
||||
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
||||
getCLS(onPerfEntry);
|
||||
getFID(onPerfEntry);
|
||||
getFCP(onPerfEntry);
|
||||
getLCP(onPerfEntry);
|
||||
getTTFB(onPerfEntry);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default reportWebVitals;
|
5
website/src/setupTests.ts
Normal file
5
website/src/setupTests.ts
Normal file
@ -0,0 +1,5 @@
|
||||
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
||||
// allows you to do things like:
|
||||
// expect(element).toHaveTextContent(/react/i)
|
||||
// learn more: https://github.com/testing-library/jest-dom
|
||||
import '@testing-library/jest-dom';
|
26
website/tsconfig.json
Normal file
26
website/tsconfig.json
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx"
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
}
|
11761
website/yarn.lock
Normal file
11761
website/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user