Compare commits
21 Commits
dev
...
dc01c83e9d
| Author | SHA1 | Date | |
|---|---|---|---|
|
dc01c83e9d
|
|||
|
c3bd20d90b
|
|||
|
93a50de9c5
|
|||
|
53f275cbb3
|
|||
|
e9516ac4cd
|
|||
|
9d1f0f73c1
|
|||
|
baeca96d10
|
|||
|
33944caab7
|
|||
|
2883ab052c
|
|||
|
a0ac2438ed
|
|||
|
d4ee96b1dc
|
|||
|
41b6201a10
|
|||
|
c892ba3d8f
|
|||
|
d72f710aaa
|
|||
|
ab66b9efc0
|
|||
|
311f1ae71a
|
|||
|
007499e104
|
|||
|
e454d97086
|
|||
|
175ab09869
|
|||
|
e025b48fb4
|
|||
|
1d65e1194b
|
7
.gitignore
vendored
7
.gitignore
vendored
@@ -2,13 +2,8 @@ t
|
||||
.env
|
||||
*.json
|
||||
*.sqlite
|
||||
#*.zsh
|
||||
tmp/card_limit.zsh
|
||||
tmp/card_day.zsh
|
||||
tmp/card_delete.zsh
|
||||
memo.md
|
||||
api
|
||||
**.DS_Store
|
||||
node_modules
|
||||
*.lock
|
||||
target
|
||||
app/data
|
||||
|
||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
||||
[submodule "scpt"]
|
||||
path = scpt
|
||||
url = git@git.syui.ai:ai/api_scpt
|
||||
@@ -1,8 +0,0 @@
|
||||
FROM archlinux
|
||||
|
||||
#RUN pacman -Syu --noconfirm
|
||||
|
||||
WORKDIR /app
|
||||
COPY api /app/
|
||||
|
||||
ENTRYPOINT ["/app/api"]
|
||||
31
build.zsh
31
build.zsh
@@ -2,33 +2,10 @@
|
||||
|
||||
d=${0:a:h}
|
||||
cd $d
|
||||
su=10000
|
||||
su=4000
|
||||
|
||||
|
||||
go1.21.8 generate ./...
|
||||
|
||||
#go generate ./...
|
||||
#PASS=`cat $f|jq -r .password` TOKEN=`cat $f|jq -r .token` go run -mod=mod main.go
|
||||
|
||||
cp -rf $d/ent/openapi.json $d/tmp/
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
sed -i '' "s/255/$su/g" $d/ent/ogent/oas_parameters_gen.go
|
||||
sed -i '' "s/255/$su/g" $d/ent/openapi.json
|
||||
;;
|
||||
linux*)
|
||||
sed -i "s/255/$su/g" $d/ent/ogent/oas_parameters_gen.go
|
||||
sed -i "s/255/$su/g" $d/ent/openapi.json
|
||||
;;
|
||||
esac
|
||||
go generate ./...
|
||||
sed -i '' "s/255/$su/g" $d/ent/ogent/oas_parameters_gen.go
|
||||
sed -i '' "s/255/$su/g" $d/ent/openapi.json
|
||||
|
||||
cp -rf $d/tmp/ogent ent/
|
||||
f=~/.config/ai/api_card.json
|
||||
|
||||
if [ -f ./.env ];then
|
||||
rm .env
|
||||
fi
|
||||
echo PASS=`cat ~/.config/ai/api_card.json|jq -r .password` >> .env
|
||||
echo TOKEN=`cat ~/.config/ai/api_card.json|jq -r .token` >> .env
|
||||
PASS=`cat $f|jq -r .password` TOKEN=`cat $f|jq -r .token` go build
|
||||
|
||||
11
compose.yml
11
compose.yml
@@ -1,11 +0,0 @@
|
||||
services:
|
||||
api:
|
||||
ports:
|
||||
- 8188:8080
|
||||
build:
|
||||
context: .
|
||||
restart: always
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- ./app/data:/app/data
|
||||
87
docs/wiki.md
87
docs/wiki.md
@@ -1,87 +0,0 @@
|
||||
## build
|
||||
|
||||
```sh
|
||||
./build.zsh
|
||||
```
|
||||
|
||||
## diff
|
||||
|
||||
> diff tmp/ogent/ogent.go ent/ogent/ogent.go
|
||||
|
||||
```diff
|
||||
< "os"
|
||||
---
|
||||
< var password = os.Getenv("PASS")
|
||||
< var token = os.Getenv("TOKEN")
|
||||
---
|
||||
< if req.Password == password {
|
||||
< b.SetOwnerID(req.Owner)
|
||||
< } else {
|
||||
< b.SetOwnerID(0)
|
||||
< }
|
||||
< //b.SetOwnerID(req.Owner)
|
||||
---
|
||||
> b.SetOwnerID(req.Owner)
|
||||
< //if v, ok := req.Owner.Get(); ok {
|
||||
< // b.SetOwnerID(v)
|
||||
< //}
|
||||
< if v, ok := req.Token.Get(); ok {
|
||||
< if v == token {
|
||||
< b.SetToken(v)
|
||||
< if v, ok := req.Owner.Get(); ok {
|
||||
< b.SetOwnerID(v)
|
||||
< }
|
||||
< }
|
||||
---
|
||||
< //err := h.client.Card.DeleteOneID(params.ID).Exec(ctx)
|
||||
< err := h.client.Card.DeleteOneID(0).Exec(ctx)
|
||||
---
|
||||
> err := h.client.Ue.DeleteOneID(params.ID).Exec(ctx)
|
||||
< //b.SetUsername(req.Username)
|
||||
< if req.Password == password {
|
||||
< b.SetUsername(req.Username)
|
||||
< } else {
|
||||
< b.SetUsername("")
|
||||
< }
|
||||
```
|
||||
|
||||
## northflank
|
||||
|
||||
- ports : http, 8080, dns=api.syui.ai
|
||||
- env : PASS=xxx, TOKEN=xxx
|
||||
- cmd-override : /bin/api
|
||||
- volumes : /app/data
|
||||
|
||||
## api
|
||||
|
||||
### get
|
||||
|
||||
```sh
|
||||
$ curl -sL $api/users/2
|
||||
|
||||
$ curl -sL "$api/users?itemsPerPage=2000"
|
||||
|
||||
$ curl -sL "$api/users/$uid/card?itemsPerPage=2550"
|
||||
```
|
||||
|
||||
### post
|
||||
|
||||
```sh
|
||||
$ curl -X POST -H "Content-Type: application/json" -d "{\"username\":\"$name\",\"password\":\"$pass\",\"did\":\"$did\"}" $api/users
|
||||
|
||||
$ curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$uid,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\"}" $api/cards
|
||||
```
|
||||
|
||||
### patch
|
||||
|
||||
```sh
|
||||
$ curl -X PATCH -H "Content-Type: application/json" -d "{\"author\":\"$username\", \"count\":$count,\"token\":\"$token\"}" $api/cards/$cid
|
||||
|
||||
$ curl -X PATCH -H "Content-Type: application/json" -d "{\"model\":true,\"model_limit\": 1,\"token\":\"$token\"}" -s $api/users/$uid
|
||||
```
|
||||
|
||||
### delete
|
||||
|
||||
```sh
|
||||
$ curl -X DELETE -H "Content-Type: application/json" -d "{'owner':\"$uid\"}" $api/cards/$cid
|
||||
```
|
||||
46
ent/card.go
46
ent/card.go
@@ -3,13 +3,12 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/card"
|
||||
"api/ent/user"
|
||||
"fmt"
|
||||
"strings"
|
||||
"t/ent/card"
|
||||
"t/ent/user"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
@@ -32,17 +31,12 @@ type Card struct {
|
||||
Cp int `json:"cp,omitempty"`
|
||||
// URL holds the value of the "url" field.
|
||||
URL string `json:"url,omitempty"`
|
||||
// Count holds the value of the "count" field.
|
||||
Count int `json:"count,omitempty"`
|
||||
// Author holds the value of the "author" field.
|
||||
Author string `json:"author,omitempty"`
|
||||
// CreatedAt holds the value of the "created_at" field.
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the CardQuery when eager-loading is set.
|
||||
Edges CardEdges `json:"edges"`
|
||||
user_card *int
|
||||
selectValues sql.SelectValues
|
||||
Edges CardEdges `json:"edges"`
|
||||
user_card *int
|
||||
}
|
||||
|
||||
// CardEdges holds the relations/edges for other nodes in the graph.
|
||||
@@ -72,16 +66,16 @@ func (*Card) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case card.FieldID, card.FieldCard, card.FieldCp, card.FieldCount:
|
||||
case card.FieldID, card.FieldCard, card.FieldCp:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case card.FieldPassword, card.FieldSkill, card.FieldStatus, card.FieldToken, card.FieldURL, card.FieldAuthor:
|
||||
case card.FieldPassword, card.FieldSkill, card.FieldStatus, card.FieldToken, card.FieldURL:
|
||||
values[i] = new(sql.NullString)
|
||||
case card.FieldCreatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case card.ForeignKeys[0]: // user_card
|
||||
values[i] = new(sql.NullInt64)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
return nil, fmt.Errorf("unexpected column %q for type Card", columns[i])
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
@@ -143,18 +137,6 @@ func (c *Card) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
c.URL = value.String
|
||||
}
|
||||
case card.FieldCount:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field count", values[i])
|
||||
} else if value.Valid {
|
||||
c.Count = int(value.Int64)
|
||||
}
|
||||
case card.FieldAuthor:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field author", values[i])
|
||||
} else if value.Valid {
|
||||
c.Author = value.String
|
||||
}
|
||||
case card.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
@@ -168,19 +150,11 @@ func (c *Card) assignValues(columns []string, values []any) error {
|
||||
c.user_card = new(int)
|
||||
*c.user_card = int(value.Int64)
|
||||
}
|
||||
default:
|
||||
c.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Card.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (c *Card) Value(name string) (ent.Value, error) {
|
||||
return c.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryOwner queries the "owner" edge of the Card entity.
|
||||
func (c *Card) QueryOwner() *UserQuery {
|
||||
return NewCardClient(c.config).QueryOwner(c)
|
||||
@@ -228,12 +202,6 @@ func (c *Card) String() string {
|
||||
builder.WriteString("url=")
|
||||
builder.WriteString(c.URL)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("count=")
|
||||
builder.WriteString(fmt.Sprintf("%v", c.Count))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("author=")
|
||||
builder.WriteString(c.Author)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(c.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
|
||||
@@ -4,9 +4,6 @@ package card
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -28,10 +25,6 @@ const (
|
||||
FieldCp = "cp"
|
||||
// FieldURL holds the string denoting the url field in the database.
|
||||
FieldURL = "url"
|
||||
// FieldCount holds the string denoting the count field in the database.
|
||||
FieldCount = "count"
|
||||
// FieldAuthor holds the string denoting the author field in the database.
|
||||
FieldAuthor = "author"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// EdgeOwner holds the string denoting the owner edge name in mutations.
|
||||
@@ -57,8 +50,6 @@ var Columns = []string{
|
||||
FieldToken,
|
||||
FieldCp,
|
||||
FieldURL,
|
||||
FieldCount,
|
||||
FieldAuthor,
|
||||
FieldCreatedAt,
|
||||
}
|
||||
|
||||
@@ -99,75 +90,3 @@ var (
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() time.Time
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the Card queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPassword orders the results by the password field.
|
||||
func ByPassword(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPassword, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCard orders the results by the card field.
|
||||
func ByCard(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCard, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySkill orders the results by the skill field.
|
||||
func BySkill(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSkill, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByStatus orders the results by the status field.
|
||||
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldStatus, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByToken orders the results by the token field.
|
||||
func ByToken(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldToken, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCp orders the results by the cp field.
|
||||
func ByCp(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCp, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByURL orders the results by the url field.
|
||||
func ByURL(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldURL, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCount orders the results by the count field.
|
||||
func ByCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCount, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByAuthor orders the results by the author field.
|
||||
func ByAuthor(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldAuthor, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByOwnerField orders the results by owner field.
|
||||
func ByOwnerField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newOwnerStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
func newOwnerStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(OwnerInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
package card
|
||||
|
||||
import (
|
||||
"api/ent/predicate"
|
||||
"t/ent/predicate"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
@@ -90,16 +90,6 @@ func URL(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldEQ(FieldURL, v))
|
||||
}
|
||||
|
||||
// Count applies equality check predicate on the "count" field. It's identical to CountEQ.
|
||||
func Count(v int) predicate.Card {
|
||||
return predicate.Card(sql.FieldEQ(FieldCount, v))
|
||||
}
|
||||
|
||||
// Author applies equality check predicate on the "author" field. It's identical to AuthorEQ.
|
||||
func Author(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldEQ(FieldAuthor, v))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v time.Time) predicate.Card {
|
||||
return predicate.Card(sql.FieldEQ(FieldCreatedAt, v))
|
||||
@@ -570,131 +560,6 @@ func URLContainsFold(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldContainsFold(FieldURL, v))
|
||||
}
|
||||
|
||||
// CountEQ applies the EQ predicate on the "count" field.
|
||||
func CountEQ(v int) predicate.Card {
|
||||
return predicate.Card(sql.FieldEQ(FieldCount, v))
|
||||
}
|
||||
|
||||
// CountNEQ applies the NEQ predicate on the "count" field.
|
||||
func CountNEQ(v int) predicate.Card {
|
||||
return predicate.Card(sql.FieldNEQ(FieldCount, v))
|
||||
}
|
||||
|
||||
// CountIn applies the In predicate on the "count" field.
|
||||
func CountIn(vs ...int) predicate.Card {
|
||||
return predicate.Card(sql.FieldIn(FieldCount, vs...))
|
||||
}
|
||||
|
||||
// CountNotIn applies the NotIn predicate on the "count" field.
|
||||
func CountNotIn(vs ...int) predicate.Card {
|
||||
return predicate.Card(sql.FieldNotIn(FieldCount, vs...))
|
||||
}
|
||||
|
||||
// CountGT applies the GT predicate on the "count" field.
|
||||
func CountGT(v int) predicate.Card {
|
||||
return predicate.Card(sql.FieldGT(FieldCount, v))
|
||||
}
|
||||
|
||||
// CountGTE applies the GTE predicate on the "count" field.
|
||||
func CountGTE(v int) predicate.Card {
|
||||
return predicate.Card(sql.FieldGTE(FieldCount, v))
|
||||
}
|
||||
|
||||
// CountLT applies the LT predicate on the "count" field.
|
||||
func CountLT(v int) predicate.Card {
|
||||
return predicate.Card(sql.FieldLT(FieldCount, v))
|
||||
}
|
||||
|
||||
// CountLTE applies the LTE predicate on the "count" field.
|
||||
func CountLTE(v int) predicate.Card {
|
||||
return predicate.Card(sql.FieldLTE(FieldCount, v))
|
||||
}
|
||||
|
||||
// CountIsNil applies the IsNil predicate on the "count" field.
|
||||
func CountIsNil() predicate.Card {
|
||||
return predicate.Card(sql.FieldIsNull(FieldCount))
|
||||
}
|
||||
|
||||
// CountNotNil applies the NotNil predicate on the "count" field.
|
||||
func CountNotNil() predicate.Card {
|
||||
return predicate.Card(sql.FieldNotNull(FieldCount))
|
||||
}
|
||||
|
||||
// AuthorEQ applies the EQ predicate on the "author" field.
|
||||
func AuthorEQ(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldEQ(FieldAuthor, v))
|
||||
}
|
||||
|
||||
// AuthorNEQ applies the NEQ predicate on the "author" field.
|
||||
func AuthorNEQ(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldNEQ(FieldAuthor, v))
|
||||
}
|
||||
|
||||
// AuthorIn applies the In predicate on the "author" field.
|
||||
func AuthorIn(vs ...string) predicate.Card {
|
||||
return predicate.Card(sql.FieldIn(FieldAuthor, vs...))
|
||||
}
|
||||
|
||||
// AuthorNotIn applies the NotIn predicate on the "author" field.
|
||||
func AuthorNotIn(vs ...string) predicate.Card {
|
||||
return predicate.Card(sql.FieldNotIn(FieldAuthor, vs...))
|
||||
}
|
||||
|
||||
// AuthorGT applies the GT predicate on the "author" field.
|
||||
func AuthorGT(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldGT(FieldAuthor, v))
|
||||
}
|
||||
|
||||
// AuthorGTE applies the GTE predicate on the "author" field.
|
||||
func AuthorGTE(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldGTE(FieldAuthor, v))
|
||||
}
|
||||
|
||||
// AuthorLT applies the LT predicate on the "author" field.
|
||||
func AuthorLT(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldLT(FieldAuthor, v))
|
||||
}
|
||||
|
||||
// AuthorLTE applies the LTE predicate on the "author" field.
|
||||
func AuthorLTE(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldLTE(FieldAuthor, v))
|
||||
}
|
||||
|
||||
// AuthorContains applies the Contains predicate on the "author" field.
|
||||
func AuthorContains(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldContains(FieldAuthor, v))
|
||||
}
|
||||
|
||||
// AuthorHasPrefix applies the HasPrefix predicate on the "author" field.
|
||||
func AuthorHasPrefix(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldHasPrefix(FieldAuthor, v))
|
||||
}
|
||||
|
||||
// AuthorHasSuffix applies the HasSuffix predicate on the "author" field.
|
||||
func AuthorHasSuffix(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldHasSuffix(FieldAuthor, v))
|
||||
}
|
||||
|
||||
// AuthorIsNil applies the IsNil predicate on the "author" field.
|
||||
func AuthorIsNil() predicate.Card {
|
||||
return predicate.Card(sql.FieldIsNull(FieldAuthor))
|
||||
}
|
||||
|
||||
// AuthorNotNil applies the NotNil predicate on the "author" field.
|
||||
func AuthorNotNil() predicate.Card {
|
||||
return predicate.Card(sql.FieldNotNull(FieldAuthor))
|
||||
}
|
||||
|
||||
// AuthorEqualFold applies the EqualFold predicate on the "author" field.
|
||||
func AuthorEqualFold(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldEqualFold(FieldAuthor, v))
|
||||
}
|
||||
|
||||
// AuthorContainsFold applies the ContainsFold predicate on the "author" field.
|
||||
func AuthorContainsFold(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldContainsFold(FieldAuthor, v))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.Card {
|
||||
return predicate.Card(sql.FieldEQ(FieldCreatedAt, v))
|
||||
@@ -759,7 +624,11 @@ func HasOwner() predicate.Card {
|
||||
// HasOwnerWith applies the HasEdge predicate on the "owner" edge with a given conditions (other predicates).
|
||||
func HasOwnerWith(preds ...predicate.User) predicate.Card {
|
||||
return predicate.Card(func(s *sql.Selector) {
|
||||
step := newOwnerStep()
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(OwnerInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn),
|
||||
)
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/card"
|
||||
"api/ent/user"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"t/ent/card"
|
||||
"t/ent/user"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -111,34 +111,6 @@ func (cc *CardCreate) SetNillableURL(s *string) *CardCreate {
|
||||
return cc
|
||||
}
|
||||
|
||||
// SetCount sets the "count" field.
|
||||
func (cc *CardCreate) SetCount(i int) *CardCreate {
|
||||
cc.mutation.SetCount(i)
|
||||
return cc
|
||||
}
|
||||
|
||||
// SetNillableCount sets the "count" field if the given value is not nil.
|
||||
func (cc *CardCreate) SetNillableCount(i *int) *CardCreate {
|
||||
if i != nil {
|
||||
cc.SetCount(*i)
|
||||
}
|
||||
return cc
|
||||
}
|
||||
|
||||
// SetAuthor sets the "author" field.
|
||||
func (cc *CardCreate) SetAuthor(s string) *CardCreate {
|
||||
cc.mutation.SetAuthor(s)
|
||||
return cc
|
||||
}
|
||||
|
||||
// SetNillableAuthor sets the "author" field if the given value is not nil.
|
||||
func (cc *CardCreate) SetNillableAuthor(s *string) *CardCreate {
|
||||
if s != nil {
|
||||
cc.SetAuthor(*s)
|
||||
}
|
||||
return cc
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (cc *CardCreate) SetCreatedAt(t time.Time) *CardCreate {
|
||||
cc.mutation.SetCreatedAt(t)
|
||||
@@ -292,14 +264,6 @@ func (cc *CardCreate) createSpec() (*Card, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(card.FieldURL, field.TypeString, value)
|
||||
_node.URL = value
|
||||
}
|
||||
if value, ok := cc.mutation.Count(); ok {
|
||||
_spec.SetField(card.FieldCount, field.TypeInt, value)
|
||||
_node.Count = value
|
||||
}
|
||||
if value, ok := cc.mutation.Author(); ok {
|
||||
_spec.SetField(card.FieldAuthor, field.TypeString, value)
|
||||
_node.Author = value
|
||||
}
|
||||
if value, ok := cc.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(card.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
@@ -348,8 +312,8 @@ func (ccb *CardCreateBulk) Save(ctx context.Context) ([]*Card, error) {
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
var err error
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, ccb.builders[i+1].mutation)
|
||||
} else {
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/card"
|
||||
"api/ent/predicate"
|
||||
"context"
|
||||
"t/ent/card"
|
||||
"t/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/card"
|
||||
"api/ent/predicate"
|
||||
"api/ent/user"
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"t/ent/card"
|
||||
"t/ent/predicate"
|
||||
"t/ent/user"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
type CardQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []card.OrderOption
|
||||
order []OrderFunc
|
||||
inters []Interceptor
|
||||
predicates []predicate.Card
|
||||
withOwner *UserQuery
|
||||
@@ -55,7 +55,7 @@ func (cq *CardQuery) Unique(unique bool) *CardQuery {
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (cq *CardQuery) Order(o ...card.OrderOption) *CardQuery {
|
||||
func (cq *CardQuery) Order(o ...OrderFunc) *CardQuery {
|
||||
cq.order = append(cq.order, o...)
|
||||
return cq
|
||||
}
|
||||
@@ -271,7 +271,7 @@ func (cq *CardQuery) Clone() *CardQuery {
|
||||
return &CardQuery{
|
||||
config: cq.config,
|
||||
ctx: cq.ctx.Clone(),
|
||||
order: append([]card.OrderOption{}, cq.order...),
|
||||
order: append([]OrderFunc{}, cq.order...),
|
||||
inters: append([]Interceptor{}, cq.inters...),
|
||||
predicates: append([]predicate.Card{}, cq.predicates...),
|
||||
withOwner: cq.withOwner.Clone(),
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/card"
|
||||
"api/ent/predicate"
|
||||
"api/ent/user"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"t/ent/card"
|
||||
"t/ent/predicate"
|
||||
"t/ent/user"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -28,33 +28,6 @@ func (cu *CardUpdate) Where(ps ...predicate.Card) *CardUpdate {
|
||||
return cu
|
||||
}
|
||||
|
||||
// SetCard sets the "card" field.
|
||||
func (cu *CardUpdate) SetCard(i int) *CardUpdate {
|
||||
cu.mutation.ResetCard()
|
||||
cu.mutation.SetCard(i)
|
||||
return cu
|
||||
}
|
||||
|
||||
// SetNillableCard sets the "card" field if the given value is not nil.
|
||||
func (cu *CardUpdate) SetNillableCard(i *int) *CardUpdate {
|
||||
if i != nil {
|
||||
cu.SetCard(*i)
|
||||
}
|
||||
return cu
|
||||
}
|
||||
|
||||
// AddCard adds i to the "card" field.
|
||||
func (cu *CardUpdate) AddCard(i int) *CardUpdate {
|
||||
cu.mutation.AddCard(i)
|
||||
return cu
|
||||
}
|
||||
|
||||
// ClearCard clears the value of the "card" field.
|
||||
func (cu *CardUpdate) ClearCard() *CardUpdate {
|
||||
cu.mutation.ClearCard()
|
||||
return cu
|
||||
}
|
||||
|
||||
// SetSkill sets the "skill" field.
|
||||
func (cu *CardUpdate) SetSkill(s string) *CardUpdate {
|
||||
cu.mutation.SetSkill(s)
|
||||
@@ -142,73 +115,6 @@ func (cu *CardUpdate) ClearCp() *CardUpdate {
|
||||
return cu
|
||||
}
|
||||
|
||||
// SetURL sets the "url" field.
|
||||
func (cu *CardUpdate) SetURL(s string) *CardUpdate {
|
||||
cu.mutation.SetURL(s)
|
||||
return cu
|
||||
}
|
||||
|
||||
// SetNillableURL sets the "url" field if the given value is not nil.
|
||||
func (cu *CardUpdate) SetNillableURL(s *string) *CardUpdate {
|
||||
if s != nil {
|
||||
cu.SetURL(*s)
|
||||
}
|
||||
return cu
|
||||
}
|
||||
|
||||
// ClearURL clears the value of the "url" field.
|
||||
func (cu *CardUpdate) ClearURL() *CardUpdate {
|
||||
cu.mutation.ClearURL()
|
||||
return cu
|
||||
}
|
||||
|
||||
// SetCount sets the "count" field.
|
||||
func (cu *CardUpdate) SetCount(i int) *CardUpdate {
|
||||
cu.mutation.ResetCount()
|
||||
cu.mutation.SetCount(i)
|
||||
return cu
|
||||
}
|
||||
|
||||
// SetNillableCount sets the "count" field if the given value is not nil.
|
||||
func (cu *CardUpdate) SetNillableCount(i *int) *CardUpdate {
|
||||
if i != nil {
|
||||
cu.SetCount(*i)
|
||||
}
|
||||
return cu
|
||||
}
|
||||
|
||||
// AddCount adds i to the "count" field.
|
||||
func (cu *CardUpdate) AddCount(i int) *CardUpdate {
|
||||
cu.mutation.AddCount(i)
|
||||
return cu
|
||||
}
|
||||
|
||||
// ClearCount clears the value of the "count" field.
|
||||
func (cu *CardUpdate) ClearCount() *CardUpdate {
|
||||
cu.mutation.ClearCount()
|
||||
return cu
|
||||
}
|
||||
|
||||
// SetAuthor sets the "author" field.
|
||||
func (cu *CardUpdate) SetAuthor(s string) *CardUpdate {
|
||||
cu.mutation.SetAuthor(s)
|
||||
return cu
|
||||
}
|
||||
|
||||
// SetNillableAuthor sets the "author" field if the given value is not nil.
|
||||
func (cu *CardUpdate) SetNillableAuthor(s *string) *CardUpdate {
|
||||
if s != nil {
|
||||
cu.SetAuthor(*s)
|
||||
}
|
||||
return cu
|
||||
}
|
||||
|
||||
// ClearAuthor clears the value of the "author" field.
|
||||
func (cu *CardUpdate) ClearAuthor() *CardUpdate {
|
||||
cu.mutation.ClearAuthor()
|
||||
return cu
|
||||
}
|
||||
|
||||
// SetOwnerID sets the "owner" edge to the User entity by ID.
|
||||
func (cu *CardUpdate) SetOwnerID(id int) *CardUpdate {
|
||||
cu.mutation.SetOwnerID(id)
|
||||
@@ -278,12 +184,6 @@ func (cu *CardUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := cu.mutation.Card(); ok {
|
||||
_spec.SetField(card.FieldCard, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := cu.mutation.AddedCard(); ok {
|
||||
_spec.AddField(card.FieldCard, field.TypeInt, value)
|
||||
}
|
||||
if cu.mutation.CardCleared() {
|
||||
_spec.ClearField(card.FieldCard, field.TypeInt)
|
||||
}
|
||||
@@ -314,27 +214,9 @@ func (cu *CardUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if cu.mutation.CpCleared() {
|
||||
_spec.ClearField(card.FieldCp, field.TypeInt)
|
||||
}
|
||||
if value, ok := cu.mutation.URL(); ok {
|
||||
_spec.SetField(card.FieldURL, field.TypeString, value)
|
||||
}
|
||||
if cu.mutation.URLCleared() {
|
||||
_spec.ClearField(card.FieldURL, field.TypeString)
|
||||
}
|
||||
if value, ok := cu.mutation.Count(); ok {
|
||||
_spec.SetField(card.FieldCount, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := cu.mutation.AddedCount(); ok {
|
||||
_spec.AddField(card.FieldCount, field.TypeInt, value)
|
||||
}
|
||||
if cu.mutation.CountCleared() {
|
||||
_spec.ClearField(card.FieldCount, field.TypeInt)
|
||||
}
|
||||
if value, ok := cu.mutation.Author(); ok {
|
||||
_spec.SetField(card.FieldAuthor, field.TypeString, value)
|
||||
}
|
||||
if cu.mutation.AuthorCleared() {
|
||||
_spec.ClearField(card.FieldAuthor, field.TypeString)
|
||||
}
|
||||
if cu.mutation.CreatedAtCleared() {
|
||||
_spec.ClearField(card.FieldCreatedAt, field.TypeTime)
|
||||
}
|
||||
@@ -387,33 +269,6 @@ type CardUpdateOne struct {
|
||||
mutation *CardMutation
|
||||
}
|
||||
|
||||
// SetCard sets the "card" field.
|
||||
func (cuo *CardUpdateOne) SetCard(i int) *CardUpdateOne {
|
||||
cuo.mutation.ResetCard()
|
||||
cuo.mutation.SetCard(i)
|
||||
return cuo
|
||||
}
|
||||
|
||||
// SetNillableCard sets the "card" field if the given value is not nil.
|
||||
func (cuo *CardUpdateOne) SetNillableCard(i *int) *CardUpdateOne {
|
||||
if i != nil {
|
||||
cuo.SetCard(*i)
|
||||
}
|
||||
return cuo
|
||||
}
|
||||
|
||||
// AddCard adds i to the "card" field.
|
||||
func (cuo *CardUpdateOne) AddCard(i int) *CardUpdateOne {
|
||||
cuo.mutation.AddCard(i)
|
||||
return cuo
|
||||
}
|
||||
|
||||
// ClearCard clears the value of the "card" field.
|
||||
func (cuo *CardUpdateOne) ClearCard() *CardUpdateOne {
|
||||
cuo.mutation.ClearCard()
|
||||
return cuo
|
||||
}
|
||||
|
||||
// SetSkill sets the "skill" field.
|
||||
func (cuo *CardUpdateOne) SetSkill(s string) *CardUpdateOne {
|
||||
cuo.mutation.SetSkill(s)
|
||||
@@ -501,73 +356,6 @@ func (cuo *CardUpdateOne) ClearCp() *CardUpdateOne {
|
||||
return cuo
|
||||
}
|
||||
|
||||
// SetURL sets the "url" field.
|
||||
func (cuo *CardUpdateOne) SetURL(s string) *CardUpdateOne {
|
||||
cuo.mutation.SetURL(s)
|
||||
return cuo
|
||||
}
|
||||
|
||||
// SetNillableURL sets the "url" field if the given value is not nil.
|
||||
func (cuo *CardUpdateOne) SetNillableURL(s *string) *CardUpdateOne {
|
||||
if s != nil {
|
||||
cuo.SetURL(*s)
|
||||
}
|
||||
return cuo
|
||||
}
|
||||
|
||||
// ClearURL clears the value of the "url" field.
|
||||
func (cuo *CardUpdateOne) ClearURL() *CardUpdateOne {
|
||||
cuo.mutation.ClearURL()
|
||||
return cuo
|
||||
}
|
||||
|
||||
// SetCount sets the "count" field.
|
||||
func (cuo *CardUpdateOne) SetCount(i int) *CardUpdateOne {
|
||||
cuo.mutation.ResetCount()
|
||||
cuo.mutation.SetCount(i)
|
||||
return cuo
|
||||
}
|
||||
|
||||
// SetNillableCount sets the "count" field if the given value is not nil.
|
||||
func (cuo *CardUpdateOne) SetNillableCount(i *int) *CardUpdateOne {
|
||||
if i != nil {
|
||||
cuo.SetCount(*i)
|
||||
}
|
||||
return cuo
|
||||
}
|
||||
|
||||
// AddCount adds i to the "count" field.
|
||||
func (cuo *CardUpdateOne) AddCount(i int) *CardUpdateOne {
|
||||
cuo.mutation.AddCount(i)
|
||||
return cuo
|
||||
}
|
||||
|
||||
// ClearCount clears the value of the "count" field.
|
||||
func (cuo *CardUpdateOne) ClearCount() *CardUpdateOne {
|
||||
cuo.mutation.ClearCount()
|
||||
return cuo
|
||||
}
|
||||
|
||||
// SetAuthor sets the "author" field.
|
||||
func (cuo *CardUpdateOne) SetAuthor(s string) *CardUpdateOne {
|
||||
cuo.mutation.SetAuthor(s)
|
||||
return cuo
|
||||
}
|
||||
|
||||
// SetNillableAuthor sets the "author" field if the given value is not nil.
|
||||
func (cuo *CardUpdateOne) SetNillableAuthor(s *string) *CardUpdateOne {
|
||||
if s != nil {
|
||||
cuo.SetAuthor(*s)
|
||||
}
|
||||
return cuo
|
||||
}
|
||||
|
||||
// ClearAuthor clears the value of the "author" field.
|
||||
func (cuo *CardUpdateOne) ClearAuthor() *CardUpdateOne {
|
||||
cuo.mutation.ClearAuthor()
|
||||
return cuo
|
||||
}
|
||||
|
||||
// SetOwnerID sets the "owner" edge to the User entity by ID.
|
||||
func (cuo *CardUpdateOne) SetOwnerID(id int) *CardUpdateOne {
|
||||
cuo.mutation.SetOwnerID(id)
|
||||
@@ -667,12 +455,6 @@ func (cuo *CardUpdateOne) sqlSave(ctx context.Context) (_node *Card, err error)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := cuo.mutation.Card(); ok {
|
||||
_spec.SetField(card.FieldCard, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := cuo.mutation.AddedCard(); ok {
|
||||
_spec.AddField(card.FieldCard, field.TypeInt, value)
|
||||
}
|
||||
if cuo.mutation.CardCleared() {
|
||||
_spec.ClearField(card.FieldCard, field.TypeInt)
|
||||
}
|
||||
@@ -703,27 +485,9 @@ func (cuo *CardUpdateOne) sqlSave(ctx context.Context) (_node *Card, err error)
|
||||
if cuo.mutation.CpCleared() {
|
||||
_spec.ClearField(card.FieldCp, field.TypeInt)
|
||||
}
|
||||
if value, ok := cuo.mutation.URL(); ok {
|
||||
_spec.SetField(card.FieldURL, field.TypeString, value)
|
||||
}
|
||||
if cuo.mutation.URLCleared() {
|
||||
_spec.ClearField(card.FieldURL, field.TypeString)
|
||||
}
|
||||
if value, ok := cuo.mutation.Count(); ok {
|
||||
_spec.SetField(card.FieldCount, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := cuo.mutation.AddedCount(); ok {
|
||||
_spec.AddField(card.FieldCount, field.TypeInt, value)
|
||||
}
|
||||
if cuo.mutation.CountCleared() {
|
||||
_spec.ClearField(card.FieldCount, field.TypeInt)
|
||||
}
|
||||
if value, ok := cuo.mutation.Author(); ok {
|
||||
_spec.SetField(card.FieldAuthor, field.TypeString, value)
|
||||
}
|
||||
if cuo.mutation.AuthorCleared() {
|
||||
_spec.ClearField(card.FieldAuthor, field.TypeString)
|
||||
}
|
||||
if cuo.mutation.CreatedAtCleared() {
|
||||
_spec.ClearField(card.FieldCreatedAt, field.TypeTime)
|
||||
}
|
||||
|
||||
502
ent/client.go
502
ent/client.go
@@ -8,14 +8,11 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"api/ent/migrate"
|
||||
"t/ent/migrate"
|
||||
|
||||
"api/ent/card"
|
||||
"api/ent/group"
|
||||
"api/ent/ma"
|
||||
"api/ent/sev"
|
||||
"api/ent/ue"
|
||||
"api/ent/user"
|
||||
"t/ent/card"
|
||||
"t/ent/group"
|
||||
"t/ent/user"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect"
|
||||
@@ -32,12 +29,6 @@ type Client struct {
|
||||
Card *CardClient
|
||||
// Group is the client for interacting with the Group builders.
|
||||
Group *GroupClient
|
||||
// Ma is the client for interacting with the Ma builders.
|
||||
Ma *MaClient
|
||||
// Sev is the client for interacting with the Sev builders.
|
||||
Sev *SevClient
|
||||
// Ue is the client for interacting with the Ue builders.
|
||||
Ue *UeClient
|
||||
// User is the client for interacting with the User builders.
|
||||
User *UserClient
|
||||
}
|
||||
@@ -55,9 +46,6 @@ func (c *Client) init() {
|
||||
c.Schema = migrate.NewSchema(c.driver)
|
||||
c.Card = NewCardClient(c.config)
|
||||
c.Group = NewGroupClient(c.config)
|
||||
c.Ma = NewMaClient(c.config)
|
||||
c.Sev = NewSevClient(c.config)
|
||||
c.Ue = NewUeClient(c.config)
|
||||
c.User = NewUserClient(c.config)
|
||||
}
|
||||
|
||||
@@ -143,9 +131,6 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
||||
config: cfg,
|
||||
Card: NewCardClient(cfg),
|
||||
Group: NewGroupClient(cfg),
|
||||
Ma: NewMaClient(cfg),
|
||||
Sev: NewSevClient(cfg),
|
||||
Ue: NewUeClient(cfg),
|
||||
User: NewUserClient(cfg),
|
||||
}, nil
|
||||
}
|
||||
@@ -168,9 +153,6 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
|
||||
config: cfg,
|
||||
Card: NewCardClient(cfg),
|
||||
Group: NewGroupClient(cfg),
|
||||
Ma: NewMaClient(cfg),
|
||||
Sev: NewSevClient(cfg),
|
||||
Ue: NewUeClient(cfg),
|
||||
User: NewUserClient(cfg),
|
||||
}, nil
|
||||
}
|
||||
@@ -200,21 +182,17 @@ func (c *Client) Close() error {
|
||||
// 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) {
|
||||
for _, n := range []interface{ Use(...Hook) }{
|
||||
c.Card, c.Group, c.Ma, c.Sev, c.Ue, c.User,
|
||||
} {
|
||||
n.Use(hooks...)
|
||||
}
|
||||
c.Card.Use(hooks...)
|
||||
c.Group.Use(hooks...)
|
||||
c.User.Use(hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds the query interceptors to all the entity clients.
|
||||
// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
|
||||
func (c *Client) Intercept(interceptors ...Interceptor) {
|
||||
for _, n := range []interface{ Intercept(...Interceptor) }{
|
||||
c.Card, c.Group, c.Ma, c.Sev, c.Ue, c.User,
|
||||
} {
|
||||
n.Intercept(interceptors...)
|
||||
}
|
||||
c.Card.Intercept(interceptors...)
|
||||
c.Group.Intercept(interceptors...)
|
||||
c.User.Intercept(interceptors...)
|
||||
}
|
||||
|
||||
// Mutate implements the ent.Mutator interface.
|
||||
@@ -224,12 +202,6 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
|
||||
return c.Card.mutate(ctx, m)
|
||||
case *GroupMutation:
|
||||
return c.Group.mutate(ctx, m)
|
||||
case *MaMutation:
|
||||
return c.Ma.mutate(ctx, m)
|
||||
case *SevMutation:
|
||||
return c.Sev.mutate(ctx, m)
|
||||
case *UeMutation:
|
||||
return c.Ue.mutate(ctx, m)
|
||||
case *UserMutation:
|
||||
return c.User.mutate(ctx, m)
|
||||
default:
|
||||
@@ -505,408 +477,6 @@ func (c *GroupClient) mutate(ctx context.Context, m *GroupMutation) (Value, erro
|
||||
}
|
||||
}
|
||||
|
||||
// MaClient is a client for the Ma schema.
|
||||
type MaClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewMaClient returns a client for the Ma from the given config.
|
||||
func NewMaClient(c config) *MaClient {
|
||||
return &MaClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `ma.Hooks(f(g(h())))`.
|
||||
func (c *MaClient) Use(hooks ...Hook) {
|
||||
c.hooks.Ma = append(c.hooks.Ma, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `ma.Intercept(f(g(h())))`.
|
||||
func (c *MaClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.Ma = append(c.inters.Ma, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a Ma entity.
|
||||
func (c *MaClient) Create() *MaCreate {
|
||||
mutation := newMaMutation(c.config, OpCreate)
|
||||
return &MaCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of Ma entities.
|
||||
func (c *MaClient) CreateBulk(builders ...*MaCreate) *MaCreateBulk {
|
||||
return &MaCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Ma.
|
||||
func (c *MaClient) Update() *MaUpdate {
|
||||
mutation := newMaMutation(c.config, OpUpdate)
|
||||
return &MaUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *MaClient) UpdateOne(m *Ma) *MaUpdateOne {
|
||||
mutation := newMaMutation(c.config, OpUpdateOne, withMa(m))
|
||||
return &MaUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *MaClient) UpdateOneID(id int) *MaUpdateOne {
|
||||
mutation := newMaMutation(c.config, OpUpdateOne, withMaID(id))
|
||||
return &MaUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for Ma.
|
||||
func (c *MaClient) Delete() *MaDelete {
|
||||
mutation := newMaMutation(c.config, OpDelete)
|
||||
return &MaDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *MaClient) DeleteOne(m *Ma) *MaDeleteOne {
|
||||
return c.DeleteOneID(m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *MaClient) DeleteOneID(id int) *MaDeleteOne {
|
||||
builder := c.Delete().Where(ma.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &MaDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for Ma.
|
||||
func (c *MaClient) Query() *MaQuery {
|
||||
return &MaQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeMa},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a Ma entity by its id.
|
||||
func (c *MaClient) Get(ctx context.Context, id int) (*Ma, error) {
|
||||
return c.Query().Where(ma.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *MaClient) GetX(ctx context.Context, id int) *Ma {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// QueryOwner queries the owner edge of a Ma.
|
||||
func (c *MaClient) QueryOwner(m *Ma) *UserQuery {
|
||||
query := (&UserClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(ma.Table, ma.FieldID, id),
|
||||
sqlgraph.To(user.Table, user.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ma.OwnerTable, ma.OwnerColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *MaClient) Hooks() []Hook {
|
||||
return c.hooks.Ma
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *MaClient) Interceptors() []Interceptor {
|
||||
return c.inters.Ma
|
||||
}
|
||||
|
||||
func (c *MaClient) mutate(ctx context.Context, m *MaMutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&MaCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&MaUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&MaUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&MaDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown Ma mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// SevClient is a client for the Sev schema.
|
||||
type SevClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewSevClient returns a client for the Sev from the given config.
|
||||
func NewSevClient(c config) *SevClient {
|
||||
return &SevClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `sev.Hooks(f(g(h())))`.
|
||||
func (c *SevClient) Use(hooks ...Hook) {
|
||||
c.hooks.Sev = append(c.hooks.Sev, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `sev.Intercept(f(g(h())))`.
|
||||
func (c *SevClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.Sev = append(c.inters.Sev, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a Sev entity.
|
||||
func (c *SevClient) Create() *SevCreate {
|
||||
mutation := newSevMutation(c.config, OpCreate)
|
||||
return &SevCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of Sev entities.
|
||||
func (c *SevClient) CreateBulk(builders ...*SevCreate) *SevCreateBulk {
|
||||
return &SevCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Sev.
|
||||
func (c *SevClient) Update() *SevUpdate {
|
||||
mutation := newSevMutation(c.config, OpUpdate)
|
||||
return &SevUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *SevClient) UpdateOne(s *Sev) *SevUpdateOne {
|
||||
mutation := newSevMutation(c.config, OpUpdateOne, withSev(s))
|
||||
return &SevUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *SevClient) UpdateOneID(id int) *SevUpdateOne {
|
||||
mutation := newSevMutation(c.config, OpUpdateOne, withSevID(id))
|
||||
return &SevUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for Sev.
|
||||
func (c *SevClient) Delete() *SevDelete {
|
||||
mutation := newSevMutation(c.config, OpDelete)
|
||||
return &SevDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *SevClient) DeleteOne(s *Sev) *SevDeleteOne {
|
||||
return c.DeleteOneID(s.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *SevClient) DeleteOneID(id int) *SevDeleteOne {
|
||||
builder := c.Delete().Where(sev.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &SevDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for Sev.
|
||||
func (c *SevClient) Query() *SevQuery {
|
||||
return &SevQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeSev},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a Sev entity by its id.
|
||||
func (c *SevClient) Get(ctx context.Context, id int) (*Sev, error) {
|
||||
return c.Query().Where(sev.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *SevClient) GetX(ctx context.Context, id int) *Sev {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// QueryOwner queries the owner edge of a Sev.
|
||||
func (c *SevClient) QueryOwner(s *Sev) *UserQuery {
|
||||
query := (&UserClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := s.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(sev.Table, sev.FieldID, id),
|
||||
sqlgraph.To(user.Table, user.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, sev.OwnerTable, sev.OwnerColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(s.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *SevClient) Hooks() []Hook {
|
||||
return c.hooks.Sev
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *SevClient) Interceptors() []Interceptor {
|
||||
return c.inters.Sev
|
||||
}
|
||||
|
||||
func (c *SevClient) mutate(ctx context.Context, m *SevMutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&SevCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&SevUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&SevUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&SevDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown Sev mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// UeClient is a client for the Ue schema.
|
||||
type UeClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewUeClient returns a client for the Ue from the given config.
|
||||
func NewUeClient(c config) *UeClient {
|
||||
return &UeClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `ue.Hooks(f(g(h())))`.
|
||||
func (c *UeClient) Use(hooks ...Hook) {
|
||||
c.hooks.Ue = append(c.hooks.Ue, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `ue.Intercept(f(g(h())))`.
|
||||
func (c *UeClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.Ue = append(c.inters.Ue, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a Ue entity.
|
||||
func (c *UeClient) Create() *UeCreate {
|
||||
mutation := newUeMutation(c.config, OpCreate)
|
||||
return &UeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of Ue entities.
|
||||
func (c *UeClient) CreateBulk(builders ...*UeCreate) *UeCreateBulk {
|
||||
return &UeCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Ue.
|
||||
func (c *UeClient) Update() *UeUpdate {
|
||||
mutation := newUeMutation(c.config, OpUpdate)
|
||||
return &UeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *UeClient) UpdateOne(u *Ue) *UeUpdateOne {
|
||||
mutation := newUeMutation(c.config, OpUpdateOne, withUe(u))
|
||||
return &UeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *UeClient) UpdateOneID(id int) *UeUpdateOne {
|
||||
mutation := newUeMutation(c.config, OpUpdateOne, withUeID(id))
|
||||
return &UeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for Ue.
|
||||
func (c *UeClient) Delete() *UeDelete {
|
||||
mutation := newUeMutation(c.config, OpDelete)
|
||||
return &UeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *UeClient) DeleteOne(u *Ue) *UeDeleteOne {
|
||||
return c.DeleteOneID(u.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *UeClient) DeleteOneID(id int) *UeDeleteOne {
|
||||
builder := c.Delete().Where(ue.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &UeDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for Ue.
|
||||
func (c *UeClient) Query() *UeQuery {
|
||||
return &UeQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeUe},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a Ue entity by its id.
|
||||
func (c *UeClient) Get(ctx context.Context, id int) (*Ue, error) {
|
||||
return c.Query().Where(ue.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *UeClient) GetX(ctx context.Context, id int) *Ue {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// QueryOwner queries the owner edge of a Ue.
|
||||
func (c *UeClient) QueryOwner(u *Ue) *UserQuery {
|
||||
query := (&UserClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := u.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(ue.Table, ue.FieldID, id),
|
||||
sqlgraph.To(user.Table, user.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ue.OwnerTable, ue.OwnerColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *UeClient) Hooks() []Hook {
|
||||
return c.hooks.Ue
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *UeClient) Interceptors() []Interceptor {
|
||||
return c.inters.Ue
|
||||
}
|
||||
|
||||
func (c *UeClient) mutate(ctx context.Context, m *UeMutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&UeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&UeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&UeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&UeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown Ue mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// UserClient is a client for the User schema.
|
||||
type UserClient struct {
|
||||
config
|
||||
@@ -1016,54 +586,6 @@ func (c *UserClient) QueryCard(u *User) *CardQuery {
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryUe queries the ue edge of a User.
|
||||
func (c *UserClient) QueryUe(u *User) *UeQuery {
|
||||
query := (&UeClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := u.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(user.Table, user.FieldID, id),
|
||||
sqlgraph.To(ue.Table, ue.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, user.UeTable, user.UeColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryMa queries the ma edge of a User.
|
||||
func (c *UserClient) QueryMa(u *User) *MaQuery {
|
||||
query := (&MaClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := u.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(user.Table, user.FieldID, id),
|
||||
sqlgraph.To(ma.Table, ma.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, user.MaTable, user.MaColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QuerySev queries the sev edge of a User.
|
||||
func (c *UserClient) QuerySev(u *User) *SevQuery {
|
||||
query := (&SevClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := u.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(user.Table, user.FieldID, id),
|
||||
sqlgraph.To(sev.Table, sev.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, user.SevTable, user.SevColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *UserClient) Hooks() []Hook {
|
||||
return c.hooks.User
|
||||
@@ -1092,9 +614,9 @@ func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error)
|
||||
// hooks and interceptors per client, for fast access.
|
||||
type (
|
||||
hooks struct {
|
||||
Card, Group, Ma, Sev, Ue, User []ent.Hook
|
||||
Card, Group, User []ent.Hook
|
||||
}
|
||||
inters struct {
|
||||
Card, Group, Ma, Sev, Ue, User []ent.Interceptor
|
||||
Card, Group, User []ent.Interceptor
|
||||
}
|
||||
)
|
||||
|
||||
70
ent/ent.go
70
ent/ent.go
@@ -3,17 +3,13 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/card"
|
||||
"api/ent/group"
|
||||
"api/ent/ma"
|
||||
"api/ent/sev"
|
||||
"api/ent/ue"
|
||||
"api/ent/user"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sync"
|
||||
"t/ent/card"
|
||||
"t/ent/group"
|
||||
"t/ent/user"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
@@ -66,34 +62,35 @@ func NewTxContext(parent context.Context, tx *Tx) context.Context {
|
||||
}
|
||||
|
||||
// OrderFunc applies an ordering on the sql selector.
|
||||
// Deprecated: Use Asc/Desc functions or the package builders instead.
|
||||
type OrderFunc func(*sql.Selector)
|
||||
|
||||
var (
|
||||
initCheck sync.Once
|
||||
columnCheck sql.ColumnCheck
|
||||
)
|
||||
|
||||
// columnChecker checks if the column exists in the given table.
|
||||
func checkColumn(table, column string) error {
|
||||
initCheck.Do(func() {
|
||||
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
|
||||
card.Table: card.ValidColumn,
|
||||
group.Table: group.ValidColumn,
|
||||
ma.Table: ma.ValidColumn,
|
||||
sev.Table: sev.ValidColumn,
|
||||
ue.Table: ue.ValidColumn,
|
||||
user.Table: user.ValidColumn,
|
||||
})
|
||||
})
|
||||
return columnCheck(table, column)
|
||||
// columnChecker returns a function indicates if the column exists in the given column.
|
||||
func columnChecker(table string) func(string) error {
|
||||
checks := map[string]func(string) bool{
|
||||
card.Table: card.ValidColumn,
|
||||
group.Table: group.ValidColumn,
|
||||
user.Table: user.ValidColumn,
|
||||
}
|
||||
check, ok := checks[table]
|
||||
if !ok {
|
||||
return func(string) error {
|
||||
return fmt.Errorf("unknown table %q", table)
|
||||
}
|
||||
}
|
||||
return func(column string) error {
|
||||
if !check(column) {
|
||||
return fmt.Errorf("unknown column %q for table %q", column, table)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Asc applies the given fields in ASC order.
|
||||
func Asc(fields ...string) func(*sql.Selector) {
|
||||
func Asc(fields ...string) OrderFunc {
|
||||
return func(s *sql.Selector) {
|
||||
check := columnChecker(s.TableName())
|
||||
for _, f := range fields {
|
||||
if err := checkColumn(s.TableName(), f); err != nil {
|
||||
if err := check(f); err != nil {
|
||||
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
|
||||
}
|
||||
s.OrderBy(sql.Asc(s.C(f)))
|
||||
@@ -102,10 +99,11 @@ func Asc(fields ...string) func(*sql.Selector) {
|
||||
}
|
||||
|
||||
// Desc applies the given fields in DESC order.
|
||||
func Desc(fields ...string) func(*sql.Selector) {
|
||||
func Desc(fields ...string) OrderFunc {
|
||||
return func(s *sql.Selector) {
|
||||
check := columnChecker(s.TableName())
|
||||
for _, f := range fields {
|
||||
if err := checkColumn(s.TableName(), f); err != nil {
|
||||
if err := check(f); err != nil {
|
||||
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
|
||||
}
|
||||
s.OrderBy(sql.Desc(s.C(f)))
|
||||
@@ -137,7 +135,8 @@ func Count() AggregateFunc {
|
||||
// Max applies the "max" aggregation function on the given field of each group.
|
||||
func Max(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
if err := checkColumn(s.TableName(), field); err != nil {
|
||||
check := columnChecker(s.TableName())
|
||||
if err := check(field); err != nil {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||
return ""
|
||||
}
|
||||
@@ -148,7 +147,8 @@ func Max(field string) AggregateFunc {
|
||||
// Mean applies the "mean" aggregation function on the given field of each group.
|
||||
func Mean(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
if err := checkColumn(s.TableName(), field); err != nil {
|
||||
check := columnChecker(s.TableName())
|
||||
if err := check(field); err != nil {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||
return ""
|
||||
}
|
||||
@@ -159,7 +159,8 @@ func Mean(field string) AggregateFunc {
|
||||
// Min applies the "min" aggregation function on the given field of each group.
|
||||
func Min(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
if err := checkColumn(s.TableName(), field); err != nil {
|
||||
check := columnChecker(s.TableName())
|
||||
if err := check(field); err != nil {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||
return ""
|
||||
}
|
||||
@@ -170,7 +171,8 @@ func Min(field string) AggregateFunc {
|
||||
// Sum applies the "sum" aggregation function on the given field of each group.
|
||||
func Sum(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
if err := checkColumn(s.TableName(), field); err != nil {
|
||||
check := columnChecker(s.TableName())
|
||||
if err := check(field); err != nil {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
package enttest
|
||||
|
||||
import (
|
||||
"api/ent"
|
||||
"context"
|
||||
"t/ent"
|
||||
// required by schema hooks.
|
||||
_ "api/ent/runtime"
|
||||
_ "t/ent/runtime"
|
||||
|
||||
"api/ent/migrate"
|
||||
"t/ent/migrate"
|
||||
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
)
|
||||
|
||||
16
ent/group.go
16
ent/group.go
@@ -3,11 +3,10 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/group"
|
||||
"fmt"
|
||||
"strings"
|
||||
"t/ent/group"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
@@ -22,8 +21,7 @@ type Group struct {
|
||||
Password string `json:"-"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the GroupQuery when eager-loading is set.
|
||||
Edges GroupEdges `json:"edges"`
|
||||
selectValues sql.SelectValues
|
||||
Edges GroupEdges `json:"edges"`
|
||||
}
|
||||
|
||||
// GroupEdges holds the relations/edges for other nodes in the graph.
|
||||
@@ -54,7 +52,7 @@ func (*Group) scanValues(columns []string) ([]any, error) {
|
||||
case group.FieldName, group.FieldPassword:
|
||||
values[i] = new(sql.NullString)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
return nil, fmt.Errorf("unexpected column %q for type Group", columns[i])
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
@@ -86,19 +84,11 @@ func (gr *Group) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
gr.Password = value.String
|
||||
}
|
||||
default:
|
||||
gr.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Group.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (gr *Group) Value(name string) (ent.Value, error) {
|
||||
return gr.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryUsers queries the "users" edge of the Group entity.
|
||||
func (gr *Group) QueryUsers() *UserQuery {
|
||||
return NewGroupClient(gr.config).QueryUsers(gr)
|
||||
|
||||
@@ -2,11 +2,6 @@
|
||||
|
||||
package group
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the group type in the database.
|
||||
Label = "group"
|
||||
@@ -50,42 +45,3 @@ var (
|
||||
// PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
PasswordValidator func(string) error
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the Group queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByName orders the results by the name field.
|
||||
func ByName(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldName, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPassword orders the results by the password field.
|
||||
func ByPassword(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPassword, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUsersCount orders the results by users count.
|
||||
func ByUsersCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newUsersStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByUsers orders the results by users terms.
|
||||
func ByUsers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newUsersStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
func newUsersStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(UsersInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, UsersTable, UsersColumn),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"api/ent/predicate"
|
||||
"t/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -208,7 +208,11 @@ func HasUsers() predicate.Group {
|
||||
// HasUsersWith applies the HasEdge predicate on the "users" edge with a given conditions (other predicates).
|
||||
func HasUsersWith(preds ...predicate.User) predicate.Group {
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
step := newUsersStep()
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(UsersInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, UsersTable, UsersColumn),
|
||||
)
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/group"
|
||||
"api/ent/user"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"t/ent/group"
|
||||
"t/ent/user"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
@@ -168,8 +168,8 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) {
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
var err error
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, gcb.builders[i+1].mutation)
|
||||
} else {
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/group"
|
||||
"api/ent/predicate"
|
||||
"context"
|
||||
"t/ent/group"
|
||||
"t/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/group"
|
||||
"api/ent/predicate"
|
||||
"api/ent/user"
|
||||
"context"
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
"math"
|
||||
"t/ent/group"
|
||||
"t/ent/predicate"
|
||||
"t/ent/user"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
type GroupQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []group.OrderOption
|
||||
order []OrderFunc
|
||||
inters []Interceptor
|
||||
predicates []predicate.Group
|
||||
withUsers *UserQuery
|
||||
@@ -55,7 +55,7 @@ func (gq *GroupQuery) Unique(unique bool) *GroupQuery {
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (gq *GroupQuery) Order(o ...group.OrderOption) *GroupQuery {
|
||||
func (gq *GroupQuery) Order(o ...OrderFunc) *GroupQuery {
|
||||
gq.order = append(gq.order, o...)
|
||||
return gq
|
||||
}
|
||||
@@ -271,7 +271,7 @@ func (gq *GroupQuery) Clone() *GroupQuery {
|
||||
return &GroupQuery{
|
||||
config: gq.config,
|
||||
ctx: gq.ctx.Clone(),
|
||||
order: append([]group.OrderOption{}, gq.order...),
|
||||
order: append([]OrderFunc{}, gq.order...),
|
||||
inters: append([]Interceptor{}, gq.inters...),
|
||||
predicates: append([]predicate.Group{}, gq.predicates...),
|
||||
withUsers: gq.withUsers.Clone(),
|
||||
@@ -414,7 +414,7 @@ func (gq *GroupQuery) loadUsers(ctx context.Context, query *UserQuery, nodes []*
|
||||
}
|
||||
query.withFKs = true
|
||||
query.Where(predicate.User(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(s.C(group.UsersColumn), fks...))
|
||||
s.Where(sql.InValues(group.UsersColumn, fks...))
|
||||
}))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
@@ -427,7 +427,7 @@ func (gq *GroupQuery) loadUsers(ctx context.Context, query *UserQuery, nodes []*
|
||||
}
|
||||
node, ok := nodeids[*fk]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected referenced foreign-key "group_users" returned %v for node %v`, *fk, n.ID)
|
||||
return fmt.Errorf(`unexpected foreign-key "group_users" returned %v for node %v`, *fk, n.ID)
|
||||
}
|
||||
assign(node, n)
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/group"
|
||||
"api/ent/predicate"
|
||||
"api/ent/user"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"t/ent/group"
|
||||
"t/ent/predicate"
|
||||
"t/ent/user"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
package hook
|
||||
|
||||
import (
|
||||
"api/ent"
|
||||
"context"
|
||||
"fmt"
|
||||
"t/ent"
|
||||
)
|
||||
|
||||
// The CardFunc type is an adapter to allow the use of ordinary
|
||||
@@ -32,42 +32,6 @@ func (f GroupFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.GroupMutation", m)
|
||||
}
|
||||
|
||||
// The MaFunc type is an adapter to allow the use of ordinary
|
||||
// function as Ma mutator.
|
||||
type MaFunc func(context.Context, *ent.MaMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f MaFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.MaMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MaMutation", m)
|
||||
}
|
||||
|
||||
// The SevFunc type is an adapter to allow the use of ordinary
|
||||
// function as Sev mutator.
|
||||
type SevFunc func(context.Context, *ent.SevMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f SevFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.SevMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SevMutation", m)
|
||||
}
|
||||
|
||||
// The UeFunc type is an adapter to allow the use of ordinary
|
||||
// function as Ue mutator.
|
||||
type UeFunc func(context.Context, *ent.UeMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f UeFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.UeMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UeMutation", m)
|
||||
}
|
||||
|
||||
// The UserFunc type is an adapter to allow the use of ordinary
|
||||
// function as User mutator.
|
||||
type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error)
|
||||
|
||||
389
ent/ma.go
389
ent/ma.go
@@ -1,389 +0,0 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/ma"
|
||||
"api/ent/user"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// Ma is the model entity for the Ma schema.
|
||||
type Ma struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// Password holds the value of the "password" field.
|
||||
Password string `json:"-"`
|
||||
// Token holds the value of the "token" field.
|
||||
Token string `json:"-"`
|
||||
// Limit holds the value of the "limit" field.
|
||||
Limit bool `json:"limit,omitempty"`
|
||||
// Count holds the value of the "count" field.
|
||||
Count int `json:"count,omitempty"`
|
||||
// Handle holds the value of the "handle" field.
|
||||
Handle string `json:"handle,omitempty"`
|
||||
// Text holds the value of the "text" field.
|
||||
Text string `json:"text,omitempty"`
|
||||
// Did holds the value of the "did" field.
|
||||
Did string `json:"did,omitempty"`
|
||||
// Avatar holds the value of the "avatar" field.
|
||||
Avatar string `json:"avatar,omitempty"`
|
||||
// Cid holds the value of the "cid" field.
|
||||
Cid string `json:"cid,omitempty"`
|
||||
// URI holds the value of the "uri" field.
|
||||
URI string `json:"uri,omitempty"`
|
||||
// CidRoot holds the value of the "cid_root" field.
|
||||
CidRoot string `json:"cid_root,omitempty"`
|
||||
// URIRoot holds the value of the "uri_root" field.
|
||||
URIRoot string `json:"uri_root,omitempty"`
|
||||
// Root holds the value of the "root" field.
|
||||
Root string `json:"root,omitempty"`
|
||||
// Rkey holds the value of the "rkey" field.
|
||||
Rkey string `json:"rkey,omitempty"`
|
||||
// BskyURL holds the value of the "bsky_url" field.
|
||||
BskyURL string `json:"bsky_url,omitempty"`
|
||||
// Comment holds the value of the "comment" field.
|
||||
Comment string `json:"comment,omitempty"`
|
||||
// Blog holds the value of the "blog" field.
|
||||
Blog string `json:"blog,omitempty"`
|
||||
// BlogURL holds the value of the "blog_url" field.
|
||||
BlogURL string `json:"blog_url,omitempty"`
|
||||
// Domain holds the value of the "domain" field.
|
||||
Domain string `json:"domain,omitempty"`
|
||||
// Host holds the value of the "host" field.
|
||||
Host string `json:"host,omitempty"`
|
||||
// Feed holds the value of the "feed" field.
|
||||
Feed string `json:"feed,omitempty"`
|
||||
// UpdatedAt holds the value of the "updated_at" field.
|
||||
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||
// CreatedAt holds the value of the "created_at" field.
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the MaQuery when eager-loading is set.
|
||||
Edges MaEdges `json:"edges"`
|
||||
user_ma *int
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// MaEdges holds the relations/edges for other nodes in the graph.
|
||||
type MaEdges struct {
|
||||
// Owner holds the value of the owner edge.
|
||||
Owner *User `json:"owner,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [1]bool
|
||||
}
|
||||
|
||||
// OwnerOrErr returns the Owner value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e MaEdges) OwnerOrErr() (*User, error) {
|
||||
if e.loadedTypes[0] {
|
||||
if e.Owner == nil {
|
||||
// Edge was loaded but was not found.
|
||||
return nil, &NotFoundError{label: user.Label}
|
||||
}
|
||||
return e.Owner, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "owner"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Ma) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case ma.FieldLimit:
|
||||
values[i] = new(sql.NullBool)
|
||||
case ma.FieldID, ma.FieldCount:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case ma.FieldPassword, ma.FieldToken, ma.FieldHandle, ma.FieldText, ma.FieldDid, ma.FieldAvatar, ma.FieldCid, ma.FieldURI, ma.FieldCidRoot, ma.FieldURIRoot, ma.FieldRoot, ma.FieldRkey, ma.FieldBskyURL, ma.FieldComment, ma.FieldBlog, ma.FieldBlogURL, ma.FieldDomain, ma.FieldHost, ma.FieldFeed:
|
||||
values[i] = new(sql.NullString)
|
||||
case ma.FieldUpdatedAt, ma.FieldCreatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case ma.ForeignKeys[0]: // user_ma
|
||||
values[i] = new(sql.NullInt64)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Ma fields.
|
||||
func (m *Ma) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case ma.FieldID:
|
||||
value, ok := values[i].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
m.ID = int(value.Int64)
|
||||
case ma.FieldPassword:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field password", values[i])
|
||||
} else if value.Valid {
|
||||
m.Password = value.String
|
||||
}
|
||||
case ma.FieldToken:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field token", values[i])
|
||||
} else if value.Valid {
|
||||
m.Token = value.String
|
||||
}
|
||||
case ma.FieldLimit:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field limit", values[i])
|
||||
} else if value.Valid {
|
||||
m.Limit = value.Bool
|
||||
}
|
||||
case ma.FieldCount:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field count", values[i])
|
||||
} else if value.Valid {
|
||||
m.Count = int(value.Int64)
|
||||
}
|
||||
case ma.FieldHandle:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field handle", values[i])
|
||||
} else if value.Valid {
|
||||
m.Handle = value.String
|
||||
}
|
||||
case ma.FieldText:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field text", values[i])
|
||||
} else if value.Valid {
|
||||
m.Text = value.String
|
||||
}
|
||||
case ma.FieldDid:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field did", values[i])
|
||||
} else if value.Valid {
|
||||
m.Did = value.String
|
||||
}
|
||||
case ma.FieldAvatar:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field avatar", values[i])
|
||||
} else if value.Valid {
|
||||
m.Avatar = value.String
|
||||
}
|
||||
case ma.FieldCid:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field cid", values[i])
|
||||
} else if value.Valid {
|
||||
m.Cid = value.String
|
||||
}
|
||||
case ma.FieldURI:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field uri", values[i])
|
||||
} else if value.Valid {
|
||||
m.URI = value.String
|
||||
}
|
||||
case ma.FieldCidRoot:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field cid_root", values[i])
|
||||
} else if value.Valid {
|
||||
m.CidRoot = value.String
|
||||
}
|
||||
case ma.FieldURIRoot:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field uri_root", values[i])
|
||||
} else if value.Valid {
|
||||
m.URIRoot = value.String
|
||||
}
|
||||
case ma.FieldRoot:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field root", values[i])
|
||||
} else if value.Valid {
|
||||
m.Root = value.String
|
||||
}
|
||||
case ma.FieldRkey:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field rkey", values[i])
|
||||
} else if value.Valid {
|
||||
m.Rkey = value.String
|
||||
}
|
||||
case ma.FieldBskyURL:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field bsky_url", values[i])
|
||||
} else if value.Valid {
|
||||
m.BskyURL = value.String
|
||||
}
|
||||
case ma.FieldComment:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field comment", values[i])
|
||||
} else if value.Valid {
|
||||
m.Comment = value.String
|
||||
}
|
||||
case ma.FieldBlog:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field blog", values[i])
|
||||
} else if value.Valid {
|
||||
m.Blog = value.String
|
||||
}
|
||||
case ma.FieldBlogURL:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field blog_url", values[i])
|
||||
} else if value.Valid {
|
||||
m.BlogURL = value.String
|
||||
}
|
||||
case ma.FieldDomain:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field domain", values[i])
|
||||
} else if value.Valid {
|
||||
m.Domain = value.String
|
||||
}
|
||||
case ma.FieldHost:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field host", values[i])
|
||||
} else if value.Valid {
|
||||
m.Host = value.String
|
||||
}
|
||||
case ma.FieldFeed:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field feed", values[i])
|
||||
} else if value.Valid {
|
||||
m.Feed = value.String
|
||||
}
|
||||
case ma.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
m.UpdatedAt = value.Time
|
||||
}
|
||||
case ma.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
m.CreatedAt = value.Time
|
||||
}
|
||||
case ma.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for edge-field user_ma", value)
|
||||
} else if value.Valid {
|
||||
m.user_ma = new(int)
|
||||
*m.user_ma = int(value.Int64)
|
||||
}
|
||||
default:
|
||||
m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Ma.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (m *Ma) Value(name string) (ent.Value, error) {
|
||||
return m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryOwner queries the "owner" edge of the Ma entity.
|
||||
func (m *Ma) QueryOwner() *UserQuery {
|
||||
return NewMaClient(m.config).QueryOwner(m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Ma.
|
||||
// Note that you need to call Ma.Unwrap() before calling this method if this Ma
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (m *Ma) Update() *MaUpdateOne {
|
||||
return NewMaClient(m.config).UpdateOne(m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Ma entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (m *Ma) Unwrap() *Ma {
|
||||
_tx, ok := m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Ma is not a transactional entity")
|
||||
}
|
||||
m.config.driver = _tx.drv
|
||||
return m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (m *Ma) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Ma(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", m.ID))
|
||||
builder.WriteString("password=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("token=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("limit=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.Limit))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("count=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.Count))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("handle=")
|
||||
builder.WriteString(m.Handle)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("text=")
|
||||
builder.WriteString(m.Text)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("did=")
|
||||
builder.WriteString(m.Did)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("avatar=")
|
||||
builder.WriteString(m.Avatar)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("cid=")
|
||||
builder.WriteString(m.Cid)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("uri=")
|
||||
builder.WriteString(m.URI)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("cid_root=")
|
||||
builder.WriteString(m.CidRoot)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("uri_root=")
|
||||
builder.WriteString(m.URIRoot)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("root=")
|
||||
builder.WriteString(m.Root)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("rkey=")
|
||||
builder.WriteString(m.Rkey)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("bsky_url=")
|
||||
builder.WriteString(m.BskyURL)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("comment=")
|
||||
builder.WriteString(m.Comment)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("blog=")
|
||||
builder.WriteString(m.Blog)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("blog_url=")
|
||||
builder.WriteString(m.BlogURL)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("domain=")
|
||||
builder.WriteString(m.Domain)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("host=")
|
||||
builder.WriteString(m.Host)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("feed=")
|
||||
builder.WriteString(m.Feed)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(m.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// Mas is a parsable slice of Ma.
|
||||
type Mas []*Ma
|
||||
269
ent/ma/ma.go
269
ent/ma/ma.go
@@ -1,269 +0,0 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ma
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the ma type in the database.
|
||||
Label = "ma"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldPassword holds the string denoting the password field in the database.
|
||||
FieldPassword = "password"
|
||||
// FieldToken holds the string denoting the token field in the database.
|
||||
FieldToken = "token"
|
||||
// FieldLimit holds the string denoting the limit field in the database.
|
||||
FieldLimit = "limit"
|
||||
// FieldCount holds the string denoting the count field in the database.
|
||||
FieldCount = "count"
|
||||
// FieldHandle holds the string denoting the handle field in the database.
|
||||
FieldHandle = "handle"
|
||||
// FieldText holds the string denoting the text field in the database.
|
||||
FieldText = "text"
|
||||
// FieldDid holds the string denoting the did field in the database.
|
||||
FieldDid = "did"
|
||||
// FieldAvatar holds the string denoting the avatar field in the database.
|
||||
FieldAvatar = "avatar"
|
||||
// FieldCid holds the string denoting the cid field in the database.
|
||||
FieldCid = "cid"
|
||||
// FieldURI holds the string denoting the uri field in the database.
|
||||
FieldURI = "uri"
|
||||
// FieldCidRoot holds the string denoting the cid_root field in the database.
|
||||
FieldCidRoot = "cid_root"
|
||||
// FieldURIRoot holds the string denoting the uri_root field in the database.
|
||||
FieldURIRoot = "uri_root"
|
||||
// FieldRoot holds the string denoting the root field in the database.
|
||||
FieldRoot = "root"
|
||||
// FieldRkey holds the string denoting the rkey field in the database.
|
||||
FieldRkey = "rkey"
|
||||
// FieldBskyURL holds the string denoting the bsky_url field in the database.
|
||||
FieldBskyURL = "bsky_url"
|
||||
// FieldComment holds the string denoting the comment field in the database.
|
||||
FieldComment = "comment"
|
||||
// FieldBlog holds the string denoting the blog field in the database.
|
||||
FieldBlog = "blog"
|
||||
// FieldBlogURL holds the string denoting the blog_url field in the database.
|
||||
FieldBlogURL = "blog_url"
|
||||
// FieldDomain holds the string denoting the domain field in the database.
|
||||
FieldDomain = "domain"
|
||||
// FieldHost holds the string denoting the host field in the database.
|
||||
FieldHost = "host"
|
||||
// FieldFeed holds the string denoting the feed field in the database.
|
||||
FieldFeed = "feed"
|
||||
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||
FieldUpdatedAt = "updated_at"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// EdgeOwner holds the string denoting the owner edge name in mutations.
|
||||
EdgeOwner = "owner"
|
||||
// Table holds the table name of the ma in the database.
|
||||
Table = "mas"
|
||||
// OwnerTable is the table that holds the owner relation/edge.
|
||||
OwnerTable = "mas"
|
||||
// OwnerInverseTable is the table name for the User entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "user" package.
|
||||
OwnerInverseTable = "users"
|
||||
// OwnerColumn is the table column denoting the owner relation/edge.
|
||||
OwnerColumn = "user_ma"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for ma fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldPassword,
|
||||
FieldToken,
|
||||
FieldLimit,
|
||||
FieldCount,
|
||||
FieldHandle,
|
||||
FieldText,
|
||||
FieldDid,
|
||||
FieldAvatar,
|
||||
FieldCid,
|
||||
FieldURI,
|
||||
FieldCidRoot,
|
||||
FieldURIRoot,
|
||||
FieldRoot,
|
||||
FieldRkey,
|
||||
FieldBskyURL,
|
||||
FieldComment,
|
||||
FieldBlog,
|
||||
FieldBlogURL,
|
||||
FieldDomain,
|
||||
FieldHost,
|
||||
FieldFeed,
|
||||
FieldUpdatedAt,
|
||||
FieldCreatedAt,
|
||||
}
|
||||
|
||||
// ForeignKeys holds the SQL foreign-keys that are owned by the "mas"
|
||||
// table and are not defined as standalone fields in the schema.
|
||||
var ForeignKeys = []string{
|
||||
"user_ma",
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
for i := range ForeignKeys {
|
||||
if column == ForeignKeys[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
PasswordValidator func(string) error
|
||||
// DefaultLimit holds the default value on creation for the "limit" field.
|
||||
DefaultLimit bool
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() time.Time
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the Ma queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPassword orders the results by the password field.
|
||||
func ByPassword(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPassword, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByToken orders the results by the token field.
|
||||
func ByToken(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldToken, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLimit orders the results by the limit field.
|
||||
func ByLimit(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLimit, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCount orders the results by the count field.
|
||||
func ByCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCount, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByHandle orders the results by the handle field.
|
||||
func ByHandle(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldHandle, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByText orders the results by the text field.
|
||||
func ByText(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldText, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDid orders the results by the did field.
|
||||
func ByDid(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDid, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByAvatar orders the results by the avatar field.
|
||||
func ByAvatar(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldAvatar, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCid orders the results by the cid field.
|
||||
func ByCid(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCid, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByURI orders the results by the uri field.
|
||||
func ByURI(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldURI, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCidRoot orders the results by the cid_root field.
|
||||
func ByCidRoot(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCidRoot, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByURIRoot orders the results by the uri_root field.
|
||||
func ByURIRoot(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldURIRoot, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByRoot orders the results by the root field.
|
||||
func ByRoot(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldRoot, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByRkey orders the results by the rkey field.
|
||||
func ByRkey(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldRkey, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByBskyURL orders the results by the bsky_url field.
|
||||
func ByBskyURL(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldBskyURL, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByComment orders the results by the comment field.
|
||||
func ByComment(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldComment, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByBlog orders the results by the blog field.
|
||||
func ByBlog(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldBlog, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByBlogURL orders the results by the blog_url field.
|
||||
func ByBlogURL(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldBlogURL, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDomain orders the results by the domain field.
|
||||
func ByDomain(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDomain, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByHost orders the results by the host field.
|
||||
func ByHost(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldHost, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByFeed orders the results by the feed field.
|
||||
func ByFeed(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldFeed, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUpdatedAt orders the results by the updated_at field.
|
||||
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByOwnerField orders the results by owner field.
|
||||
func ByOwnerField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newOwnerStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
func newOwnerStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(OwnerInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn),
|
||||
)
|
||||
}
|
||||
1811
ent/ma/where.go
1811
ent/ma/where.go
File diff suppressed because it is too large
Load Diff
627
ent/ma_create.go
627
ent/ma_create.go
@@ -1,627 +0,0 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/ma"
|
||||
"api/ent/user"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// MaCreate is the builder for creating a Ma entity.
|
||||
type MaCreate struct {
|
||||
config
|
||||
mutation *MaMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetPassword sets the "password" field.
|
||||
func (mc *MaCreate) SetPassword(s string) *MaCreate {
|
||||
mc.mutation.SetPassword(s)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetToken sets the "token" field.
|
||||
func (mc *MaCreate) SetToken(s string) *MaCreate {
|
||||
mc.mutation.SetToken(s)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableToken sets the "token" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableToken(s *string) *MaCreate {
|
||||
if s != nil {
|
||||
mc.SetToken(*s)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetLimit sets the "limit" field.
|
||||
func (mc *MaCreate) SetLimit(b bool) *MaCreate {
|
||||
mc.mutation.SetLimit(b)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableLimit sets the "limit" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableLimit(b *bool) *MaCreate {
|
||||
if b != nil {
|
||||
mc.SetLimit(*b)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetCount sets the "count" field.
|
||||
func (mc *MaCreate) SetCount(i int) *MaCreate {
|
||||
mc.mutation.SetCount(i)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableCount sets the "count" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableCount(i *int) *MaCreate {
|
||||
if i != nil {
|
||||
mc.SetCount(*i)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetHandle sets the "handle" field.
|
||||
func (mc *MaCreate) SetHandle(s string) *MaCreate {
|
||||
mc.mutation.SetHandle(s)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableHandle sets the "handle" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableHandle(s *string) *MaCreate {
|
||||
if s != nil {
|
||||
mc.SetHandle(*s)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetText sets the "text" field.
|
||||
func (mc *MaCreate) SetText(s string) *MaCreate {
|
||||
mc.mutation.SetText(s)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableText sets the "text" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableText(s *string) *MaCreate {
|
||||
if s != nil {
|
||||
mc.SetText(*s)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetDid sets the "did" field.
|
||||
func (mc *MaCreate) SetDid(s string) *MaCreate {
|
||||
mc.mutation.SetDid(s)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableDid sets the "did" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableDid(s *string) *MaCreate {
|
||||
if s != nil {
|
||||
mc.SetDid(*s)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetAvatar sets the "avatar" field.
|
||||
func (mc *MaCreate) SetAvatar(s string) *MaCreate {
|
||||
mc.mutation.SetAvatar(s)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableAvatar sets the "avatar" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableAvatar(s *string) *MaCreate {
|
||||
if s != nil {
|
||||
mc.SetAvatar(*s)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetCid sets the "cid" field.
|
||||
func (mc *MaCreate) SetCid(s string) *MaCreate {
|
||||
mc.mutation.SetCid(s)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableCid sets the "cid" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableCid(s *string) *MaCreate {
|
||||
if s != nil {
|
||||
mc.SetCid(*s)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetURI sets the "uri" field.
|
||||
func (mc *MaCreate) SetURI(s string) *MaCreate {
|
||||
mc.mutation.SetURI(s)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableURI sets the "uri" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableURI(s *string) *MaCreate {
|
||||
if s != nil {
|
||||
mc.SetURI(*s)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetCidRoot sets the "cid_root" field.
|
||||
func (mc *MaCreate) SetCidRoot(s string) *MaCreate {
|
||||
mc.mutation.SetCidRoot(s)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableCidRoot sets the "cid_root" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableCidRoot(s *string) *MaCreate {
|
||||
if s != nil {
|
||||
mc.SetCidRoot(*s)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetURIRoot sets the "uri_root" field.
|
||||
func (mc *MaCreate) SetURIRoot(s string) *MaCreate {
|
||||
mc.mutation.SetURIRoot(s)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableURIRoot sets the "uri_root" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableURIRoot(s *string) *MaCreate {
|
||||
if s != nil {
|
||||
mc.SetURIRoot(*s)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetRoot sets the "root" field.
|
||||
func (mc *MaCreate) SetRoot(s string) *MaCreate {
|
||||
mc.mutation.SetRoot(s)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableRoot sets the "root" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableRoot(s *string) *MaCreate {
|
||||
if s != nil {
|
||||
mc.SetRoot(*s)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetRkey sets the "rkey" field.
|
||||
func (mc *MaCreate) SetRkey(s string) *MaCreate {
|
||||
mc.mutation.SetRkey(s)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableRkey sets the "rkey" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableRkey(s *string) *MaCreate {
|
||||
if s != nil {
|
||||
mc.SetRkey(*s)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetBskyURL sets the "bsky_url" field.
|
||||
func (mc *MaCreate) SetBskyURL(s string) *MaCreate {
|
||||
mc.mutation.SetBskyURL(s)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableBskyURL sets the "bsky_url" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableBskyURL(s *string) *MaCreate {
|
||||
if s != nil {
|
||||
mc.SetBskyURL(*s)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetComment sets the "comment" field.
|
||||
func (mc *MaCreate) SetComment(s string) *MaCreate {
|
||||
mc.mutation.SetComment(s)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableComment sets the "comment" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableComment(s *string) *MaCreate {
|
||||
if s != nil {
|
||||
mc.SetComment(*s)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetBlog sets the "blog" field.
|
||||
func (mc *MaCreate) SetBlog(s string) *MaCreate {
|
||||
mc.mutation.SetBlog(s)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableBlog sets the "blog" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableBlog(s *string) *MaCreate {
|
||||
if s != nil {
|
||||
mc.SetBlog(*s)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetBlogURL sets the "blog_url" field.
|
||||
func (mc *MaCreate) SetBlogURL(s string) *MaCreate {
|
||||
mc.mutation.SetBlogURL(s)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableBlogURL sets the "blog_url" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableBlogURL(s *string) *MaCreate {
|
||||
if s != nil {
|
||||
mc.SetBlogURL(*s)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetDomain sets the "domain" field.
|
||||
func (mc *MaCreate) SetDomain(s string) *MaCreate {
|
||||
mc.mutation.SetDomain(s)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableDomain sets the "domain" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableDomain(s *string) *MaCreate {
|
||||
if s != nil {
|
||||
mc.SetDomain(*s)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetHost sets the "host" field.
|
||||
func (mc *MaCreate) SetHost(s string) *MaCreate {
|
||||
mc.mutation.SetHost(s)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableHost sets the "host" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableHost(s *string) *MaCreate {
|
||||
if s != nil {
|
||||
mc.SetHost(*s)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetFeed sets the "feed" field.
|
||||
func (mc *MaCreate) SetFeed(s string) *MaCreate {
|
||||
mc.mutation.SetFeed(s)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableFeed sets the "feed" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableFeed(s *string) *MaCreate {
|
||||
if s != nil {
|
||||
mc.SetFeed(*s)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (mc *MaCreate) SetUpdatedAt(t time.Time) *MaCreate {
|
||||
mc.mutation.SetUpdatedAt(t)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableUpdatedAt(t *time.Time) *MaCreate {
|
||||
if t != nil {
|
||||
mc.SetUpdatedAt(*t)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (mc *MaCreate) SetCreatedAt(t time.Time) *MaCreate {
|
||||
mc.mutation.SetCreatedAt(t)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (mc *MaCreate) SetNillableCreatedAt(t *time.Time) *MaCreate {
|
||||
if t != nil {
|
||||
mc.SetCreatedAt(*t)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetOwnerID sets the "owner" edge to the User entity by ID.
|
||||
func (mc *MaCreate) SetOwnerID(id int) *MaCreate {
|
||||
mc.mutation.SetOwnerID(id)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetOwner sets the "owner" edge to the User entity.
|
||||
func (mc *MaCreate) SetOwner(u *User) *MaCreate {
|
||||
return mc.SetOwnerID(u.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the MaMutation object of the builder.
|
||||
func (mc *MaCreate) Mutation() *MaMutation {
|
||||
return mc.mutation
|
||||
}
|
||||
|
||||
// Save creates the Ma in the database.
|
||||
func (mc *MaCreate) Save(ctx context.Context) (*Ma, error) {
|
||||
mc.defaults()
|
||||
return withHooks[*Ma, MaMutation](ctx, mc.sqlSave, mc.mutation, mc.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (mc *MaCreate) SaveX(ctx context.Context) *Ma {
|
||||
v, err := mc.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (mc *MaCreate) Exec(ctx context.Context) error {
|
||||
_, err := mc.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (mc *MaCreate) ExecX(ctx context.Context) {
|
||||
if err := mc.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (mc *MaCreate) defaults() {
|
||||
if _, ok := mc.mutation.Limit(); !ok {
|
||||
v := ma.DefaultLimit
|
||||
mc.mutation.SetLimit(v)
|
||||
}
|
||||
if _, ok := mc.mutation.CreatedAt(); !ok {
|
||||
v := ma.DefaultCreatedAt()
|
||||
mc.mutation.SetCreatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (mc *MaCreate) check() error {
|
||||
if _, ok := mc.mutation.Password(); !ok {
|
||||
return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "Ma.password"`)}
|
||||
}
|
||||
if v, ok := mc.mutation.Password(); ok {
|
||||
if err := ma.PasswordValidator(v); err != nil {
|
||||
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "Ma.password": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := mc.mutation.OwnerID(); !ok {
|
||||
return &ValidationError{Name: "owner", err: errors.New(`ent: missing required edge "Ma.owner"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mc *MaCreate) sqlSave(ctx context.Context) (*Ma, error) {
|
||||
if err := mc.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := mc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = int(id)
|
||||
mc.mutation.id = &_node.ID
|
||||
mc.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (mc *MaCreate) createSpec() (*Ma, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Ma{config: mc.config}
|
||||
_spec = sqlgraph.NewCreateSpec(ma.Table, sqlgraph.NewFieldSpec(ma.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := mc.mutation.Password(); ok {
|
||||
_spec.SetField(ma.FieldPassword, field.TypeString, value)
|
||||
_node.Password = value
|
||||
}
|
||||
if value, ok := mc.mutation.Token(); ok {
|
||||
_spec.SetField(ma.FieldToken, field.TypeString, value)
|
||||
_node.Token = value
|
||||
}
|
||||
if value, ok := mc.mutation.Limit(); ok {
|
||||
_spec.SetField(ma.FieldLimit, field.TypeBool, value)
|
||||
_node.Limit = value
|
||||
}
|
||||
if value, ok := mc.mutation.Count(); ok {
|
||||
_spec.SetField(ma.FieldCount, field.TypeInt, value)
|
||||
_node.Count = value
|
||||
}
|
||||
if value, ok := mc.mutation.Handle(); ok {
|
||||
_spec.SetField(ma.FieldHandle, field.TypeString, value)
|
||||
_node.Handle = value
|
||||
}
|
||||
if value, ok := mc.mutation.Text(); ok {
|
||||
_spec.SetField(ma.FieldText, field.TypeString, value)
|
||||
_node.Text = value
|
||||
}
|
||||
if value, ok := mc.mutation.Did(); ok {
|
||||
_spec.SetField(ma.FieldDid, field.TypeString, value)
|
||||
_node.Did = value
|
||||
}
|
||||
if value, ok := mc.mutation.Avatar(); ok {
|
||||
_spec.SetField(ma.FieldAvatar, field.TypeString, value)
|
||||
_node.Avatar = value
|
||||
}
|
||||
if value, ok := mc.mutation.Cid(); ok {
|
||||
_spec.SetField(ma.FieldCid, field.TypeString, value)
|
||||
_node.Cid = value
|
||||
}
|
||||
if value, ok := mc.mutation.URI(); ok {
|
||||
_spec.SetField(ma.FieldURI, field.TypeString, value)
|
||||
_node.URI = value
|
||||
}
|
||||
if value, ok := mc.mutation.CidRoot(); ok {
|
||||
_spec.SetField(ma.FieldCidRoot, field.TypeString, value)
|
||||
_node.CidRoot = value
|
||||
}
|
||||
if value, ok := mc.mutation.URIRoot(); ok {
|
||||
_spec.SetField(ma.FieldURIRoot, field.TypeString, value)
|
||||
_node.URIRoot = value
|
||||
}
|
||||
if value, ok := mc.mutation.Root(); ok {
|
||||
_spec.SetField(ma.FieldRoot, field.TypeString, value)
|
||||
_node.Root = value
|
||||
}
|
||||
if value, ok := mc.mutation.Rkey(); ok {
|
||||
_spec.SetField(ma.FieldRkey, field.TypeString, value)
|
||||
_node.Rkey = value
|
||||
}
|
||||
if value, ok := mc.mutation.BskyURL(); ok {
|
||||
_spec.SetField(ma.FieldBskyURL, field.TypeString, value)
|
||||
_node.BskyURL = value
|
||||
}
|
||||
if value, ok := mc.mutation.Comment(); ok {
|
||||
_spec.SetField(ma.FieldComment, field.TypeString, value)
|
||||
_node.Comment = value
|
||||
}
|
||||
if value, ok := mc.mutation.Blog(); ok {
|
||||
_spec.SetField(ma.FieldBlog, field.TypeString, value)
|
||||
_node.Blog = value
|
||||
}
|
||||
if value, ok := mc.mutation.BlogURL(); ok {
|
||||
_spec.SetField(ma.FieldBlogURL, field.TypeString, value)
|
||||
_node.BlogURL = value
|
||||
}
|
||||
if value, ok := mc.mutation.Domain(); ok {
|
||||
_spec.SetField(ma.FieldDomain, field.TypeString, value)
|
||||
_node.Domain = value
|
||||
}
|
||||
if value, ok := mc.mutation.Host(); ok {
|
||||
_spec.SetField(ma.FieldHost, field.TypeString, value)
|
||||
_node.Host = value
|
||||
}
|
||||
if value, ok := mc.mutation.Feed(); ok {
|
||||
_spec.SetField(ma.FieldFeed, field.TypeString, value)
|
||||
_node.Feed = value
|
||||
}
|
||||
if value, ok := mc.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(ma.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := mc.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(ma.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if nodes := mc.mutation.OwnerIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: ma.OwnerTable,
|
||||
Columns: []string{ma.OwnerColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_node.user_ma = &nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// MaCreateBulk is the builder for creating many Ma entities in bulk.
|
||||
type MaCreateBulk struct {
|
||||
config
|
||||
builders []*MaCreate
|
||||
}
|
||||
|
||||
// Save creates the Ma entities in the database.
|
||||
func (mcb *MaCreateBulk) Save(ctx context.Context) ([]*Ma, error) {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(mcb.builders))
|
||||
nodes := make([]*Ma, len(mcb.builders))
|
||||
mutators := make([]Mutator, len(mcb.builders))
|
||||
for i := range mcb.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := mcb.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*MaMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err := builder.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, mcb.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, mcb.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &nodes[i].ID
|
||||
if specs[i].ID.Value != nil {
|
||||
id := specs[i].ID.Value.(int64)
|
||||
nodes[i].ID = int(id)
|
||||
}
|
||||
mutation.done = true
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
mut = builder.hooks[i](mut)
|
||||
}
|
||||
mutators[i] = mut
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, mcb.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (mcb *MaCreateBulk) SaveX(ctx context.Context) []*Ma {
|
||||
v, err := mcb.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (mcb *MaCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := mcb.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (mcb *MaCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := mcb.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/ma"
|
||||
"api/ent/predicate"
|
||||
"context"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// MaDelete is the builder for deleting a Ma entity.
|
||||
type MaDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *MaMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the MaDelete builder.
|
||||
func (md *MaDelete) Where(ps ...predicate.Ma) *MaDelete {
|
||||
md.mutation.Where(ps...)
|
||||
return md
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (md *MaDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks[int, MaMutation](ctx, md.sqlExec, md.mutation, md.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (md *MaDelete) ExecX(ctx context.Context) int {
|
||||
n, err := md.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (md *MaDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(ma.Table, sqlgraph.NewFieldSpec(ma.FieldID, field.TypeInt))
|
||||
if ps := md.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, md.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
md.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// MaDeleteOne is the builder for deleting a single Ma entity.
|
||||
type MaDeleteOne struct {
|
||||
md *MaDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the MaDelete builder.
|
||||
func (mdo *MaDeleteOne) Where(ps ...predicate.Ma) *MaDeleteOne {
|
||||
mdo.md.mutation.Where(ps...)
|
||||
return mdo
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (mdo *MaDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := mdo.md.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{ma.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (mdo *MaDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := mdo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
613
ent/ma_query.go
613
ent/ma_query.go
@@ -1,613 +0,0 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/ma"
|
||||
"api/ent/predicate"
|
||||
"api/ent/user"
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// MaQuery is the builder for querying Ma entities.
|
||||
type MaQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []ma.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.Ma
|
||||
withOwner *UserQuery
|
||||
withFKs bool
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the MaQuery builder.
|
||||
func (mq *MaQuery) Where(ps ...predicate.Ma) *MaQuery {
|
||||
mq.predicates = append(mq.predicates, ps...)
|
||||
return mq
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (mq *MaQuery) Limit(limit int) *MaQuery {
|
||||
mq.ctx.Limit = &limit
|
||||
return mq
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (mq *MaQuery) Offset(offset int) *MaQuery {
|
||||
mq.ctx.Offset = &offset
|
||||
return mq
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (mq *MaQuery) Unique(unique bool) *MaQuery {
|
||||
mq.ctx.Unique = &unique
|
||||
return mq
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (mq *MaQuery) Order(o ...ma.OrderOption) *MaQuery {
|
||||
mq.order = append(mq.order, o...)
|
||||
return mq
|
||||
}
|
||||
|
||||
// QueryOwner chains the current query on the "owner" edge.
|
||||
func (mq *MaQuery) QueryOwner() *UserQuery {
|
||||
query := (&UserClient{config: mq.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := mq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := mq.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(ma.Table, ma.FieldID, selector),
|
||||
sqlgraph.To(user.Table, user.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ma.OwnerTable, ma.OwnerColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first Ma entity from the query.
|
||||
// Returns a *NotFoundError when no Ma was found.
|
||||
func (mq *MaQuery) First(ctx context.Context) (*Ma, error) {
|
||||
nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, "First"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{ma.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (mq *MaQuery) FirstX(ctx context.Context) *Ma {
|
||||
node, err := mq.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first Ma ID from the query.
|
||||
// Returns a *NotFoundError when no Ma ID was found.
|
||||
func (mq *MaQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, "FirstID")); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{ma.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (mq *MaQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := mq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single Ma entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Ma entity is found.
|
||||
// Returns a *NotFoundError when no Ma entities are found.
|
||||
func (mq *MaQuery) Only(ctx context.Context) (*Ma, error) {
|
||||
nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, "Only"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{ma.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{ma.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (mq *MaQuery) OnlyX(ctx context.Context) *Ma {
|
||||
node, err := mq.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only Ma ID in the query.
|
||||
// Returns a *NotSingularError when more than one Ma ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (mq *MaQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, "OnlyID")); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{ma.Label}
|
||||
default:
|
||||
err = &NotSingularError{ma.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (mq *MaQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := mq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of Mas.
|
||||
func (mq *MaQuery) All(ctx context.Context) ([]*Ma, error) {
|
||||
ctx = setContextOp(ctx, mq.ctx, "All")
|
||||
if err := mq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Ma, *MaQuery]()
|
||||
return withInterceptors[[]*Ma](ctx, mq, qr, mq.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (mq *MaQuery) AllX(ctx context.Context) []*Ma {
|
||||
nodes, err := mq.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Ma IDs.
|
||||
func (mq *MaQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if mq.ctx.Unique == nil && mq.path != nil {
|
||||
mq.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, mq.ctx, "IDs")
|
||||
if err = mq.Select(ma.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (mq *MaQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := mq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (mq *MaQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, mq.ctx, "Count")
|
||||
if err := mq.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, mq, querierCount[*MaQuery](), mq.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (mq *MaQuery) CountX(ctx context.Context) int {
|
||||
count, err := mq.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (mq *MaQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, mq.ctx, "Exist")
|
||||
switch _, err := mq.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||
default:
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (mq *MaQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := mq.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the MaQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (mq *MaQuery) Clone() *MaQuery {
|
||||
if mq == nil {
|
||||
return nil
|
||||
}
|
||||
return &MaQuery{
|
||||
config: mq.config,
|
||||
ctx: mq.ctx.Clone(),
|
||||
order: append([]ma.OrderOption{}, mq.order...),
|
||||
inters: append([]Interceptor{}, mq.inters...),
|
||||
predicates: append([]predicate.Ma{}, mq.predicates...),
|
||||
withOwner: mq.withOwner.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: mq.sql.Clone(),
|
||||
path: mq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithOwner tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "owner" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (mq *MaQuery) WithOwner(opts ...func(*UserQuery)) *MaQuery {
|
||||
query := (&UserClient{config: mq.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
mq.withOwner = query
|
||||
return mq
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Password string `json:"password,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Ma.Query().
|
||||
// GroupBy(ma.FieldPassword).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (mq *MaQuery) GroupBy(field string, fields ...string) *MaGroupBy {
|
||||
mq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &MaGroupBy{build: mq}
|
||||
grbuild.flds = &mq.ctx.Fields
|
||||
grbuild.label = ma.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
}
|
||||
|
||||
// Select allows the selection one or more fields/columns for the given query,
|
||||
// instead of selecting all fields in the entity.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Password string `json:"password,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Ma.Query().
|
||||
// Select(ma.FieldPassword).
|
||||
// Scan(ctx, &v)
|
||||
func (mq *MaQuery) Select(fields ...string) *MaSelect {
|
||||
mq.ctx.Fields = append(mq.ctx.Fields, fields...)
|
||||
sbuild := &MaSelect{MaQuery: mq}
|
||||
sbuild.label = ma.Label
|
||||
sbuild.flds, sbuild.scan = &mq.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a MaSelect configured with the given aggregations.
|
||||
func (mq *MaQuery) Aggregate(fns ...AggregateFunc) *MaSelect {
|
||||
return mq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (mq *MaQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range mq.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, mq); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range mq.ctx.Fields {
|
||||
if !ma.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if mq.path != nil {
|
||||
prev, err := mq.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mq.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mq *MaQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Ma, error) {
|
||||
var (
|
||||
nodes = []*Ma{}
|
||||
withFKs = mq.withFKs
|
||||
_spec = mq.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
mq.withOwner != nil,
|
||||
}
|
||||
)
|
||||
if mq.withOwner != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, ma.ForeignKeys...)
|
||||
}
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*Ma).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Ma{config: mq.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, mq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := mq.withOwner; query != nil {
|
||||
if err := mq.loadOwner(ctx, query, nodes, nil,
|
||||
func(n *Ma, e *User) { n.Edges.Owner = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (mq *MaQuery) loadOwner(ctx context.Context, query *UserQuery, nodes []*Ma, init func(*Ma), assign func(*Ma, *User)) error {
|
||||
ids := make([]int, 0, len(nodes))
|
||||
nodeids := make(map[int][]*Ma)
|
||||
for i := range nodes {
|
||||
if nodes[i].user_ma == nil {
|
||||
continue
|
||||
}
|
||||
fk := *nodes[i].user_ma
|
||||
if _, ok := nodeids[fk]; !ok {
|
||||
ids = append(ids, fk)
|
||||
}
|
||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
query.Where(user.IDIn(ids...))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nodeids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected foreign-key "user_ma" returned %v`, n.ID)
|
||||
}
|
||||
for i := range nodes {
|
||||
assign(nodes[i], n)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mq *MaQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := mq.querySpec()
|
||||
_spec.Node.Columns = mq.ctx.Fields
|
||||
if len(mq.ctx.Fields) > 0 {
|
||||
_spec.Unique = mq.ctx.Unique != nil && *mq.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, mq.driver, _spec)
|
||||
}
|
||||
|
||||
func (mq *MaQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(ma.Table, ma.Columns, sqlgraph.NewFieldSpec(ma.FieldID, field.TypeInt))
|
||||
_spec.From = mq.sql
|
||||
if unique := mq.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if mq.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := mq.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, ma.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != ma.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := mq.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := mq.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := mq.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := mq.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (mq *MaQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(mq.driver.Dialect())
|
||||
t1 := builder.Table(ma.Table)
|
||||
columns := mq.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = ma.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if mq.sql != nil {
|
||||
selector = mq.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if mq.ctx.Unique != nil && *mq.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range mq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range mq.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := mq.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := mq.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// MaGroupBy is the group-by builder for Ma entities.
|
||||
type MaGroupBy struct {
|
||||
selector
|
||||
build *MaQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (mgb *MaGroupBy) Aggregate(fns ...AggregateFunc) *MaGroupBy {
|
||||
mgb.fns = append(mgb.fns, fns...)
|
||||
return mgb
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (mgb *MaGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, mgb.build.ctx, "GroupBy")
|
||||
if err := mgb.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*MaQuery, *MaGroupBy](ctx, mgb.build, mgb, mgb.build.inters, v)
|
||||
}
|
||||
|
||||
func (mgb *MaGroupBy) sqlScan(ctx context.Context, root *MaQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(mgb.fns))
|
||||
for _, fn := range mgb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*mgb.flds)+len(mgb.fns))
|
||||
for _, f := range *mgb.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*mgb.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := mgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// MaSelect is the builder for selecting fields of Ma entities.
|
||||
type MaSelect struct {
|
||||
*MaQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ms *MaSelect) Aggregate(fns ...AggregateFunc) *MaSelect {
|
||||
ms.fns = append(ms.fns, fns...)
|
||||
return ms
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ms *MaSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ms.ctx, "Select")
|
||||
if err := ms.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*MaQuery, *MaSelect](ctx, ms.MaQuery, ms, ms.inters, v)
|
||||
}
|
||||
|
||||
func (ms *MaSelect) sqlScan(ctx context.Context, root *MaQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(ms.fns))
|
||||
for _, fn := range ms.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*ms.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
selector.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := ms.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
1409
ent/ma_update.go
1409
ent/ma_update.go
File diff suppressed because it is too large
Load Diff
@@ -18,8 +18,6 @@ var (
|
||||
{Name: "token", Type: field.TypeString, Nullable: true},
|
||||
{Name: "cp", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "url", Type: field.TypeString, Nullable: true, Default: "https://card.syui.ai"},
|
||||
{Name: "count", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "author", Type: field.TypeString, Nullable: true},
|
||||
{Name: "created_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "user_card", Type: field.TypeInt},
|
||||
}
|
||||
@@ -31,7 +29,7 @@ var (
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "cards_users_card",
|
||||
Columns: []*schema.Column{CardsColumns[11]},
|
||||
Columns: []*schema.Column{CardsColumns[9]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
@@ -56,131 +54,11 @@ var (
|
||||
},
|
||||
},
|
||||
}
|
||||
// MasColumns holds the columns for the "mas" table.
|
||||
MasColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "password", Type: field.TypeString},
|
||||
{Name: "token", Type: field.TypeString, Nullable: true},
|
||||
{Name: "limit", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "count", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "handle", Type: field.TypeString, Nullable: true},
|
||||
{Name: "text", Type: field.TypeString, Nullable: true},
|
||||
{Name: "did", Type: field.TypeString, Nullable: true},
|
||||
{Name: "avatar", Type: field.TypeString, Nullable: true},
|
||||
{Name: "cid", Type: field.TypeString, Nullable: true},
|
||||
{Name: "uri", Type: field.TypeString, Nullable: true},
|
||||
{Name: "cid_root", Type: field.TypeString, Nullable: true},
|
||||
{Name: "uri_root", Type: field.TypeString, Nullable: true},
|
||||
{Name: "root", Type: field.TypeString, Nullable: true},
|
||||
{Name: "rkey", Type: field.TypeString, Nullable: true},
|
||||
{Name: "bsky_url", Type: field.TypeString, Nullable: true},
|
||||
{Name: "comment", Type: field.TypeString, Nullable: true},
|
||||
{Name: "blog", Type: field.TypeString, Nullable: true},
|
||||
{Name: "blog_url", Type: field.TypeString, Nullable: true},
|
||||
{Name: "domain", Type: field.TypeString, Nullable: true},
|
||||
{Name: "host", Type: field.TypeString, Nullable: true},
|
||||
{Name: "feed", Type: field.TypeString, Nullable: true},
|
||||
{Name: "updated_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "created_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "user_ma", Type: field.TypeInt},
|
||||
}
|
||||
// MasTable holds the schema information for the "mas" table.
|
||||
MasTable = &schema.Table{
|
||||
Name: "mas",
|
||||
Columns: MasColumns,
|
||||
PrimaryKey: []*schema.Column{MasColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "mas_users_ma",
|
||||
Columns: []*schema.Column{MasColumns[24]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
},
|
||||
}
|
||||
// SevsColumns holds the columns for the "sevs" table.
|
||||
SevsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "password", Type: field.TypeString},
|
||||
{Name: "token", Type: field.TypeString, Nullable: true},
|
||||
{Name: "limit", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "count", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "handle", Type: field.TypeString, Nullable: true},
|
||||
{Name: "did", Type: field.TypeString, Nullable: true},
|
||||
{Name: "uid", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "cid", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "cp", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "card", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "updated_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "created_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "user_sev", Type: field.TypeInt},
|
||||
}
|
||||
// SevsTable holds the schema information for the "sevs" table.
|
||||
SevsTable = &schema.Table{
|
||||
Name: "sevs",
|
||||
Columns: SevsColumns,
|
||||
PrimaryKey: []*schema.Column{SevsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "sevs_users_sev",
|
||||
Columns: []*schema.Column{SevsColumns[13]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
},
|
||||
}
|
||||
// UesColumns holds the columns for the "ues" table.
|
||||
UesColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "limit", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "limit_boss", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "limit_item", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "password", Type: field.TypeString},
|
||||
{Name: "lv", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "lv_point", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "model", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "sword", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "card", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "mode", Type: field.TypeString, Nullable: true},
|
||||
{Name: "token", Type: field.TypeString, Nullable: true},
|
||||
{Name: "cp", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "count", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "location_x", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "location_y", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "location_z", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "location_n", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "author", Type: field.TypeString, Nullable: true},
|
||||
{Name: "game_lv", Type: field.TypeString, Nullable: true},
|
||||
{Name: "game_exp", Type: field.TypeString, Nullable: true},
|
||||
{Name: "game_id", Type: field.TypeString, Nullable: true},
|
||||
{Name: "game_story", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "game_ep", Type: field.TypeString, Nullable: true},
|
||||
{Name: "created_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "user_ue", Type: field.TypeInt},
|
||||
}
|
||||
// UesTable holds the schema information for the "ues" table.
|
||||
UesTable = &schema.Table{
|
||||
Name: "ues",
|
||||
Columns: UesColumns,
|
||||
PrimaryKey: []*schema.Column{UesColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "ues_users_ue",
|
||||
Columns: []*schema.Column{UesColumns[25]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
},
|
||||
}
|
||||
// UsersColumns holds the columns for the "users" table.
|
||||
UsersColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "username", Type: field.TypeString, Unique: true, Size: 100},
|
||||
{Name: "did", Type: field.TypeString, Nullable: true},
|
||||
{Name: "member", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "book", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "manga", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "badge", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "bsky", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "mastodon", Type: field.TypeBool, Nullable: true, Default: true},
|
||||
{Name: "delete", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
@@ -190,8 +68,6 @@ var (
|
||||
{Name: "created_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "updated_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "raid_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "server_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "egg_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "luck", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "luck_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "like", Type: field.TypeInt, Nullable: true},
|
||||
@@ -207,35 +83,7 @@ var (
|
||||
{Name: "ten_post", Type: field.TypeString, Nullable: true},
|
||||
{Name: "ten_get", Type: field.TypeString, Nullable: true},
|
||||
{Name: "ten_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "next", Type: field.TypeString, Nullable: true, Default: "20240731"},
|
||||
{Name: "room", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "model", Type: field.TypeBool, Nullable: true},
|
||||
{Name: "model_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "model_attack", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "model_limit", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "model_skill", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "model_mode", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "model_critical", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "model_critical_d", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "game", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "game_test", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "game_end", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "game_account", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "game_lv", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "game_exp", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "game_story", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "game_limit", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "coin", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "coin_open", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "coin_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "planet", Type: field.TypeFloat64, Nullable: true},
|
||||
{Name: "planet_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "login", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "login_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "location_x", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "location_y", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "location_z", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "location_n", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "next", Type: field.TypeString, Nullable: true, Default: "20230710"},
|
||||
{Name: "group_users", Type: field.TypeInt, Nullable: true},
|
||||
}
|
||||
// UsersTable holds the schema information for the "users" table.
|
||||
@@ -246,7 +94,7 @@ var (
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "users_groups_users",
|
||||
Columns: []*schema.Column{UsersColumns[62]},
|
||||
Columns: []*schema.Column{UsersColumns[28]},
|
||||
RefColumns: []*schema.Column{GroupsColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
@@ -263,17 +111,11 @@ var (
|
||||
Tables = []*schema.Table{
|
||||
CardsTable,
|
||||
GroupsTable,
|
||||
MasTable,
|
||||
SevsTable,
|
||||
UesTable,
|
||||
UsersTable,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
CardsTable.ForeignKeys[0].RefTable = UsersTable
|
||||
MasTable.ForeignKeys[0].RefTable = UsersTable
|
||||
SevsTable.ForeignKeys[0].RefTable = UsersTable
|
||||
UesTable.ForeignKeys[0].RefTable = UsersTable
|
||||
UsersTable.ForeignKeys[0].RefTable = GroupsTable
|
||||
}
|
||||
|
||||
9464
ent/mutation.go
9464
ent/mutation.go
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -9,18 +9,6 @@ type CreateGroupRes interface {
|
||||
createGroupRes()
|
||||
}
|
||||
|
||||
type CreateMaRes interface {
|
||||
createMaRes()
|
||||
}
|
||||
|
||||
type CreateSevRes interface {
|
||||
createSevRes()
|
||||
}
|
||||
|
||||
type CreateUeRes interface {
|
||||
createUeRes()
|
||||
}
|
||||
|
||||
type CreateUserRes interface {
|
||||
createUserRes()
|
||||
}
|
||||
@@ -33,18 +21,6 @@ type DeleteGroupRes interface {
|
||||
deleteGroupRes()
|
||||
}
|
||||
|
||||
type DeleteMaRes interface {
|
||||
deleteMaRes()
|
||||
}
|
||||
|
||||
type DeleteSevRes interface {
|
||||
deleteSevRes()
|
||||
}
|
||||
|
||||
type DeleteUeRes interface {
|
||||
deleteUeRes()
|
||||
}
|
||||
|
||||
type DeleteUserRes interface {
|
||||
deleteUserRes()
|
||||
}
|
||||
@@ -61,38 +37,14 @@ type ListGroupUsersRes interface {
|
||||
listGroupUsersRes()
|
||||
}
|
||||
|
||||
type ListMaRes interface {
|
||||
listMaRes()
|
||||
}
|
||||
|
||||
type ListSevRes interface {
|
||||
listSevRes()
|
||||
}
|
||||
|
||||
type ListUeRes interface {
|
||||
listUeRes()
|
||||
}
|
||||
|
||||
type ListUserCardRes interface {
|
||||
listUserCardRes()
|
||||
}
|
||||
|
||||
type ListUserMaRes interface {
|
||||
listUserMaRes()
|
||||
}
|
||||
|
||||
type ListUserRes interface {
|
||||
listUserRes()
|
||||
}
|
||||
|
||||
type ListUserSevRes interface {
|
||||
listUserSevRes()
|
||||
}
|
||||
|
||||
type ListUserUeRes interface {
|
||||
listUserUeRes()
|
||||
}
|
||||
|
||||
type ReadCardOwnerRes interface {
|
||||
readCardOwnerRes()
|
||||
}
|
||||
@@ -105,30 +57,6 @@ type ReadGroupRes interface {
|
||||
readGroupRes()
|
||||
}
|
||||
|
||||
type ReadMaOwnerRes interface {
|
||||
readMaOwnerRes()
|
||||
}
|
||||
|
||||
type ReadMaRes interface {
|
||||
readMaRes()
|
||||
}
|
||||
|
||||
type ReadSevOwnerRes interface {
|
||||
readSevOwnerRes()
|
||||
}
|
||||
|
||||
type ReadSevRes interface {
|
||||
readSevRes()
|
||||
}
|
||||
|
||||
type ReadUeOwnerRes interface {
|
||||
readUeOwnerRes()
|
||||
}
|
||||
|
||||
type ReadUeRes interface {
|
||||
readUeRes()
|
||||
}
|
||||
|
||||
type ReadUserRes interface {
|
||||
readUserRes()
|
||||
}
|
||||
@@ -141,18 +69,6 @@ type UpdateGroupRes interface {
|
||||
updateGroupRes()
|
||||
}
|
||||
|
||||
type UpdateMaRes interface {
|
||||
updateMaRes()
|
||||
}
|
||||
|
||||
type UpdateSevRes interface {
|
||||
updateSevRes()
|
||||
}
|
||||
|
||||
type UpdateUeRes interface {
|
||||
updateUeRes()
|
||||
}
|
||||
|
||||
type UpdateUserRes interface {
|
||||
updateUserRes()
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -141,195 +141,6 @@ func (s *Server) decodeCreateGroupRequest(r *http.Request) (
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeCreateMaRequest(r *http.Request) (
|
||||
req *CreateMaReq,
|
||||
close func() error,
|
||||
rerr error,
|
||||
) {
|
||||
var closers []func() error
|
||||
close = func() error {
|
||||
var merr error
|
||||
// Close in reverse order, to match defer behavior.
|
||||
for i := len(closers) - 1; i >= 0; i-- {
|
||||
c := closers[i]
|
||||
merr = multierr.Append(merr, c())
|
||||
}
|
||||
return merr
|
||||
}
|
||||
defer func() {
|
||||
if rerr != nil {
|
||||
rerr = multierr.Append(rerr, close())
|
||||
}
|
||||
}()
|
||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return req, close, errors.Wrap(err, "parse media type")
|
||||
}
|
||||
switch {
|
||||
case ct == "application/json":
|
||||
if r.ContentLength == 0 {
|
||||
return req, close, validate.ErrBodyRequired
|
||||
}
|
||||
buf, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
return req, close, err
|
||||
}
|
||||
|
||||
if len(buf) == 0 {
|
||||
return req, close, validate.ErrBodyRequired
|
||||
}
|
||||
|
||||
d := jx.DecodeBytes(buf)
|
||||
|
||||
var request CreateMaReq
|
||||
if err := func() error {
|
||||
if err := request.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Skip(); err != io.EOF {
|
||||
return errors.New("unexpected trailing data")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
err = &ogenerrors.DecodeBodyError{
|
||||
ContentType: ct,
|
||||
Body: buf,
|
||||
Err: err,
|
||||
}
|
||||
return req, close, err
|
||||
}
|
||||
return &request, close, nil
|
||||
default:
|
||||
return req, close, validate.InvalidContentType(ct)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeCreateSevRequest(r *http.Request) (
|
||||
req *CreateSevReq,
|
||||
close func() error,
|
||||
rerr error,
|
||||
) {
|
||||
var closers []func() error
|
||||
close = func() error {
|
||||
var merr error
|
||||
// Close in reverse order, to match defer behavior.
|
||||
for i := len(closers) - 1; i >= 0; i-- {
|
||||
c := closers[i]
|
||||
merr = multierr.Append(merr, c())
|
||||
}
|
||||
return merr
|
||||
}
|
||||
defer func() {
|
||||
if rerr != nil {
|
||||
rerr = multierr.Append(rerr, close())
|
||||
}
|
||||
}()
|
||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return req, close, errors.Wrap(err, "parse media type")
|
||||
}
|
||||
switch {
|
||||
case ct == "application/json":
|
||||
if r.ContentLength == 0 {
|
||||
return req, close, validate.ErrBodyRequired
|
||||
}
|
||||
buf, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
return req, close, err
|
||||
}
|
||||
|
||||
if len(buf) == 0 {
|
||||
return req, close, validate.ErrBodyRequired
|
||||
}
|
||||
|
||||
d := jx.DecodeBytes(buf)
|
||||
|
||||
var request CreateSevReq
|
||||
if err := func() error {
|
||||
if err := request.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Skip(); err != io.EOF {
|
||||
return errors.New("unexpected trailing data")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
err = &ogenerrors.DecodeBodyError{
|
||||
ContentType: ct,
|
||||
Body: buf,
|
||||
Err: err,
|
||||
}
|
||||
return req, close, err
|
||||
}
|
||||
return &request, close, nil
|
||||
default:
|
||||
return req, close, validate.InvalidContentType(ct)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeCreateUeRequest(r *http.Request) (
|
||||
req *CreateUeReq,
|
||||
close func() error,
|
||||
rerr error,
|
||||
) {
|
||||
var closers []func() error
|
||||
close = func() error {
|
||||
var merr error
|
||||
// Close in reverse order, to match defer behavior.
|
||||
for i := len(closers) - 1; i >= 0; i-- {
|
||||
c := closers[i]
|
||||
merr = multierr.Append(merr, c())
|
||||
}
|
||||
return merr
|
||||
}
|
||||
defer func() {
|
||||
if rerr != nil {
|
||||
rerr = multierr.Append(rerr, close())
|
||||
}
|
||||
}()
|
||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return req, close, errors.Wrap(err, "parse media type")
|
||||
}
|
||||
switch {
|
||||
case ct == "application/json":
|
||||
if r.ContentLength == 0 {
|
||||
return req, close, validate.ErrBodyRequired
|
||||
}
|
||||
buf, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
return req, close, err
|
||||
}
|
||||
|
||||
if len(buf) == 0 {
|
||||
return req, close, validate.ErrBodyRequired
|
||||
}
|
||||
|
||||
d := jx.DecodeBytes(buf)
|
||||
|
||||
var request CreateUeReq
|
||||
if err := func() error {
|
||||
if err := request.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Skip(); err != io.EOF {
|
||||
return errors.New("unexpected trailing data")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
err = &ogenerrors.DecodeBodyError{
|
||||
ContentType: ct,
|
||||
Body: buf,
|
||||
Err: err,
|
||||
}
|
||||
return req, close, err
|
||||
}
|
||||
return &request, close, nil
|
||||
default:
|
||||
return req, close, validate.InvalidContentType(ct)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeCreateUserRequest(r *http.Request) (
|
||||
req *CreateUserReq,
|
||||
close func() error,
|
||||
@@ -387,14 +198,6 @@ func (s *Server) decodeCreateUserRequest(r *http.Request) (
|
||||
}
|
||||
return req, close, err
|
||||
}
|
||||
if err := func() error {
|
||||
if err := request.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return req, close, errors.Wrap(err, "validate")
|
||||
}
|
||||
return &request, close, nil
|
||||
default:
|
||||
return req, close, validate.InvalidContentType(ct)
|
||||
@@ -527,195 +330,6 @@ func (s *Server) decodeUpdateGroupRequest(r *http.Request) (
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeUpdateMaRequest(r *http.Request) (
|
||||
req *UpdateMaReq,
|
||||
close func() error,
|
||||
rerr error,
|
||||
) {
|
||||
var closers []func() error
|
||||
close = func() error {
|
||||
var merr error
|
||||
// Close in reverse order, to match defer behavior.
|
||||
for i := len(closers) - 1; i >= 0; i-- {
|
||||
c := closers[i]
|
||||
merr = multierr.Append(merr, c())
|
||||
}
|
||||
return merr
|
||||
}
|
||||
defer func() {
|
||||
if rerr != nil {
|
||||
rerr = multierr.Append(rerr, close())
|
||||
}
|
||||
}()
|
||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return req, close, errors.Wrap(err, "parse media type")
|
||||
}
|
||||
switch {
|
||||
case ct == "application/json":
|
||||
if r.ContentLength == 0 {
|
||||
return req, close, validate.ErrBodyRequired
|
||||
}
|
||||
buf, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
return req, close, err
|
||||
}
|
||||
|
||||
if len(buf) == 0 {
|
||||
return req, close, validate.ErrBodyRequired
|
||||
}
|
||||
|
||||
d := jx.DecodeBytes(buf)
|
||||
|
||||
var request UpdateMaReq
|
||||
if err := func() error {
|
||||
if err := request.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Skip(); err != io.EOF {
|
||||
return errors.New("unexpected trailing data")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
err = &ogenerrors.DecodeBodyError{
|
||||
ContentType: ct,
|
||||
Body: buf,
|
||||
Err: err,
|
||||
}
|
||||
return req, close, err
|
||||
}
|
||||
return &request, close, nil
|
||||
default:
|
||||
return req, close, validate.InvalidContentType(ct)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeUpdateSevRequest(r *http.Request) (
|
||||
req *UpdateSevReq,
|
||||
close func() error,
|
||||
rerr error,
|
||||
) {
|
||||
var closers []func() error
|
||||
close = func() error {
|
||||
var merr error
|
||||
// Close in reverse order, to match defer behavior.
|
||||
for i := len(closers) - 1; i >= 0; i-- {
|
||||
c := closers[i]
|
||||
merr = multierr.Append(merr, c())
|
||||
}
|
||||
return merr
|
||||
}
|
||||
defer func() {
|
||||
if rerr != nil {
|
||||
rerr = multierr.Append(rerr, close())
|
||||
}
|
||||
}()
|
||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return req, close, errors.Wrap(err, "parse media type")
|
||||
}
|
||||
switch {
|
||||
case ct == "application/json":
|
||||
if r.ContentLength == 0 {
|
||||
return req, close, validate.ErrBodyRequired
|
||||
}
|
||||
buf, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
return req, close, err
|
||||
}
|
||||
|
||||
if len(buf) == 0 {
|
||||
return req, close, validate.ErrBodyRequired
|
||||
}
|
||||
|
||||
d := jx.DecodeBytes(buf)
|
||||
|
||||
var request UpdateSevReq
|
||||
if err := func() error {
|
||||
if err := request.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Skip(); err != io.EOF {
|
||||
return errors.New("unexpected trailing data")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
err = &ogenerrors.DecodeBodyError{
|
||||
ContentType: ct,
|
||||
Body: buf,
|
||||
Err: err,
|
||||
}
|
||||
return req, close, err
|
||||
}
|
||||
return &request, close, nil
|
||||
default:
|
||||
return req, close, validate.InvalidContentType(ct)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeUpdateUeRequest(r *http.Request) (
|
||||
req *UpdateUeReq,
|
||||
close func() error,
|
||||
rerr error,
|
||||
) {
|
||||
var closers []func() error
|
||||
close = func() error {
|
||||
var merr error
|
||||
// Close in reverse order, to match defer behavior.
|
||||
for i := len(closers) - 1; i >= 0; i-- {
|
||||
c := closers[i]
|
||||
merr = multierr.Append(merr, c())
|
||||
}
|
||||
return merr
|
||||
}
|
||||
defer func() {
|
||||
if rerr != nil {
|
||||
rerr = multierr.Append(rerr, close())
|
||||
}
|
||||
}()
|
||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return req, close, errors.Wrap(err, "parse media type")
|
||||
}
|
||||
switch {
|
||||
case ct == "application/json":
|
||||
if r.ContentLength == 0 {
|
||||
return req, close, validate.ErrBodyRequired
|
||||
}
|
||||
buf, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
return req, close, err
|
||||
}
|
||||
|
||||
if len(buf) == 0 {
|
||||
return req, close, validate.ErrBodyRequired
|
||||
}
|
||||
|
||||
d := jx.DecodeBytes(buf)
|
||||
|
||||
var request UpdateUeReq
|
||||
if err := func() error {
|
||||
if err := request.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Skip(); err != io.EOF {
|
||||
return errors.New("unexpected trailing data")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
err = &ogenerrors.DecodeBodyError{
|
||||
ContentType: ct,
|
||||
Body: buf,
|
||||
Err: err,
|
||||
}
|
||||
return req, close, err
|
||||
}
|
||||
return &request, close, nil
|
||||
default:
|
||||
return req, close, validate.InvalidContentType(ct)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeUpdateUserRequest(r *http.Request) (
|
||||
req *UpdateUserReq,
|
||||
close func() error,
|
||||
@@ -773,14 +387,6 @@ func (s *Server) decodeUpdateUserRequest(r *http.Request) (
|
||||
}
|
||||
return req, close, err
|
||||
}
|
||||
if err := func() error {
|
||||
if err := request.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return req, close, errors.Wrap(err, "validate")
|
||||
}
|
||||
return &request, close, nil
|
||||
default:
|
||||
return req, close, validate.InvalidContentType(ct)
|
||||
|
||||
@@ -39,48 +39,6 @@ func encodeCreateGroupRequest(
|
||||
return nil
|
||||
}
|
||||
|
||||
func encodeCreateMaRequest(
|
||||
req *CreateMaReq,
|
||||
r *http.Request,
|
||||
) error {
|
||||
const contentType = "application/json"
|
||||
e := jx.GetEncoder()
|
||||
{
|
||||
req.Encode(e)
|
||||
}
|
||||
encoded := e.Bytes()
|
||||
ht.SetBody(r, bytes.NewReader(encoded), contentType)
|
||||
return nil
|
||||
}
|
||||
|
||||
func encodeCreateSevRequest(
|
||||
req *CreateSevReq,
|
||||
r *http.Request,
|
||||
) error {
|
||||
const contentType = "application/json"
|
||||
e := jx.GetEncoder()
|
||||
{
|
||||
req.Encode(e)
|
||||
}
|
||||
encoded := e.Bytes()
|
||||
ht.SetBody(r, bytes.NewReader(encoded), contentType)
|
||||
return nil
|
||||
}
|
||||
|
||||
func encodeCreateUeRequest(
|
||||
req *CreateUeReq,
|
||||
r *http.Request,
|
||||
) error {
|
||||
const contentType = "application/json"
|
||||
e := jx.GetEncoder()
|
||||
{
|
||||
req.Encode(e)
|
||||
}
|
||||
encoded := e.Bytes()
|
||||
ht.SetBody(r, bytes.NewReader(encoded), contentType)
|
||||
return nil
|
||||
}
|
||||
|
||||
func encodeCreateUserRequest(
|
||||
req *CreateUserReq,
|
||||
r *http.Request,
|
||||
@@ -123,48 +81,6 @@ func encodeUpdateGroupRequest(
|
||||
return nil
|
||||
}
|
||||
|
||||
func encodeUpdateMaRequest(
|
||||
req *UpdateMaReq,
|
||||
r *http.Request,
|
||||
) error {
|
||||
const contentType = "application/json"
|
||||
e := jx.GetEncoder()
|
||||
{
|
||||
req.Encode(e)
|
||||
}
|
||||
encoded := e.Bytes()
|
||||
ht.SetBody(r, bytes.NewReader(encoded), contentType)
|
||||
return nil
|
||||
}
|
||||
|
||||
func encodeUpdateSevRequest(
|
||||
req *UpdateSevReq,
|
||||
r *http.Request,
|
||||
) error {
|
||||
const contentType = "application/json"
|
||||
e := jx.GetEncoder()
|
||||
{
|
||||
req.Encode(e)
|
||||
}
|
||||
encoded := e.Bytes()
|
||||
ht.SetBody(r, bytes.NewReader(encoded), contentType)
|
||||
return nil
|
||||
}
|
||||
|
||||
func encodeUpdateUeRequest(
|
||||
req *UpdateUeReq,
|
||||
r *http.Request,
|
||||
) error {
|
||||
const contentType = "application/json"
|
||||
e := jx.GetEncoder()
|
||||
{
|
||||
req.Encode(e)
|
||||
}
|
||||
encoded := e.Bytes()
|
||||
ht.SetBody(r, bytes.NewReader(encoded), contentType)
|
||||
return nil
|
||||
}
|
||||
|
||||
func encodeUpdateUserRequest(
|
||||
req *UpdateUserReq,
|
||||
r *http.Request,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -243,8 +243,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
}
|
||||
case 'm': // Prefix: "mas"
|
||||
if l := len("mas"); len(elem) >= l && elem[0:l] == "mas" {
|
||||
case 'u': // Prefix: "users"
|
||||
if l := len("users"); len(elem) >= l && elem[0:l] == "users" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
@@ -253,9 +253,9 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if len(elem) == 0 {
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleListMaRequest([0]string{}, w, r)
|
||||
s.handleListUserRequest([0]string{}, w, r)
|
||||
case "POST":
|
||||
s.handleCreateMaRequest([0]string{}, w, r)
|
||||
s.handleCreateUserRequest([0]string{}, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "GET,POST")
|
||||
}
|
||||
@@ -282,15 +282,15 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if len(elem) == 0 {
|
||||
switch r.Method {
|
||||
case "DELETE":
|
||||
s.handleDeleteMaRequest([1]string{
|
||||
s.handleDeleteUserRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
case "GET":
|
||||
s.handleReadMaRequest([1]string{
|
||||
s.handleReadUserRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
case "PATCH":
|
||||
s.handleUpdateMaRequest([1]string{
|
||||
s.handleUpdateUserRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
default:
|
||||
@@ -300,177 +300,28 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/owner"
|
||||
if l := len("/owner"); len(elem) >= l && elem[0:l] == "/owner" {
|
||||
case '/': // Prefix: "/card"
|
||||
if l := len("/card"); len(elem) >= l && elem[0:l] == "/card" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleReadMaOwnerRequest([1]string{
|
||||
s.handleListUserCardRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "GET")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
case 's': // Prefix: "sevs"
|
||||
if l := len("sevs"); len(elem) >= l && elem[0:l] == "sevs" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleListSevRequest([0]string{}, w, r)
|
||||
case "POST":
|
||||
s.handleCreateSevRequest([0]string{}, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "GET,POST")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/"
|
||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
// Param: "id"
|
||||
// Match until "/"
|
||||
idx := strings.IndexByte(elem, '/')
|
||||
if idx < 0 {
|
||||
idx = len(elem)
|
||||
}
|
||||
args[0] = elem[:idx]
|
||||
elem = elem[idx:]
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch r.Method {
|
||||
case "DELETE":
|
||||
s.handleDeleteSevRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
case "GET":
|
||||
s.handleReadSevRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
case "PATCH":
|
||||
s.handleUpdateSevRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "DELETE,GET,PATCH")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/owner"
|
||||
if l := len("/owner"); len(elem) >= l && elem[0:l] == "/owner" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleReadSevOwnerRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "GET")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
case 'u': // Prefix: "u"
|
||||
if l := len("u"); len(elem) >= l && elem[0:l] == "u" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'e': // Prefix: "es"
|
||||
if l := len("es"); len(elem) >= l && elem[0:l] == "es" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleListUeRequest([0]string{}, w, r)
|
||||
case "POST":
|
||||
s.handleCreateUeRequest([0]string{}, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "GET,POST")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/"
|
||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
// Param: "id"
|
||||
// Match until "/"
|
||||
idx := strings.IndexByte(elem, '/')
|
||||
if idx < 0 {
|
||||
idx = len(elem)
|
||||
}
|
||||
args[0] = elem[:idx]
|
||||
elem = elem[idx:]
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch r.Method {
|
||||
case "DELETE":
|
||||
s.handleDeleteUeRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
case "GET":
|
||||
s.handleReadUeRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
case "PATCH":
|
||||
s.handleUpdateUeRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "DELETE,GET,PATCH")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/owner"
|
||||
if l := len("/owner"); len(elem) >= l && elem[0:l] == "/owner" {
|
||||
case '/': // Prefix: "/start"
|
||||
if l := len("/start"); len(elem) >= l && elem[0:l] == "/start" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
@@ -479,190 +330,18 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleReadUeOwnerRequest([1]string{
|
||||
case "PATCH":
|
||||
s.handleDrawStartRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "GET")
|
||||
s.notAllowed(w, r, "PATCH")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
case 's': // Prefix: "sers"
|
||||
if l := len("sers"); len(elem) >= l && elem[0:l] == "sers" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleListUserRequest([0]string{}, w, r)
|
||||
case "POST":
|
||||
s.handleCreateUserRequest([0]string{}, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "GET,POST")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/"
|
||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
// Param: "id"
|
||||
// Match until "/"
|
||||
idx := strings.IndexByte(elem, '/')
|
||||
if idx < 0 {
|
||||
idx = len(elem)
|
||||
}
|
||||
args[0] = elem[:idx]
|
||||
elem = elem[idx:]
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch r.Method {
|
||||
case "DELETE":
|
||||
s.handleDeleteUserRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
case "GET":
|
||||
s.handleReadUserRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
case "PATCH":
|
||||
s.handleUpdateUserRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "DELETE,GET,PATCH")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/"
|
||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'c': // Prefix: "card"
|
||||
if l := len("card"); len(elem) >= l && elem[0:l] == "card" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleListUserCardRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "GET")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/start"
|
||||
if l := len("/start"); len(elem) >= l && elem[0:l] == "/start" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "PATCH":
|
||||
s.handleDrawStartRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "PATCH")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'm': // Prefix: "ma"
|
||||
if l := len("ma"); len(elem) >= l && elem[0:l] == "ma" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleListUserMaRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "GET")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
case 's': // Prefix: "sev"
|
||||
if l := len("sev"); len(elem) >= l && elem[0:l] == "sev" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleListUserSevRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "GET")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
case 'u': // Prefix: "ue"
|
||||
if l := len("ue"); len(elem) >= l && elem[0:l] == "ue" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleListUserUeRequest([1]string{
|
||||
args[0],
|
||||
}, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "GET")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -968,8 +647,8 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
}
|
||||
}
|
||||
}
|
||||
case 'm': // Prefix: "mas"
|
||||
if l := len("mas"); len(elem) >= l && elem[0:l] == "mas" {
|
||||
case 'u': // Prefix: "users"
|
||||
if l := len("users"); len(elem) >= l && elem[0:l] == "users" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
@@ -978,16 +657,16 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = "ListMa"
|
||||
r.operationID = "listMa"
|
||||
r.pathPattern = "/mas"
|
||||
r.name = "ListUser"
|
||||
r.operationID = "listUser"
|
||||
r.pathPattern = "/users"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
case "POST":
|
||||
r.name = "CreateMa"
|
||||
r.operationID = "createMa"
|
||||
r.pathPattern = "/mas"
|
||||
r.name = "CreateUser"
|
||||
r.operationID = "createUser"
|
||||
r.pathPattern = "/users"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
@@ -1015,23 +694,23 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "DELETE":
|
||||
r.name = "DeleteMa"
|
||||
r.operationID = "deleteMa"
|
||||
r.pathPattern = "/mas/{id}"
|
||||
r.name = "DeleteUser"
|
||||
r.operationID = "deleteUser"
|
||||
r.pathPattern = "/users/{id}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
case "GET":
|
||||
r.name = "ReadMa"
|
||||
r.operationID = "readMa"
|
||||
r.pathPattern = "/mas/{id}"
|
||||
r.name = "ReadUser"
|
||||
r.operationID = "readUser"
|
||||
r.pathPattern = "/users/{id}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
case "PATCH":
|
||||
r.name = "UpdateMa"
|
||||
r.operationID = "updateMa"
|
||||
r.pathPattern = "/mas/{id}"
|
||||
r.name = "UpdateUser"
|
||||
r.operationID = "updateUser"
|
||||
r.pathPattern = "/users/{id}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
@@ -1040,8 +719,8 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
}
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/owner"
|
||||
if l := len("/owner"); len(elem) >= l && elem[0:l] == "/owner" {
|
||||
case '/': // Prefix: "/card"
|
||||
if l := len("/card"); len(elem) >= l && elem[0:l] == "/card" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
@@ -1050,189 +729,9 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "GET":
|
||||
// Leaf: ReadMaOwner
|
||||
r.name = "ReadMaOwner"
|
||||
r.operationID = "readMaOwner"
|
||||
r.pathPattern = "/mas/{id}/owner"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case 's': // Prefix: "sevs"
|
||||
if l := len("sevs"); len(elem) >= l && elem[0:l] == "sevs" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = "ListSev"
|
||||
r.operationID = "listSev"
|
||||
r.pathPattern = "/sevs"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
case "POST":
|
||||
r.name = "CreateSev"
|
||||
r.operationID = "createSev"
|
||||
r.pathPattern = "/sevs"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/"
|
||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
// Param: "id"
|
||||
// Match until "/"
|
||||
idx := strings.IndexByte(elem, '/')
|
||||
if idx < 0 {
|
||||
idx = len(elem)
|
||||
}
|
||||
args[0] = elem[:idx]
|
||||
elem = elem[idx:]
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "DELETE":
|
||||
r.name = "DeleteSev"
|
||||
r.operationID = "deleteSev"
|
||||
r.pathPattern = "/sevs/{id}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
case "GET":
|
||||
r.name = "ReadSev"
|
||||
r.operationID = "readSev"
|
||||
r.pathPattern = "/sevs/{id}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
case "PATCH":
|
||||
r.name = "UpdateSev"
|
||||
r.operationID = "updateSev"
|
||||
r.pathPattern = "/sevs/{id}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/owner"
|
||||
if l := len("/owner"); len(elem) >= l && elem[0:l] == "/owner" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "GET":
|
||||
// Leaf: ReadSevOwner
|
||||
r.name = "ReadSevOwner"
|
||||
r.operationID = "readSevOwner"
|
||||
r.pathPattern = "/sevs/{id}/owner"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case 'u': // Prefix: "u"
|
||||
if l := len("u"); len(elem) >= l && elem[0:l] == "u" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'e': // Prefix: "es"
|
||||
if l := len("es"); len(elem) >= l && elem[0:l] == "es" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = "ListUe"
|
||||
r.operationID = "listUe"
|
||||
r.pathPattern = "/ues"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
case "POST":
|
||||
r.name = "CreateUe"
|
||||
r.operationID = "createUe"
|
||||
r.pathPattern = "/ues"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/"
|
||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
// Param: "id"
|
||||
// Match until "/"
|
||||
idx := strings.IndexByte(elem, '/')
|
||||
if idx < 0 {
|
||||
idx = len(elem)
|
||||
}
|
||||
args[0] = elem[:idx]
|
||||
elem = elem[idx:]
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "DELETE":
|
||||
r.name = "DeleteUe"
|
||||
r.operationID = "deleteUe"
|
||||
r.pathPattern = "/ues/{id}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
case "GET":
|
||||
r.name = "ReadUe"
|
||||
r.operationID = "readUe"
|
||||
r.pathPattern = "/ues/{id}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
case "PATCH":
|
||||
r.name = "UpdateUe"
|
||||
r.operationID = "updateUe"
|
||||
r.pathPattern = "/ues/{id}"
|
||||
r.name = "ListUserCard"
|
||||
r.operationID = "listUserCard"
|
||||
r.pathPattern = "/users/{id}/card"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
@@ -1241,8 +740,8 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
}
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/owner"
|
||||
if l := len("/owner"); len(elem) >= l && elem[0:l] == "/owner" {
|
||||
case '/': // Prefix: "/start"
|
||||
if l := len("/start"); len(elem) >= l && elem[0:l] == "/start" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
@@ -1250,11 +749,11 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "GET":
|
||||
// Leaf: ReadUeOwner
|
||||
r.name = "ReadUeOwner"
|
||||
r.operationID = "readUeOwner"
|
||||
r.pathPattern = "/ues/{id}/owner"
|
||||
case "PATCH":
|
||||
// Leaf: DrawStart
|
||||
r.name = "DrawStart"
|
||||
r.operationID = "drawStart"
|
||||
r.pathPattern = "/users/{id}/card/start"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
@@ -1264,198 +763,6 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
}
|
||||
}
|
||||
}
|
||||
case 's': // Prefix: "sers"
|
||||
if l := len("sers"); len(elem) >= l && elem[0:l] == "sers" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = "ListUser"
|
||||
r.operationID = "listUser"
|
||||
r.pathPattern = "/users"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
case "POST":
|
||||
r.name = "CreateUser"
|
||||
r.operationID = "createUser"
|
||||
r.pathPattern = "/users"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/"
|
||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
// Param: "id"
|
||||
// Match until "/"
|
||||
idx := strings.IndexByte(elem, '/')
|
||||
if idx < 0 {
|
||||
idx = len(elem)
|
||||
}
|
||||
args[0] = elem[:idx]
|
||||
elem = elem[idx:]
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "DELETE":
|
||||
r.name = "DeleteUser"
|
||||
r.operationID = "deleteUser"
|
||||
r.pathPattern = "/users/{id}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
case "GET":
|
||||
r.name = "ReadUser"
|
||||
r.operationID = "readUser"
|
||||
r.pathPattern = "/users/{id}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
case "PATCH":
|
||||
r.name = "UpdateUser"
|
||||
r.operationID = "updateUser"
|
||||
r.pathPattern = "/users/{id}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/"
|
||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'c': // Prefix: "card"
|
||||
if l := len("card"); len(elem) >= l && elem[0:l] == "card" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = "ListUserCard"
|
||||
r.operationID = "listUserCard"
|
||||
r.pathPattern = "/users/{id}/card"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/start"
|
||||
if l := len("/start"); len(elem) >= l && elem[0:l] == "/start" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "PATCH":
|
||||
// Leaf: DrawStart
|
||||
r.name = "DrawStart"
|
||||
r.operationID = "drawStart"
|
||||
r.pathPattern = "/users/{id}/card/start"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
case 'm': // Prefix: "ma"
|
||||
if l := len("ma"); len(elem) >= l && elem[0:l] == "ma" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "GET":
|
||||
// Leaf: ListUserMa
|
||||
r.name = "ListUserMa"
|
||||
r.operationID = "listUserMa"
|
||||
r.pathPattern = "/users/{id}/ma"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
case 's': // Prefix: "sev"
|
||||
if l := len("sev"); len(elem) >= l && elem[0:l] == "sev" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "GET":
|
||||
// Leaf: ListUserSev
|
||||
r.name = "ListUserSev"
|
||||
r.operationID = "listUserSev"
|
||||
r.pathPattern = "/users/{id}/sev"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'u': // Prefix: "ue"
|
||||
if l := len("ue"); len(elem) >= l && elem[0:l] == "ue" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "GET":
|
||||
// Leaf: ListUserUe
|
||||
r.name = "ListUserUe"
|
||||
r.operationID = "listUserUe"
|
||||
r.pathPattern = "/users/{id}/ue"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,24 +20,6 @@ type Handler interface {
|
||||
//
|
||||
// POST /groups
|
||||
CreateGroup(ctx context.Context, req *CreateGroupReq) (CreateGroupRes, error)
|
||||
// CreateMa implements createMa operation.
|
||||
//
|
||||
// Creates a new Ma and persists it to storage.
|
||||
//
|
||||
// POST /mas
|
||||
CreateMa(ctx context.Context, req *CreateMaReq) (CreateMaRes, error)
|
||||
// CreateSev implements createSev operation.
|
||||
//
|
||||
// Creates a new Sev and persists it to storage.
|
||||
//
|
||||
// POST /sevs
|
||||
CreateSev(ctx context.Context, req *CreateSevReq) (CreateSevRes, error)
|
||||
// CreateUe implements createUe operation.
|
||||
//
|
||||
// Creates a new Ue and persists it to storage.
|
||||
//
|
||||
// POST /ues
|
||||
CreateUe(ctx context.Context, req *CreateUeReq) (CreateUeRes, error)
|
||||
// CreateUser implements createUser operation.
|
||||
//
|
||||
// Creates a new User and persists it to storage.
|
||||
@@ -56,24 +38,6 @@ type Handler interface {
|
||||
//
|
||||
// DELETE /groups/{id}
|
||||
DeleteGroup(ctx context.Context, params DeleteGroupParams) (DeleteGroupRes, error)
|
||||
// DeleteMa implements deleteMa operation.
|
||||
//
|
||||
// Deletes the Ma with the requested ID.
|
||||
//
|
||||
// DELETE /mas/{id}
|
||||
DeleteMa(ctx context.Context, params DeleteMaParams) (DeleteMaRes, error)
|
||||
// DeleteSev implements deleteSev operation.
|
||||
//
|
||||
// Deletes the Sev with the requested ID.
|
||||
//
|
||||
// DELETE /sevs/{id}
|
||||
DeleteSev(ctx context.Context, params DeleteSevParams) (DeleteSevRes, error)
|
||||
// DeleteUe implements deleteUe operation.
|
||||
//
|
||||
// Deletes the Ue with the requested ID.
|
||||
//
|
||||
// DELETE /ues/{id}
|
||||
DeleteUe(ctx context.Context, params DeleteUeParams) (DeleteUeRes, error)
|
||||
// DeleteUser implements deleteUser operation.
|
||||
//
|
||||
// Deletes the User with the requested ID.
|
||||
@@ -110,24 +74,6 @@ type Handler interface {
|
||||
//
|
||||
// GET /groups/{id}/users
|
||||
ListGroupUsers(ctx context.Context, params ListGroupUsersParams) (ListGroupUsersRes, error)
|
||||
// ListMa implements listMa operation.
|
||||
//
|
||||
// List Mas.
|
||||
//
|
||||
// GET /mas
|
||||
ListMa(ctx context.Context, params ListMaParams) (ListMaRes, error)
|
||||
// ListSev implements listSev operation.
|
||||
//
|
||||
// List Sevs.
|
||||
//
|
||||
// GET /sevs
|
||||
ListSev(ctx context.Context, params ListSevParams) (ListSevRes, error)
|
||||
// ListUe implements listUe operation.
|
||||
//
|
||||
// List Ues.
|
||||
//
|
||||
// GET /ues
|
||||
ListUe(ctx context.Context, params ListUeParams) (ListUeRes, error)
|
||||
// ListUser implements listUser operation.
|
||||
//
|
||||
// List Users.
|
||||
@@ -140,24 +86,6 @@ type Handler interface {
|
||||
//
|
||||
// GET /users/{id}/card
|
||||
ListUserCard(ctx context.Context, params ListUserCardParams) (ListUserCardRes, error)
|
||||
// ListUserMa implements listUserMa operation.
|
||||
//
|
||||
// List attached Mas.
|
||||
//
|
||||
// GET /users/{id}/ma
|
||||
ListUserMa(ctx context.Context, params ListUserMaParams) (ListUserMaRes, error)
|
||||
// ListUserSev implements listUserSev operation.
|
||||
//
|
||||
// List attached Sevs.
|
||||
//
|
||||
// GET /users/{id}/sev
|
||||
ListUserSev(ctx context.Context, params ListUserSevParams) (ListUserSevRes, error)
|
||||
// ListUserUe implements listUserUe operation.
|
||||
//
|
||||
// List attached Ues.
|
||||
//
|
||||
// GET /users/{id}/ue
|
||||
ListUserUe(ctx context.Context, params ListUserUeParams) (ListUserUeRes, error)
|
||||
// ReadCard implements readCard operation.
|
||||
//
|
||||
// Finds the Card with the requested ID and returns it.
|
||||
@@ -176,42 +104,6 @@ type Handler interface {
|
||||
//
|
||||
// GET /groups/{id}
|
||||
ReadGroup(ctx context.Context, params ReadGroupParams) (ReadGroupRes, error)
|
||||
// ReadMa implements readMa operation.
|
||||
//
|
||||
// Finds the Ma with the requested ID and returns it.
|
||||
//
|
||||
// GET /mas/{id}
|
||||
ReadMa(ctx context.Context, params ReadMaParams) (ReadMaRes, error)
|
||||
// ReadMaOwner implements readMaOwner operation.
|
||||
//
|
||||
// Find the attached User of the Ma with the given ID.
|
||||
//
|
||||
// GET /mas/{id}/owner
|
||||
ReadMaOwner(ctx context.Context, params ReadMaOwnerParams) (ReadMaOwnerRes, error)
|
||||
// ReadSev implements readSev operation.
|
||||
//
|
||||
// Finds the Sev with the requested ID and returns it.
|
||||
//
|
||||
// GET /sevs/{id}
|
||||
ReadSev(ctx context.Context, params ReadSevParams) (ReadSevRes, error)
|
||||
// ReadSevOwner implements readSevOwner operation.
|
||||
//
|
||||
// Find the attached User of the Sev with the given ID.
|
||||
//
|
||||
// GET /sevs/{id}/owner
|
||||
ReadSevOwner(ctx context.Context, params ReadSevOwnerParams) (ReadSevOwnerRes, error)
|
||||
// ReadUe implements readUe operation.
|
||||
//
|
||||
// Finds the Ue with the requested ID and returns it.
|
||||
//
|
||||
// GET /ues/{id}
|
||||
ReadUe(ctx context.Context, params ReadUeParams) (ReadUeRes, error)
|
||||
// ReadUeOwner implements readUeOwner operation.
|
||||
//
|
||||
// Find the attached User of the Ue with the given ID.
|
||||
//
|
||||
// GET /ues/{id}/owner
|
||||
ReadUeOwner(ctx context.Context, params ReadUeOwnerParams) (ReadUeOwnerRes, error)
|
||||
// ReadUser implements readUser operation.
|
||||
//
|
||||
// Finds the User with the requested ID and returns it.
|
||||
@@ -230,24 +122,6 @@ type Handler interface {
|
||||
//
|
||||
// PATCH /groups/{id}
|
||||
UpdateGroup(ctx context.Context, req *UpdateGroupReq, params UpdateGroupParams) (UpdateGroupRes, error)
|
||||
// UpdateMa implements updateMa operation.
|
||||
//
|
||||
// Updates a Ma and persists changes to storage.
|
||||
//
|
||||
// PATCH /mas/{id}
|
||||
UpdateMa(ctx context.Context, req *UpdateMaReq, params UpdateMaParams) (UpdateMaRes, error)
|
||||
// UpdateSev implements updateSev operation.
|
||||
//
|
||||
// Updates a Sev and persists changes to storage.
|
||||
//
|
||||
// PATCH /sevs/{id}
|
||||
UpdateSev(ctx context.Context, req *UpdateSevReq, params UpdateSevParams) (UpdateSevRes, error)
|
||||
// UpdateUe implements updateUe operation.
|
||||
//
|
||||
// Updates a Ue and persists changes to storage.
|
||||
//
|
||||
// PATCH /ues/{id}
|
||||
UpdateUe(ctx context.Context, req *UpdateUeReq, params UpdateUeParams) (UpdateUeRes, error)
|
||||
// UpdateUser implements updateUser operation.
|
||||
//
|
||||
// Updates a User and persists changes to storage.
|
||||
|
||||
@@ -31,33 +31,6 @@ func (UnimplementedHandler) CreateGroup(ctx context.Context, req *CreateGroupReq
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// CreateMa implements createMa operation.
|
||||
//
|
||||
// Creates a new Ma and persists it to storage.
|
||||
//
|
||||
// POST /mas
|
||||
func (UnimplementedHandler) CreateMa(ctx context.Context, req *CreateMaReq) (r CreateMaRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// CreateSev implements createSev operation.
|
||||
//
|
||||
// Creates a new Sev and persists it to storage.
|
||||
//
|
||||
// POST /sevs
|
||||
func (UnimplementedHandler) CreateSev(ctx context.Context, req *CreateSevReq) (r CreateSevRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// CreateUe implements createUe operation.
|
||||
//
|
||||
// Creates a new Ue and persists it to storage.
|
||||
//
|
||||
// POST /ues
|
||||
func (UnimplementedHandler) CreateUe(ctx context.Context, req *CreateUeReq) (r CreateUeRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// CreateUser implements createUser operation.
|
||||
//
|
||||
// Creates a new User and persists it to storage.
|
||||
@@ -85,33 +58,6 @@ func (UnimplementedHandler) DeleteGroup(ctx context.Context, params DeleteGroupP
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// DeleteMa implements deleteMa operation.
|
||||
//
|
||||
// Deletes the Ma with the requested ID.
|
||||
//
|
||||
// DELETE /mas/{id}
|
||||
func (UnimplementedHandler) DeleteMa(ctx context.Context, params DeleteMaParams) (r DeleteMaRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// DeleteSev implements deleteSev operation.
|
||||
//
|
||||
// Deletes the Sev with the requested ID.
|
||||
//
|
||||
// DELETE /sevs/{id}
|
||||
func (UnimplementedHandler) DeleteSev(ctx context.Context, params DeleteSevParams) (r DeleteSevRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// DeleteUe implements deleteUe operation.
|
||||
//
|
||||
// Deletes the Ue with the requested ID.
|
||||
//
|
||||
// DELETE /ues/{id}
|
||||
func (UnimplementedHandler) DeleteUe(ctx context.Context, params DeleteUeParams) (r DeleteUeRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// DeleteUser implements deleteUser operation.
|
||||
//
|
||||
// Deletes the User with the requested ID.
|
||||
@@ -166,33 +112,6 @@ func (UnimplementedHandler) ListGroupUsers(ctx context.Context, params ListGroup
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ListMa implements listMa operation.
|
||||
//
|
||||
// List Mas.
|
||||
//
|
||||
// GET /mas
|
||||
func (UnimplementedHandler) ListMa(ctx context.Context, params ListMaParams) (r ListMaRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ListSev implements listSev operation.
|
||||
//
|
||||
// List Sevs.
|
||||
//
|
||||
// GET /sevs
|
||||
func (UnimplementedHandler) ListSev(ctx context.Context, params ListSevParams) (r ListSevRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ListUe implements listUe operation.
|
||||
//
|
||||
// List Ues.
|
||||
//
|
||||
// GET /ues
|
||||
func (UnimplementedHandler) ListUe(ctx context.Context, params ListUeParams) (r ListUeRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ListUser implements listUser operation.
|
||||
//
|
||||
// List Users.
|
||||
@@ -211,33 +130,6 @@ func (UnimplementedHandler) ListUserCard(ctx context.Context, params ListUserCar
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ListUserMa implements listUserMa operation.
|
||||
//
|
||||
// List attached Mas.
|
||||
//
|
||||
// GET /users/{id}/ma
|
||||
func (UnimplementedHandler) ListUserMa(ctx context.Context, params ListUserMaParams) (r ListUserMaRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ListUserSev implements listUserSev operation.
|
||||
//
|
||||
// List attached Sevs.
|
||||
//
|
||||
// GET /users/{id}/sev
|
||||
func (UnimplementedHandler) ListUserSev(ctx context.Context, params ListUserSevParams) (r ListUserSevRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ListUserUe implements listUserUe operation.
|
||||
//
|
||||
// List attached Ues.
|
||||
//
|
||||
// GET /users/{id}/ue
|
||||
func (UnimplementedHandler) ListUserUe(ctx context.Context, params ListUserUeParams) (r ListUserUeRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ReadCard implements readCard operation.
|
||||
//
|
||||
// Finds the Card with the requested ID and returns it.
|
||||
@@ -265,60 +157,6 @@ func (UnimplementedHandler) ReadGroup(ctx context.Context, params ReadGroupParam
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ReadMa implements readMa operation.
|
||||
//
|
||||
// Finds the Ma with the requested ID and returns it.
|
||||
//
|
||||
// GET /mas/{id}
|
||||
func (UnimplementedHandler) ReadMa(ctx context.Context, params ReadMaParams) (r ReadMaRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ReadMaOwner implements readMaOwner operation.
|
||||
//
|
||||
// Find the attached User of the Ma with the given ID.
|
||||
//
|
||||
// GET /mas/{id}/owner
|
||||
func (UnimplementedHandler) ReadMaOwner(ctx context.Context, params ReadMaOwnerParams) (r ReadMaOwnerRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ReadSev implements readSev operation.
|
||||
//
|
||||
// Finds the Sev with the requested ID and returns it.
|
||||
//
|
||||
// GET /sevs/{id}
|
||||
func (UnimplementedHandler) ReadSev(ctx context.Context, params ReadSevParams) (r ReadSevRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ReadSevOwner implements readSevOwner operation.
|
||||
//
|
||||
// Find the attached User of the Sev with the given ID.
|
||||
//
|
||||
// GET /sevs/{id}/owner
|
||||
func (UnimplementedHandler) ReadSevOwner(ctx context.Context, params ReadSevOwnerParams) (r ReadSevOwnerRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ReadUe implements readUe operation.
|
||||
//
|
||||
// Finds the Ue with the requested ID and returns it.
|
||||
//
|
||||
// GET /ues/{id}
|
||||
func (UnimplementedHandler) ReadUe(ctx context.Context, params ReadUeParams) (r ReadUeRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ReadUeOwner implements readUeOwner operation.
|
||||
//
|
||||
// Find the attached User of the Ue with the given ID.
|
||||
//
|
||||
// GET /ues/{id}/owner
|
||||
func (UnimplementedHandler) ReadUeOwner(ctx context.Context, params ReadUeOwnerParams) (r ReadUeOwnerRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ReadUser implements readUser operation.
|
||||
//
|
||||
// Finds the User with the requested ID and returns it.
|
||||
@@ -346,33 +184,6 @@ func (UnimplementedHandler) UpdateGroup(ctx context.Context, req *UpdateGroupReq
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// UpdateMa implements updateMa operation.
|
||||
//
|
||||
// Updates a Ma and persists changes to storage.
|
||||
//
|
||||
// PATCH /mas/{id}
|
||||
func (UnimplementedHandler) UpdateMa(ctx context.Context, req *UpdateMaReq, params UpdateMaParams) (r UpdateMaRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// UpdateSev implements updateSev operation.
|
||||
//
|
||||
// Updates a Sev and persists changes to storage.
|
||||
//
|
||||
// PATCH /sevs/{id}
|
||||
func (UnimplementedHandler) UpdateSev(ctx context.Context, req *UpdateSevReq, params UpdateSevParams) (r UpdateSevRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// UpdateUe implements updateUe operation.
|
||||
//
|
||||
// Updates a Ue and persists changes to storage.
|
||||
//
|
||||
// PATCH /ues/{id}
|
||||
func (UnimplementedHandler) UpdateUe(ctx context.Context, req *UpdateUeReq, params UpdateUeParams) (r UpdateUeRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// UpdateUser implements updateUser operation.
|
||||
//
|
||||
// Updates a User and persists changes to storage.
|
||||
|
||||
@@ -3,88 +3,9 @@
|
||||
package ogent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-faster/errors"
|
||||
|
||||
"github.com/ogen-go/ogen/validate"
|
||||
)
|
||||
|
||||
func (s *CardOwnerRead) Validate() error {
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if s.Planet.Set {
|
||||
if err := func() error {
|
||||
if err := (validate.Float{}).Validate(float64(s.Planet.Value)); err != nil {
|
||||
return errors.Wrap(err, "float")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "planet",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s *CreateUserReq) Validate() error {
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if s.Planet.Set {
|
||||
if err := func() error {
|
||||
if err := (validate.Float{}).Validate(float64(s.Planet.Value)); err != nil {
|
||||
return errors.Wrap(err, "float")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "planet",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s *GroupUsersList) Validate() error {
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if s.Planet.Set {
|
||||
if err := func() error {
|
||||
if err := (validate.Float{}).Validate(float64(s.Planet.Value)); err != nil {
|
||||
return errors.Wrap(err, "float")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "planet",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s ListCardOKApplicationJSON) Validate() error {
|
||||
if s == nil {
|
||||
return errors.New("nil is invalid value")
|
||||
@@ -98,41 +19,6 @@ func (s ListGroupOKApplicationJSON) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (s ListGroupUsersOKApplicationJSON) Validate() error {
|
||||
if s == nil {
|
||||
return errors.New("nil is invalid value")
|
||||
}
|
||||
var failures []validate.FieldError
|
||||
for i, elem := range s {
|
||||
if err := func() error {
|
||||
if err := elem.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: fmt.Sprintf("[%d]", i),
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s ListMaOKApplicationJSON) Validate() error {
|
||||
if s == nil {
|
||||
return errors.New("nil is invalid value")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s ListSevOKApplicationJSON) Validate() error {
|
||||
if s == nil {
|
||||
return errors.New("nil is invalid value")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s ListUeOKApplicationJSON) Validate() error {
|
||||
if s == nil {
|
||||
return errors.New("nil is invalid value")
|
||||
}
|
||||
@@ -144,245 +30,9 @@ func (s ListUserCardOKApplicationJSON) Validate() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s ListUserMaOKApplicationJSON) Validate() error {
|
||||
if s == nil {
|
||||
return errors.New("nil is invalid value")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s ListUserOKApplicationJSON) Validate() error {
|
||||
if s == nil {
|
||||
return errors.New("nil is invalid value")
|
||||
}
|
||||
var failures []validate.FieldError
|
||||
for i, elem := range s {
|
||||
if err := func() error {
|
||||
if err := elem.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: fmt.Sprintf("[%d]", i),
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s ListUserSevOKApplicationJSON) Validate() error {
|
||||
if s == nil {
|
||||
return errors.New("nil is invalid value")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s ListUserUeOKApplicationJSON) Validate() error {
|
||||
if s == nil {
|
||||
return errors.New("nil is invalid value")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s *MaOwnerRead) Validate() error {
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if s.Planet.Set {
|
||||
if err := func() error {
|
||||
if err := (validate.Float{}).Validate(float64(s.Planet.Value)); err != nil {
|
||||
return errors.Wrap(err, "float")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "planet",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SevOwnerRead) Validate() error {
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if s.Planet.Set {
|
||||
if err := func() error {
|
||||
if err := (validate.Float{}).Validate(float64(s.Planet.Value)); err != nil {
|
||||
return errors.Wrap(err, "float")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "planet",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s *UeOwnerRead) Validate() error {
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if s.Planet.Set {
|
||||
if err := func() error {
|
||||
if err := (validate.Float{}).Validate(float64(s.Planet.Value)); err != nil {
|
||||
return errors.Wrap(err, "float")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "planet",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s *UpdateUserReq) Validate() error {
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if s.Planet.Set {
|
||||
if err := func() error {
|
||||
if err := (validate.Float{}).Validate(float64(s.Planet.Value)); err != nil {
|
||||
return errors.Wrap(err, "float")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "planet",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s *UserCreate) Validate() error {
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if s.Planet.Set {
|
||||
if err := func() error {
|
||||
if err := (validate.Float{}).Validate(float64(s.Planet.Value)); err != nil {
|
||||
return errors.Wrap(err, "float")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "planet",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s *UserList) Validate() error {
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if s.Planet.Set {
|
||||
if err := func() error {
|
||||
if err := (validate.Float{}).Validate(float64(s.Planet.Value)); err != nil {
|
||||
return errors.Wrap(err, "float")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "planet",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s *UserRead) Validate() error {
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if s.Planet.Set {
|
||||
if err := func() error {
|
||||
if err := (validate.Float{}).Validate(float64(s.Planet.Value)); err != nil {
|
||||
return errors.Wrap(err, "float")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "planet",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s *UserUpdate) Validate() error {
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if s.Planet.Set {
|
||||
if err := func() error {
|
||||
if err := (validate.Float{}).Validate(float64(s.Planet.Value)); err != nil {
|
||||
return errors.Wrap(err, "float")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "planet",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
1519
ent/ogent/ogent.go
1519
ent/ogent/ogent.go
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
4327
ent/openapi.json
4327
ent/openapi.json
File diff suppressed because it is too large
Load Diff
@@ -12,14 +12,5 @@ type Card func(*sql.Selector)
|
||||
// Group is the predicate function for group builders.
|
||||
type Group func(*sql.Selector)
|
||||
|
||||
// Ma is the predicate function for ma builders.
|
||||
type Ma func(*sql.Selector)
|
||||
|
||||
// Sev is the predicate function for sev builders.
|
||||
type Sev func(*sql.Selector)
|
||||
|
||||
// Ue is the predicate function for ue builders.
|
||||
type Ue func(*sql.Selector)
|
||||
|
||||
// User is the predicate function for user builders.
|
||||
type User func(*sql.Selector)
|
||||
|
||||
155
ent/runtime.go
155
ent/runtime.go
@@ -3,13 +3,10 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/card"
|
||||
"api/ent/group"
|
||||
"api/ent/ma"
|
||||
"api/ent/schema"
|
||||
"api/ent/sev"
|
||||
"api/ent/ue"
|
||||
"api/ent/user"
|
||||
"t/ent/card"
|
||||
"t/ent/group"
|
||||
"t/ent/schema"
|
||||
"t/ent/user"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -44,7 +41,7 @@ func init() {
|
||||
// card.DefaultURL holds the default value on creation for the url field.
|
||||
card.DefaultURL = cardDescURL.Default.(string)
|
||||
// cardDescCreatedAt is the schema descriptor for created_at field.
|
||||
cardDescCreatedAt := cardFields[9].Descriptor()
|
||||
cardDescCreatedAt := cardFields[7].Descriptor()
|
||||
// card.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
card.DefaultCreatedAt = cardDescCreatedAt.Default.(func() time.Time)
|
||||
groupFields := schema.Group{}.Fields()
|
||||
@@ -53,56 +50,6 @@ func init() {
|
||||
groupDescPassword := groupFields[1].Descriptor()
|
||||
// group.PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
group.PasswordValidator = groupDescPassword.Validators[0].(func(string) error)
|
||||
maFields := schema.Ma{}.Fields()
|
||||
_ = maFields
|
||||
// maDescPassword is the schema descriptor for password field.
|
||||
maDescPassword := maFields[0].Descriptor()
|
||||
// ma.PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
ma.PasswordValidator = maDescPassword.Validators[0].(func(string) error)
|
||||
// maDescLimit is the schema descriptor for limit field.
|
||||
maDescLimit := maFields[2].Descriptor()
|
||||
// ma.DefaultLimit holds the default value on creation for the limit field.
|
||||
ma.DefaultLimit = maDescLimit.Default.(bool)
|
||||
// maDescCreatedAt is the schema descriptor for created_at field.
|
||||
maDescCreatedAt := maFields[22].Descriptor()
|
||||
// ma.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
ma.DefaultCreatedAt = maDescCreatedAt.Default.(func() time.Time)
|
||||
sevFields := schema.Sev{}.Fields()
|
||||
_ = sevFields
|
||||
// sevDescPassword is the schema descriptor for password field.
|
||||
sevDescPassword := sevFields[0].Descriptor()
|
||||
// sev.PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
sev.PasswordValidator = sevDescPassword.Validators[0].(func(string) error)
|
||||
// sevDescLimit is the schema descriptor for limit field.
|
||||
sevDescLimit := sevFields[2].Descriptor()
|
||||
// sev.DefaultLimit holds the default value on creation for the limit field.
|
||||
sev.DefaultLimit = sevDescLimit.Default.(bool)
|
||||
// sevDescCreatedAt is the schema descriptor for created_at field.
|
||||
sevDescCreatedAt := sevFields[11].Descriptor()
|
||||
// sev.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
sev.DefaultCreatedAt = sevDescCreatedAt.Default.(func() time.Time)
|
||||
ueFields := schema.Ue{}.Fields()
|
||||
_ = ueFields
|
||||
// ueDescLimit is the schema descriptor for limit field.
|
||||
ueDescLimit := ueFields[0].Descriptor()
|
||||
// ue.DefaultLimit holds the default value on creation for the limit field.
|
||||
ue.DefaultLimit = ueDescLimit.Default.(bool)
|
||||
// ueDescLimitBoss is the schema descriptor for limit_boss field.
|
||||
ueDescLimitBoss := ueFields[1].Descriptor()
|
||||
// ue.DefaultLimitBoss holds the default value on creation for the limit_boss field.
|
||||
ue.DefaultLimitBoss = ueDescLimitBoss.Default.(bool)
|
||||
// ueDescLimitItem is the schema descriptor for limit_item field.
|
||||
ueDescLimitItem := ueFields[2].Descriptor()
|
||||
// ue.DefaultLimitItem holds the default value on creation for the limit_item field.
|
||||
ue.DefaultLimitItem = ueDescLimitItem.Default.(bool)
|
||||
// ueDescPassword is the schema descriptor for password field.
|
||||
ueDescPassword := ueFields[3].Descriptor()
|
||||
// ue.PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
ue.PasswordValidator = ueDescPassword.Validators[0].(func(string) error)
|
||||
// ueDescCreatedAt is the schema descriptor for created_at field.
|
||||
ueDescCreatedAt := ueFields[23].Descriptor()
|
||||
// ue.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
ue.DefaultCreatedAt = ueDescCreatedAt.Default.(func() time.Time)
|
||||
userFields := schema.User{}.Fields()
|
||||
_ = userFields
|
||||
// userDescUsername is the schema descriptor for username field.
|
||||
@@ -123,120 +70,52 @@ func init() {
|
||||
return nil
|
||||
}
|
||||
}()
|
||||
// userDescMember is the schema descriptor for member field.
|
||||
userDescMember := userFields[2].Descriptor()
|
||||
// user.DefaultMember holds the default value on creation for the member field.
|
||||
user.DefaultMember = userDescMember.Default.(bool)
|
||||
// userDescBook is the schema descriptor for book field.
|
||||
userDescBook := userFields[3].Descriptor()
|
||||
// user.DefaultBook holds the default value on creation for the book field.
|
||||
user.DefaultBook = userDescBook.Default.(bool)
|
||||
// userDescManga is the schema descriptor for manga field.
|
||||
userDescManga := userFields[4].Descriptor()
|
||||
// user.DefaultManga holds the default value on creation for the manga field.
|
||||
user.DefaultManga = userDescManga.Default.(bool)
|
||||
// userDescBadge is the schema descriptor for badge field.
|
||||
userDescBadge := userFields[5].Descriptor()
|
||||
// user.DefaultBadge holds the default value on creation for the badge field.
|
||||
user.DefaultBadge = userDescBadge.Default.(bool)
|
||||
// userDescBsky is the schema descriptor for bsky field.
|
||||
userDescBsky := userFields[6].Descriptor()
|
||||
userDescBsky := userFields[2].Descriptor()
|
||||
// user.DefaultBsky holds the default value on creation for the bsky field.
|
||||
user.DefaultBsky = userDescBsky.Default.(bool)
|
||||
// userDescMastodon is the schema descriptor for mastodon field.
|
||||
userDescMastodon := userFields[7].Descriptor()
|
||||
userDescMastodon := userFields[3].Descriptor()
|
||||
// user.DefaultMastodon holds the default value on creation for the mastodon field.
|
||||
user.DefaultMastodon = userDescMastodon.Default.(bool)
|
||||
// userDescDelete is the schema descriptor for delete field.
|
||||
userDescDelete := userFields[8].Descriptor()
|
||||
userDescDelete := userFields[4].Descriptor()
|
||||
// user.DefaultDelete holds the default value on creation for the delete field.
|
||||
user.DefaultDelete = userDescDelete.Default.(bool)
|
||||
// userDescHandle is the schema descriptor for handle field.
|
||||
userDescHandle := userFields[9].Descriptor()
|
||||
userDescHandle := userFields[5].Descriptor()
|
||||
// user.DefaultHandle holds the default value on creation for the handle field.
|
||||
user.DefaultHandle = userDescHandle.Default.(bool)
|
||||
// userDescPassword is the schema descriptor for password field.
|
||||
userDescPassword := userFields[11].Descriptor()
|
||||
userDescPassword := userFields[7].Descriptor()
|
||||
// user.PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
user.PasswordValidator = userDescPassword.Validators[0].(func(string) error)
|
||||
// userDescCreatedAt is the schema descriptor for created_at field.
|
||||
userDescCreatedAt := userFields[12].Descriptor()
|
||||
userDescCreatedAt := userFields[8].Descriptor()
|
||||
// user.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
user.DefaultCreatedAt = userDescCreatedAt.Default.(func() time.Time)
|
||||
// userDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
userDescUpdatedAt := userFields[13].Descriptor()
|
||||
userDescUpdatedAt := userFields[9].Descriptor()
|
||||
// user.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
user.DefaultUpdatedAt = userDescUpdatedAt.Default.(func() time.Time)
|
||||
// userDescRaidAt is the schema descriptor for raid_at field.
|
||||
userDescRaidAt := userFields[14].Descriptor()
|
||||
userDescRaidAt := userFields[10].Descriptor()
|
||||
// user.DefaultRaidAt holds the default value on creation for the raid_at field.
|
||||
user.DefaultRaidAt = userDescRaidAt.Default.(func() time.Time)
|
||||
// userDescServerAt is the schema descriptor for server_at field.
|
||||
userDescServerAt := userFields[15].Descriptor()
|
||||
// user.DefaultServerAt holds the default value on creation for the server_at field.
|
||||
user.DefaultServerAt = userDescServerAt.Default.(func() time.Time)
|
||||
// userDescEggAt is the schema descriptor for egg_at field.
|
||||
userDescEggAt := userFields[16].Descriptor()
|
||||
// user.DefaultEggAt holds the default value on creation for the egg_at field.
|
||||
user.DefaultEggAt = userDescEggAt.Default.(func() time.Time)
|
||||
// userDescLuckAt is the schema descriptor for luck_at field.
|
||||
userDescLuckAt := userFields[18].Descriptor()
|
||||
userDescLuckAt := userFields[12].Descriptor()
|
||||
// user.DefaultLuckAt holds the default value on creation for the luck_at field.
|
||||
user.DefaultLuckAt = userDescLuckAt.Default.(func() time.Time)
|
||||
// userDescLikeAt is the schema descriptor for like_at field.
|
||||
userDescLikeAt := userFields[21].Descriptor()
|
||||
userDescLikeAt := userFields[15].Descriptor()
|
||||
// user.DefaultLikeAt holds the default value on creation for the like_at field.
|
||||
user.DefaultLikeAt = userDescLikeAt.Default.(func() time.Time)
|
||||
// userDescTenAt is the schema descriptor for ten_at field.
|
||||
userDescTenAt := userFields[31].Descriptor()
|
||||
userDescTenAt := userFields[25].Descriptor()
|
||||
// user.DefaultTenAt holds the default value on creation for the ten_at field.
|
||||
user.DefaultTenAt = userDescTenAt.Default.(func() time.Time)
|
||||
// userDescNext is the schema descriptor for next field.
|
||||
userDescNext := userFields[32].Descriptor()
|
||||
userDescNext := userFields[26].Descriptor()
|
||||
// user.DefaultNext holds the default value on creation for the next field.
|
||||
user.DefaultNext = userDescNext.Default.(string)
|
||||
// userDescModelAt is the schema descriptor for model_at field.
|
||||
userDescModelAt := userFields[35].Descriptor()
|
||||
// user.DefaultModelAt holds the default value on creation for the model_at field.
|
||||
user.DefaultModelAt = userDescModelAt.Default.(func() time.Time)
|
||||
// userDescGame is the schema descriptor for game field.
|
||||
userDescGame := userFields[42].Descriptor()
|
||||
// user.DefaultGame holds the default value on creation for the game field.
|
||||
user.DefaultGame = userDescGame.Default.(bool)
|
||||
// userDescGameTest is the schema descriptor for game_test field.
|
||||
userDescGameTest := userFields[43].Descriptor()
|
||||
// user.DefaultGameTest holds the default value on creation for the game_test field.
|
||||
user.DefaultGameTest = userDescGameTest.Default.(bool)
|
||||
// userDescGameEnd is the schema descriptor for game_end field.
|
||||
userDescGameEnd := userFields[44].Descriptor()
|
||||
// user.DefaultGameEnd holds the default value on creation for the game_end field.
|
||||
user.DefaultGameEnd = userDescGameEnd.Default.(bool)
|
||||
// userDescGameAccount is the schema descriptor for game_account field.
|
||||
userDescGameAccount := userFields[45].Descriptor()
|
||||
// user.DefaultGameAccount holds the default value on creation for the game_account field.
|
||||
user.DefaultGameAccount = userDescGameAccount.Default.(bool)
|
||||
// userDescGameLimit is the schema descriptor for game_limit field.
|
||||
userDescGameLimit := userFields[49].Descriptor()
|
||||
// user.DefaultGameLimit holds the default value on creation for the game_limit field.
|
||||
user.DefaultGameLimit = userDescGameLimit.Default.(bool)
|
||||
// userDescCoinOpen is the schema descriptor for coin_open field.
|
||||
userDescCoinOpen := userFields[51].Descriptor()
|
||||
// user.DefaultCoinOpen holds the default value on creation for the coin_open field.
|
||||
user.DefaultCoinOpen = userDescCoinOpen.Default.(bool)
|
||||
// userDescCoinAt is the schema descriptor for coin_at field.
|
||||
userDescCoinAt := userFields[52].Descriptor()
|
||||
// user.DefaultCoinAt holds the default value on creation for the coin_at field.
|
||||
user.DefaultCoinAt = userDescCoinAt.Default.(func() time.Time)
|
||||
// userDescPlanetAt is the schema descriptor for planet_at field.
|
||||
userDescPlanetAt := userFields[54].Descriptor()
|
||||
// user.DefaultPlanetAt holds the default value on creation for the planet_at field.
|
||||
user.DefaultPlanetAt = userDescPlanetAt.Default.(func() time.Time)
|
||||
// userDescLogin is the schema descriptor for login field.
|
||||
userDescLogin := userFields[55].Descriptor()
|
||||
// user.DefaultLogin holds the default value on creation for the login field.
|
||||
user.DefaultLogin = userDescLogin.Default.(bool)
|
||||
// userDescLoginAt is the schema descriptor for login_at field.
|
||||
userDescLoginAt := userFields[56].Descriptor()
|
||||
// user.DefaultLoginAt holds the default value on creation for the login_at field.
|
||||
user.DefaultLoginAt = userDescLoginAt.Default.(func() time.Time)
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
package runtime
|
||||
|
||||
// The schema-stitching logic is generated in api/ent/runtime.go
|
||||
// The schema-stitching logic is generated in t/ent/runtime.go
|
||||
|
||||
const (
|
||||
Version = "v0.12.2" // Version of ent codegen.
|
||||
Sum = "h1:Ndl/JvCX76xCtUDlrUfMnOKBRodAtxE5yfGYxjbOxmM=" // Sum of ent codegen.
|
||||
Version = "v0.11.10" // Version of ent codegen.
|
||||
Sum = "h1:iqn32ybY5HRW3xSAyMNdNKpZhKgMf1Zunsej9yPKUI8=" // Sum of ent codegen.
|
||||
)
|
||||
|
||||
@@ -28,16 +28,37 @@ func (Card) Fields() []ent.Field {
|
||||
Sensitive(),
|
||||
|
||||
field.Int("card").
|
||||
Immutable().
|
||||
DefaultFunc(func() int {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
var a = rand.Intn(20)
|
||||
var a = rand.Intn(10)
|
||||
if a == 1 {
|
||||
card = rand.Intn(3) + 123
|
||||
} else if a == 2 {
|
||||
card = rand.Intn(14) + 1
|
||||
card = rand.Intn(16)
|
||||
} else {
|
||||
card = 0
|
||||
}
|
||||
|
||||
if card == 13 {
|
||||
card = 2
|
||||
}
|
||||
|
||||
// 2023/04/09 premium card id:15
|
||||
if card == 15 {
|
||||
card = 3
|
||||
}
|
||||
|
||||
if card == 16 {
|
||||
card = 4
|
||||
}
|
||||
|
||||
if card == 17 {
|
||||
card = 5
|
||||
}
|
||||
|
||||
if card == 18 {
|
||||
card = 6
|
||||
}
|
||||
|
||||
return card
|
||||
}).
|
||||
Optional(),
|
||||
@@ -45,7 +66,7 @@ func (Card) Fields() []ent.Field {
|
||||
field.String("skill").
|
||||
DefaultFunc(func() string {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
var a = rand.Intn(30)
|
||||
var a = rand.Intn(12)
|
||||
if a == 1 {
|
||||
skill = "critical"
|
||||
} else {
|
||||
@@ -62,7 +83,7 @@ func (Card) Fields() []ent.Field {
|
||||
//Immutable().
|
||||
DefaultFunc(func() string {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
var a = rand.Intn(40)
|
||||
var a = rand.Intn(10)
|
||||
if a == 1 {
|
||||
super = "super"
|
||||
} else {
|
||||
@@ -83,19 +104,19 @@ func (Card) Fields() []ent.Field {
|
||||
//Immutable().
|
||||
DefaultFunc(func() int {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
var cp = 1 + rand.Intn(200)
|
||||
var cp = 1 + rand.Intn(100)
|
||||
if cp == 2 {
|
||||
cp = 50 + rand.Intn(300)
|
||||
cp = 50 + rand.Intn(150)
|
||||
}
|
||||
if card >= 1 {
|
||||
cp = 200 + cp + rand.Intn(500)
|
||||
cp = 150 + cp + rand.Intn(300)
|
||||
}
|
||||
if super == "super" {
|
||||
cp = 400 + cp + rand.Intn(700)
|
||||
cp = 300 + cp + rand.Intn(500)
|
||||
}
|
||||
|
||||
if skill == "critical" {
|
||||
cp = 400 + cp + rand.Intn(700)
|
||||
cp = 300 + cp + rand.Intn(500)
|
||||
}
|
||||
|
||||
if card == 22 {
|
||||
@@ -111,15 +132,10 @@ func (Card) Fields() []ent.Field {
|
||||
Optional(),
|
||||
|
||||
field.String("url").
|
||||
Immutable().
|
||||
Default(url).
|
||||
Optional(),
|
||||
|
||||
field.Int("count").
|
||||
Optional(),
|
||||
|
||||
field.String("author").
|
||||
Optional(),
|
||||
|
||||
field.Time("created_at").
|
||||
Immutable().
|
||||
Optional().
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// Game holds the schema definition for the Game entity.
|
||||
type Ma struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (Ma) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
|
||||
field.String("password").
|
||||
NotEmpty().
|
||||
Immutable().
|
||||
Sensitive(),
|
||||
|
||||
field.String("token").
|
||||
Optional().
|
||||
Sensitive(),
|
||||
|
||||
field.Bool("limit").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.Int("count").
|
||||
Optional(),
|
||||
|
||||
field.String("handle").
|
||||
Optional(),
|
||||
|
||||
field.String("text").
|
||||
Optional(),
|
||||
|
||||
field.String("did").
|
||||
Optional(),
|
||||
|
||||
field.String("avatar").
|
||||
Optional(),
|
||||
|
||||
field.String("cid").
|
||||
Optional(),
|
||||
|
||||
field.String("uri").
|
||||
Optional(),
|
||||
|
||||
field.String("cid_root").
|
||||
Optional(),
|
||||
|
||||
field.String("uri_root").
|
||||
Optional(),
|
||||
|
||||
field.String("root").
|
||||
Optional(),
|
||||
|
||||
field.String("rkey").
|
||||
Optional(),
|
||||
|
||||
field.String("bsky_url").
|
||||
Optional(),
|
||||
|
||||
field.String("comment").
|
||||
Optional(),
|
||||
|
||||
field.String("blog").
|
||||
Optional(),
|
||||
|
||||
field.String("blog_url").
|
||||
Optional(),
|
||||
|
||||
field.String("domain").
|
||||
Optional(),
|
||||
|
||||
field.String("host").
|
||||
Optional(),
|
||||
|
||||
field.String("feed").
|
||||
Optional(),
|
||||
|
||||
field.Time("updated_at").
|
||||
Optional(),
|
||||
|
||||
field.Time("created_at").
|
||||
Immutable().
|
||||
Optional().
|
||||
Default(func() time.Time {
|
||||
return time.Now().In(jst)
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
func (Ma) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("owner", User.Type).
|
||||
Ref("ma").
|
||||
Unique().
|
||||
Required(),
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// Game holds the schema definition for the Game entity.
|
||||
type Sev struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (Sev) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
|
||||
field.String("password").
|
||||
NotEmpty().
|
||||
Immutable().
|
||||
Sensitive(),
|
||||
|
||||
field.String("token").
|
||||
Optional().
|
||||
Sensitive(),
|
||||
|
||||
field.Bool("limit").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.Int("count").
|
||||
Optional(),
|
||||
|
||||
field.String("handle").
|
||||
Optional(),
|
||||
|
||||
field.String("did").
|
||||
Optional(),
|
||||
|
||||
field.Int("uid").
|
||||
Optional(),
|
||||
|
||||
field.Int("cid").
|
||||
Optional(),
|
||||
|
||||
field.Int("cp").
|
||||
Optional(),
|
||||
|
||||
field.Int("card").
|
||||
Optional(),
|
||||
|
||||
field.Time("updated_at").
|
||||
Optional(),
|
||||
|
||||
field.Time("created_at").
|
||||
Immutable().
|
||||
Optional().
|
||||
Default(func() time.Time {
|
||||
return time.Now().In(jst)
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
func (Sev) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("owner", User.Type).
|
||||
Ref("sev").
|
||||
Unique().
|
||||
Required(),
|
||||
}
|
||||
}
|
||||
110
ent/schema/ue.go
110
ent/schema/ue.go
@@ -1,110 +0,0 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// Game holds the schema definition for the Game entity.
|
||||
type Ue struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (Ue) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
|
||||
field.Bool("limit").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.Bool("limit_boss").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.Bool("limit_item").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.String("password").
|
||||
NotEmpty().
|
||||
Immutable().
|
||||
Sensitive(),
|
||||
|
||||
field.Int("lv").
|
||||
Optional(),
|
||||
|
||||
field.Int("lv_point").
|
||||
Optional(),
|
||||
|
||||
field.Int("model").
|
||||
Optional(),
|
||||
|
||||
field.Int("sword").
|
||||
Optional(),
|
||||
|
||||
field.Int("card").
|
||||
Optional(),
|
||||
|
||||
field.String("mode").
|
||||
Optional(),
|
||||
|
||||
field.String("token").
|
||||
Optional().
|
||||
Sensitive(),
|
||||
|
||||
field.Int("cp").
|
||||
Optional(),
|
||||
|
||||
field.Int("count").
|
||||
Optional(),
|
||||
|
||||
field.Int("location_x").
|
||||
Optional(),
|
||||
|
||||
field.Int("location_y").
|
||||
Optional(),
|
||||
|
||||
field.Int("location_z").
|
||||
Optional(),
|
||||
|
||||
field.Int("location_n").
|
||||
Optional(),
|
||||
|
||||
field.String("author").
|
||||
Optional(),
|
||||
|
||||
field.String("game_lv").
|
||||
Optional(),
|
||||
|
||||
field.String("game_exp").
|
||||
Optional(),
|
||||
|
||||
field.String("game_id").
|
||||
Optional(),
|
||||
|
||||
field.Int("game_story").
|
||||
Optional(),
|
||||
|
||||
field.String("game_ep").
|
||||
Optional(),
|
||||
|
||||
field.Time("created_at").
|
||||
Immutable().
|
||||
Optional().
|
||||
Default(func() time.Time {
|
||||
return time.Now().In(jst)
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
func (Ue) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("owner", User.Type).
|
||||
Ref("ue").
|
||||
Unique().
|
||||
Required(),
|
||||
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,8 @@ type User struct {
|
||||
}
|
||||
|
||||
func Nextime() (tt string){
|
||||
//t := time.Now().In(jst)
|
||||
//t := time.Now().Add(time.Hour * 24 * 1).In(jst)
|
||||
t := time.Now().AddDate(0, 0, -1).In(jst)
|
||||
t := time.Now().In(jst)
|
||||
//t := time.Now().Add(time.Hour * 24 * 1).In(jst)
|
||||
tt = t.Format("20060102")
|
||||
return
|
||||
}
|
||||
@@ -39,22 +38,6 @@ func (User) Fields() []ent.Field {
|
||||
field.String("did").
|
||||
Optional(),
|
||||
|
||||
field.Bool("member").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.Bool("book").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.Bool("manga").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.Bool("badge").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.Bool("bsky").
|
||||
Default(false).
|
||||
Optional(),
|
||||
@@ -99,18 +82,6 @@ func (User) Fields() []ent.Field {
|
||||
return time.Now().In(jst)
|
||||
}),
|
||||
|
||||
field.Time("server_at").
|
||||
Optional().
|
||||
Default(func() time.Time {
|
||||
return time.Now().In(jst)
|
||||
}),
|
||||
|
||||
field.Time("egg_at").
|
||||
Optional().
|
||||
Default(func() time.Time {
|
||||
return time.Now().In(jst)
|
||||
}),
|
||||
|
||||
field.Int("luck").
|
||||
Optional(),
|
||||
|
||||
@@ -169,109 +140,6 @@ func (User) Fields() []ent.Field {
|
||||
Default(Nextime()).
|
||||
Optional(),
|
||||
|
||||
field.Int("room").
|
||||
Optional(),
|
||||
|
||||
field.Bool("model").
|
||||
Optional(),
|
||||
|
||||
field.Time("model_at").
|
||||
Optional().
|
||||
Default(func() time.Time {
|
||||
return time.Now().In(jst)
|
||||
}),
|
||||
|
||||
field.Int("model_attack").
|
||||
Optional(),
|
||||
|
||||
field.Int("model_limit").
|
||||
Optional(),
|
||||
|
||||
field.Int("model_skill").
|
||||
Optional(),
|
||||
|
||||
field.Int("model_mode").
|
||||
Optional(),
|
||||
|
||||
field.Int("model_critical").
|
||||
Optional(),
|
||||
|
||||
field.Int("model_critical_d").
|
||||
Optional(),
|
||||
|
||||
field.Bool("game").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.Bool("game_test").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.Bool("game_end").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.Bool("game_account").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.Int("game_lv").
|
||||
Optional(),
|
||||
|
||||
field.Int("game_exp").
|
||||
Optional(),
|
||||
|
||||
field.Int("game_story").
|
||||
Optional(),
|
||||
|
||||
field.Bool("game_limit").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.Int("coin").
|
||||
Optional(),
|
||||
|
||||
field.Bool("coin_open").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.Time("coin_at").
|
||||
Optional().
|
||||
Default(func() time.Time {
|
||||
return time.Now().In(jst)
|
||||
}),
|
||||
|
||||
field.Float("planet").
|
||||
Optional(),
|
||||
|
||||
field.Time("planet_at").
|
||||
Optional().
|
||||
Default(func() time.Time {
|
||||
return time.Now().In(jst)
|
||||
}),
|
||||
|
||||
field.Bool("login").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.Time("login_at").
|
||||
Optional().
|
||||
Default(func() time.Time {
|
||||
return time.Now().In(jst)
|
||||
}),
|
||||
|
||||
field.Int("location_x").
|
||||
Optional(),
|
||||
|
||||
field.Int("location_y").
|
||||
Optional(),
|
||||
|
||||
field.Int("location_z").
|
||||
Optional(),
|
||||
|
||||
field.Int("location_n").
|
||||
Optional(),
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,10 +153,6 @@ func (User) Indexes() []ent.Index {
|
||||
func (User) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.To("card", Card.Type),
|
||||
edge.To("ue", Ue.Type),
|
||||
edge.To("ma", Ma.Type),
|
||||
edge.To("sev", Sev.Type),
|
||||
//Unique(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
268
ent/sev.go
268
ent/sev.go
@@ -1,268 +0,0 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/sev"
|
||||
"api/ent/user"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// Sev is the model entity for the Sev schema.
|
||||
type Sev struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// Password holds the value of the "password" field.
|
||||
Password string `json:"-"`
|
||||
// Token holds the value of the "token" field.
|
||||
Token string `json:"-"`
|
||||
// Limit holds the value of the "limit" field.
|
||||
Limit bool `json:"limit,omitempty"`
|
||||
// Count holds the value of the "count" field.
|
||||
Count int `json:"count,omitempty"`
|
||||
// Handle holds the value of the "handle" field.
|
||||
Handle string `json:"handle,omitempty"`
|
||||
// Did holds the value of the "did" field.
|
||||
Did string `json:"did,omitempty"`
|
||||
// UID holds the value of the "uid" field.
|
||||
UID int `json:"uid,omitempty"`
|
||||
// Cid holds the value of the "cid" field.
|
||||
Cid int `json:"cid,omitempty"`
|
||||
// Cp holds the value of the "cp" field.
|
||||
Cp int `json:"cp,omitempty"`
|
||||
// Card holds the value of the "card" field.
|
||||
Card int `json:"card,omitempty"`
|
||||
// UpdatedAt holds the value of the "updated_at" field.
|
||||
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||
// CreatedAt holds the value of the "created_at" field.
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the SevQuery when eager-loading is set.
|
||||
Edges SevEdges `json:"edges"`
|
||||
user_sev *int
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// SevEdges holds the relations/edges for other nodes in the graph.
|
||||
type SevEdges struct {
|
||||
// Owner holds the value of the owner edge.
|
||||
Owner *User `json:"owner,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [1]bool
|
||||
}
|
||||
|
||||
// OwnerOrErr returns the Owner value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e SevEdges) OwnerOrErr() (*User, error) {
|
||||
if e.loadedTypes[0] {
|
||||
if e.Owner == nil {
|
||||
// Edge was loaded but was not found.
|
||||
return nil, &NotFoundError{label: user.Label}
|
||||
}
|
||||
return e.Owner, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "owner"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Sev) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case sev.FieldLimit:
|
||||
values[i] = new(sql.NullBool)
|
||||
case sev.FieldID, sev.FieldCount, sev.FieldUID, sev.FieldCid, sev.FieldCp, sev.FieldCard:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case sev.FieldPassword, sev.FieldToken, sev.FieldHandle, sev.FieldDid:
|
||||
values[i] = new(sql.NullString)
|
||||
case sev.FieldUpdatedAt, sev.FieldCreatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case sev.ForeignKeys[0]: // user_sev
|
||||
values[i] = new(sql.NullInt64)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Sev fields.
|
||||
func (s *Sev) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case sev.FieldID:
|
||||
value, ok := values[i].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
s.ID = int(value.Int64)
|
||||
case sev.FieldPassword:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field password", values[i])
|
||||
} else if value.Valid {
|
||||
s.Password = value.String
|
||||
}
|
||||
case sev.FieldToken:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field token", values[i])
|
||||
} else if value.Valid {
|
||||
s.Token = value.String
|
||||
}
|
||||
case sev.FieldLimit:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field limit", values[i])
|
||||
} else if value.Valid {
|
||||
s.Limit = value.Bool
|
||||
}
|
||||
case sev.FieldCount:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field count", values[i])
|
||||
} else if value.Valid {
|
||||
s.Count = int(value.Int64)
|
||||
}
|
||||
case sev.FieldHandle:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field handle", values[i])
|
||||
} else if value.Valid {
|
||||
s.Handle = value.String
|
||||
}
|
||||
case sev.FieldDid:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field did", values[i])
|
||||
} else if value.Valid {
|
||||
s.Did = value.String
|
||||
}
|
||||
case sev.FieldUID:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field uid", values[i])
|
||||
} else if value.Valid {
|
||||
s.UID = int(value.Int64)
|
||||
}
|
||||
case sev.FieldCid:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field cid", values[i])
|
||||
} else if value.Valid {
|
||||
s.Cid = int(value.Int64)
|
||||
}
|
||||
case sev.FieldCp:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field cp", values[i])
|
||||
} else if value.Valid {
|
||||
s.Cp = int(value.Int64)
|
||||
}
|
||||
case sev.FieldCard:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field card", values[i])
|
||||
} else if value.Valid {
|
||||
s.Card = int(value.Int64)
|
||||
}
|
||||
case sev.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
s.UpdatedAt = value.Time
|
||||
}
|
||||
case sev.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
s.CreatedAt = value.Time
|
||||
}
|
||||
case sev.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for edge-field user_sev", value)
|
||||
} else if value.Valid {
|
||||
s.user_sev = new(int)
|
||||
*s.user_sev = int(value.Int64)
|
||||
}
|
||||
default:
|
||||
s.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Sev.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (s *Sev) Value(name string) (ent.Value, error) {
|
||||
return s.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryOwner queries the "owner" edge of the Sev entity.
|
||||
func (s *Sev) QueryOwner() *UserQuery {
|
||||
return NewSevClient(s.config).QueryOwner(s)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Sev.
|
||||
// Note that you need to call Sev.Unwrap() before calling this method if this Sev
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (s *Sev) Update() *SevUpdateOne {
|
||||
return NewSevClient(s.config).UpdateOne(s)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Sev entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (s *Sev) Unwrap() *Sev {
|
||||
_tx, ok := s.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Sev is not a transactional entity")
|
||||
}
|
||||
s.config.driver = _tx.drv
|
||||
return s
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (s *Sev) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Sev(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", s.ID))
|
||||
builder.WriteString("password=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("token=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("limit=")
|
||||
builder.WriteString(fmt.Sprintf("%v", s.Limit))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("count=")
|
||||
builder.WriteString(fmt.Sprintf("%v", s.Count))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("handle=")
|
||||
builder.WriteString(s.Handle)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("did=")
|
||||
builder.WriteString(s.Did)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("uid=")
|
||||
builder.WriteString(fmt.Sprintf("%v", s.UID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("cid=")
|
||||
builder.WriteString(fmt.Sprintf("%v", s.Cid))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("cp=")
|
||||
builder.WriteString(fmt.Sprintf("%v", s.Cp))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("card=")
|
||||
builder.WriteString(fmt.Sprintf("%v", s.Card))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(s.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(s.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// Sevs is a parsable slice of Sev.
|
||||
type Sevs []*Sev
|
||||
181
ent/sev/sev.go
181
ent/sev/sev.go
@@ -1,181 +0,0 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package sev
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the sev type in the database.
|
||||
Label = "sev"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldPassword holds the string denoting the password field in the database.
|
||||
FieldPassword = "password"
|
||||
// FieldToken holds the string denoting the token field in the database.
|
||||
FieldToken = "token"
|
||||
// FieldLimit holds the string denoting the limit field in the database.
|
||||
FieldLimit = "limit"
|
||||
// FieldCount holds the string denoting the count field in the database.
|
||||
FieldCount = "count"
|
||||
// FieldHandle holds the string denoting the handle field in the database.
|
||||
FieldHandle = "handle"
|
||||
// FieldDid holds the string denoting the did field in the database.
|
||||
FieldDid = "did"
|
||||
// FieldUID holds the string denoting the uid field in the database.
|
||||
FieldUID = "uid"
|
||||
// FieldCid holds the string denoting the cid field in the database.
|
||||
FieldCid = "cid"
|
||||
// FieldCp holds the string denoting the cp field in the database.
|
||||
FieldCp = "cp"
|
||||
// FieldCard holds the string denoting the card field in the database.
|
||||
FieldCard = "card"
|
||||
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||
FieldUpdatedAt = "updated_at"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// EdgeOwner holds the string denoting the owner edge name in mutations.
|
||||
EdgeOwner = "owner"
|
||||
// Table holds the table name of the sev in the database.
|
||||
Table = "sevs"
|
||||
// OwnerTable is the table that holds the owner relation/edge.
|
||||
OwnerTable = "sevs"
|
||||
// OwnerInverseTable is the table name for the User entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "user" package.
|
||||
OwnerInverseTable = "users"
|
||||
// OwnerColumn is the table column denoting the owner relation/edge.
|
||||
OwnerColumn = "user_sev"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for sev fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldPassword,
|
||||
FieldToken,
|
||||
FieldLimit,
|
||||
FieldCount,
|
||||
FieldHandle,
|
||||
FieldDid,
|
||||
FieldUID,
|
||||
FieldCid,
|
||||
FieldCp,
|
||||
FieldCard,
|
||||
FieldUpdatedAt,
|
||||
FieldCreatedAt,
|
||||
}
|
||||
|
||||
// ForeignKeys holds the SQL foreign-keys that are owned by the "sevs"
|
||||
// table and are not defined as standalone fields in the schema.
|
||||
var ForeignKeys = []string{
|
||||
"user_sev",
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
for i := range ForeignKeys {
|
||||
if column == ForeignKeys[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
PasswordValidator func(string) error
|
||||
// DefaultLimit holds the default value on creation for the "limit" field.
|
||||
DefaultLimit bool
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() time.Time
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the Sev queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPassword orders the results by the password field.
|
||||
func ByPassword(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPassword, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByToken orders the results by the token field.
|
||||
func ByToken(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldToken, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLimit orders the results by the limit field.
|
||||
func ByLimit(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLimit, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCount orders the results by the count field.
|
||||
func ByCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCount, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByHandle orders the results by the handle field.
|
||||
func ByHandle(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldHandle, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDid orders the results by the did field.
|
||||
func ByDid(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDid, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUID orders the results by the uid field.
|
||||
func ByUID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCid orders the results by the cid field.
|
||||
func ByCid(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCid, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCp orders the results by the cp field.
|
||||
func ByCp(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCp, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCard orders the results by the card field.
|
||||
func ByCard(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCard, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUpdatedAt orders the results by the updated_at field.
|
||||
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByOwnerField orders the results by owner field.
|
||||
func ByOwnerField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newOwnerStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
func newOwnerStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(OwnerInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn),
|
||||
)
|
||||
}
|
||||
831
ent/sev/where.go
831
ent/sev/where.go
@@ -1,831 +0,0 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package sev
|
||||
|
||||
import (
|
||||
"api/ent/predicate"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// Password applies equality check predicate on the "password" field. It's identical to PasswordEQ.
|
||||
func Password(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldPassword, v))
|
||||
}
|
||||
|
||||
// Token applies equality check predicate on the "token" field. It's identical to TokenEQ.
|
||||
func Token(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldToken, v))
|
||||
}
|
||||
|
||||
// Limit applies equality check predicate on the "limit" field. It's identical to LimitEQ.
|
||||
func Limit(v bool) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldLimit, v))
|
||||
}
|
||||
|
||||
// Count applies equality check predicate on the "count" field. It's identical to CountEQ.
|
||||
func Count(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldCount, v))
|
||||
}
|
||||
|
||||
// Handle applies equality check predicate on the "handle" field. It's identical to HandleEQ.
|
||||
func Handle(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldHandle, v))
|
||||
}
|
||||
|
||||
// Did applies equality check predicate on the "did" field. It's identical to DidEQ.
|
||||
func Did(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldDid, v))
|
||||
}
|
||||
|
||||
// UID applies equality check predicate on the "uid" field. It's identical to UIDEQ.
|
||||
func UID(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldUID, v))
|
||||
}
|
||||
|
||||
// Cid applies equality check predicate on the "cid" field. It's identical to CidEQ.
|
||||
func Cid(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldCid, v))
|
||||
}
|
||||
|
||||
// Cp applies equality check predicate on the "cp" field. It's identical to CpEQ.
|
||||
func Cp(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldCp, v))
|
||||
}
|
||||
|
||||
// Card applies equality check predicate on the "card" field. It's identical to CardEQ.
|
||||
func Card(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldCard, v))
|
||||
}
|
||||
|
||||
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
|
||||
func UpdatedAt(v time.Time) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v time.Time) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// PasswordEQ applies the EQ predicate on the "password" field.
|
||||
func PasswordEQ(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordNEQ applies the NEQ predicate on the "password" field.
|
||||
func PasswordNEQ(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNEQ(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordIn applies the In predicate on the "password" field.
|
||||
func PasswordIn(vs ...string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIn(FieldPassword, vs...))
|
||||
}
|
||||
|
||||
// PasswordNotIn applies the NotIn predicate on the "password" field.
|
||||
func PasswordNotIn(vs ...string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotIn(FieldPassword, vs...))
|
||||
}
|
||||
|
||||
// PasswordGT applies the GT predicate on the "password" field.
|
||||
func PasswordGT(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGT(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordGTE applies the GTE predicate on the "password" field.
|
||||
func PasswordGTE(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGTE(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordLT applies the LT predicate on the "password" field.
|
||||
func PasswordLT(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLT(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordLTE applies the LTE predicate on the "password" field.
|
||||
func PasswordLTE(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLTE(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordContains applies the Contains predicate on the "password" field.
|
||||
func PasswordContains(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldContains(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordHasPrefix applies the HasPrefix predicate on the "password" field.
|
||||
func PasswordHasPrefix(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldHasPrefix(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordHasSuffix applies the HasSuffix predicate on the "password" field.
|
||||
func PasswordHasSuffix(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldHasSuffix(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordEqualFold applies the EqualFold predicate on the "password" field.
|
||||
func PasswordEqualFold(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEqualFold(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordContainsFold applies the ContainsFold predicate on the "password" field.
|
||||
func PasswordContainsFold(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldContainsFold(FieldPassword, v))
|
||||
}
|
||||
|
||||
// TokenEQ applies the EQ predicate on the "token" field.
|
||||
func TokenEQ(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldToken, v))
|
||||
}
|
||||
|
||||
// TokenNEQ applies the NEQ predicate on the "token" field.
|
||||
func TokenNEQ(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNEQ(FieldToken, v))
|
||||
}
|
||||
|
||||
// TokenIn applies the In predicate on the "token" field.
|
||||
func TokenIn(vs ...string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIn(FieldToken, vs...))
|
||||
}
|
||||
|
||||
// TokenNotIn applies the NotIn predicate on the "token" field.
|
||||
func TokenNotIn(vs ...string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotIn(FieldToken, vs...))
|
||||
}
|
||||
|
||||
// TokenGT applies the GT predicate on the "token" field.
|
||||
func TokenGT(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGT(FieldToken, v))
|
||||
}
|
||||
|
||||
// TokenGTE applies the GTE predicate on the "token" field.
|
||||
func TokenGTE(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGTE(FieldToken, v))
|
||||
}
|
||||
|
||||
// TokenLT applies the LT predicate on the "token" field.
|
||||
func TokenLT(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLT(FieldToken, v))
|
||||
}
|
||||
|
||||
// TokenLTE applies the LTE predicate on the "token" field.
|
||||
func TokenLTE(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLTE(FieldToken, v))
|
||||
}
|
||||
|
||||
// TokenContains applies the Contains predicate on the "token" field.
|
||||
func TokenContains(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldContains(FieldToken, v))
|
||||
}
|
||||
|
||||
// TokenHasPrefix applies the HasPrefix predicate on the "token" field.
|
||||
func TokenHasPrefix(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldHasPrefix(FieldToken, v))
|
||||
}
|
||||
|
||||
// TokenHasSuffix applies the HasSuffix predicate on the "token" field.
|
||||
func TokenHasSuffix(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldHasSuffix(FieldToken, v))
|
||||
}
|
||||
|
||||
// TokenIsNil applies the IsNil predicate on the "token" field.
|
||||
func TokenIsNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIsNull(FieldToken))
|
||||
}
|
||||
|
||||
// TokenNotNil applies the NotNil predicate on the "token" field.
|
||||
func TokenNotNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotNull(FieldToken))
|
||||
}
|
||||
|
||||
// TokenEqualFold applies the EqualFold predicate on the "token" field.
|
||||
func TokenEqualFold(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEqualFold(FieldToken, v))
|
||||
}
|
||||
|
||||
// TokenContainsFold applies the ContainsFold predicate on the "token" field.
|
||||
func TokenContainsFold(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldContainsFold(FieldToken, v))
|
||||
}
|
||||
|
||||
// LimitEQ applies the EQ predicate on the "limit" field.
|
||||
func LimitEQ(v bool) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldLimit, v))
|
||||
}
|
||||
|
||||
// LimitNEQ applies the NEQ predicate on the "limit" field.
|
||||
func LimitNEQ(v bool) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNEQ(FieldLimit, v))
|
||||
}
|
||||
|
||||
// LimitIsNil applies the IsNil predicate on the "limit" field.
|
||||
func LimitIsNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIsNull(FieldLimit))
|
||||
}
|
||||
|
||||
// LimitNotNil applies the NotNil predicate on the "limit" field.
|
||||
func LimitNotNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotNull(FieldLimit))
|
||||
}
|
||||
|
||||
// CountEQ applies the EQ predicate on the "count" field.
|
||||
func CountEQ(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldCount, v))
|
||||
}
|
||||
|
||||
// CountNEQ applies the NEQ predicate on the "count" field.
|
||||
func CountNEQ(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNEQ(FieldCount, v))
|
||||
}
|
||||
|
||||
// CountIn applies the In predicate on the "count" field.
|
||||
func CountIn(vs ...int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIn(FieldCount, vs...))
|
||||
}
|
||||
|
||||
// CountNotIn applies the NotIn predicate on the "count" field.
|
||||
func CountNotIn(vs ...int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotIn(FieldCount, vs...))
|
||||
}
|
||||
|
||||
// CountGT applies the GT predicate on the "count" field.
|
||||
func CountGT(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGT(FieldCount, v))
|
||||
}
|
||||
|
||||
// CountGTE applies the GTE predicate on the "count" field.
|
||||
func CountGTE(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGTE(FieldCount, v))
|
||||
}
|
||||
|
||||
// CountLT applies the LT predicate on the "count" field.
|
||||
func CountLT(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLT(FieldCount, v))
|
||||
}
|
||||
|
||||
// CountLTE applies the LTE predicate on the "count" field.
|
||||
func CountLTE(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLTE(FieldCount, v))
|
||||
}
|
||||
|
||||
// CountIsNil applies the IsNil predicate on the "count" field.
|
||||
func CountIsNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIsNull(FieldCount))
|
||||
}
|
||||
|
||||
// CountNotNil applies the NotNil predicate on the "count" field.
|
||||
func CountNotNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotNull(FieldCount))
|
||||
}
|
||||
|
||||
// HandleEQ applies the EQ predicate on the "handle" field.
|
||||
func HandleEQ(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldHandle, v))
|
||||
}
|
||||
|
||||
// HandleNEQ applies the NEQ predicate on the "handle" field.
|
||||
func HandleNEQ(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNEQ(FieldHandle, v))
|
||||
}
|
||||
|
||||
// HandleIn applies the In predicate on the "handle" field.
|
||||
func HandleIn(vs ...string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIn(FieldHandle, vs...))
|
||||
}
|
||||
|
||||
// HandleNotIn applies the NotIn predicate on the "handle" field.
|
||||
func HandleNotIn(vs ...string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotIn(FieldHandle, vs...))
|
||||
}
|
||||
|
||||
// HandleGT applies the GT predicate on the "handle" field.
|
||||
func HandleGT(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGT(FieldHandle, v))
|
||||
}
|
||||
|
||||
// HandleGTE applies the GTE predicate on the "handle" field.
|
||||
func HandleGTE(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGTE(FieldHandle, v))
|
||||
}
|
||||
|
||||
// HandleLT applies the LT predicate on the "handle" field.
|
||||
func HandleLT(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLT(FieldHandle, v))
|
||||
}
|
||||
|
||||
// HandleLTE applies the LTE predicate on the "handle" field.
|
||||
func HandleLTE(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLTE(FieldHandle, v))
|
||||
}
|
||||
|
||||
// HandleContains applies the Contains predicate on the "handle" field.
|
||||
func HandleContains(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldContains(FieldHandle, v))
|
||||
}
|
||||
|
||||
// HandleHasPrefix applies the HasPrefix predicate on the "handle" field.
|
||||
func HandleHasPrefix(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldHasPrefix(FieldHandle, v))
|
||||
}
|
||||
|
||||
// HandleHasSuffix applies the HasSuffix predicate on the "handle" field.
|
||||
func HandleHasSuffix(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldHasSuffix(FieldHandle, v))
|
||||
}
|
||||
|
||||
// HandleIsNil applies the IsNil predicate on the "handle" field.
|
||||
func HandleIsNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIsNull(FieldHandle))
|
||||
}
|
||||
|
||||
// HandleNotNil applies the NotNil predicate on the "handle" field.
|
||||
func HandleNotNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotNull(FieldHandle))
|
||||
}
|
||||
|
||||
// HandleEqualFold applies the EqualFold predicate on the "handle" field.
|
||||
func HandleEqualFold(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEqualFold(FieldHandle, v))
|
||||
}
|
||||
|
||||
// HandleContainsFold applies the ContainsFold predicate on the "handle" field.
|
||||
func HandleContainsFold(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldContainsFold(FieldHandle, v))
|
||||
}
|
||||
|
||||
// DidEQ applies the EQ predicate on the "did" field.
|
||||
func DidEQ(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldDid, v))
|
||||
}
|
||||
|
||||
// DidNEQ applies the NEQ predicate on the "did" field.
|
||||
func DidNEQ(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNEQ(FieldDid, v))
|
||||
}
|
||||
|
||||
// DidIn applies the In predicate on the "did" field.
|
||||
func DidIn(vs ...string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIn(FieldDid, vs...))
|
||||
}
|
||||
|
||||
// DidNotIn applies the NotIn predicate on the "did" field.
|
||||
func DidNotIn(vs ...string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotIn(FieldDid, vs...))
|
||||
}
|
||||
|
||||
// DidGT applies the GT predicate on the "did" field.
|
||||
func DidGT(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGT(FieldDid, v))
|
||||
}
|
||||
|
||||
// DidGTE applies the GTE predicate on the "did" field.
|
||||
func DidGTE(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGTE(FieldDid, v))
|
||||
}
|
||||
|
||||
// DidLT applies the LT predicate on the "did" field.
|
||||
func DidLT(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLT(FieldDid, v))
|
||||
}
|
||||
|
||||
// DidLTE applies the LTE predicate on the "did" field.
|
||||
func DidLTE(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLTE(FieldDid, v))
|
||||
}
|
||||
|
||||
// DidContains applies the Contains predicate on the "did" field.
|
||||
func DidContains(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldContains(FieldDid, v))
|
||||
}
|
||||
|
||||
// DidHasPrefix applies the HasPrefix predicate on the "did" field.
|
||||
func DidHasPrefix(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldHasPrefix(FieldDid, v))
|
||||
}
|
||||
|
||||
// DidHasSuffix applies the HasSuffix predicate on the "did" field.
|
||||
func DidHasSuffix(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldHasSuffix(FieldDid, v))
|
||||
}
|
||||
|
||||
// DidIsNil applies the IsNil predicate on the "did" field.
|
||||
func DidIsNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIsNull(FieldDid))
|
||||
}
|
||||
|
||||
// DidNotNil applies the NotNil predicate on the "did" field.
|
||||
func DidNotNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotNull(FieldDid))
|
||||
}
|
||||
|
||||
// DidEqualFold applies the EqualFold predicate on the "did" field.
|
||||
func DidEqualFold(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEqualFold(FieldDid, v))
|
||||
}
|
||||
|
||||
// DidContainsFold applies the ContainsFold predicate on the "did" field.
|
||||
func DidContainsFold(v string) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldContainsFold(FieldDid, v))
|
||||
}
|
||||
|
||||
// UIDEQ applies the EQ predicate on the "uid" field.
|
||||
func UIDEQ(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldUID, v))
|
||||
}
|
||||
|
||||
// UIDNEQ applies the NEQ predicate on the "uid" field.
|
||||
func UIDNEQ(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNEQ(FieldUID, v))
|
||||
}
|
||||
|
||||
// UIDIn applies the In predicate on the "uid" field.
|
||||
func UIDIn(vs ...int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIn(FieldUID, vs...))
|
||||
}
|
||||
|
||||
// UIDNotIn applies the NotIn predicate on the "uid" field.
|
||||
func UIDNotIn(vs ...int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotIn(FieldUID, vs...))
|
||||
}
|
||||
|
||||
// UIDGT applies the GT predicate on the "uid" field.
|
||||
func UIDGT(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGT(FieldUID, v))
|
||||
}
|
||||
|
||||
// UIDGTE applies the GTE predicate on the "uid" field.
|
||||
func UIDGTE(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGTE(FieldUID, v))
|
||||
}
|
||||
|
||||
// UIDLT applies the LT predicate on the "uid" field.
|
||||
func UIDLT(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLT(FieldUID, v))
|
||||
}
|
||||
|
||||
// UIDLTE applies the LTE predicate on the "uid" field.
|
||||
func UIDLTE(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLTE(FieldUID, v))
|
||||
}
|
||||
|
||||
// UIDIsNil applies the IsNil predicate on the "uid" field.
|
||||
func UIDIsNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIsNull(FieldUID))
|
||||
}
|
||||
|
||||
// UIDNotNil applies the NotNil predicate on the "uid" field.
|
||||
func UIDNotNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotNull(FieldUID))
|
||||
}
|
||||
|
||||
// CidEQ applies the EQ predicate on the "cid" field.
|
||||
func CidEQ(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldCid, v))
|
||||
}
|
||||
|
||||
// CidNEQ applies the NEQ predicate on the "cid" field.
|
||||
func CidNEQ(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNEQ(FieldCid, v))
|
||||
}
|
||||
|
||||
// CidIn applies the In predicate on the "cid" field.
|
||||
func CidIn(vs ...int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIn(FieldCid, vs...))
|
||||
}
|
||||
|
||||
// CidNotIn applies the NotIn predicate on the "cid" field.
|
||||
func CidNotIn(vs ...int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotIn(FieldCid, vs...))
|
||||
}
|
||||
|
||||
// CidGT applies the GT predicate on the "cid" field.
|
||||
func CidGT(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGT(FieldCid, v))
|
||||
}
|
||||
|
||||
// CidGTE applies the GTE predicate on the "cid" field.
|
||||
func CidGTE(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGTE(FieldCid, v))
|
||||
}
|
||||
|
||||
// CidLT applies the LT predicate on the "cid" field.
|
||||
func CidLT(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLT(FieldCid, v))
|
||||
}
|
||||
|
||||
// CidLTE applies the LTE predicate on the "cid" field.
|
||||
func CidLTE(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLTE(FieldCid, v))
|
||||
}
|
||||
|
||||
// CidIsNil applies the IsNil predicate on the "cid" field.
|
||||
func CidIsNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIsNull(FieldCid))
|
||||
}
|
||||
|
||||
// CidNotNil applies the NotNil predicate on the "cid" field.
|
||||
func CidNotNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotNull(FieldCid))
|
||||
}
|
||||
|
||||
// CpEQ applies the EQ predicate on the "cp" field.
|
||||
func CpEQ(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldCp, v))
|
||||
}
|
||||
|
||||
// CpNEQ applies the NEQ predicate on the "cp" field.
|
||||
func CpNEQ(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNEQ(FieldCp, v))
|
||||
}
|
||||
|
||||
// CpIn applies the In predicate on the "cp" field.
|
||||
func CpIn(vs ...int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIn(FieldCp, vs...))
|
||||
}
|
||||
|
||||
// CpNotIn applies the NotIn predicate on the "cp" field.
|
||||
func CpNotIn(vs ...int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotIn(FieldCp, vs...))
|
||||
}
|
||||
|
||||
// CpGT applies the GT predicate on the "cp" field.
|
||||
func CpGT(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGT(FieldCp, v))
|
||||
}
|
||||
|
||||
// CpGTE applies the GTE predicate on the "cp" field.
|
||||
func CpGTE(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGTE(FieldCp, v))
|
||||
}
|
||||
|
||||
// CpLT applies the LT predicate on the "cp" field.
|
||||
func CpLT(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLT(FieldCp, v))
|
||||
}
|
||||
|
||||
// CpLTE applies the LTE predicate on the "cp" field.
|
||||
func CpLTE(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLTE(FieldCp, v))
|
||||
}
|
||||
|
||||
// CpIsNil applies the IsNil predicate on the "cp" field.
|
||||
func CpIsNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIsNull(FieldCp))
|
||||
}
|
||||
|
||||
// CpNotNil applies the NotNil predicate on the "cp" field.
|
||||
func CpNotNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotNull(FieldCp))
|
||||
}
|
||||
|
||||
// CardEQ applies the EQ predicate on the "card" field.
|
||||
func CardEQ(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldCard, v))
|
||||
}
|
||||
|
||||
// CardNEQ applies the NEQ predicate on the "card" field.
|
||||
func CardNEQ(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNEQ(FieldCard, v))
|
||||
}
|
||||
|
||||
// CardIn applies the In predicate on the "card" field.
|
||||
func CardIn(vs ...int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIn(FieldCard, vs...))
|
||||
}
|
||||
|
||||
// CardNotIn applies the NotIn predicate on the "card" field.
|
||||
func CardNotIn(vs ...int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotIn(FieldCard, vs...))
|
||||
}
|
||||
|
||||
// CardGT applies the GT predicate on the "card" field.
|
||||
func CardGT(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGT(FieldCard, v))
|
||||
}
|
||||
|
||||
// CardGTE applies the GTE predicate on the "card" field.
|
||||
func CardGTE(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGTE(FieldCard, v))
|
||||
}
|
||||
|
||||
// CardLT applies the LT predicate on the "card" field.
|
||||
func CardLT(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLT(FieldCard, v))
|
||||
}
|
||||
|
||||
// CardLTE applies the LTE predicate on the "card" field.
|
||||
func CardLTE(v int) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLTE(FieldCard, v))
|
||||
}
|
||||
|
||||
// CardIsNil applies the IsNil predicate on the "card" field.
|
||||
func CardIsNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIsNull(FieldCard))
|
||||
}
|
||||
|
||||
// CardNotNil applies the NotNil predicate on the "card" field.
|
||||
func CardNotNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotNull(FieldCard))
|
||||
}
|
||||
|
||||
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
|
||||
func UpdatedAtEQ(v time.Time) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
|
||||
func UpdatedAtNEQ(v time.Time) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||
func UpdatedAtIn(vs ...time.Time) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||
func UpdatedAtNotIn(vs ...time.Time) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
|
||||
func UpdatedAtGT(v time.Time) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
|
||||
func UpdatedAtGTE(v time.Time) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
|
||||
func UpdatedAtLT(v time.Time) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
|
||||
func UpdatedAtLTE(v time.Time) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtIsNil applies the IsNil predicate on the "updated_at" field.
|
||||
func UpdatedAtIsNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIsNull(FieldUpdatedAt))
|
||||
}
|
||||
|
||||
// UpdatedAtNotNil applies the NotNil predicate on the "updated_at" field.
|
||||
func UpdatedAtNotNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotNull(FieldUpdatedAt))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||
func CreatedAtNEQ(v time.Time) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||
func CreatedAtIn(vs ...time.Time) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||
func CreatedAtNotIn(vs ...time.Time) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||
func CreatedAtGT(v time.Time) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||
func CreatedAtGTE(v time.Time) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldGTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||
func CreatedAtLT(v time.Time) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||
func CreatedAtLTE(v time.Time) predicate.Sev {
|
||||
return predicate.Sev(sql.FieldLTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtIsNil applies the IsNil predicate on the "created_at" field.
|
||||
func CreatedAtIsNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldIsNull(FieldCreatedAt))
|
||||
}
|
||||
|
||||
// CreatedAtNotNil applies the NotNil predicate on the "created_at" field.
|
||||
func CreatedAtNotNil() predicate.Sev {
|
||||
return predicate.Sev(sql.FieldNotNull(FieldCreatedAt))
|
||||
}
|
||||
|
||||
// HasOwner applies the HasEdge predicate on the "owner" edge.
|
||||
func HasOwner() predicate.Sev {
|
||||
return predicate.Sev(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasOwnerWith applies the HasEdge predicate on the "owner" edge with a given conditions (other predicates).
|
||||
func HasOwnerWith(preds ...predicate.User) predicate.Sev {
|
||||
return predicate.Sev(func(s *sql.Selector) {
|
||||
step := newOwnerStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Sev) predicate.Sev {
|
||||
return predicate.Sev(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for _, p := range predicates {
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.Sev) predicate.Sev {
|
||||
return predicate.Sev(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.Sev) predicate.Sev {
|
||||
return predicate.Sev(func(s *sql.Selector) {
|
||||
p(s.Not())
|
||||
})
|
||||
}
|
||||
@@ -1,429 +0,0 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/sev"
|
||||
"api/ent/user"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// SevCreate is the builder for creating a Sev entity.
|
||||
type SevCreate struct {
|
||||
config
|
||||
mutation *SevMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetPassword sets the "password" field.
|
||||
func (sc *SevCreate) SetPassword(s string) *SevCreate {
|
||||
sc.mutation.SetPassword(s)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetToken sets the "token" field.
|
||||
func (sc *SevCreate) SetToken(s string) *SevCreate {
|
||||
sc.mutation.SetToken(s)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetNillableToken sets the "token" field if the given value is not nil.
|
||||
func (sc *SevCreate) SetNillableToken(s *string) *SevCreate {
|
||||
if s != nil {
|
||||
sc.SetToken(*s)
|
||||
}
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetLimit sets the "limit" field.
|
||||
func (sc *SevCreate) SetLimit(b bool) *SevCreate {
|
||||
sc.mutation.SetLimit(b)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetNillableLimit sets the "limit" field if the given value is not nil.
|
||||
func (sc *SevCreate) SetNillableLimit(b *bool) *SevCreate {
|
||||
if b != nil {
|
||||
sc.SetLimit(*b)
|
||||
}
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetCount sets the "count" field.
|
||||
func (sc *SevCreate) SetCount(i int) *SevCreate {
|
||||
sc.mutation.SetCount(i)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetNillableCount sets the "count" field if the given value is not nil.
|
||||
func (sc *SevCreate) SetNillableCount(i *int) *SevCreate {
|
||||
if i != nil {
|
||||
sc.SetCount(*i)
|
||||
}
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetHandle sets the "handle" field.
|
||||
func (sc *SevCreate) SetHandle(s string) *SevCreate {
|
||||
sc.mutation.SetHandle(s)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetNillableHandle sets the "handle" field if the given value is not nil.
|
||||
func (sc *SevCreate) SetNillableHandle(s *string) *SevCreate {
|
||||
if s != nil {
|
||||
sc.SetHandle(*s)
|
||||
}
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetDid sets the "did" field.
|
||||
func (sc *SevCreate) SetDid(s string) *SevCreate {
|
||||
sc.mutation.SetDid(s)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetNillableDid sets the "did" field if the given value is not nil.
|
||||
func (sc *SevCreate) SetNillableDid(s *string) *SevCreate {
|
||||
if s != nil {
|
||||
sc.SetDid(*s)
|
||||
}
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetUID sets the "uid" field.
|
||||
func (sc *SevCreate) SetUID(i int) *SevCreate {
|
||||
sc.mutation.SetUID(i)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetNillableUID sets the "uid" field if the given value is not nil.
|
||||
func (sc *SevCreate) SetNillableUID(i *int) *SevCreate {
|
||||
if i != nil {
|
||||
sc.SetUID(*i)
|
||||
}
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetCid sets the "cid" field.
|
||||
func (sc *SevCreate) SetCid(i int) *SevCreate {
|
||||
sc.mutation.SetCid(i)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetNillableCid sets the "cid" field if the given value is not nil.
|
||||
func (sc *SevCreate) SetNillableCid(i *int) *SevCreate {
|
||||
if i != nil {
|
||||
sc.SetCid(*i)
|
||||
}
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetCp sets the "cp" field.
|
||||
func (sc *SevCreate) SetCp(i int) *SevCreate {
|
||||
sc.mutation.SetCp(i)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetNillableCp sets the "cp" field if the given value is not nil.
|
||||
func (sc *SevCreate) SetNillableCp(i *int) *SevCreate {
|
||||
if i != nil {
|
||||
sc.SetCp(*i)
|
||||
}
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetCard sets the "card" field.
|
||||
func (sc *SevCreate) SetCard(i int) *SevCreate {
|
||||
sc.mutation.SetCard(i)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetNillableCard sets the "card" field if the given value is not nil.
|
||||
func (sc *SevCreate) SetNillableCard(i *int) *SevCreate {
|
||||
if i != nil {
|
||||
sc.SetCard(*i)
|
||||
}
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (sc *SevCreate) SetUpdatedAt(t time.Time) *SevCreate {
|
||||
sc.mutation.SetUpdatedAt(t)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (sc *SevCreate) SetNillableUpdatedAt(t *time.Time) *SevCreate {
|
||||
if t != nil {
|
||||
sc.SetUpdatedAt(*t)
|
||||
}
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (sc *SevCreate) SetCreatedAt(t time.Time) *SevCreate {
|
||||
sc.mutation.SetCreatedAt(t)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (sc *SevCreate) SetNillableCreatedAt(t *time.Time) *SevCreate {
|
||||
if t != nil {
|
||||
sc.SetCreatedAt(*t)
|
||||
}
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetOwnerID sets the "owner" edge to the User entity by ID.
|
||||
func (sc *SevCreate) SetOwnerID(id int) *SevCreate {
|
||||
sc.mutation.SetOwnerID(id)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetOwner sets the "owner" edge to the User entity.
|
||||
func (sc *SevCreate) SetOwner(u *User) *SevCreate {
|
||||
return sc.SetOwnerID(u.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the SevMutation object of the builder.
|
||||
func (sc *SevCreate) Mutation() *SevMutation {
|
||||
return sc.mutation
|
||||
}
|
||||
|
||||
// Save creates the Sev in the database.
|
||||
func (sc *SevCreate) Save(ctx context.Context) (*Sev, error) {
|
||||
sc.defaults()
|
||||
return withHooks[*Sev, SevMutation](ctx, sc.sqlSave, sc.mutation, sc.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (sc *SevCreate) SaveX(ctx context.Context) *Sev {
|
||||
v, err := sc.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (sc *SevCreate) Exec(ctx context.Context) error {
|
||||
_, err := sc.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (sc *SevCreate) ExecX(ctx context.Context) {
|
||||
if err := sc.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (sc *SevCreate) defaults() {
|
||||
if _, ok := sc.mutation.Limit(); !ok {
|
||||
v := sev.DefaultLimit
|
||||
sc.mutation.SetLimit(v)
|
||||
}
|
||||
if _, ok := sc.mutation.CreatedAt(); !ok {
|
||||
v := sev.DefaultCreatedAt()
|
||||
sc.mutation.SetCreatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (sc *SevCreate) check() error {
|
||||
if _, ok := sc.mutation.Password(); !ok {
|
||||
return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "Sev.password"`)}
|
||||
}
|
||||
if v, ok := sc.mutation.Password(); ok {
|
||||
if err := sev.PasswordValidator(v); err != nil {
|
||||
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "Sev.password": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := sc.mutation.OwnerID(); !ok {
|
||||
return &ValidationError{Name: "owner", err: errors.New(`ent: missing required edge "Sev.owner"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sc *SevCreate) sqlSave(ctx context.Context) (*Sev, error) {
|
||||
if err := sc.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := sc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, sc.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = int(id)
|
||||
sc.mutation.id = &_node.ID
|
||||
sc.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (sc *SevCreate) createSpec() (*Sev, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Sev{config: sc.config}
|
||||
_spec = sqlgraph.NewCreateSpec(sev.Table, sqlgraph.NewFieldSpec(sev.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := sc.mutation.Password(); ok {
|
||||
_spec.SetField(sev.FieldPassword, field.TypeString, value)
|
||||
_node.Password = value
|
||||
}
|
||||
if value, ok := sc.mutation.Token(); ok {
|
||||
_spec.SetField(sev.FieldToken, field.TypeString, value)
|
||||
_node.Token = value
|
||||
}
|
||||
if value, ok := sc.mutation.Limit(); ok {
|
||||
_spec.SetField(sev.FieldLimit, field.TypeBool, value)
|
||||
_node.Limit = value
|
||||
}
|
||||
if value, ok := sc.mutation.Count(); ok {
|
||||
_spec.SetField(sev.FieldCount, field.TypeInt, value)
|
||||
_node.Count = value
|
||||
}
|
||||
if value, ok := sc.mutation.Handle(); ok {
|
||||
_spec.SetField(sev.FieldHandle, field.TypeString, value)
|
||||
_node.Handle = value
|
||||
}
|
||||
if value, ok := sc.mutation.Did(); ok {
|
||||
_spec.SetField(sev.FieldDid, field.TypeString, value)
|
||||
_node.Did = value
|
||||
}
|
||||
if value, ok := sc.mutation.UID(); ok {
|
||||
_spec.SetField(sev.FieldUID, field.TypeInt, value)
|
||||
_node.UID = value
|
||||
}
|
||||
if value, ok := sc.mutation.Cid(); ok {
|
||||
_spec.SetField(sev.FieldCid, field.TypeInt, value)
|
||||
_node.Cid = value
|
||||
}
|
||||
if value, ok := sc.mutation.Cp(); ok {
|
||||
_spec.SetField(sev.FieldCp, field.TypeInt, value)
|
||||
_node.Cp = value
|
||||
}
|
||||
if value, ok := sc.mutation.Card(); ok {
|
||||
_spec.SetField(sev.FieldCard, field.TypeInt, value)
|
||||
_node.Card = value
|
||||
}
|
||||
if value, ok := sc.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(sev.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := sc.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(sev.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if nodes := sc.mutation.OwnerIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: sev.OwnerTable,
|
||||
Columns: []string{sev.OwnerColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_node.user_sev = &nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// SevCreateBulk is the builder for creating many Sev entities in bulk.
|
||||
type SevCreateBulk struct {
|
||||
config
|
||||
builders []*SevCreate
|
||||
}
|
||||
|
||||
// Save creates the Sev entities in the database.
|
||||
func (scb *SevCreateBulk) Save(ctx context.Context) ([]*Sev, error) {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(scb.builders))
|
||||
nodes := make([]*Sev, len(scb.builders))
|
||||
mutators := make([]Mutator, len(scb.builders))
|
||||
for i := range scb.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := scb.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*SevMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err := builder.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, scb.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, scb.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &nodes[i].ID
|
||||
if specs[i].ID.Value != nil {
|
||||
id := specs[i].ID.Value.(int64)
|
||||
nodes[i].ID = int(id)
|
||||
}
|
||||
mutation.done = true
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
mut = builder.hooks[i](mut)
|
||||
}
|
||||
mutators[i] = mut
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, scb.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (scb *SevCreateBulk) SaveX(ctx context.Context) []*Sev {
|
||||
v, err := scb.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (scb *SevCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := scb.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (scb *SevCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := scb.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/predicate"
|
||||
"api/ent/sev"
|
||||
"context"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// SevDelete is the builder for deleting a Sev entity.
|
||||
type SevDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *SevMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the SevDelete builder.
|
||||
func (sd *SevDelete) Where(ps ...predicate.Sev) *SevDelete {
|
||||
sd.mutation.Where(ps...)
|
||||
return sd
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (sd *SevDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks[int, SevMutation](ctx, sd.sqlExec, sd.mutation, sd.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (sd *SevDelete) ExecX(ctx context.Context) int {
|
||||
n, err := sd.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (sd *SevDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(sev.Table, sqlgraph.NewFieldSpec(sev.FieldID, field.TypeInt))
|
||||
if ps := sd.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, sd.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
sd.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// SevDeleteOne is the builder for deleting a single Sev entity.
|
||||
type SevDeleteOne struct {
|
||||
sd *SevDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the SevDelete builder.
|
||||
func (sdo *SevDeleteOne) Where(ps ...predicate.Sev) *SevDeleteOne {
|
||||
sdo.sd.mutation.Where(ps...)
|
||||
return sdo
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (sdo *SevDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := sdo.sd.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{sev.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (sdo *SevDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := sdo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
613
ent/sev_query.go
613
ent/sev_query.go
@@ -1,613 +0,0 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/predicate"
|
||||
"api/ent/sev"
|
||||
"api/ent/user"
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// SevQuery is the builder for querying Sev entities.
|
||||
type SevQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []sev.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.Sev
|
||||
withOwner *UserQuery
|
||||
withFKs bool
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the SevQuery builder.
|
||||
func (sq *SevQuery) Where(ps ...predicate.Sev) *SevQuery {
|
||||
sq.predicates = append(sq.predicates, ps...)
|
||||
return sq
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (sq *SevQuery) Limit(limit int) *SevQuery {
|
||||
sq.ctx.Limit = &limit
|
||||
return sq
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (sq *SevQuery) Offset(offset int) *SevQuery {
|
||||
sq.ctx.Offset = &offset
|
||||
return sq
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (sq *SevQuery) Unique(unique bool) *SevQuery {
|
||||
sq.ctx.Unique = &unique
|
||||
return sq
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (sq *SevQuery) Order(o ...sev.OrderOption) *SevQuery {
|
||||
sq.order = append(sq.order, o...)
|
||||
return sq
|
||||
}
|
||||
|
||||
// QueryOwner chains the current query on the "owner" edge.
|
||||
func (sq *SevQuery) QueryOwner() *UserQuery {
|
||||
query := (&UserClient{config: sq.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := sq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := sq.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(sev.Table, sev.FieldID, selector),
|
||||
sqlgraph.To(user.Table, user.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, sev.OwnerTable, sev.OwnerColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first Sev entity from the query.
|
||||
// Returns a *NotFoundError when no Sev was found.
|
||||
func (sq *SevQuery) First(ctx context.Context) (*Sev, error) {
|
||||
nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, "First"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{sev.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (sq *SevQuery) FirstX(ctx context.Context) *Sev {
|
||||
node, err := sq.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first Sev ID from the query.
|
||||
// Returns a *NotFoundError when no Sev ID was found.
|
||||
func (sq *SevQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, "FirstID")); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{sev.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (sq *SevQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := sq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single Sev entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Sev entity is found.
|
||||
// Returns a *NotFoundError when no Sev entities are found.
|
||||
func (sq *SevQuery) Only(ctx context.Context) (*Sev, error) {
|
||||
nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, "Only"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{sev.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{sev.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (sq *SevQuery) OnlyX(ctx context.Context) *Sev {
|
||||
node, err := sq.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only Sev ID in the query.
|
||||
// Returns a *NotSingularError when more than one Sev ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (sq *SevQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, "OnlyID")); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{sev.Label}
|
||||
default:
|
||||
err = &NotSingularError{sev.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (sq *SevQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := sq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of Sevs.
|
||||
func (sq *SevQuery) All(ctx context.Context) ([]*Sev, error) {
|
||||
ctx = setContextOp(ctx, sq.ctx, "All")
|
||||
if err := sq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Sev, *SevQuery]()
|
||||
return withInterceptors[[]*Sev](ctx, sq, qr, sq.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (sq *SevQuery) AllX(ctx context.Context) []*Sev {
|
||||
nodes, err := sq.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Sev IDs.
|
||||
func (sq *SevQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if sq.ctx.Unique == nil && sq.path != nil {
|
||||
sq.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, sq.ctx, "IDs")
|
||||
if err = sq.Select(sev.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (sq *SevQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := sq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (sq *SevQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, sq.ctx, "Count")
|
||||
if err := sq.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, sq, querierCount[*SevQuery](), sq.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (sq *SevQuery) CountX(ctx context.Context) int {
|
||||
count, err := sq.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (sq *SevQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, sq.ctx, "Exist")
|
||||
switch _, err := sq.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||
default:
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (sq *SevQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := sq.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the SevQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (sq *SevQuery) Clone() *SevQuery {
|
||||
if sq == nil {
|
||||
return nil
|
||||
}
|
||||
return &SevQuery{
|
||||
config: sq.config,
|
||||
ctx: sq.ctx.Clone(),
|
||||
order: append([]sev.OrderOption{}, sq.order...),
|
||||
inters: append([]Interceptor{}, sq.inters...),
|
||||
predicates: append([]predicate.Sev{}, sq.predicates...),
|
||||
withOwner: sq.withOwner.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: sq.sql.Clone(),
|
||||
path: sq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithOwner tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "owner" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (sq *SevQuery) WithOwner(opts ...func(*UserQuery)) *SevQuery {
|
||||
query := (&UserClient{config: sq.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
sq.withOwner = query
|
||||
return sq
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Password string `json:"password,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Sev.Query().
|
||||
// GroupBy(sev.FieldPassword).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (sq *SevQuery) GroupBy(field string, fields ...string) *SevGroupBy {
|
||||
sq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &SevGroupBy{build: sq}
|
||||
grbuild.flds = &sq.ctx.Fields
|
||||
grbuild.label = sev.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
}
|
||||
|
||||
// Select allows the selection one or more fields/columns for the given query,
|
||||
// instead of selecting all fields in the entity.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Password string `json:"password,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Sev.Query().
|
||||
// Select(sev.FieldPassword).
|
||||
// Scan(ctx, &v)
|
||||
func (sq *SevQuery) Select(fields ...string) *SevSelect {
|
||||
sq.ctx.Fields = append(sq.ctx.Fields, fields...)
|
||||
sbuild := &SevSelect{SevQuery: sq}
|
||||
sbuild.label = sev.Label
|
||||
sbuild.flds, sbuild.scan = &sq.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a SevSelect configured with the given aggregations.
|
||||
func (sq *SevQuery) Aggregate(fns ...AggregateFunc) *SevSelect {
|
||||
return sq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (sq *SevQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range sq.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, sq); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range sq.ctx.Fields {
|
||||
if !sev.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if sq.path != nil {
|
||||
prev, err := sq.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sq.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sq *SevQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Sev, error) {
|
||||
var (
|
||||
nodes = []*Sev{}
|
||||
withFKs = sq.withFKs
|
||||
_spec = sq.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
sq.withOwner != nil,
|
||||
}
|
||||
)
|
||||
if sq.withOwner != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, sev.ForeignKeys...)
|
||||
}
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*Sev).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Sev{config: sq.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, sq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := sq.withOwner; query != nil {
|
||||
if err := sq.loadOwner(ctx, query, nodes, nil,
|
||||
func(n *Sev, e *User) { n.Edges.Owner = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (sq *SevQuery) loadOwner(ctx context.Context, query *UserQuery, nodes []*Sev, init func(*Sev), assign func(*Sev, *User)) error {
|
||||
ids := make([]int, 0, len(nodes))
|
||||
nodeids := make(map[int][]*Sev)
|
||||
for i := range nodes {
|
||||
if nodes[i].user_sev == nil {
|
||||
continue
|
||||
}
|
||||
fk := *nodes[i].user_sev
|
||||
if _, ok := nodeids[fk]; !ok {
|
||||
ids = append(ids, fk)
|
||||
}
|
||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
query.Where(user.IDIn(ids...))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nodeids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected foreign-key "user_sev" returned %v`, n.ID)
|
||||
}
|
||||
for i := range nodes {
|
||||
assign(nodes[i], n)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sq *SevQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := sq.querySpec()
|
||||
_spec.Node.Columns = sq.ctx.Fields
|
||||
if len(sq.ctx.Fields) > 0 {
|
||||
_spec.Unique = sq.ctx.Unique != nil && *sq.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, sq.driver, _spec)
|
||||
}
|
||||
|
||||
func (sq *SevQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(sev.Table, sev.Columns, sqlgraph.NewFieldSpec(sev.FieldID, field.TypeInt))
|
||||
_spec.From = sq.sql
|
||||
if unique := sq.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if sq.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := sq.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, sev.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != sev.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := sq.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := sq.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := sq.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := sq.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (sq *SevQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(sq.driver.Dialect())
|
||||
t1 := builder.Table(sev.Table)
|
||||
columns := sq.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = sev.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if sq.sql != nil {
|
||||
selector = sq.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if sq.ctx.Unique != nil && *sq.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range sq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range sq.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := sq.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := sq.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// SevGroupBy is the group-by builder for Sev entities.
|
||||
type SevGroupBy struct {
|
||||
selector
|
||||
build *SevQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (sgb *SevGroupBy) Aggregate(fns ...AggregateFunc) *SevGroupBy {
|
||||
sgb.fns = append(sgb.fns, fns...)
|
||||
return sgb
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (sgb *SevGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, sgb.build.ctx, "GroupBy")
|
||||
if err := sgb.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*SevQuery, *SevGroupBy](ctx, sgb.build, sgb, sgb.build.inters, v)
|
||||
}
|
||||
|
||||
func (sgb *SevGroupBy) sqlScan(ctx context.Context, root *SevQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(sgb.fns))
|
||||
for _, fn := range sgb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*sgb.flds)+len(sgb.fns))
|
||||
for _, f := range *sgb.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*sgb.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := sgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// SevSelect is the builder for selecting fields of Sev entities.
|
||||
type SevSelect struct {
|
||||
*SevQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ss *SevSelect) Aggregate(fns ...AggregateFunc) *SevSelect {
|
||||
ss.fns = append(ss.fns, fns...)
|
||||
return ss
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ss *SevSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ss.ctx, "Select")
|
||||
if err := ss.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*SevQuery, *SevSelect](ctx, ss.SevQuery, ss, ss.inters, v)
|
||||
}
|
||||
|
||||
func (ss *SevSelect) sqlScan(ctx context.Context, root *SevQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(ss.fns))
|
||||
for _, fn := range ss.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*ss.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
selector.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := ss.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
@@ -1,917 +0,0 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/predicate"
|
||||
"api/ent/sev"
|
||||
"api/ent/user"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// SevUpdate is the builder for updating Sev entities.
|
||||
type SevUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *SevMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the SevUpdate builder.
|
||||
func (su *SevUpdate) Where(ps ...predicate.Sev) *SevUpdate {
|
||||
su.mutation.Where(ps...)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetToken sets the "token" field.
|
||||
func (su *SevUpdate) SetToken(s string) *SevUpdate {
|
||||
su.mutation.SetToken(s)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetNillableToken sets the "token" field if the given value is not nil.
|
||||
func (su *SevUpdate) SetNillableToken(s *string) *SevUpdate {
|
||||
if s != nil {
|
||||
su.SetToken(*s)
|
||||
}
|
||||
return su
|
||||
}
|
||||
|
||||
// ClearToken clears the value of the "token" field.
|
||||
func (su *SevUpdate) ClearToken() *SevUpdate {
|
||||
su.mutation.ClearToken()
|
||||
return su
|
||||
}
|
||||
|
||||
// SetLimit sets the "limit" field.
|
||||
func (su *SevUpdate) SetLimit(b bool) *SevUpdate {
|
||||
su.mutation.SetLimit(b)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetNillableLimit sets the "limit" field if the given value is not nil.
|
||||
func (su *SevUpdate) SetNillableLimit(b *bool) *SevUpdate {
|
||||
if b != nil {
|
||||
su.SetLimit(*b)
|
||||
}
|
||||
return su
|
||||
}
|
||||
|
||||
// ClearLimit clears the value of the "limit" field.
|
||||
func (su *SevUpdate) ClearLimit() *SevUpdate {
|
||||
su.mutation.ClearLimit()
|
||||
return su
|
||||
}
|
||||
|
||||
// SetCount sets the "count" field.
|
||||
func (su *SevUpdate) SetCount(i int) *SevUpdate {
|
||||
su.mutation.ResetCount()
|
||||
su.mutation.SetCount(i)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetNillableCount sets the "count" field if the given value is not nil.
|
||||
func (su *SevUpdate) SetNillableCount(i *int) *SevUpdate {
|
||||
if i != nil {
|
||||
su.SetCount(*i)
|
||||
}
|
||||
return su
|
||||
}
|
||||
|
||||
// AddCount adds i to the "count" field.
|
||||
func (su *SevUpdate) AddCount(i int) *SevUpdate {
|
||||
su.mutation.AddCount(i)
|
||||
return su
|
||||
}
|
||||
|
||||
// ClearCount clears the value of the "count" field.
|
||||
func (su *SevUpdate) ClearCount() *SevUpdate {
|
||||
su.mutation.ClearCount()
|
||||
return su
|
||||
}
|
||||
|
||||
// SetHandle sets the "handle" field.
|
||||
func (su *SevUpdate) SetHandle(s string) *SevUpdate {
|
||||
su.mutation.SetHandle(s)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetNillableHandle sets the "handle" field if the given value is not nil.
|
||||
func (su *SevUpdate) SetNillableHandle(s *string) *SevUpdate {
|
||||
if s != nil {
|
||||
su.SetHandle(*s)
|
||||
}
|
||||
return su
|
||||
}
|
||||
|
||||
// ClearHandle clears the value of the "handle" field.
|
||||
func (su *SevUpdate) ClearHandle() *SevUpdate {
|
||||
su.mutation.ClearHandle()
|
||||
return su
|
||||
}
|
||||
|
||||
// SetDid sets the "did" field.
|
||||
func (su *SevUpdate) SetDid(s string) *SevUpdate {
|
||||
su.mutation.SetDid(s)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetNillableDid sets the "did" field if the given value is not nil.
|
||||
func (su *SevUpdate) SetNillableDid(s *string) *SevUpdate {
|
||||
if s != nil {
|
||||
su.SetDid(*s)
|
||||
}
|
||||
return su
|
||||
}
|
||||
|
||||
// ClearDid clears the value of the "did" field.
|
||||
func (su *SevUpdate) ClearDid() *SevUpdate {
|
||||
su.mutation.ClearDid()
|
||||
return su
|
||||
}
|
||||
|
||||
// SetUID sets the "uid" field.
|
||||
func (su *SevUpdate) SetUID(i int) *SevUpdate {
|
||||
su.mutation.ResetUID()
|
||||
su.mutation.SetUID(i)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetNillableUID sets the "uid" field if the given value is not nil.
|
||||
func (su *SevUpdate) SetNillableUID(i *int) *SevUpdate {
|
||||
if i != nil {
|
||||
su.SetUID(*i)
|
||||
}
|
||||
return su
|
||||
}
|
||||
|
||||
// AddUID adds i to the "uid" field.
|
||||
func (su *SevUpdate) AddUID(i int) *SevUpdate {
|
||||
su.mutation.AddUID(i)
|
||||
return su
|
||||
}
|
||||
|
||||
// ClearUID clears the value of the "uid" field.
|
||||
func (su *SevUpdate) ClearUID() *SevUpdate {
|
||||
su.mutation.ClearUID()
|
||||
return su
|
||||
}
|
||||
|
||||
// SetCid sets the "cid" field.
|
||||
func (su *SevUpdate) SetCid(i int) *SevUpdate {
|
||||
su.mutation.ResetCid()
|
||||
su.mutation.SetCid(i)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetNillableCid sets the "cid" field if the given value is not nil.
|
||||
func (su *SevUpdate) SetNillableCid(i *int) *SevUpdate {
|
||||
if i != nil {
|
||||
su.SetCid(*i)
|
||||
}
|
||||
return su
|
||||
}
|
||||
|
||||
// AddCid adds i to the "cid" field.
|
||||
func (su *SevUpdate) AddCid(i int) *SevUpdate {
|
||||
su.mutation.AddCid(i)
|
||||
return su
|
||||
}
|
||||
|
||||
// ClearCid clears the value of the "cid" field.
|
||||
func (su *SevUpdate) ClearCid() *SevUpdate {
|
||||
su.mutation.ClearCid()
|
||||
return su
|
||||
}
|
||||
|
||||
// SetCp sets the "cp" field.
|
||||
func (su *SevUpdate) SetCp(i int) *SevUpdate {
|
||||
su.mutation.ResetCp()
|
||||
su.mutation.SetCp(i)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetNillableCp sets the "cp" field if the given value is not nil.
|
||||
func (su *SevUpdate) SetNillableCp(i *int) *SevUpdate {
|
||||
if i != nil {
|
||||
su.SetCp(*i)
|
||||
}
|
||||
return su
|
||||
}
|
||||
|
||||
// AddCp adds i to the "cp" field.
|
||||
func (su *SevUpdate) AddCp(i int) *SevUpdate {
|
||||
su.mutation.AddCp(i)
|
||||
return su
|
||||
}
|
||||
|
||||
// ClearCp clears the value of the "cp" field.
|
||||
func (su *SevUpdate) ClearCp() *SevUpdate {
|
||||
su.mutation.ClearCp()
|
||||
return su
|
||||
}
|
||||
|
||||
// SetCard sets the "card" field.
|
||||
func (su *SevUpdate) SetCard(i int) *SevUpdate {
|
||||
su.mutation.ResetCard()
|
||||
su.mutation.SetCard(i)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetNillableCard sets the "card" field if the given value is not nil.
|
||||
func (su *SevUpdate) SetNillableCard(i *int) *SevUpdate {
|
||||
if i != nil {
|
||||
su.SetCard(*i)
|
||||
}
|
||||
return su
|
||||
}
|
||||
|
||||
// AddCard adds i to the "card" field.
|
||||
func (su *SevUpdate) AddCard(i int) *SevUpdate {
|
||||
su.mutation.AddCard(i)
|
||||
return su
|
||||
}
|
||||
|
||||
// ClearCard clears the value of the "card" field.
|
||||
func (su *SevUpdate) ClearCard() *SevUpdate {
|
||||
su.mutation.ClearCard()
|
||||
return su
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (su *SevUpdate) SetUpdatedAt(t time.Time) *SevUpdate {
|
||||
su.mutation.SetUpdatedAt(t)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (su *SevUpdate) SetNillableUpdatedAt(t *time.Time) *SevUpdate {
|
||||
if t != nil {
|
||||
su.SetUpdatedAt(*t)
|
||||
}
|
||||
return su
|
||||
}
|
||||
|
||||
// ClearUpdatedAt clears the value of the "updated_at" field.
|
||||
func (su *SevUpdate) ClearUpdatedAt() *SevUpdate {
|
||||
su.mutation.ClearUpdatedAt()
|
||||
return su
|
||||
}
|
||||
|
||||
// SetOwnerID sets the "owner" edge to the User entity by ID.
|
||||
func (su *SevUpdate) SetOwnerID(id int) *SevUpdate {
|
||||
su.mutation.SetOwnerID(id)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetOwner sets the "owner" edge to the User entity.
|
||||
func (su *SevUpdate) SetOwner(u *User) *SevUpdate {
|
||||
return su.SetOwnerID(u.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the SevMutation object of the builder.
|
||||
func (su *SevUpdate) Mutation() *SevMutation {
|
||||
return su.mutation
|
||||
}
|
||||
|
||||
// ClearOwner clears the "owner" edge to the User entity.
|
||||
func (su *SevUpdate) ClearOwner() *SevUpdate {
|
||||
su.mutation.ClearOwner()
|
||||
return su
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (su *SevUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks[int, SevMutation](ctx, su.sqlSave, su.mutation, su.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (su *SevUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := su.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (su *SevUpdate) Exec(ctx context.Context) error {
|
||||
_, err := su.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (su *SevUpdate) ExecX(ctx context.Context) {
|
||||
if err := su.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (su *SevUpdate) check() error {
|
||||
if _, ok := su.mutation.OwnerID(); su.mutation.OwnerCleared() && !ok {
|
||||
return errors.New(`ent: clearing a required unique edge "Sev.owner"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (su *SevUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if err := su.check(); err != nil {
|
||||
return n, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(sev.Table, sev.Columns, sqlgraph.NewFieldSpec(sev.FieldID, field.TypeInt))
|
||||
if ps := su.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := su.mutation.Token(); ok {
|
||||
_spec.SetField(sev.FieldToken, field.TypeString, value)
|
||||
}
|
||||
if su.mutation.TokenCleared() {
|
||||
_spec.ClearField(sev.FieldToken, field.TypeString)
|
||||
}
|
||||
if value, ok := su.mutation.Limit(); ok {
|
||||
_spec.SetField(sev.FieldLimit, field.TypeBool, value)
|
||||
}
|
||||
if su.mutation.LimitCleared() {
|
||||
_spec.ClearField(sev.FieldLimit, field.TypeBool)
|
||||
}
|
||||
if value, ok := su.mutation.Count(); ok {
|
||||
_spec.SetField(sev.FieldCount, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := su.mutation.AddedCount(); ok {
|
||||
_spec.AddField(sev.FieldCount, field.TypeInt, value)
|
||||
}
|
||||
if su.mutation.CountCleared() {
|
||||
_spec.ClearField(sev.FieldCount, field.TypeInt)
|
||||
}
|
||||
if value, ok := su.mutation.Handle(); ok {
|
||||
_spec.SetField(sev.FieldHandle, field.TypeString, value)
|
||||
}
|
||||
if su.mutation.HandleCleared() {
|
||||
_spec.ClearField(sev.FieldHandle, field.TypeString)
|
||||
}
|
||||
if value, ok := su.mutation.Did(); ok {
|
||||
_spec.SetField(sev.FieldDid, field.TypeString, value)
|
||||
}
|
||||
if su.mutation.DidCleared() {
|
||||
_spec.ClearField(sev.FieldDid, field.TypeString)
|
||||
}
|
||||
if value, ok := su.mutation.UID(); ok {
|
||||
_spec.SetField(sev.FieldUID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := su.mutation.AddedUID(); ok {
|
||||
_spec.AddField(sev.FieldUID, field.TypeInt, value)
|
||||
}
|
||||
if su.mutation.UIDCleared() {
|
||||
_spec.ClearField(sev.FieldUID, field.TypeInt)
|
||||
}
|
||||
if value, ok := su.mutation.Cid(); ok {
|
||||
_spec.SetField(sev.FieldCid, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := su.mutation.AddedCid(); ok {
|
||||
_spec.AddField(sev.FieldCid, field.TypeInt, value)
|
||||
}
|
||||
if su.mutation.CidCleared() {
|
||||
_spec.ClearField(sev.FieldCid, field.TypeInt)
|
||||
}
|
||||
if value, ok := su.mutation.Cp(); ok {
|
||||
_spec.SetField(sev.FieldCp, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := su.mutation.AddedCp(); ok {
|
||||
_spec.AddField(sev.FieldCp, field.TypeInt, value)
|
||||
}
|
||||
if su.mutation.CpCleared() {
|
||||
_spec.ClearField(sev.FieldCp, field.TypeInt)
|
||||
}
|
||||
if value, ok := su.mutation.Card(); ok {
|
||||
_spec.SetField(sev.FieldCard, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := su.mutation.AddedCard(); ok {
|
||||
_spec.AddField(sev.FieldCard, field.TypeInt, value)
|
||||
}
|
||||
if su.mutation.CardCleared() {
|
||||
_spec.ClearField(sev.FieldCard, field.TypeInt)
|
||||
}
|
||||
if value, ok := su.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(sev.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if su.mutation.UpdatedAtCleared() {
|
||||
_spec.ClearField(sev.FieldUpdatedAt, field.TypeTime)
|
||||
}
|
||||
if su.mutation.CreatedAtCleared() {
|
||||
_spec.ClearField(sev.FieldCreatedAt, field.TypeTime)
|
||||
}
|
||||
if su.mutation.OwnerCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: sev.OwnerTable,
|
||||
Columns: []string{sev.OwnerColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := su.mutation.OwnerIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: sev.OwnerTable,
|
||||
Columns: []string{sev.OwnerColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{sev.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
su.mutation.done = true
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// SevUpdateOne is the builder for updating a single Sev entity.
|
||||
type SevUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *SevMutation
|
||||
}
|
||||
|
||||
// SetToken sets the "token" field.
|
||||
func (suo *SevUpdateOne) SetToken(s string) *SevUpdateOne {
|
||||
suo.mutation.SetToken(s)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetNillableToken sets the "token" field if the given value is not nil.
|
||||
func (suo *SevUpdateOne) SetNillableToken(s *string) *SevUpdateOne {
|
||||
if s != nil {
|
||||
suo.SetToken(*s)
|
||||
}
|
||||
return suo
|
||||
}
|
||||
|
||||
// ClearToken clears the value of the "token" field.
|
||||
func (suo *SevUpdateOne) ClearToken() *SevUpdateOne {
|
||||
suo.mutation.ClearToken()
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetLimit sets the "limit" field.
|
||||
func (suo *SevUpdateOne) SetLimit(b bool) *SevUpdateOne {
|
||||
suo.mutation.SetLimit(b)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetNillableLimit sets the "limit" field if the given value is not nil.
|
||||
func (suo *SevUpdateOne) SetNillableLimit(b *bool) *SevUpdateOne {
|
||||
if b != nil {
|
||||
suo.SetLimit(*b)
|
||||
}
|
||||
return suo
|
||||
}
|
||||
|
||||
// ClearLimit clears the value of the "limit" field.
|
||||
func (suo *SevUpdateOne) ClearLimit() *SevUpdateOne {
|
||||
suo.mutation.ClearLimit()
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetCount sets the "count" field.
|
||||
func (suo *SevUpdateOne) SetCount(i int) *SevUpdateOne {
|
||||
suo.mutation.ResetCount()
|
||||
suo.mutation.SetCount(i)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetNillableCount sets the "count" field if the given value is not nil.
|
||||
func (suo *SevUpdateOne) SetNillableCount(i *int) *SevUpdateOne {
|
||||
if i != nil {
|
||||
suo.SetCount(*i)
|
||||
}
|
||||
return suo
|
||||
}
|
||||
|
||||
// AddCount adds i to the "count" field.
|
||||
func (suo *SevUpdateOne) AddCount(i int) *SevUpdateOne {
|
||||
suo.mutation.AddCount(i)
|
||||
return suo
|
||||
}
|
||||
|
||||
// ClearCount clears the value of the "count" field.
|
||||
func (suo *SevUpdateOne) ClearCount() *SevUpdateOne {
|
||||
suo.mutation.ClearCount()
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetHandle sets the "handle" field.
|
||||
func (suo *SevUpdateOne) SetHandle(s string) *SevUpdateOne {
|
||||
suo.mutation.SetHandle(s)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetNillableHandle sets the "handle" field if the given value is not nil.
|
||||
func (suo *SevUpdateOne) SetNillableHandle(s *string) *SevUpdateOne {
|
||||
if s != nil {
|
||||
suo.SetHandle(*s)
|
||||
}
|
||||
return suo
|
||||
}
|
||||
|
||||
// ClearHandle clears the value of the "handle" field.
|
||||
func (suo *SevUpdateOne) ClearHandle() *SevUpdateOne {
|
||||
suo.mutation.ClearHandle()
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetDid sets the "did" field.
|
||||
func (suo *SevUpdateOne) SetDid(s string) *SevUpdateOne {
|
||||
suo.mutation.SetDid(s)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetNillableDid sets the "did" field if the given value is not nil.
|
||||
func (suo *SevUpdateOne) SetNillableDid(s *string) *SevUpdateOne {
|
||||
if s != nil {
|
||||
suo.SetDid(*s)
|
||||
}
|
||||
return suo
|
||||
}
|
||||
|
||||
// ClearDid clears the value of the "did" field.
|
||||
func (suo *SevUpdateOne) ClearDid() *SevUpdateOne {
|
||||
suo.mutation.ClearDid()
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetUID sets the "uid" field.
|
||||
func (suo *SevUpdateOne) SetUID(i int) *SevUpdateOne {
|
||||
suo.mutation.ResetUID()
|
||||
suo.mutation.SetUID(i)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetNillableUID sets the "uid" field if the given value is not nil.
|
||||
func (suo *SevUpdateOne) SetNillableUID(i *int) *SevUpdateOne {
|
||||
if i != nil {
|
||||
suo.SetUID(*i)
|
||||
}
|
||||
return suo
|
||||
}
|
||||
|
||||
// AddUID adds i to the "uid" field.
|
||||
func (suo *SevUpdateOne) AddUID(i int) *SevUpdateOne {
|
||||
suo.mutation.AddUID(i)
|
||||
return suo
|
||||
}
|
||||
|
||||
// ClearUID clears the value of the "uid" field.
|
||||
func (suo *SevUpdateOne) ClearUID() *SevUpdateOne {
|
||||
suo.mutation.ClearUID()
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetCid sets the "cid" field.
|
||||
func (suo *SevUpdateOne) SetCid(i int) *SevUpdateOne {
|
||||
suo.mutation.ResetCid()
|
||||
suo.mutation.SetCid(i)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetNillableCid sets the "cid" field if the given value is not nil.
|
||||
func (suo *SevUpdateOne) SetNillableCid(i *int) *SevUpdateOne {
|
||||
if i != nil {
|
||||
suo.SetCid(*i)
|
||||
}
|
||||
return suo
|
||||
}
|
||||
|
||||
// AddCid adds i to the "cid" field.
|
||||
func (suo *SevUpdateOne) AddCid(i int) *SevUpdateOne {
|
||||
suo.mutation.AddCid(i)
|
||||
return suo
|
||||
}
|
||||
|
||||
// ClearCid clears the value of the "cid" field.
|
||||
func (suo *SevUpdateOne) ClearCid() *SevUpdateOne {
|
||||
suo.mutation.ClearCid()
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetCp sets the "cp" field.
|
||||
func (suo *SevUpdateOne) SetCp(i int) *SevUpdateOne {
|
||||
suo.mutation.ResetCp()
|
||||
suo.mutation.SetCp(i)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetNillableCp sets the "cp" field if the given value is not nil.
|
||||
func (suo *SevUpdateOne) SetNillableCp(i *int) *SevUpdateOne {
|
||||
if i != nil {
|
||||
suo.SetCp(*i)
|
||||
}
|
||||
return suo
|
||||
}
|
||||
|
||||
// AddCp adds i to the "cp" field.
|
||||
func (suo *SevUpdateOne) AddCp(i int) *SevUpdateOne {
|
||||
suo.mutation.AddCp(i)
|
||||
return suo
|
||||
}
|
||||
|
||||
// ClearCp clears the value of the "cp" field.
|
||||
func (suo *SevUpdateOne) ClearCp() *SevUpdateOne {
|
||||
suo.mutation.ClearCp()
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetCard sets the "card" field.
|
||||
func (suo *SevUpdateOne) SetCard(i int) *SevUpdateOne {
|
||||
suo.mutation.ResetCard()
|
||||
suo.mutation.SetCard(i)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetNillableCard sets the "card" field if the given value is not nil.
|
||||
func (suo *SevUpdateOne) SetNillableCard(i *int) *SevUpdateOne {
|
||||
if i != nil {
|
||||
suo.SetCard(*i)
|
||||
}
|
||||
return suo
|
||||
}
|
||||
|
||||
// AddCard adds i to the "card" field.
|
||||
func (suo *SevUpdateOne) AddCard(i int) *SevUpdateOne {
|
||||
suo.mutation.AddCard(i)
|
||||
return suo
|
||||
}
|
||||
|
||||
// ClearCard clears the value of the "card" field.
|
||||
func (suo *SevUpdateOne) ClearCard() *SevUpdateOne {
|
||||
suo.mutation.ClearCard()
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (suo *SevUpdateOne) SetUpdatedAt(t time.Time) *SevUpdateOne {
|
||||
suo.mutation.SetUpdatedAt(t)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (suo *SevUpdateOne) SetNillableUpdatedAt(t *time.Time) *SevUpdateOne {
|
||||
if t != nil {
|
||||
suo.SetUpdatedAt(*t)
|
||||
}
|
||||
return suo
|
||||
}
|
||||
|
||||
// ClearUpdatedAt clears the value of the "updated_at" field.
|
||||
func (suo *SevUpdateOne) ClearUpdatedAt() *SevUpdateOne {
|
||||
suo.mutation.ClearUpdatedAt()
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetOwnerID sets the "owner" edge to the User entity by ID.
|
||||
func (suo *SevUpdateOne) SetOwnerID(id int) *SevUpdateOne {
|
||||
suo.mutation.SetOwnerID(id)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetOwner sets the "owner" edge to the User entity.
|
||||
func (suo *SevUpdateOne) SetOwner(u *User) *SevUpdateOne {
|
||||
return suo.SetOwnerID(u.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the SevMutation object of the builder.
|
||||
func (suo *SevUpdateOne) Mutation() *SevMutation {
|
||||
return suo.mutation
|
||||
}
|
||||
|
||||
// ClearOwner clears the "owner" edge to the User entity.
|
||||
func (suo *SevUpdateOne) ClearOwner() *SevUpdateOne {
|
||||
suo.mutation.ClearOwner()
|
||||
return suo
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the SevUpdate builder.
|
||||
func (suo *SevUpdateOne) Where(ps ...predicate.Sev) *SevUpdateOne {
|
||||
suo.mutation.Where(ps...)
|
||||
return suo
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (suo *SevUpdateOne) Select(field string, fields ...string) *SevUpdateOne {
|
||||
suo.fields = append([]string{field}, fields...)
|
||||
return suo
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated Sev entity.
|
||||
func (suo *SevUpdateOne) Save(ctx context.Context) (*Sev, error) {
|
||||
return withHooks[*Sev, SevMutation](ctx, suo.sqlSave, suo.mutation, suo.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (suo *SevUpdateOne) SaveX(ctx context.Context) *Sev {
|
||||
node, err := suo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (suo *SevUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := suo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (suo *SevUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := suo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (suo *SevUpdateOne) check() error {
|
||||
if _, ok := suo.mutation.OwnerID(); suo.mutation.OwnerCleared() && !ok {
|
||||
return errors.New(`ent: clearing a required unique edge "Sev.owner"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (suo *SevUpdateOne) sqlSave(ctx context.Context) (_node *Sev, err error) {
|
||||
if err := suo.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(sev.Table, sev.Columns, sqlgraph.NewFieldSpec(sev.FieldID, field.TypeInt))
|
||||
id, ok := suo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Sev.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := suo.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, sev.FieldID)
|
||||
for _, f := range fields {
|
||||
if !sev.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != sev.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := suo.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := suo.mutation.Token(); ok {
|
||||
_spec.SetField(sev.FieldToken, field.TypeString, value)
|
||||
}
|
||||
if suo.mutation.TokenCleared() {
|
||||
_spec.ClearField(sev.FieldToken, field.TypeString)
|
||||
}
|
||||
if value, ok := suo.mutation.Limit(); ok {
|
||||
_spec.SetField(sev.FieldLimit, field.TypeBool, value)
|
||||
}
|
||||
if suo.mutation.LimitCleared() {
|
||||
_spec.ClearField(sev.FieldLimit, field.TypeBool)
|
||||
}
|
||||
if value, ok := suo.mutation.Count(); ok {
|
||||
_spec.SetField(sev.FieldCount, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := suo.mutation.AddedCount(); ok {
|
||||
_spec.AddField(sev.FieldCount, field.TypeInt, value)
|
||||
}
|
||||
if suo.mutation.CountCleared() {
|
||||
_spec.ClearField(sev.FieldCount, field.TypeInt)
|
||||
}
|
||||
if value, ok := suo.mutation.Handle(); ok {
|
||||
_spec.SetField(sev.FieldHandle, field.TypeString, value)
|
||||
}
|
||||
if suo.mutation.HandleCleared() {
|
||||
_spec.ClearField(sev.FieldHandle, field.TypeString)
|
||||
}
|
||||
if value, ok := suo.mutation.Did(); ok {
|
||||
_spec.SetField(sev.FieldDid, field.TypeString, value)
|
||||
}
|
||||
if suo.mutation.DidCleared() {
|
||||
_spec.ClearField(sev.FieldDid, field.TypeString)
|
||||
}
|
||||
if value, ok := suo.mutation.UID(); ok {
|
||||
_spec.SetField(sev.FieldUID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := suo.mutation.AddedUID(); ok {
|
||||
_spec.AddField(sev.FieldUID, field.TypeInt, value)
|
||||
}
|
||||
if suo.mutation.UIDCleared() {
|
||||
_spec.ClearField(sev.FieldUID, field.TypeInt)
|
||||
}
|
||||
if value, ok := suo.mutation.Cid(); ok {
|
||||
_spec.SetField(sev.FieldCid, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := suo.mutation.AddedCid(); ok {
|
||||
_spec.AddField(sev.FieldCid, field.TypeInt, value)
|
||||
}
|
||||
if suo.mutation.CidCleared() {
|
||||
_spec.ClearField(sev.FieldCid, field.TypeInt)
|
||||
}
|
||||
if value, ok := suo.mutation.Cp(); ok {
|
||||
_spec.SetField(sev.FieldCp, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := suo.mutation.AddedCp(); ok {
|
||||
_spec.AddField(sev.FieldCp, field.TypeInt, value)
|
||||
}
|
||||
if suo.mutation.CpCleared() {
|
||||
_spec.ClearField(sev.FieldCp, field.TypeInt)
|
||||
}
|
||||
if value, ok := suo.mutation.Card(); ok {
|
||||
_spec.SetField(sev.FieldCard, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := suo.mutation.AddedCard(); ok {
|
||||
_spec.AddField(sev.FieldCard, field.TypeInt, value)
|
||||
}
|
||||
if suo.mutation.CardCleared() {
|
||||
_spec.ClearField(sev.FieldCard, field.TypeInt)
|
||||
}
|
||||
if value, ok := suo.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(sev.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if suo.mutation.UpdatedAtCleared() {
|
||||
_spec.ClearField(sev.FieldUpdatedAt, field.TypeTime)
|
||||
}
|
||||
if suo.mutation.CreatedAtCleared() {
|
||||
_spec.ClearField(sev.FieldCreatedAt, field.TypeTime)
|
||||
}
|
||||
if suo.mutation.OwnerCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: sev.OwnerTable,
|
||||
Columns: []string{sev.OwnerColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := suo.mutation.OwnerIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: sev.OwnerTable,
|
||||
Columns: []string{sev.OwnerColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &Sev{config: suo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{sev.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
suo.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
@@ -16,12 +16,6 @@ type Tx struct {
|
||||
Card *CardClient
|
||||
// Group is the client for interacting with the Group builders.
|
||||
Group *GroupClient
|
||||
// Ma is the client for interacting with the Ma builders.
|
||||
Ma *MaClient
|
||||
// Sev is the client for interacting with the Sev builders.
|
||||
Sev *SevClient
|
||||
// Ue is the client for interacting with the Ue builders.
|
||||
Ue *UeClient
|
||||
// User is the client for interacting with the User builders.
|
||||
User *UserClient
|
||||
|
||||
@@ -157,9 +151,6 @@ func (tx *Tx) Client() *Client {
|
||||
func (tx *Tx) init() {
|
||||
tx.Card = NewCardClient(tx.config)
|
||||
tx.Group = NewGroupClient(tx.config)
|
||||
tx.Ma = NewMaClient(tx.config)
|
||||
tx.Sev = NewSevClient(tx.config)
|
||||
tx.Ue = NewUeClient(tx.config)
|
||||
tx.User = NewUserClient(tx.config)
|
||||
}
|
||||
|
||||
|
||||
400
ent/ue.go
400
ent/ue.go
@@ -1,400 +0,0 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/ue"
|
||||
"api/ent/user"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// Ue is the model entity for the Ue schema.
|
||||
type Ue struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// Limit holds the value of the "limit" field.
|
||||
Limit bool `json:"limit,omitempty"`
|
||||
// LimitBoss holds the value of the "limit_boss" field.
|
||||
LimitBoss bool `json:"limit_boss,omitempty"`
|
||||
// LimitItem holds the value of the "limit_item" field.
|
||||
LimitItem bool `json:"limit_item,omitempty"`
|
||||
// Password holds the value of the "password" field.
|
||||
Password string `json:"-"`
|
||||
// Lv holds the value of the "lv" field.
|
||||
Lv int `json:"lv,omitempty"`
|
||||
// LvPoint holds the value of the "lv_point" field.
|
||||
LvPoint int `json:"lv_point,omitempty"`
|
||||
// Model holds the value of the "model" field.
|
||||
Model int `json:"model,omitempty"`
|
||||
// Sword holds the value of the "sword" field.
|
||||
Sword int `json:"sword,omitempty"`
|
||||
// Card holds the value of the "card" field.
|
||||
Card int `json:"card,omitempty"`
|
||||
// Mode holds the value of the "mode" field.
|
||||
Mode string `json:"mode,omitempty"`
|
||||
// Token holds the value of the "token" field.
|
||||
Token string `json:"-"`
|
||||
// Cp holds the value of the "cp" field.
|
||||
Cp int `json:"cp,omitempty"`
|
||||
// Count holds the value of the "count" field.
|
||||
Count int `json:"count,omitempty"`
|
||||
// LocationX holds the value of the "location_x" field.
|
||||
LocationX int `json:"location_x,omitempty"`
|
||||
// LocationY holds the value of the "location_y" field.
|
||||
LocationY int `json:"location_y,omitempty"`
|
||||
// LocationZ holds the value of the "location_z" field.
|
||||
LocationZ int `json:"location_z,omitempty"`
|
||||
// LocationN holds the value of the "location_n" field.
|
||||
LocationN int `json:"location_n,omitempty"`
|
||||
// Author holds the value of the "author" field.
|
||||
Author string `json:"author,omitempty"`
|
||||
// GameLv holds the value of the "game_lv" field.
|
||||
GameLv string `json:"game_lv,omitempty"`
|
||||
// GameExp holds the value of the "game_exp" field.
|
||||
GameExp string `json:"game_exp,omitempty"`
|
||||
// GameID holds the value of the "game_id" field.
|
||||
GameID string `json:"game_id,omitempty"`
|
||||
// GameStory holds the value of the "game_story" field.
|
||||
GameStory int `json:"game_story,omitempty"`
|
||||
// GameEp holds the value of the "game_ep" field.
|
||||
GameEp string `json:"game_ep,omitempty"`
|
||||
// CreatedAt holds the value of the "created_at" field.
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the UeQuery when eager-loading is set.
|
||||
Edges UeEdges `json:"edges"`
|
||||
user_ue *int
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// UeEdges holds the relations/edges for other nodes in the graph.
|
||||
type UeEdges struct {
|
||||
// Owner holds the value of the owner edge.
|
||||
Owner *User `json:"owner,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [1]bool
|
||||
}
|
||||
|
||||
// OwnerOrErr returns the Owner value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e UeEdges) OwnerOrErr() (*User, error) {
|
||||
if e.loadedTypes[0] {
|
||||
if e.Owner == nil {
|
||||
// Edge was loaded but was not found.
|
||||
return nil, &NotFoundError{label: user.Label}
|
||||
}
|
||||
return e.Owner, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "owner"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Ue) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case ue.FieldLimit, ue.FieldLimitBoss, ue.FieldLimitItem:
|
||||
values[i] = new(sql.NullBool)
|
||||
case ue.FieldID, ue.FieldLv, ue.FieldLvPoint, ue.FieldModel, ue.FieldSword, ue.FieldCard, ue.FieldCp, ue.FieldCount, ue.FieldLocationX, ue.FieldLocationY, ue.FieldLocationZ, ue.FieldLocationN, ue.FieldGameStory:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case ue.FieldPassword, ue.FieldMode, ue.FieldToken, ue.FieldAuthor, ue.FieldGameLv, ue.FieldGameExp, ue.FieldGameID, ue.FieldGameEp:
|
||||
values[i] = new(sql.NullString)
|
||||
case ue.FieldCreatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case ue.ForeignKeys[0]: // user_ue
|
||||
values[i] = new(sql.NullInt64)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Ue fields.
|
||||
func (u *Ue) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case ue.FieldID:
|
||||
value, ok := values[i].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
u.ID = int(value.Int64)
|
||||
case ue.FieldLimit:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field limit", values[i])
|
||||
} else if value.Valid {
|
||||
u.Limit = value.Bool
|
||||
}
|
||||
case ue.FieldLimitBoss:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field limit_boss", values[i])
|
||||
} else if value.Valid {
|
||||
u.LimitBoss = value.Bool
|
||||
}
|
||||
case ue.FieldLimitItem:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field limit_item", values[i])
|
||||
} else if value.Valid {
|
||||
u.LimitItem = value.Bool
|
||||
}
|
||||
case ue.FieldPassword:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field password", values[i])
|
||||
} else if value.Valid {
|
||||
u.Password = value.String
|
||||
}
|
||||
case ue.FieldLv:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field lv", values[i])
|
||||
} else if value.Valid {
|
||||
u.Lv = int(value.Int64)
|
||||
}
|
||||
case ue.FieldLvPoint:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field lv_point", values[i])
|
||||
} else if value.Valid {
|
||||
u.LvPoint = int(value.Int64)
|
||||
}
|
||||
case ue.FieldModel:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field model", values[i])
|
||||
} else if value.Valid {
|
||||
u.Model = int(value.Int64)
|
||||
}
|
||||
case ue.FieldSword:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field sword", values[i])
|
||||
} else if value.Valid {
|
||||
u.Sword = int(value.Int64)
|
||||
}
|
||||
case ue.FieldCard:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field card", values[i])
|
||||
} else if value.Valid {
|
||||
u.Card = int(value.Int64)
|
||||
}
|
||||
case ue.FieldMode:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field mode", values[i])
|
||||
} else if value.Valid {
|
||||
u.Mode = value.String
|
||||
}
|
||||
case ue.FieldToken:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field token", values[i])
|
||||
} else if value.Valid {
|
||||
u.Token = value.String
|
||||
}
|
||||
case ue.FieldCp:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field cp", values[i])
|
||||
} else if value.Valid {
|
||||
u.Cp = int(value.Int64)
|
||||
}
|
||||
case ue.FieldCount:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field count", values[i])
|
||||
} else if value.Valid {
|
||||
u.Count = int(value.Int64)
|
||||
}
|
||||
case ue.FieldLocationX:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field location_x", values[i])
|
||||
} else if value.Valid {
|
||||
u.LocationX = int(value.Int64)
|
||||
}
|
||||
case ue.FieldLocationY:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field location_y", values[i])
|
||||
} else if value.Valid {
|
||||
u.LocationY = int(value.Int64)
|
||||
}
|
||||
case ue.FieldLocationZ:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field location_z", values[i])
|
||||
} else if value.Valid {
|
||||
u.LocationZ = int(value.Int64)
|
||||
}
|
||||
case ue.FieldLocationN:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field location_n", values[i])
|
||||
} else if value.Valid {
|
||||
u.LocationN = int(value.Int64)
|
||||
}
|
||||
case ue.FieldAuthor:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field author", values[i])
|
||||
} else if value.Valid {
|
||||
u.Author = value.String
|
||||
}
|
||||
case ue.FieldGameLv:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field game_lv", values[i])
|
||||
} else if value.Valid {
|
||||
u.GameLv = value.String
|
||||
}
|
||||
case ue.FieldGameExp:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field game_exp", values[i])
|
||||
} else if value.Valid {
|
||||
u.GameExp = value.String
|
||||
}
|
||||
case ue.FieldGameID:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field game_id", values[i])
|
||||
} else if value.Valid {
|
||||
u.GameID = value.String
|
||||
}
|
||||
case ue.FieldGameStory:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field game_story", values[i])
|
||||
} else if value.Valid {
|
||||
u.GameStory = int(value.Int64)
|
||||
}
|
||||
case ue.FieldGameEp:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field game_ep", values[i])
|
||||
} else if value.Valid {
|
||||
u.GameEp = value.String
|
||||
}
|
||||
case ue.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
u.CreatedAt = value.Time
|
||||
}
|
||||
case ue.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for edge-field user_ue", value)
|
||||
} else if value.Valid {
|
||||
u.user_ue = new(int)
|
||||
*u.user_ue = int(value.Int64)
|
||||
}
|
||||
default:
|
||||
u.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Ue.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (u *Ue) Value(name string) (ent.Value, error) {
|
||||
return u.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryOwner queries the "owner" edge of the Ue entity.
|
||||
func (u *Ue) QueryOwner() *UserQuery {
|
||||
return NewUeClient(u.config).QueryOwner(u)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Ue.
|
||||
// Note that you need to call Ue.Unwrap() before calling this method if this Ue
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (u *Ue) Update() *UeUpdateOne {
|
||||
return NewUeClient(u.config).UpdateOne(u)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Ue entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (u *Ue) Unwrap() *Ue {
|
||||
_tx, ok := u.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Ue is not a transactional entity")
|
||||
}
|
||||
u.config.driver = _tx.drv
|
||||
return u
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (u *Ue) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Ue(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", u.ID))
|
||||
builder.WriteString("limit=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Limit))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("limit_boss=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.LimitBoss))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("limit_item=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.LimitItem))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("password=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("lv=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Lv))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("lv_point=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.LvPoint))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("model=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Model))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("sword=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Sword))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("card=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Card))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("mode=")
|
||||
builder.WriteString(u.Mode)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("token=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("cp=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Cp))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("count=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Count))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("location_x=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.LocationX))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("location_y=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.LocationY))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("location_z=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.LocationZ))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("location_n=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.LocationN))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("author=")
|
||||
builder.WriteString(u.Author)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("game_lv=")
|
||||
builder.WriteString(u.GameLv)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("game_exp=")
|
||||
builder.WriteString(u.GameExp)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("game_id=")
|
||||
builder.WriteString(u.GameID)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("game_story=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.GameStory))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("game_ep=")
|
||||
builder.WriteString(u.GameEp)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(u.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// Ues is a parsable slice of Ue.
|
||||
type Ues []*Ue
|
||||
281
ent/ue/ue.go
281
ent/ue/ue.go
@@ -1,281 +0,0 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ue
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the ue type in the database.
|
||||
Label = "ue"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldLimit holds the string denoting the limit field in the database.
|
||||
FieldLimit = "limit"
|
||||
// FieldLimitBoss holds the string denoting the limit_boss field in the database.
|
||||
FieldLimitBoss = "limit_boss"
|
||||
// FieldLimitItem holds the string denoting the limit_item field in the database.
|
||||
FieldLimitItem = "limit_item"
|
||||
// FieldPassword holds the string denoting the password field in the database.
|
||||
FieldPassword = "password"
|
||||
// FieldLv holds the string denoting the lv field in the database.
|
||||
FieldLv = "lv"
|
||||
// FieldLvPoint holds the string denoting the lv_point field in the database.
|
||||
FieldLvPoint = "lv_point"
|
||||
// FieldModel holds the string denoting the model field in the database.
|
||||
FieldModel = "model"
|
||||
// FieldSword holds the string denoting the sword field in the database.
|
||||
FieldSword = "sword"
|
||||
// FieldCard holds the string denoting the card field in the database.
|
||||
FieldCard = "card"
|
||||
// FieldMode holds the string denoting the mode field in the database.
|
||||
FieldMode = "mode"
|
||||
// FieldToken holds the string denoting the token field in the database.
|
||||
FieldToken = "token"
|
||||
// FieldCp holds the string denoting the cp field in the database.
|
||||
FieldCp = "cp"
|
||||
// FieldCount holds the string denoting the count field in the database.
|
||||
FieldCount = "count"
|
||||
// FieldLocationX holds the string denoting the location_x field in the database.
|
||||
FieldLocationX = "location_x"
|
||||
// FieldLocationY holds the string denoting the location_y field in the database.
|
||||
FieldLocationY = "location_y"
|
||||
// FieldLocationZ holds the string denoting the location_z field in the database.
|
||||
FieldLocationZ = "location_z"
|
||||
// FieldLocationN holds the string denoting the location_n field in the database.
|
||||
FieldLocationN = "location_n"
|
||||
// FieldAuthor holds the string denoting the author field in the database.
|
||||
FieldAuthor = "author"
|
||||
// FieldGameLv holds the string denoting the game_lv field in the database.
|
||||
FieldGameLv = "game_lv"
|
||||
// FieldGameExp holds the string denoting the game_exp field in the database.
|
||||
FieldGameExp = "game_exp"
|
||||
// FieldGameID holds the string denoting the game_id field in the database.
|
||||
FieldGameID = "game_id"
|
||||
// FieldGameStory holds the string denoting the game_story field in the database.
|
||||
FieldGameStory = "game_story"
|
||||
// FieldGameEp holds the string denoting the game_ep field in the database.
|
||||
FieldGameEp = "game_ep"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// EdgeOwner holds the string denoting the owner edge name in mutations.
|
||||
EdgeOwner = "owner"
|
||||
// Table holds the table name of the ue in the database.
|
||||
Table = "ues"
|
||||
// OwnerTable is the table that holds the owner relation/edge.
|
||||
OwnerTable = "ues"
|
||||
// OwnerInverseTable is the table name for the User entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "user" package.
|
||||
OwnerInverseTable = "users"
|
||||
// OwnerColumn is the table column denoting the owner relation/edge.
|
||||
OwnerColumn = "user_ue"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for ue fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldLimit,
|
||||
FieldLimitBoss,
|
||||
FieldLimitItem,
|
||||
FieldPassword,
|
||||
FieldLv,
|
||||
FieldLvPoint,
|
||||
FieldModel,
|
||||
FieldSword,
|
||||
FieldCard,
|
||||
FieldMode,
|
||||
FieldToken,
|
||||
FieldCp,
|
||||
FieldCount,
|
||||
FieldLocationX,
|
||||
FieldLocationY,
|
||||
FieldLocationZ,
|
||||
FieldLocationN,
|
||||
FieldAuthor,
|
||||
FieldGameLv,
|
||||
FieldGameExp,
|
||||
FieldGameID,
|
||||
FieldGameStory,
|
||||
FieldGameEp,
|
||||
FieldCreatedAt,
|
||||
}
|
||||
|
||||
// ForeignKeys holds the SQL foreign-keys that are owned by the "ues"
|
||||
// table and are not defined as standalone fields in the schema.
|
||||
var ForeignKeys = []string{
|
||||
"user_ue",
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
for i := range ForeignKeys {
|
||||
if column == ForeignKeys[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// DefaultLimit holds the default value on creation for the "limit" field.
|
||||
DefaultLimit bool
|
||||
// DefaultLimitBoss holds the default value on creation for the "limit_boss" field.
|
||||
DefaultLimitBoss bool
|
||||
// DefaultLimitItem holds the default value on creation for the "limit_item" field.
|
||||
DefaultLimitItem bool
|
||||
// PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
PasswordValidator func(string) error
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() time.Time
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the Ue queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLimit orders the results by the limit field.
|
||||
func ByLimit(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLimit, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLimitBoss orders the results by the limit_boss field.
|
||||
func ByLimitBoss(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLimitBoss, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLimitItem orders the results by the limit_item field.
|
||||
func ByLimitItem(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLimitItem, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPassword orders the results by the password field.
|
||||
func ByPassword(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPassword, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLv orders the results by the lv field.
|
||||
func ByLv(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLv, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLvPoint orders the results by the lv_point field.
|
||||
func ByLvPoint(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLvPoint, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByModel orders the results by the model field.
|
||||
func ByModel(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldModel, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySword orders the results by the sword field.
|
||||
func BySword(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSword, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCard orders the results by the card field.
|
||||
func ByCard(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCard, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByMode orders the results by the mode field.
|
||||
func ByMode(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldMode, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByToken orders the results by the token field.
|
||||
func ByToken(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldToken, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCp orders the results by the cp field.
|
||||
func ByCp(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCp, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCount orders the results by the count field.
|
||||
func ByCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCount, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLocationX orders the results by the location_x field.
|
||||
func ByLocationX(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLocationX, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLocationY orders the results by the location_y field.
|
||||
func ByLocationY(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLocationY, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLocationZ orders the results by the location_z field.
|
||||
func ByLocationZ(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLocationZ, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLocationN orders the results by the location_n field.
|
||||
func ByLocationN(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLocationN, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByAuthor orders the results by the author field.
|
||||
func ByAuthor(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldAuthor, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByGameLv orders the results by the game_lv field.
|
||||
func ByGameLv(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldGameLv, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByGameExp orders the results by the game_exp field.
|
||||
func ByGameExp(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldGameExp, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByGameID orders the results by the game_id field.
|
||||
func ByGameID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldGameID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByGameStory orders the results by the game_story field.
|
||||
func ByGameStory(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldGameStory, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByGameEp orders the results by the game_ep field.
|
||||
func ByGameEp(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldGameEp, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByOwnerField orders the results by owner field.
|
||||
func ByOwnerField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newOwnerStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
func newOwnerStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(OwnerInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn),
|
||||
)
|
||||
}
|
||||
1531
ent/ue/where.go
1531
ent/ue/where.go
File diff suppressed because it is too large
Load Diff
653
ent/ue_create.go
653
ent/ue_create.go
@@ -1,653 +0,0 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/ue"
|
||||
"api/ent/user"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// UeCreate is the builder for creating a Ue entity.
|
||||
type UeCreate struct {
|
||||
config
|
||||
mutation *UeMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetLimit sets the "limit" field.
|
||||
func (uc *UeCreate) SetLimit(b bool) *UeCreate {
|
||||
uc.mutation.SetLimit(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLimit sets the "limit" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableLimit(b *bool) *UeCreate {
|
||||
if b != nil {
|
||||
uc.SetLimit(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLimitBoss sets the "limit_boss" field.
|
||||
func (uc *UeCreate) SetLimitBoss(b bool) *UeCreate {
|
||||
uc.mutation.SetLimitBoss(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLimitBoss sets the "limit_boss" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableLimitBoss(b *bool) *UeCreate {
|
||||
if b != nil {
|
||||
uc.SetLimitBoss(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLimitItem sets the "limit_item" field.
|
||||
func (uc *UeCreate) SetLimitItem(b bool) *UeCreate {
|
||||
uc.mutation.SetLimitItem(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLimitItem sets the "limit_item" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableLimitItem(b *bool) *UeCreate {
|
||||
if b != nil {
|
||||
uc.SetLimitItem(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetPassword sets the "password" field.
|
||||
func (uc *UeCreate) SetPassword(s string) *UeCreate {
|
||||
uc.mutation.SetPassword(s)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLv sets the "lv" field.
|
||||
func (uc *UeCreate) SetLv(i int) *UeCreate {
|
||||
uc.mutation.SetLv(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLv sets the "lv" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableLv(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetLv(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLvPoint sets the "lv_point" field.
|
||||
func (uc *UeCreate) SetLvPoint(i int) *UeCreate {
|
||||
uc.mutation.SetLvPoint(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLvPoint sets the "lv_point" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableLvPoint(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetLvPoint(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetModel sets the "model" field.
|
||||
func (uc *UeCreate) SetModel(i int) *UeCreate {
|
||||
uc.mutation.SetModel(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableModel sets the "model" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableModel(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetModel(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetSword sets the "sword" field.
|
||||
func (uc *UeCreate) SetSword(i int) *UeCreate {
|
||||
uc.mutation.SetSword(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableSword sets the "sword" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableSword(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetSword(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetCard sets the "card" field.
|
||||
func (uc *UeCreate) SetCard(i int) *UeCreate {
|
||||
uc.mutation.SetCard(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableCard sets the "card" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableCard(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetCard(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetMode sets the "mode" field.
|
||||
func (uc *UeCreate) SetMode(s string) *UeCreate {
|
||||
uc.mutation.SetMode(s)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableMode sets the "mode" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableMode(s *string) *UeCreate {
|
||||
if s != nil {
|
||||
uc.SetMode(*s)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetToken sets the "token" field.
|
||||
func (uc *UeCreate) SetToken(s string) *UeCreate {
|
||||
uc.mutation.SetToken(s)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableToken sets the "token" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableToken(s *string) *UeCreate {
|
||||
if s != nil {
|
||||
uc.SetToken(*s)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetCp sets the "cp" field.
|
||||
func (uc *UeCreate) SetCp(i int) *UeCreate {
|
||||
uc.mutation.SetCp(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableCp sets the "cp" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableCp(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetCp(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetCount sets the "count" field.
|
||||
func (uc *UeCreate) SetCount(i int) *UeCreate {
|
||||
uc.mutation.SetCount(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableCount sets the "count" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableCount(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetCount(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLocationX sets the "location_x" field.
|
||||
func (uc *UeCreate) SetLocationX(i int) *UeCreate {
|
||||
uc.mutation.SetLocationX(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLocationX sets the "location_x" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableLocationX(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetLocationX(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLocationY sets the "location_y" field.
|
||||
func (uc *UeCreate) SetLocationY(i int) *UeCreate {
|
||||
uc.mutation.SetLocationY(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLocationY sets the "location_y" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableLocationY(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetLocationY(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLocationZ sets the "location_z" field.
|
||||
func (uc *UeCreate) SetLocationZ(i int) *UeCreate {
|
||||
uc.mutation.SetLocationZ(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLocationZ sets the "location_z" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableLocationZ(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetLocationZ(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLocationN sets the "location_n" field.
|
||||
func (uc *UeCreate) SetLocationN(i int) *UeCreate {
|
||||
uc.mutation.SetLocationN(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLocationN sets the "location_n" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableLocationN(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetLocationN(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetAuthor sets the "author" field.
|
||||
func (uc *UeCreate) SetAuthor(s string) *UeCreate {
|
||||
uc.mutation.SetAuthor(s)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableAuthor sets the "author" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableAuthor(s *string) *UeCreate {
|
||||
if s != nil {
|
||||
uc.SetAuthor(*s)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetGameLv sets the "game_lv" field.
|
||||
func (uc *UeCreate) SetGameLv(s string) *UeCreate {
|
||||
uc.mutation.SetGameLv(s)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableGameLv sets the "game_lv" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableGameLv(s *string) *UeCreate {
|
||||
if s != nil {
|
||||
uc.SetGameLv(*s)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetGameExp sets the "game_exp" field.
|
||||
func (uc *UeCreate) SetGameExp(s string) *UeCreate {
|
||||
uc.mutation.SetGameExp(s)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableGameExp sets the "game_exp" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableGameExp(s *string) *UeCreate {
|
||||
if s != nil {
|
||||
uc.SetGameExp(*s)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetGameID sets the "game_id" field.
|
||||
func (uc *UeCreate) SetGameID(s string) *UeCreate {
|
||||
uc.mutation.SetGameID(s)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableGameID sets the "game_id" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableGameID(s *string) *UeCreate {
|
||||
if s != nil {
|
||||
uc.SetGameID(*s)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetGameStory sets the "game_story" field.
|
||||
func (uc *UeCreate) SetGameStory(i int) *UeCreate {
|
||||
uc.mutation.SetGameStory(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableGameStory sets the "game_story" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableGameStory(i *int) *UeCreate {
|
||||
if i != nil {
|
||||
uc.SetGameStory(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetGameEp sets the "game_ep" field.
|
||||
func (uc *UeCreate) SetGameEp(s string) *UeCreate {
|
||||
uc.mutation.SetGameEp(s)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableGameEp sets the "game_ep" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableGameEp(s *string) *UeCreate {
|
||||
if s != nil {
|
||||
uc.SetGameEp(*s)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (uc *UeCreate) SetCreatedAt(t time.Time) *UeCreate {
|
||||
uc.mutation.SetCreatedAt(t)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (uc *UeCreate) SetNillableCreatedAt(t *time.Time) *UeCreate {
|
||||
if t != nil {
|
||||
uc.SetCreatedAt(*t)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetOwnerID sets the "owner" edge to the User entity by ID.
|
||||
func (uc *UeCreate) SetOwnerID(id int) *UeCreate {
|
||||
uc.mutation.SetOwnerID(id)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetOwner sets the "owner" edge to the User entity.
|
||||
func (uc *UeCreate) SetOwner(u *User) *UeCreate {
|
||||
return uc.SetOwnerID(u.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the UeMutation object of the builder.
|
||||
func (uc *UeCreate) Mutation() *UeMutation {
|
||||
return uc.mutation
|
||||
}
|
||||
|
||||
// Save creates the Ue in the database.
|
||||
func (uc *UeCreate) Save(ctx context.Context) (*Ue, error) {
|
||||
uc.defaults()
|
||||
return withHooks[*Ue, UeMutation](ctx, uc.sqlSave, uc.mutation, uc.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (uc *UeCreate) SaveX(ctx context.Context) *Ue {
|
||||
v, err := uc.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (uc *UeCreate) Exec(ctx context.Context) error {
|
||||
_, err := uc.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (uc *UeCreate) ExecX(ctx context.Context) {
|
||||
if err := uc.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (uc *UeCreate) defaults() {
|
||||
if _, ok := uc.mutation.Limit(); !ok {
|
||||
v := ue.DefaultLimit
|
||||
uc.mutation.SetLimit(v)
|
||||
}
|
||||
if _, ok := uc.mutation.LimitBoss(); !ok {
|
||||
v := ue.DefaultLimitBoss
|
||||
uc.mutation.SetLimitBoss(v)
|
||||
}
|
||||
if _, ok := uc.mutation.LimitItem(); !ok {
|
||||
v := ue.DefaultLimitItem
|
||||
uc.mutation.SetLimitItem(v)
|
||||
}
|
||||
if _, ok := uc.mutation.CreatedAt(); !ok {
|
||||
v := ue.DefaultCreatedAt()
|
||||
uc.mutation.SetCreatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (uc *UeCreate) check() error {
|
||||
if _, ok := uc.mutation.Password(); !ok {
|
||||
return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "Ue.password"`)}
|
||||
}
|
||||
if v, ok := uc.mutation.Password(); ok {
|
||||
if err := ue.PasswordValidator(v); err != nil {
|
||||
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "Ue.password": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := uc.mutation.OwnerID(); !ok {
|
||||
return &ValidationError{Name: "owner", err: errors.New(`ent: missing required edge "Ue.owner"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (uc *UeCreate) sqlSave(ctx context.Context) (*Ue, error) {
|
||||
if err := uc.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := uc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = int(id)
|
||||
uc.mutation.id = &_node.ID
|
||||
uc.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (uc *UeCreate) createSpec() (*Ue, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Ue{config: uc.config}
|
||||
_spec = sqlgraph.NewCreateSpec(ue.Table, sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := uc.mutation.Limit(); ok {
|
||||
_spec.SetField(ue.FieldLimit, field.TypeBool, value)
|
||||
_node.Limit = value
|
||||
}
|
||||
if value, ok := uc.mutation.LimitBoss(); ok {
|
||||
_spec.SetField(ue.FieldLimitBoss, field.TypeBool, value)
|
||||
_node.LimitBoss = value
|
||||
}
|
||||
if value, ok := uc.mutation.LimitItem(); ok {
|
||||
_spec.SetField(ue.FieldLimitItem, field.TypeBool, value)
|
||||
_node.LimitItem = value
|
||||
}
|
||||
if value, ok := uc.mutation.Password(); ok {
|
||||
_spec.SetField(ue.FieldPassword, field.TypeString, value)
|
||||
_node.Password = value
|
||||
}
|
||||
if value, ok := uc.mutation.Lv(); ok {
|
||||
_spec.SetField(ue.FieldLv, field.TypeInt, value)
|
||||
_node.Lv = value
|
||||
}
|
||||
if value, ok := uc.mutation.LvPoint(); ok {
|
||||
_spec.SetField(ue.FieldLvPoint, field.TypeInt, value)
|
||||
_node.LvPoint = value
|
||||
}
|
||||
if value, ok := uc.mutation.Model(); ok {
|
||||
_spec.SetField(ue.FieldModel, field.TypeInt, value)
|
||||
_node.Model = value
|
||||
}
|
||||
if value, ok := uc.mutation.Sword(); ok {
|
||||
_spec.SetField(ue.FieldSword, field.TypeInt, value)
|
||||
_node.Sword = value
|
||||
}
|
||||
if value, ok := uc.mutation.Card(); ok {
|
||||
_spec.SetField(ue.FieldCard, field.TypeInt, value)
|
||||
_node.Card = value
|
||||
}
|
||||
if value, ok := uc.mutation.Mode(); ok {
|
||||
_spec.SetField(ue.FieldMode, field.TypeString, value)
|
||||
_node.Mode = value
|
||||
}
|
||||
if value, ok := uc.mutation.Token(); ok {
|
||||
_spec.SetField(ue.FieldToken, field.TypeString, value)
|
||||
_node.Token = value
|
||||
}
|
||||
if value, ok := uc.mutation.Cp(); ok {
|
||||
_spec.SetField(ue.FieldCp, field.TypeInt, value)
|
||||
_node.Cp = value
|
||||
}
|
||||
if value, ok := uc.mutation.Count(); ok {
|
||||
_spec.SetField(ue.FieldCount, field.TypeInt, value)
|
||||
_node.Count = value
|
||||
}
|
||||
if value, ok := uc.mutation.LocationX(); ok {
|
||||
_spec.SetField(ue.FieldLocationX, field.TypeInt, value)
|
||||
_node.LocationX = value
|
||||
}
|
||||
if value, ok := uc.mutation.LocationY(); ok {
|
||||
_spec.SetField(ue.FieldLocationY, field.TypeInt, value)
|
||||
_node.LocationY = value
|
||||
}
|
||||
if value, ok := uc.mutation.LocationZ(); ok {
|
||||
_spec.SetField(ue.FieldLocationZ, field.TypeInt, value)
|
||||
_node.LocationZ = value
|
||||
}
|
||||
if value, ok := uc.mutation.LocationN(); ok {
|
||||
_spec.SetField(ue.FieldLocationN, field.TypeInt, value)
|
||||
_node.LocationN = value
|
||||
}
|
||||
if value, ok := uc.mutation.Author(); ok {
|
||||
_spec.SetField(ue.FieldAuthor, field.TypeString, value)
|
||||
_node.Author = value
|
||||
}
|
||||
if value, ok := uc.mutation.GameLv(); ok {
|
||||
_spec.SetField(ue.FieldGameLv, field.TypeString, value)
|
||||
_node.GameLv = value
|
||||
}
|
||||
if value, ok := uc.mutation.GameExp(); ok {
|
||||
_spec.SetField(ue.FieldGameExp, field.TypeString, value)
|
||||
_node.GameExp = value
|
||||
}
|
||||
if value, ok := uc.mutation.GameID(); ok {
|
||||
_spec.SetField(ue.FieldGameID, field.TypeString, value)
|
||||
_node.GameID = value
|
||||
}
|
||||
if value, ok := uc.mutation.GameStory(); ok {
|
||||
_spec.SetField(ue.FieldGameStory, field.TypeInt, value)
|
||||
_node.GameStory = value
|
||||
}
|
||||
if value, ok := uc.mutation.GameEp(); ok {
|
||||
_spec.SetField(ue.FieldGameEp, field.TypeString, value)
|
||||
_node.GameEp = value
|
||||
}
|
||||
if value, ok := uc.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(ue.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if nodes := uc.mutation.OwnerIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: ue.OwnerTable,
|
||||
Columns: []string{ue.OwnerColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_node.user_ue = &nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// UeCreateBulk is the builder for creating many Ue entities in bulk.
|
||||
type UeCreateBulk struct {
|
||||
config
|
||||
builders []*UeCreate
|
||||
}
|
||||
|
||||
// Save creates the Ue entities in the database.
|
||||
func (ucb *UeCreateBulk) Save(ctx context.Context) ([]*Ue, error) {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(ucb.builders))
|
||||
nodes := make([]*Ue, len(ucb.builders))
|
||||
mutators := make([]Mutator, len(ucb.builders))
|
||||
for i := range ucb.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := ucb.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*UeMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err := builder.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, ucb.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &nodes[i].ID
|
||||
if specs[i].ID.Value != nil {
|
||||
id := specs[i].ID.Value.(int64)
|
||||
nodes[i].ID = int(id)
|
||||
}
|
||||
mutation.done = true
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
mut = builder.hooks[i](mut)
|
||||
}
|
||||
mutators[i] = mut
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, ucb.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (ucb *UeCreateBulk) SaveX(ctx context.Context) []*Ue {
|
||||
v, err := ucb.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (ucb *UeCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := ucb.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ucb *UeCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := ucb.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/predicate"
|
||||
"api/ent/ue"
|
||||
"context"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// UeDelete is the builder for deleting a Ue entity.
|
||||
type UeDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *UeMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the UeDelete builder.
|
||||
func (ud *UeDelete) Where(ps ...predicate.Ue) *UeDelete {
|
||||
ud.mutation.Where(ps...)
|
||||
return ud
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (ud *UeDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks[int, UeMutation](ctx, ud.sqlExec, ud.mutation, ud.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ud *UeDelete) ExecX(ctx context.Context) int {
|
||||
n, err := ud.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (ud *UeDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(ue.Table, sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt))
|
||||
if ps := ud.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, ud.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
ud.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// UeDeleteOne is the builder for deleting a single Ue entity.
|
||||
type UeDeleteOne struct {
|
||||
ud *UeDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the UeDelete builder.
|
||||
func (udo *UeDeleteOne) Where(ps ...predicate.Ue) *UeDeleteOne {
|
||||
udo.ud.mutation.Where(ps...)
|
||||
return udo
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (udo *UeDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := udo.ud.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{ue.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (udo *UeDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := udo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
613
ent/ue_query.go
613
ent/ue_query.go
@@ -1,613 +0,0 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/predicate"
|
||||
"api/ent/ue"
|
||||
"api/ent/user"
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// UeQuery is the builder for querying Ue entities.
|
||||
type UeQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []ue.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.Ue
|
||||
withOwner *UserQuery
|
||||
withFKs bool
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the UeQuery builder.
|
||||
func (uq *UeQuery) Where(ps ...predicate.Ue) *UeQuery {
|
||||
uq.predicates = append(uq.predicates, ps...)
|
||||
return uq
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (uq *UeQuery) Limit(limit int) *UeQuery {
|
||||
uq.ctx.Limit = &limit
|
||||
return uq
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (uq *UeQuery) Offset(offset int) *UeQuery {
|
||||
uq.ctx.Offset = &offset
|
||||
return uq
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (uq *UeQuery) Unique(unique bool) *UeQuery {
|
||||
uq.ctx.Unique = &unique
|
||||
return uq
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (uq *UeQuery) Order(o ...ue.OrderOption) *UeQuery {
|
||||
uq.order = append(uq.order, o...)
|
||||
return uq
|
||||
}
|
||||
|
||||
// QueryOwner chains the current query on the "owner" edge.
|
||||
func (uq *UeQuery) QueryOwner() *UserQuery {
|
||||
query := (&UserClient{config: uq.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := uq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := uq.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(ue.Table, ue.FieldID, selector),
|
||||
sqlgraph.To(user.Table, user.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ue.OwnerTable, ue.OwnerColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first Ue entity from the query.
|
||||
// Returns a *NotFoundError when no Ue was found.
|
||||
func (uq *UeQuery) First(ctx context.Context) (*Ue, error) {
|
||||
nodes, err := uq.Limit(1).All(setContextOp(ctx, uq.ctx, "First"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{ue.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (uq *UeQuery) FirstX(ctx context.Context) *Ue {
|
||||
node, err := uq.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first Ue ID from the query.
|
||||
// Returns a *NotFoundError when no Ue ID was found.
|
||||
func (uq *UeQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = uq.Limit(1).IDs(setContextOp(ctx, uq.ctx, "FirstID")); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{ue.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (uq *UeQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := uq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single Ue entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Ue entity is found.
|
||||
// Returns a *NotFoundError when no Ue entities are found.
|
||||
func (uq *UeQuery) Only(ctx context.Context) (*Ue, error) {
|
||||
nodes, err := uq.Limit(2).All(setContextOp(ctx, uq.ctx, "Only"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{ue.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{ue.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (uq *UeQuery) OnlyX(ctx context.Context) *Ue {
|
||||
node, err := uq.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only Ue ID in the query.
|
||||
// Returns a *NotSingularError when more than one Ue ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (uq *UeQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = uq.Limit(2).IDs(setContextOp(ctx, uq.ctx, "OnlyID")); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{ue.Label}
|
||||
default:
|
||||
err = &NotSingularError{ue.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (uq *UeQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := uq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of Ues.
|
||||
func (uq *UeQuery) All(ctx context.Context) ([]*Ue, error) {
|
||||
ctx = setContextOp(ctx, uq.ctx, "All")
|
||||
if err := uq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Ue, *UeQuery]()
|
||||
return withInterceptors[[]*Ue](ctx, uq, qr, uq.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (uq *UeQuery) AllX(ctx context.Context) []*Ue {
|
||||
nodes, err := uq.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Ue IDs.
|
||||
func (uq *UeQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if uq.ctx.Unique == nil && uq.path != nil {
|
||||
uq.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, uq.ctx, "IDs")
|
||||
if err = uq.Select(ue.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (uq *UeQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := uq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (uq *UeQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, uq.ctx, "Count")
|
||||
if err := uq.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, uq, querierCount[*UeQuery](), uq.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (uq *UeQuery) CountX(ctx context.Context) int {
|
||||
count, err := uq.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (uq *UeQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, uq.ctx, "Exist")
|
||||
switch _, err := uq.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||
default:
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (uq *UeQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := uq.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the UeQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (uq *UeQuery) Clone() *UeQuery {
|
||||
if uq == nil {
|
||||
return nil
|
||||
}
|
||||
return &UeQuery{
|
||||
config: uq.config,
|
||||
ctx: uq.ctx.Clone(),
|
||||
order: append([]ue.OrderOption{}, uq.order...),
|
||||
inters: append([]Interceptor{}, uq.inters...),
|
||||
predicates: append([]predicate.Ue{}, uq.predicates...),
|
||||
withOwner: uq.withOwner.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: uq.sql.Clone(),
|
||||
path: uq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithOwner tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "owner" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (uq *UeQuery) WithOwner(opts ...func(*UserQuery)) *UeQuery {
|
||||
query := (&UserClient{config: uq.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
uq.withOwner = query
|
||||
return uq
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Limit bool `json:"limit,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Ue.Query().
|
||||
// GroupBy(ue.FieldLimit).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (uq *UeQuery) GroupBy(field string, fields ...string) *UeGroupBy {
|
||||
uq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &UeGroupBy{build: uq}
|
||||
grbuild.flds = &uq.ctx.Fields
|
||||
grbuild.label = ue.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
}
|
||||
|
||||
// Select allows the selection one or more fields/columns for the given query,
|
||||
// instead of selecting all fields in the entity.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Limit bool `json:"limit,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Ue.Query().
|
||||
// Select(ue.FieldLimit).
|
||||
// Scan(ctx, &v)
|
||||
func (uq *UeQuery) Select(fields ...string) *UeSelect {
|
||||
uq.ctx.Fields = append(uq.ctx.Fields, fields...)
|
||||
sbuild := &UeSelect{UeQuery: uq}
|
||||
sbuild.label = ue.Label
|
||||
sbuild.flds, sbuild.scan = &uq.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a UeSelect configured with the given aggregations.
|
||||
func (uq *UeQuery) Aggregate(fns ...AggregateFunc) *UeSelect {
|
||||
return uq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (uq *UeQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range uq.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, uq); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range uq.ctx.Fields {
|
||||
if !ue.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if uq.path != nil {
|
||||
prev, err := uq.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
uq.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (uq *UeQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Ue, error) {
|
||||
var (
|
||||
nodes = []*Ue{}
|
||||
withFKs = uq.withFKs
|
||||
_spec = uq.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
uq.withOwner != nil,
|
||||
}
|
||||
)
|
||||
if uq.withOwner != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, ue.ForeignKeys...)
|
||||
}
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*Ue).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Ue{config: uq.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, uq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := uq.withOwner; query != nil {
|
||||
if err := uq.loadOwner(ctx, query, nodes, nil,
|
||||
func(n *Ue, e *User) { n.Edges.Owner = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (uq *UeQuery) loadOwner(ctx context.Context, query *UserQuery, nodes []*Ue, init func(*Ue), assign func(*Ue, *User)) error {
|
||||
ids := make([]int, 0, len(nodes))
|
||||
nodeids := make(map[int][]*Ue)
|
||||
for i := range nodes {
|
||||
if nodes[i].user_ue == nil {
|
||||
continue
|
||||
}
|
||||
fk := *nodes[i].user_ue
|
||||
if _, ok := nodeids[fk]; !ok {
|
||||
ids = append(ids, fk)
|
||||
}
|
||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
query.Where(user.IDIn(ids...))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nodeids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected foreign-key "user_ue" returned %v`, n.ID)
|
||||
}
|
||||
for i := range nodes {
|
||||
assign(nodes[i], n)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (uq *UeQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := uq.querySpec()
|
||||
_spec.Node.Columns = uq.ctx.Fields
|
||||
if len(uq.ctx.Fields) > 0 {
|
||||
_spec.Unique = uq.ctx.Unique != nil && *uq.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, uq.driver, _spec)
|
||||
}
|
||||
|
||||
func (uq *UeQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(ue.Table, ue.Columns, sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt))
|
||||
_spec.From = uq.sql
|
||||
if unique := uq.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if uq.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := uq.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, ue.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != ue.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := uq.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := uq.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := uq.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := uq.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (uq *UeQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(uq.driver.Dialect())
|
||||
t1 := builder.Table(ue.Table)
|
||||
columns := uq.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = ue.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if uq.sql != nil {
|
||||
selector = uq.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if uq.ctx.Unique != nil && *uq.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range uq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range uq.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := uq.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := uq.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// UeGroupBy is the group-by builder for Ue entities.
|
||||
type UeGroupBy struct {
|
||||
selector
|
||||
build *UeQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (ugb *UeGroupBy) Aggregate(fns ...AggregateFunc) *UeGroupBy {
|
||||
ugb.fns = append(ugb.fns, fns...)
|
||||
return ugb
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ugb *UeGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ugb.build.ctx, "GroupBy")
|
||||
if err := ugb.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*UeQuery, *UeGroupBy](ctx, ugb.build, ugb, ugb.build.inters, v)
|
||||
}
|
||||
|
||||
func (ugb *UeGroupBy) sqlScan(ctx context.Context, root *UeQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(ugb.fns))
|
||||
for _, fn := range ugb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*ugb.flds)+len(ugb.fns))
|
||||
for _, f := range *ugb.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*ugb.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := ugb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// UeSelect is the builder for selecting fields of Ue entities.
|
||||
type UeSelect struct {
|
||||
*UeQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (us *UeSelect) Aggregate(fns ...AggregateFunc) *UeSelect {
|
||||
us.fns = append(us.fns, fns...)
|
||||
return us
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (us *UeSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, us.ctx, "Select")
|
||||
if err := us.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*UeQuery, *UeSelect](ctx, us.UeQuery, us, us.inters, v)
|
||||
}
|
||||
|
||||
func (us *UeSelect) sqlScan(ctx context.Context, root *UeQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(us.fns))
|
||||
for _, fn := range us.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*us.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
selector.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := us.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
1680
ent/ue_update.go
1680
ent/ue_update.go
File diff suppressed because it is too large
Load Diff
450
ent/user.go
450
ent/user.go
@@ -3,12 +3,11 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/user"
|
||||
"fmt"
|
||||
"strings"
|
||||
"t/ent/user"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
@@ -21,14 +20,6 @@ type User struct {
|
||||
Username string `json:"username,omitempty"`
|
||||
// Did holds the value of the "did" field.
|
||||
Did string `json:"did,omitempty"`
|
||||
// Member holds the value of the "member" field.
|
||||
Member bool `json:"member,omitempty"`
|
||||
// Book holds the value of the "book" field.
|
||||
Book bool `json:"book,omitempty"`
|
||||
// Manga holds the value of the "manga" field.
|
||||
Manga bool `json:"manga,omitempty"`
|
||||
// Badge holds the value of the "badge" field.
|
||||
Badge bool `json:"badge,omitempty"`
|
||||
// Bsky holds the value of the "bsky" field.
|
||||
Bsky bool `json:"bsky,omitempty"`
|
||||
// Mastodon holds the value of the "mastodon" field.
|
||||
@@ -47,10 +38,6 @@ type User struct {
|
||||
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||
// RaidAt holds the value of the "raid_at" field.
|
||||
RaidAt time.Time `json:"raid_at,omitempty"`
|
||||
// ServerAt holds the value of the "server_at" field.
|
||||
ServerAt time.Time `json:"server_at,omitempty"`
|
||||
// EggAt holds the value of the "egg_at" field.
|
||||
EggAt time.Time `json:"egg_at,omitempty"`
|
||||
// Luck holds the value of the "luck" field.
|
||||
Luck int `json:"luck,omitempty"`
|
||||
// LuckAt holds the value of the "luck_at" field.
|
||||
@@ -83,82 +70,19 @@ type User struct {
|
||||
TenAt time.Time `json:"ten_at,omitempty"`
|
||||
// Next holds the value of the "next" field.
|
||||
Next string `json:"next,omitempty"`
|
||||
// Room holds the value of the "room" field.
|
||||
Room int `json:"room,omitempty"`
|
||||
// Model holds the value of the "model" field.
|
||||
Model bool `json:"model,omitempty"`
|
||||
// ModelAt holds the value of the "model_at" field.
|
||||
ModelAt time.Time `json:"model_at,omitempty"`
|
||||
// ModelAttack holds the value of the "model_attack" field.
|
||||
ModelAttack int `json:"model_attack,omitempty"`
|
||||
// ModelLimit holds the value of the "model_limit" field.
|
||||
ModelLimit int `json:"model_limit,omitempty"`
|
||||
// ModelSkill holds the value of the "model_skill" field.
|
||||
ModelSkill int `json:"model_skill,omitempty"`
|
||||
// ModelMode holds the value of the "model_mode" field.
|
||||
ModelMode int `json:"model_mode,omitempty"`
|
||||
// ModelCritical holds the value of the "model_critical" field.
|
||||
ModelCritical int `json:"model_critical,omitempty"`
|
||||
// ModelCriticalD holds the value of the "model_critical_d" field.
|
||||
ModelCriticalD int `json:"model_critical_d,omitempty"`
|
||||
// Game holds the value of the "game" field.
|
||||
Game bool `json:"game,omitempty"`
|
||||
// GameTest holds the value of the "game_test" field.
|
||||
GameTest bool `json:"game_test,omitempty"`
|
||||
// GameEnd holds the value of the "game_end" field.
|
||||
GameEnd bool `json:"game_end,omitempty"`
|
||||
// GameAccount holds the value of the "game_account" field.
|
||||
GameAccount bool `json:"game_account,omitempty"`
|
||||
// GameLv holds the value of the "game_lv" field.
|
||||
GameLv int `json:"game_lv,omitempty"`
|
||||
// GameExp holds the value of the "game_exp" field.
|
||||
GameExp int `json:"game_exp,omitempty"`
|
||||
// GameStory holds the value of the "game_story" field.
|
||||
GameStory int `json:"game_story,omitempty"`
|
||||
// GameLimit holds the value of the "game_limit" field.
|
||||
GameLimit bool `json:"game_limit,omitempty"`
|
||||
// Coin holds the value of the "coin" field.
|
||||
Coin int `json:"coin,omitempty"`
|
||||
// CoinOpen holds the value of the "coin_open" field.
|
||||
CoinOpen bool `json:"coin_open,omitempty"`
|
||||
// CoinAt holds the value of the "coin_at" field.
|
||||
CoinAt time.Time `json:"coin_at,omitempty"`
|
||||
// Planet holds the value of the "planet" field.
|
||||
Planet float64 `json:"planet,omitempty"`
|
||||
// PlanetAt holds the value of the "planet_at" field.
|
||||
PlanetAt time.Time `json:"planet_at,omitempty"`
|
||||
// Login holds the value of the "login" field.
|
||||
Login bool `json:"login,omitempty"`
|
||||
// LoginAt holds the value of the "login_at" field.
|
||||
LoginAt time.Time `json:"login_at,omitempty"`
|
||||
// LocationX holds the value of the "location_x" field.
|
||||
LocationX int `json:"location_x,omitempty"`
|
||||
// LocationY holds the value of the "location_y" field.
|
||||
LocationY int `json:"location_y,omitempty"`
|
||||
// LocationZ holds the value of the "location_z" field.
|
||||
LocationZ int `json:"location_z,omitempty"`
|
||||
// LocationN holds the value of the "location_n" field.
|
||||
LocationN int `json:"location_n,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the UserQuery when eager-loading is set.
|
||||
Edges UserEdges `json:"edges"`
|
||||
group_users *int
|
||||
selectValues sql.SelectValues
|
||||
Edges UserEdges `json:"edges"`
|
||||
group_users *int
|
||||
}
|
||||
|
||||
// UserEdges holds the relations/edges for other nodes in the graph.
|
||||
type UserEdges struct {
|
||||
// Card holds the value of the card edge.
|
||||
Card []*Card `json:"card,omitempty"`
|
||||
// Ue holds the value of the ue edge.
|
||||
Ue []*Ue `json:"ue,omitempty"`
|
||||
// Ma holds the value of the ma edge.
|
||||
Ma []*Ma `json:"ma,omitempty"`
|
||||
// Sev holds the value of the sev edge.
|
||||
Sev []*Sev `json:"sev,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [4]bool
|
||||
loadedTypes [1]bool
|
||||
}
|
||||
|
||||
// CardOrErr returns the Card value or an error if the edge
|
||||
@@ -170,52 +94,23 @@ func (e UserEdges) CardOrErr() ([]*Card, error) {
|
||||
return nil, &NotLoadedError{edge: "card"}
|
||||
}
|
||||
|
||||
// UeOrErr returns the Ue value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e UserEdges) UeOrErr() ([]*Ue, error) {
|
||||
if e.loadedTypes[1] {
|
||||
return e.Ue, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "ue"}
|
||||
}
|
||||
|
||||
// MaOrErr returns the Ma value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e UserEdges) MaOrErr() ([]*Ma, error) {
|
||||
if e.loadedTypes[2] {
|
||||
return e.Ma, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "ma"}
|
||||
}
|
||||
|
||||
// SevOrErr returns the Sev value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e UserEdges) SevOrErr() ([]*Sev, error) {
|
||||
if e.loadedTypes[3] {
|
||||
return e.Sev, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "sev"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*User) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case user.FieldMember, user.FieldBook, user.FieldManga, user.FieldBadge, user.FieldBsky, user.FieldMastodon, user.FieldDelete, user.FieldHandle, user.FieldTen, user.FieldModel, user.FieldGame, user.FieldGameTest, user.FieldGameEnd, user.FieldGameAccount, user.FieldGameLimit, user.FieldCoinOpen, user.FieldLogin:
|
||||
case user.FieldBsky, user.FieldMastodon, user.FieldDelete, user.FieldHandle, user.FieldTen:
|
||||
values[i] = new(sql.NullBool)
|
||||
case user.FieldPlanet:
|
||||
values[i] = new(sql.NullFloat64)
|
||||
case user.FieldID, user.FieldLuck, user.FieldLike, user.FieldLikeRank, user.FieldFav, user.FieldTenSu, user.FieldTenKai, user.FieldAiten, user.FieldRoom, user.FieldModelAttack, user.FieldModelLimit, user.FieldModelSkill, user.FieldModelMode, user.FieldModelCritical, user.FieldModelCriticalD, user.FieldGameLv, user.FieldGameExp, user.FieldGameStory, user.FieldCoin, user.FieldLocationX, user.FieldLocationY, user.FieldLocationZ, user.FieldLocationN:
|
||||
case user.FieldID, user.FieldLuck, user.FieldLike, user.FieldLikeRank, user.FieldFav, user.FieldTenSu, user.FieldTenKai, user.FieldAiten:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case user.FieldUsername, user.FieldDid, user.FieldToken, user.FieldPassword, user.FieldTenCard, user.FieldTenDelete, user.FieldTenPost, user.FieldTenGet, user.FieldNext:
|
||||
values[i] = new(sql.NullString)
|
||||
case user.FieldCreatedAt, user.FieldUpdatedAt, user.FieldRaidAt, user.FieldServerAt, user.FieldEggAt, user.FieldLuckAt, user.FieldLikeAt, user.FieldTenAt, user.FieldModelAt, user.FieldCoinAt, user.FieldPlanetAt, user.FieldLoginAt:
|
||||
case user.FieldCreatedAt, user.FieldUpdatedAt, user.FieldRaidAt, user.FieldLuckAt, user.FieldLikeAt, user.FieldTenAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case user.ForeignKeys[0]: // group_users
|
||||
values[i] = new(sql.NullInt64)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
return nil, fmt.Errorf("unexpected column %q for type User", columns[i])
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
@@ -247,30 +142,6 @@ func (u *User) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
u.Did = value.String
|
||||
}
|
||||
case user.FieldMember:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field member", values[i])
|
||||
} else if value.Valid {
|
||||
u.Member = value.Bool
|
||||
}
|
||||
case user.FieldBook:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field book", values[i])
|
||||
} else if value.Valid {
|
||||
u.Book = value.Bool
|
||||
}
|
||||
case user.FieldManga:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field manga", values[i])
|
||||
} else if value.Valid {
|
||||
u.Manga = value.Bool
|
||||
}
|
||||
case user.FieldBadge:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field badge", values[i])
|
||||
} else if value.Valid {
|
||||
u.Badge = value.Bool
|
||||
}
|
||||
case user.FieldBsky:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field bsky", values[i])
|
||||
@@ -325,18 +196,6 @@ func (u *User) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
u.RaidAt = value.Time
|
||||
}
|
||||
case user.FieldServerAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field server_at", values[i])
|
||||
} else if value.Valid {
|
||||
u.ServerAt = value.Time
|
||||
}
|
||||
case user.FieldEggAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field egg_at", values[i])
|
||||
} else if value.Valid {
|
||||
u.EggAt = value.Time
|
||||
}
|
||||
case user.FieldLuck:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field luck", values[i])
|
||||
@@ -433,174 +292,6 @@ func (u *User) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
u.Next = value.String
|
||||
}
|
||||
case user.FieldRoom:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field room", values[i])
|
||||
} else if value.Valid {
|
||||
u.Room = int(value.Int64)
|
||||
}
|
||||
case user.FieldModel:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field model", values[i])
|
||||
} else if value.Valid {
|
||||
u.Model = value.Bool
|
||||
}
|
||||
case user.FieldModelAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field model_at", values[i])
|
||||
} else if value.Valid {
|
||||
u.ModelAt = value.Time
|
||||
}
|
||||
case user.FieldModelAttack:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field model_attack", values[i])
|
||||
} else if value.Valid {
|
||||
u.ModelAttack = int(value.Int64)
|
||||
}
|
||||
case user.FieldModelLimit:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field model_limit", values[i])
|
||||
} else if value.Valid {
|
||||
u.ModelLimit = int(value.Int64)
|
||||
}
|
||||
case user.FieldModelSkill:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field model_skill", values[i])
|
||||
} else if value.Valid {
|
||||
u.ModelSkill = int(value.Int64)
|
||||
}
|
||||
case user.FieldModelMode:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field model_mode", values[i])
|
||||
} else if value.Valid {
|
||||
u.ModelMode = int(value.Int64)
|
||||
}
|
||||
case user.FieldModelCritical:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field model_critical", values[i])
|
||||
} else if value.Valid {
|
||||
u.ModelCritical = int(value.Int64)
|
||||
}
|
||||
case user.FieldModelCriticalD:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field model_critical_d", values[i])
|
||||
} else if value.Valid {
|
||||
u.ModelCriticalD = int(value.Int64)
|
||||
}
|
||||
case user.FieldGame:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field game", values[i])
|
||||
} else if value.Valid {
|
||||
u.Game = value.Bool
|
||||
}
|
||||
case user.FieldGameTest:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field game_test", values[i])
|
||||
} else if value.Valid {
|
||||
u.GameTest = value.Bool
|
||||
}
|
||||
case user.FieldGameEnd:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field game_end", values[i])
|
||||
} else if value.Valid {
|
||||
u.GameEnd = value.Bool
|
||||
}
|
||||
case user.FieldGameAccount:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field game_account", values[i])
|
||||
} else if value.Valid {
|
||||
u.GameAccount = value.Bool
|
||||
}
|
||||
case user.FieldGameLv:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field game_lv", values[i])
|
||||
} else if value.Valid {
|
||||
u.GameLv = int(value.Int64)
|
||||
}
|
||||
case user.FieldGameExp:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field game_exp", values[i])
|
||||
} else if value.Valid {
|
||||
u.GameExp = int(value.Int64)
|
||||
}
|
||||
case user.FieldGameStory:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field game_story", values[i])
|
||||
} else if value.Valid {
|
||||
u.GameStory = int(value.Int64)
|
||||
}
|
||||
case user.FieldGameLimit:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field game_limit", values[i])
|
||||
} else if value.Valid {
|
||||
u.GameLimit = value.Bool
|
||||
}
|
||||
case user.FieldCoin:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field coin", values[i])
|
||||
} else if value.Valid {
|
||||
u.Coin = int(value.Int64)
|
||||
}
|
||||
case user.FieldCoinOpen:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field coin_open", values[i])
|
||||
} else if value.Valid {
|
||||
u.CoinOpen = value.Bool
|
||||
}
|
||||
case user.FieldCoinAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field coin_at", values[i])
|
||||
} else if value.Valid {
|
||||
u.CoinAt = value.Time
|
||||
}
|
||||
case user.FieldPlanet:
|
||||
if value, ok := values[i].(*sql.NullFloat64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field planet", values[i])
|
||||
} else if value.Valid {
|
||||
u.Planet = value.Float64
|
||||
}
|
||||
case user.FieldPlanetAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field planet_at", values[i])
|
||||
} else if value.Valid {
|
||||
u.PlanetAt = value.Time
|
||||
}
|
||||
case user.FieldLogin:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field login", values[i])
|
||||
} else if value.Valid {
|
||||
u.Login = value.Bool
|
||||
}
|
||||
case user.FieldLoginAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field login_at", values[i])
|
||||
} else if value.Valid {
|
||||
u.LoginAt = value.Time
|
||||
}
|
||||
case user.FieldLocationX:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field location_x", values[i])
|
||||
} else if value.Valid {
|
||||
u.LocationX = int(value.Int64)
|
||||
}
|
||||
case user.FieldLocationY:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field location_y", values[i])
|
||||
} else if value.Valid {
|
||||
u.LocationY = int(value.Int64)
|
||||
}
|
||||
case user.FieldLocationZ:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field location_z", values[i])
|
||||
} else if value.Valid {
|
||||
u.LocationZ = int(value.Int64)
|
||||
}
|
||||
case user.FieldLocationN:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field location_n", values[i])
|
||||
} else if value.Valid {
|
||||
u.LocationN = int(value.Int64)
|
||||
}
|
||||
case user.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for edge-field group_users", value)
|
||||
@@ -608,39 +299,16 @@ func (u *User) assignValues(columns []string, values []any) error {
|
||||
u.group_users = new(int)
|
||||
*u.group_users = int(value.Int64)
|
||||
}
|
||||
default:
|
||||
u.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the User.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (u *User) Value(name string) (ent.Value, error) {
|
||||
return u.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryCard queries the "card" edge of the User entity.
|
||||
func (u *User) QueryCard() *CardQuery {
|
||||
return NewUserClient(u.config).QueryCard(u)
|
||||
}
|
||||
|
||||
// QueryUe queries the "ue" edge of the User entity.
|
||||
func (u *User) QueryUe() *UeQuery {
|
||||
return NewUserClient(u.config).QueryUe(u)
|
||||
}
|
||||
|
||||
// QueryMa queries the "ma" edge of the User entity.
|
||||
func (u *User) QueryMa() *MaQuery {
|
||||
return NewUserClient(u.config).QueryMa(u)
|
||||
}
|
||||
|
||||
// QuerySev queries the "sev" edge of the User entity.
|
||||
func (u *User) QuerySev() *SevQuery {
|
||||
return NewUserClient(u.config).QuerySev(u)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this User.
|
||||
// Note that you need to call User.Unwrap() before calling this method if this User
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
@@ -670,18 +338,6 @@ func (u *User) String() string {
|
||||
builder.WriteString("did=")
|
||||
builder.WriteString(u.Did)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("member=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Member))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("book=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Book))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("manga=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Manga))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("badge=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Badge))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("bsky=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Bsky))
|
||||
builder.WriteString(", ")
|
||||
@@ -707,12 +363,6 @@ func (u *User) String() string {
|
||||
builder.WriteString("raid_at=")
|
||||
builder.WriteString(u.RaidAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("server_at=")
|
||||
builder.WriteString(u.ServerAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("egg_at=")
|
||||
builder.WriteString(u.EggAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("luck=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Luck))
|
||||
builder.WriteString(", ")
|
||||
@@ -760,90 +410,6 @@ func (u *User) String() string {
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("next=")
|
||||
builder.WriteString(u.Next)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("room=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Room))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("model=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Model))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("model_at=")
|
||||
builder.WriteString(u.ModelAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("model_attack=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.ModelAttack))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("model_limit=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.ModelLimit))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("model_skill=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.ModelSkill))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("model_mode=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.ModelMode))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("model_critical=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.ModelCritical))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("model_critical_d=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.ModelCriticalD))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("game=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Game))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("game_test=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.GameTest))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("game_end=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.GameEnd))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("game_account=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.GameAccount))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("game_lv=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.GameLv))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("game_exp=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.GameExp))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("game_story=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.GameStory))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("game_limit=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.GameLimit))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("coin=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Coin))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("coin_open=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.CoinOpen))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("coin_at=")
|
||||
builder.WriteString(u.CoinAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("planet=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Planet))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("planet_at=")
|
||||
builder.WriteString(u.PlanetAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("login=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Login))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("login_at=")
|
||||
builder.WriteString(u.LoginAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("location_x=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.LocationX))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("location_y=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.LocationY))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("location_z=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.LocationZ))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("location_n=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.LocationN))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
563
ent/user/user.go
563
ent/user/user.go
@@ -4,9 +4,6 @@ package user
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -18,14 +15,6 @@ const (
|
||||
FieldUsername = "username"
|
||||
// FieldDid holds the string denoting the did field in the database.
|
||||
FieldDid = "did"
|
||||
// FieldMember holds the string denoting the member field in the database.
|
||||
FieldMember = "member"
|
||||
// FieldBook holds the string denoting the book field in the database.
|
||||
FieldBook = "book"
|
||||
// FieldManga holds the string denoting the manga field in the database.
|
||||
FieldManga = "manga"
|
||||
// FieldBadge holds the string denoting the badge field in the database.
|
||||
FieldBadge = "badge"
|
||||
// FieldBsky holds the string denoting the bsky field in the database.
|
||||
FieldBsky = "bsky"
|
||||
// FieldMastodon holds the string denoting the mastodon field in the database.
|
||||
@@ -44,10 +33,6 @@ const (
|
||||
FieldUpdatedAt = "updated_at"
|
||||
// FieldRaidAt holds the string denoting the raid_at field in the database.
|
||||
FieldRaidAt = "raid_at"
|
||||
// FieldServerAt holds the string denoting the server_at field in the database.
|
||||
FieldServerAt = "server_at"
|
||||
// FieldEggAt holds the string denoting the egg_at field in the database.
|
||||
FieldEggAt = "egg_at"
|
||||
// FieldLuck holds the string denoting the luck field in the database.
|
||||
FieldLuck = "luck"
|
||||
// FieldLuckAt holds the string denoting the luck_at field in the database.
|
||||
@@ -80,70 +65,8 @@ const (
|
||||
FieldTenAt = "ten_at"
|
||||
// FieldNext holds the string denoting the next field in the database.
|
||||
FieldNext = "next"
|
||||
// FieldRoom holds the string denoting the room field in the database.
|
||||
FieldRoom = "room"
|
||||
// FieldModel holds the string denoting the model field in the database.
|
||||
FieldModel = "model"
|
||||
// FieldModelAt holds the string denoting the model_at field in the database.
|
||||
FieldModelAt = "model_at"
|
||||
// FieldModelAttack holds the string denoting the model_attack field in the database.
|
||||
FieldModelAttack = "model_attack"
|
||||
// FieldModelLimit holds the string denoting the model_limit field in the database.
|
||||
FieldModelLimit = "model_limit"
|
||||
// FieldModelSkill holds the string denoting the model_skill field in the database.
|
||||
FieldModelSkill = "model_skill"
|
||||
// FieldModelMode holds the string denoting the model_mode field in the database.
|
||||
FieldModelMode = "model_mode"
|
||||
// FieldModelCritical holds the string denoting the model_critical field in the database.
|
||||
FieldModelCritical = "model_critical"
|
||||
// FieldModelCriticalD holds the string denoting the model_critical_d field in the database.
|
||||
FieldModelCriticalD = "model_critical_d"
|
||||
// FieldGame holds the string denoting the game field in the database.
|
||||
FieldGame = "game"
|
||||
// FieldGameTest holds the string denoting the game_test field in the database.
|
||||
FieldGameTest = "game_test"
|
||||
// FieldGameEnd holds the string denoting the game_end field in the database.
|
||||
FieldGameEnd = "game_end"
|
||||
// FieldGameAccount holds the string denoting the game_account field in the database.
|
||||
FieldGameAccount = "game_account"
|
||||
// FieldGameLv holds the string denoting the game_lv field in the database.
|
||||
FieldGameLv = "game_lv"
|
||||
// FieldGameExp holds the string denoting the game_exp field in the database.
|
||||
FieldGameExp = "game_exp"
|
||||
// FieldGameStory holds the string denoting the game_story field in the database.
|
||||
FieldGameStory = "game_story"
|
||||
// FieldGameLimit holds the string denoting the game_limit field in the database.
|
||||
FieldGameLimit = "game_limit"
|
||||
// FieldCoin holds the string denoting the coin field in the database.
|
||||
FieldCoin = "coin"
|
||||
// FieldCoinOpen holds the string denoting the coin_open field in the database.
|
||||
FieldCoinOpen = "coin_open"
|
||||
// FieldCoinAt holds the string denoting the coin_at field in the database.
|
||||
FieldCoinAt = "coin_at"
|
||||
// FieldPlanet holds the string denoting the planet field in the database.
|
||||
FieldPlanet = "planet"
|
||||
// FieldPlanetAt holds the string denoting the planet_at field in the database.
|
||||
FieldPlanetAt = "planet_at"
|
||||
// FieldLogin holds the string denoting the login field in the database.
|
||||
FieldLogin = "login"
|
||||
// FieldLoginAt holds the string denoting the login_at field in the database.
|
||||
FieldLoginAt = "login_at"
|
||||
// FieldLocationX holds the string denoting the location_x field in the database.
|
||||
FieldLocationX = "location_x"
|
||||
// FieldLocationY holds the string denoting the location_y field in the database.
|
||||
FieldLocationY = "location_y"
|
||||
// FieldLocationZ holds the string denoting the location_z field in the database.
|
||||
FieldLocationZ = "location_z"
|
||||
// FieldLocationN holds the string denoting the location_n field in the database.
|
||||
FieldLocationN = "location_n"
|
||||
// EdgeCard holds the string denoting the card edge name in mutations.
|
||||
EdgeCard = "card"
|
||||
// EdgeUe holds the string denoting the ue edge name in mutations.
|
||||
EdgeUe = "ue"
|
||||
// EdgeMa holds the string denoting the ma edge name in mutations.
|
||||
EdgeMa = "ma"
|
||||
// EdgeSev holds the string denoting the sev edge name in mutations.
|
||||
EdgeSev = "sev"
|
||||
// Table holds the table name of the user in the database.
|
||||
Table = "users"
|
||||
// CardTable is the table that holds the card relation/edge.
|
||||
@@ -153,27 +76,6 @@ const (
|
||||
CardInverseTable = "cards"
|
||||
// CardColumn is the table column denoting the card relation/edge.
|
||||
CardColumn = "user_card"
|
||||
// UeTable is the table that holds the ue relation/edge.
|
||||
UeTable = "ues"
|
||||
// UeInverseTable is the table name for the Ue entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "ue" package.
|
||||
UeInverseTable = "ues"
|
||||
// UeColumn is the table column denoting the ue relation/edge.
|
||||
UeColumn = "user_ue"
|
||||
// MaTable is the table that holds the ma relation/edge.
|
||||
MaTable = "mas"
|
||||
// MaInverseTable is the table name for the Ma entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "ma" package.
|
||||
MaInverseTable = "mas"
|
||||
// MaColumn is the table column denoting the ma relation/edge.
|
||||
MaColumn = "user_ma"
|
||||
// SevTable is the table that holds the sev relation/edge.
|
||||
SevTable = "sevs"
|
||||
// SevInverseTable is the table name for the Sev entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "sev" package.
|
||||
SevInverseTable = "sevs"
|
||||
// SevColumn is the table column denoting the sev relation/edge.
|
||||
SevColumn = "user_sev"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for user fields.
|
||||
@@ -181,10 +83,6 @@ var Columns = []string{
|
||||
FieldID,
|
||||
FieldUsername,
|
||||
FieldDid,
|
||||
FieldMember,
|
||||
FieldBook,
|
||||
FieldManga,
|
||||
FieldBadge,
|
||||
FieldBsky,
|
||||
FieldMastodon,
|
||||
FieldDelete,
|
||||
@@ -194,8 +92,6 @@ var Columns = []string{
|
||||
FieldCreatedAt,
|
||||
FieldUpdatedAt,
|
||||
FieldRaidAt,
|
||||
FieldServerAt,
|
||||
FieldEggAt,
|
||||
FieldLuck,
|
||||
FieldLuckAt,
|
||||
FieldLike,
|
||||
@@ -212,34 +108,6 @@ var Columns = []string{
|
||||
FieldTenGet,
|
||||
FieldTenAt,
|
||||
FieldNext,
|
||||
FieldRoom,
|
||||
FieldModel,
|
||||
FieldModelAt,
|
||||
FieldModelAttack,
|
||||
FieldModelLimit,
|
||||
FieldModelSkill,
|
||||
FieldModelMode,
|
||||
FieldModelCritical,
|
||||
FieldModelCriticalD,
|
||||
FieldGame,
|
||||
FieldGameTest,
|
||||
FieldGameEnd,
|
||||
FieldGameAccount,
|
||||
FieldGameLv,
|
||||
FieldGameExp,
|
||||
FieldGameStory,
|
||||
FieldGameLimit,
|
||||
FieldCoin,
|
||||
FieldCoinOpen,
|
||||
FieldCoinAt,
|
||||
FieldPlanet,
|
||||
FieldPlanetAt,
|
||||
FieldLogin,
|
||||
FieldLoginAt,
|
||||
FieldLocationX,
|
||||
FieldLocationY,
|
||||
FieldLocationZ,
|
||||
FieldLocationN,
|
||||
}
|
||||
|
||||
// ForeignKeys holds the SQL foreign-keys that are owned by the "users"
|
||||
@@ -266,14 +134,6 @@ func ValidColumn(column string) bool {
|
||||
var (
|
||||
// UsernameValidator is a validator for the "username" field. It is called by the builders before save.
|
||||
UsernameValidator func(string) error
|
||||
// DefaultMember holds the default value on creation for the "member" field.
|
||||
DefaultMember bool
|
||||
// DefaultBook holds the default value on creation for the "book" field.
|
||||
DefaultBook bool
|
||||
// DefaultManga holds the default value on creation for the "manga" field.
|
||||
DefaultManga bool
|
||||
// DefaultBadge holds the default value on creation for the "badge" field.
|
||||
DefaultBadge bool
|
||||
// DefaultBsky holds the default value on creation for the "bsky" field.
|
||||
DefaultBsky bool
|
||||
// DefaultMastodon holds the default value on creation for the "mastodon" field.
|
||||
@@ -290,10 +150,6 @@ var (
|
||||
DefaultUpdatedAt func() time.Time
|
||||
// DefaultRaidAt holds the default value on creation for the "raid_at" field.
|
||||
DefaultRaidAt func() time.Time
|
||||
// DefaultServerAt holds the default value on creation for the "server_at" field.
|
||||
DefaultServerAt func() time.Time
|
||||
// DefaultEggAt holds the default value on creation for the "egg_at" field.
|
||||
DefaultEggAt func() time.Time
|
||||
// DefaultLuckAt holds the default value on creation for the "luck_at" field.
|
||||
DefaultLuckAt func() time.Time
|
||||
// DefaultLikeAt holds the default value on creation for the "like_at" field.
|
||||
@@ -302,423 +158,4 @@ var (
|
||||
DefaultTenAt func() time.Time
|
||||
// DefaultNext holds the default value on creation for the "next" field.
|
||||
DefaultNext string
|
||||
// DefaultModelAt holds the default value on creation for the "model_at" field.
|
||||
DefaultModelAt func() time.Time
|
||||
// DefaultGame holds the default value on creation for the "game" field.
|
||||
DefaultGame bool
|
||||
// DefaultGameTest holds the default value on creation for the "game_test" field.
|
||||
DefaultGameTest bool
|
||||
// DefaultGameEnd holds the default value on creation for the "game_end" field.
|
||||
DefaultGameEnd bool
|
||||
// DefaultGameAccount holds the default value on creation for the "game_account" field.
|
||||
DefaultGameAccount bool
|
||||
// DefaultGameLimit holds the default value on creation for the "game_limit" field.
|
||||
DefaultGameLimit bool
|
||||
// DefaultCoinOpen holds the default value on creation for the "coin_open" field.
|
||||
DefaultCoinOpen bool
|
||||
// DefaultCoinAt holds the default value on creation for the "coin_at" field.
|
||||
DefaultCoinAt func() time.Time
|
||||
// DefaultPlanetAt holds the default value on creation for the "planet_at" field.
|
||||
DefaultPlanetAt func() time.Time
|
||||
// DefaultLogin holds the default value on creation for the "login" field.
|
||||
DefaultLogin bool
|
||||
// DefaultLoginAt holds the default value on creation for the "login_at" field.
|
||||
DefaultLoginAt func() time.Time
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the User queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUsername orders the results by the username field.
|
||||
func ByUsername(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUsername, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDid orders the results by the did field.
|
||||
func ByDid(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDid, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByMember orders the results by the member field.
|
||||
func ByMember(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldMember, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByBook orders the results by the book field.
|
||||
func ByBook(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldBook, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByManga orders the results by the manga field.
|
||||
func ByManga(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldManga, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByBadge orders the results by the badge field.
|
||||
func ByBadge(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldBadge, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByBsky orders the results by the bsky field.
|
||||
func ByBsky(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldBsky, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByMastodon orders the results by the mastodon field.
|
||||
func ByMastodon(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldMastodon, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDelete orders the results by the delete field.
|
||||
func ByDelete(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDelete, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByHandle orders the results by the handle field.
|
||||
func ByHandle(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldHandle, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByToken orders the results by the token field.
|
||||
func ByToken(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldToken, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPassword orders the results by the password field.
|
||||
func ByPassword(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPassword, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUpdatedAt orders the results by the updated_at field.
|
||||
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByRaidAt orders the results by the raid_at field.
|
||||
func ByRaidAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldRaidAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByServerAt orders the results by the server_at field.
|
||||
func ByServerAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldServerAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByEggAt orders the results by the egg_at field.
|
||||
func ByEggAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldEggAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLuck orders the results by the luck field.
|
||||
func ByLuck(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLuck, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLuckAt orders the results by the luck_at field.
|
||||
func ByLuckAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLuckAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLike orders the results by the like field.
|
||||
func ByLike(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLike, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLikeRank orders the results by the like_rank field.
|
||||
func ByLikeRank(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLikeRank, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLikeAt orders the results by the like_at field.
|
||||
func ByLikeAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLikeAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByFav orders the results by the fav field.
|
||||
func ByFav(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldFav, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTen orders the results by the ten field.
|
||||
func ByTen(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTen, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTenSu orders the results by the ten_su field.
|
||||
func ByTenSu(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTenSu, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTenKai orders the results by the ten_kai field.
|
||||
func ByTenKai(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTenKai, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByAiten orders the results by the aiten field.
|
||||
func ByAiten(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldAiten, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTenCard orders the results by the ten_card field.
|
||||
func ByTenCard(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTenCard, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTenDelete orders the results by the ten_delete field.
|
||||
func ByTenDelete(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTenDelete, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTenPost orders the results by the ten_post field.
|
||||
func ByTenPost(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTenPost, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTenGet orders the results by the ten_get field.
|
||||
func ByTenGet(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTenGet, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTenAt orders the results by the ten_at field.
|
||||
func ByTenAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTenAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByNext orders the results by the next field.
|
||||
func ByNext(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldNext, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByRoom orders the results by the room field.
|
||||
func ByRoom(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldRoom, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByModel orders the results by the model field.
|
||||
func ByModel(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldModel, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByModelAt orders the results by the model_at field.
|
||||
func ByModelAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldModelAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByModelAttack orders the results by the model_attack field.
|
||||
func ByModelAttack(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldModelAttack, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByModelLimit orders the results by the model_limit field.
|
||||
func ByModelLimit(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldModelLimit, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByModelSkill orders the results by the model_skill field.
|
||||
func ByModelSkill(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldModelSkill, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByModelMode orders the results by the model_mode field.
|
||||
func ByModelMode(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldModelMode, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByModelCritical orders the results by the model_critical field.
|
||||
func ByModelCritical(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldModelCritical, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByModelCriticalD orders the results by the model_critical_d field.
|
||||
func ByModelCriticalD(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldModelCriticalD, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByGame orders the results by the game field.
|
||||
func ByGame(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldGame, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByGameTest orders the results by the game_test field.
|
||||
func ByGameTest(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldGameTest, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByGameEnd orders the results by the game_end field.
|
||||
func ByGameEnd(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldGameEnd, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByGameAccount orders the results by the game_account field.
|
||||
func ByGameAccount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldGameAccount, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByGameLv orders the results by the game_lv field.
|
||||
func ByGameLv(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldGameLv, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByGameExp orders the results by the game_exp field.
|
||||
func ByGameExp(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldGameExp, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByGameStory orders the results by the game_story field.
|
||||
func ByGameStory(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldGameStory, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByGameLimit orders the results by the game_limit field.
|
||||
func ByGameLimit(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldGameLimit, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCoin orders the results by the coin field.
|
||||
func ByCoin(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCoin, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCoinOpen orders the results by the coin_open field.
|
||||
func ByCoinOpen(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCoinOpen, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCoinAt orders the results by the coin_at field.
|
||||
func ByCoinAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCoinAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPlanet orders the results by the planet field.
|
||||
func ByPlanet(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPlanet, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPlanetAt orders the results by the planet_at field.
|
||||
func ByPlanetAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPlanetAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLogin orders the results by the login field.
|
||||
func ByLogin(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLogin, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLoginAt orders the results by the login_at field.
|
||||
func ByLoginAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLoginAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLocationX orders the results by the location_x field.
|
||||
func ByLocationX(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLocationX, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLocationY orders the results by the location_y field.
|
||||
func ByLocationY(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLocationY, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLocationZ orders the results by the location_z field.
|
||||
func ByLocationZ(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLocationZ, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLocationN orders the results by the location_n field.
|
||||
func ByLocationN(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLocationN, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCardCount orders the results by card count.
|
||||
func ByCardCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newCardStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByCard orders the results by card terms.
|
||||
func ByCard(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newCardStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByUeCount orders the results by ue count.
|
||||
func ByUeCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newUeStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByUe orders the results by ue terms.
|
||||
func ByUe(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newUeStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByMaCount orders the results by ma count.
|
||||
func ByMaCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newMaStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByMa orders the results by ma terms.
|
||||
func ByMa(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newMaStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
|
||||
// BySevCount orders the results by sev count.
|
||||
func BySevCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newSevStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// BySev orders the results by sev terms.
|
||||
func BySev(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newSevStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
func newCardStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(CardInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, CardTable, CardColumn),
|
||||
)
|
||||
}
|
||||
func newUeStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(UeInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, UeTable, UeColumn),
|
||||
)
|
||||
}
|
||||
func newMaStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(MaInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, MaTable, MaColumn),
|
||||
)
|
||||
}
|
||||
func newSevStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(SevInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, SevTable, SevColumn),
|
||||
)
|
||||
}
|
||||
|
||||
1581
ent/user/where.go
1581
ent/user/where.go
File diff suppressed because it is too large
Load Diff
@@ -3,14 +3,11 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/card"
|
||||
"api/ent/ma"
|
||||
"api/ent/sev"
|
||||
"api/ent/ue"
|
||||
"api/ent/user"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"t/ent/card"
|
||||
"t/ent/user"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -44,62 +41,6 @@ func (uc *UserCreate) SetNillableDid(s *string) *UserCreate {
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetMember sets the "member" field.
|
||||
func (uc *UserCreate) SetMember(b bool) *UserCreate {
|
||||
uc.mutation.SetMember(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableMember sets the "member" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableMember(b *bool) *UserCreate {
|
||||
if b != nil {
|
||||
uc.SetMember(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetBook sets the "book" field.
|
||||
func (uc *UserCreate) SetBook(b bool) *UserCreate {
|
||||
uc.mutation.SetBook(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableBook sets the "book" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableBook(b *bool) *UserCreate {
|
||||
if b != nil {
|
||||
uc.SetBook(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetManga sets the "manga" field.
|
||||
func (uc *UserCreate) SetManga(b bool) *UserCreate {
|
||||
uc.mutation.SetManga(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableManga sets the "manga" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableManga(b *bool) *UserCreate {
|
||||
if b != nil {
|
||||
uc.SetManga(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetBadge sets the "badge" field.
|
||||
func (uc *UserCreate) SetBadge(b bool) *UserCreate {
|
||||
uc.mutation.SetBadge(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableBadge sets the "badge" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableBadge(b *bool) *UserCreate {
|
||||
if b != nil {
|
||||
uc.SetBadge(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetBsky sets the "bsky" field.
|
||||
func (uc *UserCreate) SetBsky(b bool) *UserCreate {
|
||||
uc.mutation.SetBsky(b)
|
||||
@@ -218,34 +159,6 @@ func (uc *UserCreate) SetNillableRaidAt(t *time.Time) *UserCreate {
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetServerAt sets the "server_at" field.
|
||||
func (uc *UserCreate) SetServerAt(t time.Time) *UserCreate {
|
||||
uc.mutation.SetServerAt(t)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableServerAt sets the "server_at" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableServerAt(t *time.Time) *UserCreate {
|
||||
if t != nil {
|
||||
uc.SetServerAt(*t)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetEggAt sets the "egg_at" field.
|
||||
func (uc *UserCreate) SetEggAt(t time.Time) *UserCreate {
|
||||
uc.mutation.SetEggAt(t)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableEggAt sets the "egg_at" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableEggAt(t *time.Time) *UserCreate {
|
||||
if t != nil {
|
||||
uc.SetEggAt(*t)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLuck sets the "luck" field.
|
||||
func (uc *UserCreate) SetLuck(i int) *UserCreate {
|
||||
uc.mutation.SetLuck(i)
|
||||
@@ -470,398 +383,6 @@ func (uc *UserCreate) SetNillableNext(s *string) *UserCreate {
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetRoom sets the "room" field.
|
||||
func (uc *UserCreate) SetRoom(i int) *UserCreate {
|
||||
uc.mutation.SetRoom(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableRoom sets the "room" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableRoom(i *int) *UserCreate {
|
||||
if i != nil {
|
||||
uc.SetRoom(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetModel sets the "model" field.
|
||||
func (uc *UserCreate) SetModel(b bool) *UserCreate {
|
||||
uc.mutation.SetModel(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableModel sets the "model" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableModel(b *bool) *UserCreate {
|
||||
if b != nil {
|
||||
uc.SetModel(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetModelAt sets the "model_at" field.
|
||||
func (uc *UserCreate) SetModelAt(t time.Time) *UserCreate {
|
||||
uc.mutation.SetModelAt(t)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableModelAt sets the "model_at" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableModelAt(t *time.Time) *UserCreate {
|
||||
if t != nil {
|
||||
uc.SetModelAt(*t)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetModelAttack sets the "model_attack" field.
|
||||
func (uc *UserCreate) SetModelAttack(i int) *UserCreate {
|
||||
uc.mutation.SetModelAttack(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableModelAttack sets the "model_attack" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableModelAttack(i *int) *UserCreate {
|
||||
if i != nil {
|
||||
uc.SetModelAttack(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetModelLimit sets the "model_limit" field.
|
||||
func (uc *UserCreate) SetModelLimit(i int) *UserCreate {
|
||||
uc.mutation.SetModelLimit(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableModelLimit sets the "model_limit" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableModelLimit(i *int) *UserCreate {
|
||||
if i != nil {
|
||||
uc.SetModelLimit(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetModelSkill sets the "model_skill" field.
|
||||
func (uc *UserCreate) SetModelSkill(i int) *UserCreate {
|
||||
uc.mutation.SetModelSkill(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableModelSkill sets the "model_skill" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableModelSkill(i *int) *UserCreate {
|
||||
if i != nil {
|
||||
uc.SetModelSkill(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetModelMode sets the "model_mode" field.
|
||||
func (uc *UserCreate) SetModelMode(i int) *UserCreate {
|
||||
uc.mutation.SetModelMode(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableModelMode sets the "model_mode" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableModelMode(i *int) *UserCreate {
|
||||
if i != nil {
|
||||
uc.SetModelMode(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetModelCritical sets the "model_critical" field.
|
||||
func (uc *UserCreate) SetModelCritical(i int) *UserCreate {
|
||||
uc.mutation.SetModelCritical(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableModelCritical sets the "model_critical" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableModelCritical(i *int) *UserCreate {
|
||||
if i != nil {
|
||||
uc.SetModelCritical(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetModelCriticalD sets the "model_critical_d" field.
|
||||
func (uc *UserCreate) SetModelCriticalD(i int) *UserCreate {
|
||||
uc.mutation.SetModelCriticalD(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableModelCriticalD sets the "model_critical_d" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableModelCriticalD(i *int) *UserCreate {
|
||||
if i != nil {
|
||||
uc.SetModelCriticalD(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetGame sets the "game" field.
|
||||
func (uc *UserCreate) SetGame(b bool) *UserCreate {
|
||||
uc.mutation.SetGame(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableGame sets the "game" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableGame(b *bool) *UserCreate {
|
||||
if b != nil {
|
||||
uc.SetGame(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetGameTest sets the "game_test" field.
|
||||
func (uc *UserCreate) SetGameTest(b bool) *UserCreate {
|
||||
uc.mutation.SetGameTest(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableGameTest sets the "game_test" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableGameTest(b *bool) *UserCreate {
|
||||
if b != nil {
|
||||
uc.SetGameTest(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetGameEnd sets the "game_end" field.
|
||||
func (uc *UserCreate) SetGameEnd(b bool) *UserCreate {
|
||||
uc.mutation.SetGameEnd(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableGameEnd sets the "game_end" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableGameEnd(b *bool) *UserCreate {
|
||||
if b != nil {
|
||||
uc.SetGameEnd(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetGameAccount sets the "game_account" field.
|
||||
func (uc *UserCreate) SetGameAccount(b bool) *UserCreate {
|
||||
uc.mutation.SetGameAccount(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableGameAccount sets the "game_account" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableGameAccount(b *bool) *UserCreate {
|
||||
if b != nil {
|
||||
uc.SetGameAccount(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetGameLv sets the "game_lv" field.
|
||||
func (uc *UserCreate) SetGameLv(i int) *UserCreate {
|
||||
uc.mutation.SetGameLv(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableGameLv sets the "game_lv" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableGameLv(i *int) *UserCreate {
|
||||
if i != nil {
|
||||
uc.SetGameLv(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetGameExp sets the "game_exp" field.
|
||||
func (uc *UserCreate) SetGameExp(i int) *UserCreate {
|
||||
uc.mutation.SetGameExp(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableGameExp sets the "game_exp" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableGameExp(i *int) *UserCreate {
|
||||
if i != nil {
|
||||
uc.SetGameExp(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetGameStory sets the "game_story" field.
|
||||
func (uc *UserCreate) SetGameStory(i int) *UserCreate {
|
||||
uc.mutation.SetGameStory(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableGameStory sets the "game_story" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableGameStory(i *int) *UserCreate {
|
||||
if i != nil {
|
||||
uc.SetGameStory(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetGameLimit sets the "game_limit" field.
|
||||
func (uc *UserCreate) SetGameLimit(b bool) *UserCreate {
|
||||
uc.mutation.SetGameLimit(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableGameLimit sets the "game_limit" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableGameLimit(b *bool) *UserCreate {
|
||||
if b != nil {
|
||||
uc.SetGameLimit(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetCoin sets the "coin" field.
|
||||
func (uc *UserCreate) SetCoin(i int) *UserCreate {
|
||||
uc.mutation.SetCoin(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableCoin sets the "coin" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableCoin(i *int) *UserCreate {
|
||||
if i != nil {
|
||||
uc.SetCoin(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetCoinOpen sets the "coin_open" field.
|
||||
func (uc *UserCreate) SetCoinOpen(b bool) *UserCreate {
|
||||
uc.mutation.SetCoinOpen(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableCoinOpen sets the "coin_open" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableCoinOpen(b *bool) *UserCreate {
|
||||
if b != nil {
|
||||
uc.SetCoinOpen(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetCoinAt sets the "coin_at" field.
|
||||
func (uc *UserCreate) SetCoinAt(t time.Time) *UserCreate {
|
||||
uc.mutation.SetCoinAt(t)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableCoinAt sets the "coin_at" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableCoinAt(t *time.Time) *UserCreate {
|
||||
if t != nil {
|
||||
uc.SetCoinAt(*t)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetPlanet sets the "planet" field.
|
||||
func (uc *UserCreate) SetPlanet(f float64) *UserCreate {
|
||||
uc.mutation.SetPlanet(f)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillablePlanet sets the "planet" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillablePlanet(f *float64) *UserCreate {
|
||||
if f != nil {
|
||||
uc.SetPlanet(*f)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetPlanetAt sets the "planet_at" field.
|
||||
func (uc *UserCreate) SetPlanetAt(t time.Time) *UserCreate {
|
||||
uc.mutation.SetPlanetAt(t)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillablePlanetAt sets the "planet_at" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillablePlanetAt(t *time.Time) *UserCreate {
|
||||
if t != nil {
|
||||
uc.SetPlanetAt(*t)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLogin sets the "login" field.
|
||||
func (uc *UserCreate) SetLogin(b bool) *UserCreate {
|
||||
uc.mutation.SetLogin(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLogin sets the "login" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableLogin(b *bool) *UserCreate {
|
||||
if b != nil {
|
||||
uc.SetLogin(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLoginAt sets the "login_at" field.
|
||||
func (uc *UserCreate) SetLoginAt(t time.Time) *UserCreate {
|
||||
uc.mutation.SetLoginAt(t)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLoginAt sets the "login_at" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableLoginAt(t *time.Time) *UserCreate {
|
||||
if t != nil {
|
||||
uc.SetLoginAt(*t)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLocationX sets the "location_x" field.
|
||||
func (uc *UserCreate) SetLocationX(i int) *UserCreate {
|
||||
uc.mutation.SetLocationX(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLocationX sets the "location_x" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableLocationX(i *int) *UserCreate {
|
||||
if i != nil {
|
||||
uc.SetLocationX(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLocationY sets the "location_y" field.
|
||||
func (uc *UserCreate) SetLocationY(i int) *UserCreate {
|
||||
uc.mutation.SetLocationY(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLocationY sets the "location_y" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableLocationY(i *int) *UserCreate {
|
||||
if i != nil {
|
||||
uc.SetLocationY(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLocationZ sets the "location_z" field.
|
||||
func (uc *UserCreate) SetLocationZ(i int) *UserCreate {
|
||||
uc.mutation.SetLocationZ(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLocationZ sets the "location_z" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableLocationZ(i *int) *UserCreate {
|
||||
if i != nil {
|
||||
uc.SetLocationZ(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLocationN sets the "location_n" field.
|
||||
func (uc *UserCreate) SetLocationN(i int) *UserCreate {
|
||||
uc.mutation.SetLocationN(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLocationN sets the "location_n" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableLocationN(i *int) *UserCreate {
|
||||
if i != nil {
|
||||
uc.SetLocationN(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// AddCardIDs adds the "card" edge to the Card entity by IDs.
|
||||
func (uc *UserCreate) AddCardIDs(ids ...int) *UserCreate {
|
||||
uc.mutation.AddCardIDs(ids...)
|
||||
@@ -877,51 +398,6 @@ func (uc *UserCreate) AddCard(c ...*Card) *UserCreate {
|
||||
return uc.AddCardIDs(ids...)
|
||||
}
|
||||
|
||||
// AddUeIDs adds the "ue" edge to the Ue entity by IDs.
|
||||
func (uc *UserCreate) AddUeIDs(ids ...int) *UserCreate {
|
||||
uc.mutation.AddUeIDs(ids...)
|
||||
return uc
|
||||
}
|
||||
|
||||
// AddUe adds the "ue" edges to the Ue entity.
|
||||
func (uc *UserCreate) AddUe(u ...*Ue) *UserCreate {
|
||||
ids := make([]int, len(u))
|
||||
for i := range u {
|
||||
ids[i] = u[i].ID
|
||||
}
|
||||
return uc.AddUeIDs(ids...)
|
||||
}
|
||||
|
||||
// AddMaIDs adds the "ma" edge to the Ma entity by IDs.
|
||||
func (uc *UserCreate) AddMaIDs(ids ...int) *UserCreate {
|
||||
uc.mutation.AddMaIDs(ids...)
|
||||
return uc
|
||||
}
|
||||
|
||||
// AddMa adds the "ma" edges to the Ma entity.
|
||||
func (uc *UserCreate) AddMa(m ...*Ma) *UserCreate {
|
||||
ids := make([]int, len(m))
|
||||
for i := range m {
|
||||
ids[i] = m[i].ID
|
||||
}
|
||||
return uc.AddMaIDs(ids...)
|
||||
}
|
||||
|
||||
// AddSevIDs adds the "sev" edge to the Sev entity by IDs.
|
||||
func (uc *UserCreate) AddSevIDs(ids ...int) *UserCreate {
|
||||
uc.mutation.AddSevIDs(ids...)
|
||||
return uc
|
||||
}
|
||||
|
||||
// AddSev adds the "sev" edges to the Sev entity.
|
||||
func (uc *UserCreate) AddSev(s ...*Sev) *UserCreate {
|
||||
ids := make([]int, len(s))
|
||||
for i := range s {
|
||||
ids[i] = s[i].ID
|
||||
}
|
||||
return uc.AddSevIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the UserMutation object of the builder.
|
||||
func (uc *UserCreate) Mutation() *UserMutation {
|
||||
return uc.mutation
|
||||
@@ -957,22 +433,6 @@ func (uc *UserCreate) ExecX(ctx context.Context) {
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (uc *UserCreate) defaults() {
|
||||
if _, ok := uc.mutation.Member(); !ok {
|
||||
v := user.DefaultMember
|
||||
uc.mutation.SetMember(v)
|
||||
}
|
||||
if _, ok := uc.mutation.Book(); !ok {
|
||||
v := user.DefaultBook
|
||||
uc.mutation.SetBook(v)
|
||||
}
|
||||
if _, ok := uc.mutation.Manga(); !ok {
|
||||
v := user.DefaultManga
|
||||
uc.mutation.SetManga(v)
|
||||
}
|
||||
if _, ok := uc.mutation.Badge(); !ok {
|
||||
v := user.DefaultBadge
|
||||
uc.mutation.SetBadge(v)
|
||||
}
|
||||
if _, ok := uc.mutation.Bsky(); !ok {
|
||||
v := user.DefaultBsky
|
||||
uc.mutation.SetBsky(v)
|
||||
@@ -1001,14 +461,6 @@ func (uc *UserCreate) defaults() {
|
||||
v := user.DefaultRaidAt()
|
||||
uc.mutation.SetRaidAt(v)
|
||||
}
|
||||
if _, ok := uc.mutation.ServerAt(); !ok {
|
||||
v := user.DefaultServerAt()
|
||||
uc.mutation.SetServerAt(v)
|
||||
}
|
||||
if _, ok := uc.mutation.EggAt(); !ok {
|
||||
v := user.DefaultEggAt()
|
||||
uc.mutation.SetEggAt(v)
|
||||
}
|
||||
if _, ok := uc.mutation.LuckAt(); !ok {
|
||||
v := user.DefaultLuckAt()
|
||||
uc.mutation.SetLuckAt(v)
|
||||
@@ -1025,50 +477,6 @@ func (uc *UserCreate) defaults() {
|
||||
v := user.DefaultNext
|
||||
uc.mutation.SetNext(v)
|
||||
}
|
||||
if _, ok := uc.mutation.ModelAt(); !ok {
|
||||
v := user.DefaultModelAt()
|
||||
uc.mutation.SetModelAt(v)
|
||||
}
|
||||
if _, ok := uc.mutation.Game(); !ok {
|
||||
v := user.DefaultGame
|
||||
uc.mutation.SetGame(v)
|
||||
}
|
||||
if _, ok := uc.mutation.GameTest(); !ok {
|
||||
v := user.DefaultGameTest
|
||||
uc.mutation.SetGameTest(v)
|
||||
}
|
||||
if _, ok := uc.mutation.GameEnd(); !ok {
|
||||
v := user.DefaultGameEnd
|
||||
uc.mutation.SetGameEnd(v)
|
||||
}
|
||||
if _, ok := uc.mutation.GameAccount(); !ok {
|
||||
v := user.DefaultGameAccount
|
||||
uc.mutation.SetGameAccount(v)
|
||||
}
|
||||
if _, ok := uc.mutation.GameLimit(); !ok {
|
||||
v := user.DefaultGameLimit
|
||||
uc.mutation.SetGameLimit(v)
|
||||
}
|
||||
if _, ok := uc.mutation.CoinOpen(); !ok {
|
||||
v := user.DefaultCoinOpen
|
||||
uc.mutation.SetCoinOpen(v)
|
||||
}
|
||||
if _, ok := uc.mutation.CoinAt(); !ok {
|
||||
v := user.DefaultCoinAt()
|
||||
uc.mutation.SetCoinAt(v)
|
||||
}
|
||||
if _, ok := uc.mutation.PlanetAt(); !ok {
|
||||
v := user.DefaultPlanetAt()
|
||||
uc.mutation.SetPlanetAt(v)
|
||||
}
|
||||
if _, ok := uc.mutation.Login(); !ok {
|
||||
v := user.DefaultLogin
|
||||
uc.mutation.SetLogin(v)
|
||||
}
|
||||
if _, ok := uc.mutation.LoginAt(); !ok {
|
||||
v := user.DefaultLoginAt()
|
||||
uc.mutation.SetLoginAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
@@ -1123,22 +531,6 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(user.FieldDid, field.TypeString, value)
|
||||
_node.Did = value
|
||||
}
|
||||
if value, ok := uc.mutation.Member(); ok {
|
||||
_spec.SetField(user.FieldMember, field.TypeBool, value)
|
||||
_node.Member = value
|
||||
}
|
||||
if value, ok := uc.mutation.Book(); ok {
|
||||
_spec.SetField(user.FieldBook, field.TypeBool, value)
|
||||
_node.Book = value
|
||||
}
|
||||
if value, ok := uc.mutation.Manga(); ok {
|
||||
_spec.SetField(user.FieldManga, field.TypeBool, value)
|
||||
_node.Manga = value
|
||||
}
|
||||
if value, ok := uc.mutation.Badge(); ok {
|
||||
_spec.SetField(user.FieldBadge, field.TypeBool, value)
|
||||
_node.Badge = value
|
||||
}
|
||||
if value, ok := uc.mutation.Bsky(); ok {
|
||||
_spec.SetField(user.FieldBsky, field.TypeBool, value)
|
||||
_node.Bsky = value
|
||||
@@ -1175,14 +567,6 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(user.FieldRaidAt, field.TypeTime, value)
|
||||
_node.RaidAt = value
|
||||
}
|
||||
if value, ok := uc.mutation.ServerAt(); ok {
|
||||
_spec.SetField(user.FieldServerAt, field.TypeTime, value)
|
||||
_node.ServerAt = value
|
||||
}
|
||||
if value, ok := uc.mutation.EggAt(); ok {
|
||||
_spec.SetField(user.FieldEggAt, field.TypeTime, value)
|
||||
_node.EggAt = value
|
||||
}
|
||||
if value, ok := uc.mutation.Luck(); ok {
|
||||
_spec.SetField(user.FieldLuck, field.TypeInt, value)
|
||||
_node.Luck = value
|
||||
@@ -1247,118 +631,6 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(user.FieldNext, field.TypeString, value)
|
||||
_node.Next = value
|
||||
}
|
||||
if value, ok := uc.mutation.Room(); ok {
|
||||
_spec.SetField(user.FieldRoom, field.TypeInt, value)
|
||||
_node.Room = value
|
||||
}
|
||||
if value, ok := uc.mutation.Model(); ok {
|
||||
_spec.SetField(user.FieldModel, field.TypeBool, value)
|
||||
_node.Model = value
|
||||
}
|
||||
if value, ok := uc.mutation.ModelAt(); ok {
|
||||
_spec.SetField(user.FieldModelAt, field.TypeTime, value)
|
||||
_node.ModelAt = value
|
||||
}
|
||||
if value, ok := uc.mutation.ModelAttack(); ok {
|
||||
_spec.SetField(user.FieldModelAttack, field.TypeInt, value)
|
||||
_node.ModelAttack = value
|
||||
}
|
||||
if value, ok := uc.mutation.ModelLimit(); ok {
|
||||
_spec.SetField(user.FieldModelLimit, field.TypeInt, value)
|
||||
_node.ModelLimit = value
|
||||
}
|
||||
if value, ok := uc.mutation.ModelSkill(); ok {
|
||||
_spec.SetField(user.FieldModelSkill, field.TypeInt, value)
|
||||
_node.ModelSkill = value
|
||||
}
|
||||
if value, ok := uc.mutation.ModelMode(); ok {
|
||||
_spec.SetField(user.FieldModelMode, field.TypeInt, value)
|
||||
_node.ModelMode = value
|
||||
}
|
||||
if value, ok := uc.mutation.ModelCritical(); ok {
|
||||
_spec.SetField(user.FieldModelCritical, field.TypeInt, value)
|
||||
_node.ModelCritical = value
|
||||
}
|
||||
if value, ok := uc.mutation.ModelCriticalD(); ok {
|
||||
_spec.SetField(user.FieldModelCriticalD, field.TypeInt, value)
|
||||
_node.ModelCriticalD = value
|
||||
}
|
||||
if value, ok := uc.mutation.Game(); ok {
|
||||
_spec.SetField(user.FieldGame, field.TypeBool, value)
|
||||
_node.Game = value
|
||||
}
|
||||
if value, ok := uc.mutation.GameTest(); ok {
|
||||
_spec.SetField(user.FieldGameTest, field.TypeBool, value)
|
||||
_node.GameTest = value
|
||||
}
|
||||
if value, ok := uc.mutation.GameEnd(); ok {
|
||||
_spec.SetField(user.FieldGameEnd, field.TypeBool, value)
|
||||
_node.GameEnd = value
|
||||
}
|
||||
if value, ok := uc.mutation.GameAccount(); ok {
|
||||
_spec.SetField(user.FieldGameAccount, field.TypeBool, value)
|
||||
_node.GameAccount = value
|
||||
}
|
||||
if value, ok := uc.mutation.GameLv(); ok {
|
||||
_spec.SetField(user.FieldGameLv, field.TypeInt, value)
|
||||
_node.GameLv = value
|
||||
}
|
||||
if value, ok := uc.mutation.GameExp(); ok {
|
||||
_spec.SetField(user.FieldGameExp, field.TypeInt, value)
|
||||
_node.GameExp = value
|
||||
}
|
||||
if value, ok := uc.mutation.GameStory(); ok {
|
||||
_spec.SetField(user.FieldGameStory, field.TypeInt, value)
|
||||
_node.GameStory = value
|
||||
}
|
||||
if value, ok := uc.mutation.GameLimit(); ok {
|
||||
_spec.SetField(user.FieldGameLimit, field.TypeBool, value)
|
||||
_node.GameLimit = value
|
||||
}
|
||||
if value, ok := uc.mutation.Coin(); ok {
|
||||
_spec.SetField(user.FieldCoin, field.TypeInt, value)
|
||||
_node.Coin = value
|
||||
}
|
||||
if value, ok := uc.mutation.CoinOpen(); ok {
|
||||
_spec.SetField(user.FieldCoinOpen, field.TypeBool, value)
|
||||
_node.CoinOpen = value
|
||||
}
|
||||
if value, ok := uc.mutation.CoinAt(); ok {
|
||||
_spec.SetField(user.FieldCoinAt, field.TypeTime, value)
|
||||
_node.CoinAt = value
|
||||
}
|
||||
if value, ok := uc.mutation.Planet(); ok {
|
||||
_spec.SetField(user.FieldPlanet, field.TypeFloat64, value)
|
||||
_node.Planet = value
|
||||
}
|
||||
if value, ok := uc.mutation.PlanetAt(); ok {
|
||||
_spec.SetField(user.FieldPlanetAt, field.TypeTime, value)
|
||||
_node.PlanetAt = value
|
||||
}
|
||||
if value, ok := uc.mutation.Login(); ok {
|
||||
_spec.SetField(user.FieldLogin, field.TypeBool, value)
|
||||
_node.Login = value
|
||||
}
|
||||
if value, ok := uc.mutation.LoginAt(); ok {
|
||||
_spec.SetField(user.FieldLoginAt, field.TypeTime, value)
|
||||
_node.LoginAt = value
|
||||
}
|
||||
if value, ok := uc.mutation.LocationX(); ok {
|
||||
_spec.SetField(user.FieldLocationX, field.TypeInt, value)
|
||||
_node.LocationX = value
|
||||
}
|
||||
if value, ok := uc.mutation.LocationY(); ok {
|
||||
_spec.SetField(user.FieldLocationY, field.TypeInt, value)
|
||||
_node.LocationY = value
|
||||
}
|
||||
if value, ok := uc.mutation.LocationZ(); ok {
|
||||
_spec.SetField(user.FieldLocationZ, field.TypeInt, value)
|
||||
_node.LocationZ = value
|
||||
}
|
||||
if value, ok := uc.mutation.LocationN(); ok {
|
||||
_spec.SetField(user.FieldLocationN, field.TypeInt, value)
|
||||
_node.LocationN = value
|
||||
}
|
||||
if nodes := uc.mutation.CardIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
@@ -1375,54 +647,6 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := uc.mutation.UeIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.UeTable,
|
||||
Columns: []string{user.UeColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := uc.mutation.MaIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.MaTable,
|
||||
Columns: []string{user.MaColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(ma.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := uc.mutation.SevIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.SevTable,
|
||||
Columns: []string{user.SevColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(sev.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
@@ -1450,8 +674,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
var err error
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation)
|
||||
} else {
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/predicate"
|
||||
"api/ent/user"
|
||||
"context"
|
||||
"t/ent/predicate"
|
||||
"t/ent/user"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
|
||||
@@ -3,16 +3,13 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/card"
|
||||
"api/ent/ma"
|
||||
"api/ent/predicate"
|
||||
"api/ent/sev"
|
||||
"api/ent/ue"
|
||||
"api/ent/user"
|
||||
"context"
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
"math"
|
||||
"t/ent/card"
|
||||
"t/ent/predicate"
|
||||
"t/ent/user"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -23,13 +20,10 @@ import (
|
||||
type UserQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []user.OrderOption
|
||||
order []OrderFunc
|
||||
inters []Interceptor
|
||||
predicates []predicate.User
|
||||
withCard *CardQuery
|
||||
withUe *UeQuery
|
||||
withMa *MaQuery
|
||||
withSev *SevQuery
|
||||
withFKs bool
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
@@ -62,7 +56,7 @@ func (uq *UserQuery) Unique(unique bool) *UserQuery {
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (uq *UserQuery) Order(o ...user.OrderOption) *UserQuery {
|
||||
func (uq *UserQuery) Order(o ...OrderFunc) *UserQuery {
|
||||
uq.order = append(uq.order, o...)
|
||||
return uq
|
||||
}
|
||||
@@ -89,72 +83,6 @@ func (uq *UserQuery) QueryCard() *CardQuery {
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryUe chains the current query on the "ue" edge.
|
||||
func (uq *UserQuery) QueryUe() *UeQuery {
|
||||
query := (&UeClient{config: uq.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := uq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := uq.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(user.Table, user.FieldID, selector),
|
||||
sqlgraph.To(ue.Table, ue.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, user.UeTable, user.UeColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryMa chains the current query on the "ma" edge.
|
||||
func (uq *UserQuery) QueryMa() *MaQuery {
|
||||
query := (&MaClient{config: uq.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := uq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := uq.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(user.Table, user.FieldID, selector),
|
||||
sqlgraph.To(ma.Table, ma.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, user.MaTable, user.MaColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QuerySev chains the current query on the "sev" edge.
|
||||
func (uq *UserQuery) QuerySev() *SevQuery {
|
||||
query := (&SevClient{config: uq.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := uq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := uq.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(user.Table, user.FieldID, selector),
|
||||
sqlgraph.To(sev.Table, sev.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, user.SevTable, user.SevColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first User entity from the query.
|
||||
// Returns a *NotFoundError when no User was found.
|
||||
func (uq *UserQuery) First(ctx context.Context) (*User, error) {
|
||||
@@ -344,13 +272,10 @@ func (uq *UserQuery) Clone() *UserQuery {
|
||||
return &UserQuery{
|
||||
config: uq.config,
|
||||
ctx: uq.ctx.Clone(),
|
||||
order: append([]user.OrderOption{}, uq.order...),
|
||||
order: append([]OrderFunc{}, uq.order...),
|
||||
inters: append([]Interceptor{}, uq.inters...),
|
||||
predicates: append([]predicate.User{}, uq.predicates...),
|
||||
withCard: uq.withCard.Clone(),
|
||||
withUe: uq.withUe.Clone(),
|
||||
withMa: uq.withMa.Clone(),
|
||||
withSev: uq.withSev.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: uq.sql.Clone(),
|
||||
path: uq.path,
|
||||
@@ -368,39 +293,6 @@ func (uq *UserQuery) WithCard(opts ...func(*CardQuery)) *UserQuery {
|
||||
return uq
|
||||
}
|
||||
|
||||
// WithUe tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "ue" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (uq *UserQuery) WithUe(opts ...func(*UeQuery)) *UserQuery {
|
||||
query := (&UeClient{config: uq.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
uq.withUe = query
|
||||
return uq
|
||||
}
|
||||
|
||||
// WithMa tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "ma" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (uq *UserQuery) WithMa(opts ...func(*MaQuery)) *UserQuery {
|
||||
query := (&MaClient{config: uq.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
uq.withMa = query
|
||||
return uq
|
||||
}
|
||||
|
||||
// WithSev tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "sev" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (uq *UserQuery) WithSev(opts ...func(*SevQuery)) *UserQuery {
|
||||
query := (&SevClient{config: uq.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
uq.withSev = query
|
||||
return uq
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
@@ -480,11 +372,8 @@ func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e
|
||||
nodes = []*User{}
|
||||
withFKs = uq.withFKs
|
||||
_spec = uq.querySpec()
|
||||
loadedTypes = [4]bool{
|
||||
loadedTypes = [1]bool{
|
||||
uq.withCard != nil,
|
||||
uq.withUe != nil,
|
||||
uq.withMa != nil,
|
||||
uq.withSev != nil,
|
||||
}
|
||||
)
|
||||
if withFKs {
|
||||
@@ -515,27 +404,6 @@ func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := uq.withUe; query != nil {
|
||||
if err := uq.loadUe(ctx, query, nodes,
|
||||
func(n *User) { n.Edges.Ue = []*Ue{} },
|
||||
func(n *User, e *Ue) { n.Edges.Ue = append(n.Edges.Ue, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := uq.withMa; query != nil {
|
||||
if err := uq.loadMa(ctx, query, nodes,
|
||||
func(n *User) { n.Edges.Ma = []*Ma{} },
|
||||
func(n *User, e *Ma) { n.Edges.Ma = append(n.Edges.Ma, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := uq.withSev; query != nil {
|
||||
if err := uq.loadSev(ctx, query, nodes,
|
||||
func(n *User) { n.Edges.Sev = []*Sev{} },
|
||||
func(n *User, e *Sev) { n.Edges.Sev = append(n.Edges.Sev, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
@@ -551,7 +419,7 @@ func (uq *UserQuery) loadCard(ctx context.Context, query *CardQuery, nodes []*Us
|
||||
}
|
||||
query.withFKs = true
|
||||
query.Where(predicate.Card(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(s.C(user.CardColumn), fks...))
|
||||
s.Where(sql.InValues(user.CardColumn, fks...))
|
||||
}))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
@@ -564,100 +432,7 @@ func (uq *UserQuery) loadCard(ctx context.Context, query *CardQuery, nodes []*Us
|
||||
}
|
||||
node, ok := nodeids[*fk]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected referenced foreign-key "user_card" returned %v for node %v`, *fk, n.ID)
|
||||
}
|
||||
assign(node, n)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (uq *UserQuery) loadUe(ctx context.Context, query *UeQuery, nodes []*User, init func(*User), assign func(*User, *Ue)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[int]*User)
|
||||
for i := range nodes {
|
||||
fks = append(fks, nodes[i].ID)
|
||||
nodeids[nodes[i].ID] = nodes[i]
|
||||
if init != nil {
|
||||
init(nodes[i])
|
||||
}
|
||||
}
|
||||
query.withFKs = true
|
||||
query.Where(predicate.Ue(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(s.C(user.UeColumn), fks...))
|
||||
}))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
fk := n.user_ue
|
||||
if fk == nil {
|
||||
return fmt.Errorf(`foreign-key "user_ue" is nil for node %v`, n.ID)
|
||||
}
|
||||
node, ok := nodeids[*fk]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected referenced foreign-key "user_ue" returned %v for node %v`, *fk, n.ID)
|
||||
}
|
||||
assign(node, n)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (uq *UserQuery) loadMa(ctx context.Context, query *MaQuery, nodes []*User, init func(*User), assign func(*User, *Ma)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[int]*User)
|
||||
for i := range nodes {
|
||||
fks = append(fks, nodes[i].ID)
|
||||
nodeids[nodes[i].ID] = nodes[i]
|
||||
if init != nil {
|
||||
init(nodes[i])
|
||||
}
|
||||
}
|
||||
query.withFKs = true
|
||||
query.Where(predicate.Ma(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(s.C(user.MaColumn), fks...))
|
||||
}))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
fk := n.user_ma
|
||||
if fk == nil {
|
||||
return fmt.Errorf(`foreign-key "user_ma" is nil for node %v`, n.ID)
|
||||
}
|
||||
node, ok := nodeids[*fk]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected referenced foreign-key "user_ma" returned %v for node %v`, *fk, n.ID)
|
||||
}
|
||||
assign(node, n)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (uq *UserQuery) loadSev(ctx context.Context, query *SevQuery, nodes []*User, init func(*User), assign func(*User, *Sev)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[int]*User)
|
||||
for i := range nodes {
|
||||
fks = append(fks, nodes[i].ID)
|
||||
nodeids[nodes[i].ID] = nodes[i]
|
||||
if init != nil {
|
||||
init(nodes[i])
|
||||
}
|
||||
}
|
||||
query.withFKs = true
|
||||
query.Where(predicate.Sev(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(s.C(user.SevColumn), fks...))
|
||||
}))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
fk := n.user_sev
|
||||
if fk == nil {
|
||||
return fmt.Errorf(`foreign-key "user_sev" is nil for node %v`, n.ID)
|
||||
}
|
||||
node, ok := nodeids[*fk]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected referenced foreign-key "user_sev" returned %v for node %v`, *fk, n.ID)
|
||||
return fmt.Errorf(`unexpected foreign-key "user_card" returned %v for node %v`, *fk, n.ID)
|
||||
}
|
||||
assign(node, n)
|
||||
}
|
||||
|
||||
2583
ent/user_update.go
2583
ent/user_update.go
File diff suppressed because it is too large
Load Diff
27
go.mod
27
go.mod
@@ -1,14 +1,15 @@
|
||||
module api
|
||||
module t
|
||||
|
||||
go 1.21
|
||||
go 1.19
|
||||
|
||||
//replace ariga.io/ogent => ../../
|
||||
|
||||
require (
|
||||
entgo.io/ent v0.12.2
|
||||
entgo.io/ent v0.11.10
|
||||
github.com/go-faster/errors v0.6.1
|
||||
github.com/go-faster/jx v0.42.0-alpha.1
|
||||
github.com/mattn/go-sqlite3 v1.14.16
|
||||
github.com/mazen160/go-random v0.0.0-20210308102632-d2b501c85c03
|
||||
github.com/ogen-go/ogen v0.59.0
|
||||
go.opentelemetry.io/otel v1.13.0
|
||||
go.opentelemetry.io/otel/metric v0.36.0
|
||||
@@ -17,9 +18,10 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
ariga.io/atlas v0.10.0 // indirect
|
||||
ariga.io/ogent v0.0.0-20230621041143-ed3e5d4da458 // indirect
|
||||
entgo.io/contrib v0.4.5 // indirect
|
||||
ariga.io/atlas v0.9.2-0.20230303073438-03a4779a6338 // indirect
|
||||
ariga.io/entviz v0.0.0-20230125130633-6c9be8e08c7c // indirect
|
||||
ariga.io/ogent v0.0.0-20230309073626-8dc564a6a73e // indirect
|
||||
entgo.io/contrib v0.3.5 // indirect
|
||||
github.com/agext/levenshtein v1.2.3 // indirect
|
||||
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
|
||||
github.com/dlclark/regexp2 v1.8.0 // indirect
|
||||
@@ -29,21 +31,28 @@ require (
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-openapi/inflect v0.19.0 // indirect
|
||||
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/hashicorp/hcl/v2 v2.15.0 // indirect
|
||||
github.com/joho/godotenv v1.5.1 // indirect
|
||||
github.com/kyokomi/lottery v1.2.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
|
||||
github.com/segmentio/asm v1.2.0 // indirect
|
||||
github.com/sergi/go-diff v1.1.0 // indirect
|
||||
github.com/stoewer/go-strcase v1.2.0 // indirect
|
||||
github.com/zclconf/go-cty v1.12.1 // indirect
|
||||
go.uber.org/atomic v1.10.0 // indirect
|
||||
go.uber.org/zap v1.24.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20230206171751-46f607a40771 // indirect
|
||||
golang.org/x/mod v0.9.0 // indirect
|
||||
golang.org/x/mod v0.8.0 // indirect
|
||||
golang.org/x/net v0.7.0 // indirect
|
||||
golang.org/x/sync v0.1.0 // indirect
|
||||
golang.org/x/sys v0.6.0 // indirect
|
||||
golang.org/x/text v0.8.0 // indirect
|
||||
golang.org/x/sys v0.5.0 // indirect
|
||||
golang.org/x/text v0.7.0 // indirect
|
||||
golang.org/x/tools v0.6.1-0.20230222164832-25d2519c8696 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
)
|
||||
|
||||
83
go.sum
83
go.sum
@@ -1,23 +1,24 @@
|
||||
ariga.io/atlas v0.9.1 h1:EpoPMnwsQG0vn9c0sYExpwSYtr7bvuSUXzQclU2pMjc=
|
||||
ariga.io/atlas v0.9.1/go.mod h1:T230JFcENj4ZZzMkZrXFDSkv+2kXkUgpJ5FQQ5hMcKU=
|
||||
ariga.io/atlas v0.9.2-0.20230303073438-03a4779a6338 h1:8kmSV3mbQKn0niZ/EdE11uhFvFKiW1VlaqVBIYOyahM=
|
||||
ariga.io/atlas v0.9.2-0.20230303073438-03a4779a6338/go.mod h1:T230JFcENj4ZZzMkZrXFDSkv+2kXkUgpJ5FQQ5hMcKU=
|
||||
ariga.io/atlas v0.10.0 h1:B1aCP6gSDQET6j8ybn7m6MArjQuoLH5d4DQBT+NP5k8=
|
||||
ariga.io/atlas v0.10.0/go.mod h1:+TR129FJZ5Lvzms6dvCeGWh1yR6hMvmXBhug4hrNIGk=
|
||||
ariga.io/ogent v0.0.0-20230621041143-ed3e5d4da458 h1:FShFeMszKX8VcySiTRgshmj98jQWMv2GjQgMJcHJJi4=
|
||||
ariga.io/ogent v0.0.0-20230621041143-ed3e5d4da458/go.mod h1:95vCbvAYAW6NsWUrSL23k2SQykuf/yjellmwV1X+svI=
|
||||
entgo.io/contrib v0.4.5 h1:BFaOHwFLE8WZjVJadP0XHCIaxgcC1BAtUvAyw7M/GHk=
|
||||
entgo.io/contrib v0.4.5/go.mod h1:wpZyq2DJgthugFvDBlaqMXj9mV4/9ebyGEn7xlTVQqE=
|
||||
ariga.io/entviz v0.0.0-20230125130633-6c9be8e08c7c h1:7FbOjKKWKqD7FZXQq3qWcRlvGFO1LGYvVZIWQ2D9Evs=
|
||||
ariga.io/entviz v0.0.0-20230125130633-6c9be8e08c7c/go.mod h1:wArXZPqbbWBcOmkqwmIF6hIcW+3T1NLDde0iRhW6an8=
|
||||
ariga.io/ogent v0.0.0-20230309073626-8dc564a6a73e h1:8mxC+4Y7pVKgfoUJIMdChrS95d+TcJ6xuhw49nVYIAY=
|
||||
ariga.io/ogent v0.0.0-20230309073626-8dc564a6a73e/go.mod h1:95vCbvAYAW6NsWUrSL23k2SQykuf/yjellmwV1X+svI=
|
||||
entgo.io/contrib v0.3.5 h1:wY85TgRp3j5ix/SZ9IE6Ob5lObHFmVUYH0ZFw1D5Hzc=
|
||||
entgo.io/contrib v0.3.5/go.mod h1:R5HiFszVD8OVOZKFGRbqYogRxK7z1ruzWyEEesjQwE0=
|
||||
entgo.io/ent v0.11.9 h1:dbbCkAiPVTRBIJwoZctiSYjB7zxQIBOzVSU5H9VYIQI=
|
||||
entgo.io/ent v0.11.9/go.mod h1:KWHOcDZn1xk3mz3ipWdKrQpMvwqa/9B69TUuAPP9W6g=
|
||||
entgo.io/ent v0.11.10 h1:iqn32ybY5HRW3xSAyMNdNKpZhKgMf1Zunsej9yPKUI8=
|
||||
entgo.io/ent v0.11.10/go.mod h1:mzTZ0trE+jCQw/fnzijbm5Mck/l8Gbg7gC/+L1COyzM=
|
||||
entgo.io/ent v0.12.2 h1:Ndl/JvCX76xCtUDlrUfMnOKBRodAtxE5yfGYxjbOxmM=
|
||||
entgo.io/ent v0.12.2/go.mod h1:OA1Y5bNE8EtlxKv4IyzWwt4jgvGbkoKMcwp668iEKQE=
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
||||
github.com/Khan/genqlient v0.5.0 h1:TMZJ+tl/BpbmGyIBiXzKzUftDhw4ZWxQZ+1ydn0gyII=
|
||||
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
|
||||
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
|
||||
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
|
||||
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
|
||||
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
|
||||
github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||
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=
|
||||
@@ -40,48 +41,60 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4=
|
||||
github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4=
|
||||
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
|
||||
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
||||
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
|
||||
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
|
||||
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
|
||||
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/hashicorp/hcl/v2 v2.15.0 h1:CPDXO6+uORPjKflkWCCwoWc9uRp+zSIPcCQ+BrxV7m8=
|
||||
github.com/hashicorp/hcl/v2 v2.15.0/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4=
|
||||
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
|
||||
github.com/kyokomi/lottery v1.2.0 h1:oW9YxYv5j/nu/Kkf8K5tu7Vn8dAoZTjluDxihTPX/68=
|
||||
github.com/kyokomi/lottery v1.2.0/go.mod h1:TkKpJrFrOJNHpblUqYu0bAQWil3NMwKMBluHyqFfU6Y=
|
||||
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
|
||||
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||
github.com/mazen160/go-random v0.0.0-20210308102632-d2b501c85c03 h1:iM7JTVzKOYKWjzhGcgHAgFVQt5QfiHIVrRUaWPfh0Q4=
|
||||
github.com/mazen160/go-random v0.0.0-20210308102632-d2b501c85c03/go.mod h1:APoDd0B2pYeB5kU/g7Mw14mFsljp5HfzrC7arsKbi8U=
|
||||
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
|
||||
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
|
||||
github.com/ogen-go/ogen v0.59.0 h1:9aSSZ1KCLJIcRyjkO7IHrG0vAI6l1BO877LwTbMcX+k=
|
||||
github.com/ogen-go/ogen v0.59.0/go.mod h1:0MHLcWEbxwdvR+R9E05paQSRh/2vHtVSJgKqmwYyW8M=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.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/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
|
||||
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
|
||||
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU=
|
||||
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
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.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/vektah/gqlparser/v2 v2.4.5 h1:C02NsyEsL4TXJB7ndonqTfuQOL4XPIu0aAWugdmTgmc=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY=
|
||||
github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA=
|
||||
go.opentelemetry.io/otel v1.13.0 h1:1ZAKnNQKwBBxFtww/GwxNUyTf0AxkZzrukO8MeXqe4Y=
|
||||
@@ -93,32 +106,47 @@ go.opentelemetry.io/otel/trace v1.13.0/go.mod h1:muCvmmO9KKpvuXSf3KKAXXB2ygNYHQ+
|
||||
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
|
||||
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
|
||||
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
|
||||
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
|
||||
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
|
||||
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
|
||||
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/exp v0.0.0-20230206171751-46f607a40771 h1:xP7rWLUr1e1n2xkK5YB4LI0hPEy3LJC6Wk+D4pGlOJg=
|
||||
golang.org/x/exp v0.0.0-20230206171751-46f607a40771/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs=
|
||||
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
|
||||
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
|
||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
|
||||
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4=
|
||||
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.6.1-0.20230222164832-25d2519c8696 h1:8985/C5IvACpd9DDXckSnjSBLKDgbxXiyODgi94zOPM=
|
||||
golang.org/x/tools v0.6.1-0.20230222164832-25d2519c8696/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
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-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
@@ -127,4 +155,3 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
BIN
icon/api.png
BIN
icon/api.png
Binary file not shown.
|
Before Width: | Height: | Size: 100 KiB |
BIN
icon/card.png
BIN
icon/card.png
Binary file not shown.
|
Before Width: | Height: | Size: 49 KiB |
BIN
icon/db.png
BIN
icon/db.png
Binary file not shown.
|
Before Width: | Height: | Size: 44 KiB |
6
main.go
6
main.go
@@ -5,8 +5,8 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"api/ent"
|
||||
"api/ent/ogent"
|
||||
"t/ent"
|
||||
"t/ent/ogent"
|
||||
"entgo.io/ent/dialect"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
@@ -51,7 +51,7 @@ func (h handler) DrawDone(ctx context.Context, params ogent.DrawDoneParams) erro
|
||||
|
||||
func main() {
|
||||
// Create ent client.
|
||||
client, err := ent.Open(dialect.SQLite, "file:/app/data/new.sqlite?_fk=1")
|
||||
client, err := ent.Open(dialect.SQLite, "file:/data/new.sqlite?_fk=1")
|
||||
//client, err := ent.Open(dialect.SQLite, "file:data/new.sqlite?_fk=1")
|
||||
//client, err := ent.Open(dialect.SQLite, "file:data?mode=memory&cache=shared&_fk=1")
|
||||
if err != nil {
|
||||
|
||||
95
readme.md
95
readme.md
@@ -1,15 +1,94 @@
|
||||
## ai `api`
|
||||
|
||||
<img src="./icon/card.png" width="100">
|
||||
|
||||
- name : ai `api`
|
||||
- host : [card.syui.ai](https://card.syui.ai)
|
||||
### build
|
||||
|
||||
```sh
|
||||
$ vim ent/entc.go
|
||||
$ vim ent/schema/users.go
|
||||
$ go generate ./...
|
||||
$ go build
|
||||
$ ./card
|
||||
|
||||
$ go generate ./...
|
||||
$ PASS=`cat ./token.json|jq -r .password` TOKEN=`cat ./token.json|jq -r .token` go run -mod=mod main.go
|
||||
$ curl -X POST -H "Content-Type: application/json" -d "{\"username\":\"syui\",\"password\":\"$pass\"}" localhost:8080/users
|
||||
$ curl -X POST -H "Content-Type: application/json" -d "{\"owner\":1,\"password\":\"$pass\"}" localhost:8080/cards
|
||||
$ curl -X POST -H "Content-Type: application/json" -d "{\"owner\":1,\"card\":1,\"cp\":11,\"status\":\"normal\",\"password\":\"$pass\"}" localhost:8080/cards
|
||||
$ curl localhost:8080/users
|
||||
$ curl localhost:8080/cards
|
||||
$ curl localhost:8080/users/1
|
||||
$ curl localhost:8080/users/1/card
|
||||
```
|
||||
|
||||
### use
|
||||
|
||||
```sh
|
||||
$ curl -X POST -H "Content-Type: application/json" -d '{"username":"syui",\"password\":\"$pass\"}' https://api.syui.ai/users
|
||||
|
||||
# onconflict
|
||||
$ !!
|
||||
|
||||
$ curl -sL https://api.syui.ai/users/1
|
||||
```
|
||||
|
||||
## link
|
||||
```sh
|
||||
# item select
|
||||
$ curl -sL "https://api.syui.ai/users?itemsPerPage=255"
|
||||
$ curl -sL "https://api.syui.ai/cards?itemsPerPage=255"
|
||||
$ curl -sL "https://api.syui.ai/users/1/card?itemsPerPage=255"
|
||||
```
|
||||
|
||||
- https://github.com/ariga/ogent
|
||||
### ref
|
||||
|
||||
```sh
|
||||
$ vim ./ent/ogent/ogent.go
|
||||
// 新規登録の停止
|
||||
// CreateUsers handles POST /users-slice requests.
|
||||
func (h *OgentHandler) CreateUsers(ctx context.Context, req CreateUsersReq) (CreateUsersRes, error) {
|
||||
b := h.client.Users.Create()
|
||||
//b.SetUser(req.User)
|
||||
b.SetUser("syui")
|
||||
}
|
||||
|
||||
// 削除の無効
|
||||
// DeleteUsers handles DELETE /users-slice/{id} requests.
|
||||
func (h *OgentHandler) DeleteUsers(ctx context.Context, params DeleteUsersParams) (DeleteUsersRes, error) {
|
||||
if params.ID != 1 {
|
||||
err := h.client.Users.DeleteOneID(params.ID).Exec(ctx)
|
||||
}
|
||||
return new(DeleteUsersNoContent), nil
|
||||
}
|
||||
|
||||
// 要素の書き換えの禁止
|
||||
// UpdateUsers handles PATCH /users-slice/{id} requests.
|
||||
func (h *OgentHandler) UpdateUsers(ctx context.Context, req UpdateUsersReq, params UpdateUsersParams) (UpdateUsersRes, error) {
|
||||
b := h.client.Users.UpdateOneID(params.ID)
|
||||
// Add all fields.
|
||||
//if v, ok := req.Hp.Get(); ok {
|
||||
// b.SetHp(v)
|
||||
//}
|
||||
```
|
||||
|
||||
### link
|
||||
|
||||
- https://entgo.io/ja/blog/2022/02/15/generate-rest-crud-with-ent-and-ogen/
|
||||
|
||||
- https://github.com/ariga/ogent/blob/main/example/todo/ent/entc.go
|
||||
|
||||
- https://github.com/ent/ent/blob/master/dialect/sql/schema/postgres_test.go
|
||||
|
||||
- https://github.com/go-kratos/beer-shop/tree/main/app/catalog/service/internal/data/ent
|
||||
|
||||
|
||||
### update
|
||||
|
||||
```sh
|
||||
$ curl --dump-header - 'https://api.syui.ai/users' -H 'Origin: https://card.syui.ai'|less
|
||||
```
|
||||
|
||||
> ent/ogent/oas_response_encoders_gen.go
|
||||
|
||||
```go
|
||||
func encodeCreateGroupResponse(response CreateGroupRes, w http.ResponseWriter, span trace.Span) error {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai")
|
||||
switch response := response.(type) {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai")
|
||||
```
|
||||
|
||||
3
run.zsh
Executable file
3
run.zsh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/zsh
|
||||
d=${0:a:h}
|
||||
PASS=`cat token.json|jq -r .password` go run -mod=mod main.go
|
||||
1
scpt
1
scpt
Submodule scpt deleted from 87e087752d
31
tmp/card_account_change.zsh
Executable file
31
tmp/card_account_change.zsh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/zsh
|
||||
echo old_id new_id
|
||||
host=https://api.syui.ai
|
||||
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
|
||||
if [ -z "$1" ];then
|
||||
exit
|
||||
fi
|
||||
if [ -z "$2" ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
echo old-id new-id
|
||||
|
||||
id=$1
|
||||
data=`curl -sL "$host/users/$id/card?itemsPerPage=2550"`
|
||||
echo $data
|
||||
id_n=$2
|
||||
echo $id_n
|
||||
read
|
||||
|
||||
n=`echo $data|jq length`
|
||||
n=$((n - 1))
|
||||
|
||||
for ((i=0;i<=$n;i++))
|
||||
do
|
||||
card=`echo $data|jq -r ".[$i].card"`
|
||||
s=`echo $data|jq -r ".[$i].status"`
|
||||
cp=`echo $data|jq -r ".[$i].cp"`
|
||||
skill=`echo $data|jq -r ".[$i].skill"`
|
||||
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id_n,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\",\"skill\":\"$skill\"}" -sL $host/cards
|
||||
done
|
||||
12
tmp/card_account_delete.zsh
Executable file
12
tmp/card_account_delete.zsh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/zsh
|
||||
echo id
|
||||
host=https://api.syui.ai
|
||||
token=`cat ~/.config/atr/api_card.json|jq -r .token`
|
||||
pass=`cat ~/.config/atr/api_card.json|jq -r .pass`
|
||||
if [ -z "$1" ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
id=$1
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"delete\":true,\"token\":\"$token\"}" -s $host/users/$id
|
||||
|
||||
27
tmp/card_account_select_delete.zsh
Executable file
27
tmp/card_account_select_delete.zsh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/zsh
|
||||
|
||||
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
|
||||
d=${0:a:h}
|
||||
f=$d/t.txt
|
||||
|
||||
if [ -z "$1" ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -f $f ];then
|
||||
echo $f
|
||||
exit
|
||||
fi
|
||||
|
||||
id=$1
|
||||
n=`cat $f|wc -l`
|
||||
|
||||
for ((i=1;i<=$n;i++))
|
||||
do
|
||||
card=`cat $d/t.txt|awk "NR==$i"`
|
||||
echo $card
|
||||
read
|
||||
curl -X DELETE -H "Content-Type: application/json" -d "{'owner':\"$id\"}" https://api.syui.ai/cards/$card
|
||||
done
|
||||
|
||||
rm $d/t.txt
|
||||
22
tmp/card_add.zsh
Executable file
22
tmp/card_add.zsh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/zsh
|
||||
|
||||
host=https://api.syui.ai
|
||||
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
|
||||
if [ -z "$1" ];then
|
||||
exit
|
||||
fi
|
||||
if [ -z "$2" ];then
|
||||
exit
|
||||
fi
|
||||
if [ -z "$3" ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
echo username card cp
|
||||
read
|
||||
id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id`
|
||||
card=$2
|
||||
cp=$3
|
||||
s=super
|
||||
skill=normal
|
||||
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\",\"skill\":\"$skill\"}" -sL $host/cards
|
||||
20
tmp/card_did_change.zsh
Executable file
20
tmp/card_did_change.zsh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/zsh
|
||||
echo id
|
||||
host=https://api.syui.ai
|
||||
token=`cat ~/.config/atr/api_card.json|jq -r .token`
|
||||
echo $token
|
||||
pass=`cat ~/.config/atr/api_card.json|jq -r .pass`
|
||||
if [ -z "$1" ];then
|
||||
echo 1 : id
|
||||
exit
|
||||
fi
|
||||
if [ -z "$2" ];then
|
||||
echo 2 : did
|
||||
exit
|
||||
fi
|
||||
|
||||
id=$1
|
||||
did=$2
|
||||
|
||||
id=$1
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"did\":\"$did\",\"token\":\"$token\"}" -s $host/users/$id
|
||||
29
tmp/card_fav_first.zsh
Executable file
29
tmp/card_fav_first.zsh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/zsh
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias date="/opt/homebrew/bin/gdate"
|
||||
;;
|
||||
esac
|
||||
|
||||
card_status=first
|
||||
host=https://api.syui.ai
|
||||
token=`cat ~/.config/atr/api_card.json|jq -r .token`
|
||||
|
||||
data=`curl -sL "https://api.syui.ai/users?itemsPerPage=2555"`
|
||||
fav=`echo $data|jq ".[]|select(.fav != 0)|.fav"`
|
||||
id=`echo $data|jq ".[]|select(.fav != 0)|.id"`
|
||||
|
||||
n=`echo $fav|wc -l`
|
||||
echo $n
|
||||
|
||||
for ((i=1;i<=$n;i++))
|
||||
do
|
||||
cid=`echo $fav|awk "NR==$i"`
|
||||
uid=`echo $id|awk "NR==$i"`
|
||||
#check
|
||||
u_data=`curl -sL "https://api.syui.ai/users/$uid/card?itemsPerPage=2555"|jq -r ".[]|select(.status == \"first\")"`
|
||||
if [ -z "$u_data" ];then
|
||||
echo no $uid $cid
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"status\":\"$card_status\",\"token\":\"$token\"}" $host/cards/$cid
|
||||
fi
|
||||
done
|
||||
32
tmp/card_fav_second.zsh
Executable file
32
tmp/card_fav_second.zsh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/zsh
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias date="/opt/homebrew/bin/gdate"
|
||||
;;
|
||||
esac
|
||||
|
||||
card_status=second
|
||||
host=https://api.syui.ai
|
||||
token=`cat ~/.config/atr/api_card.json|jq -r .token`
|
||||
|
||||
data=`curl -sL "https://api.syui.ai/users?itemsPerPage=2555"`
|
||||
fav=`echo $data|jq ".[]|select(.fav != 0)|.fav"`
|
||||
id=`echo $data|jq ".[]|select(.fav != 0)|.id"`
|
||||
|
||||
n=`echo $fav|wc -l`
|
||||
echo $n
|
||||
|
||||
for ((i=1;i<=$n;i++))
|
||||
do
|
||||
cid=`echo $fav|awk "NR==$i"`
|
||||
uid=`echo $id|awk "NR==$i"`
|
||||
#check
|
||||
u_data=`curl -sL "https://api.syui.ai/users/$uid/card?itemsPerPage=2555"|jq -r ".[]|select(.status == \"second\" or \"second\")"`
|
||||
if [ -z "$u_data" ];then
|
||||
d_data=`curl -sL $host/cards/$cid|jq -r "select(.status == \"first\")"`
|
||||
echo $d_data
|
||||
if [ -z "$d_data" ];then
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"status\":\"$card_status\",\"token\":\"$token\"}" $host/cards/$cid
|
||||
fi
|
||||
fi
|
||||
done
|
||||
40
tmp/card_limit_all.zsh
Executable file
40
tmp/card_limit_all.zsh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/zsh
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias date="/opt/homebrew/bin/gdate"
|
||||
;;
|
||||
esac
|
||||
host=https://api.syui.ai
|
||||
token=`cat ~/.config/atr/api_card.json|jq -r .token`
|
||||
host_users="$host/users?itemsPerPage=2550"
|
||||
updated_at_n=`date --iso-8601=seconds -d '1 days ago'`
|
||||
now_at=`date --iso-8601=seconds`
|
||||
raid_at_n=`date --iso-8601=seconds -d '1 days ago'`
|
||||
data=`curl -sL "$host_users"|jq .`
|
||||
nd=`date +"%Y%m%d"`
|
||||
|
||||
n=`echo $data|jq length`
|
||||
n=$((n - 1))
|
||||
|
||||
if [ -n "$1" ];then
|
||||
id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id`
|
||||
if [ "ai" = "$1" ] || [ "yui" = "$1" ];then
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"token\":\"$token\", \"luck_at\": \"$now_at\", \"luck\": 7, \"like\":0,\"aiten\":1000}" -s $host/users/$id
|
||||
else
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"luck_at\": \"$updated_at_n\", \"ten_at\": \"$updated_at_n\",\"token\": \"$token\"}" -s $host/users/$id
|
||||
fi
|
||||
exit
|
||||
fi
|
||||
|
||||
for ((i=0;i<=$n;i++))
|
||||
do
|
||||
name=`echo $data|jq ".[$i]"|jq -r .username`
|
||||
id=`echo $data|jq ".[$i]"|jq -r .id`
|
||||
echo "{\"updated_at\":\"$updated_at_n\"} -s $host/users/$id"
|
||||
if [ "ai" = "$1" ];then
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"token\":\"$token\", \"luck_at\": \"$now_at\", \"luck\": 7}" -s $host/users/$id
|
||||
else
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"token\":\"$token\", \"luck_at\": \"$now_at\", \"ten_at\": \"$updated_at_n\"}" -s $host/users/$id
|
||||
fi
|
||||
done
|
||||
69
tmp/card_sqlite.zsh
Executable file
69
tmp/card_sqlite.zsh
Executable file
@@ -0,0 +1,69 @@
|
||||
#!/bin/zsh
|
||||
|
||||
host=https://api.syui.ai
|
||||
api=localhost:8080
|
||||
|
||||
host_users="$host/users?itemsPerPage=2550"
|
||||
d=${0:a:h}
|
||||
dd=${0:a:h:h}
|
||||
pass=`cat $dd/token.json|jq -r .password`
|
||||
host_at=bsky.social
|
||||
|
||||
if [ -f $d/user.json ] && [ "$1" = "-s" ];then
|
||||
rm $d/user.json
|
||||
fi
|
||||
function did() {
|
||||
unset did
|
||||
url="https://$host_at/xrpc/com.atproto.repo.listRecords?repo=${name}.${host_at}&collection=app.bsky.actor.profile"
|
||||
if [ "`curl -sL $url| jq -r .error`" = "null" ];then
|
||||
t=`curl -sL $url | jq -r ".records|.[]|.uri"|cut -d / -f 3`
|
||||
did=$t
|
||||
else
|
||||
#did=`curl -sL "search.bsky.social/search/posts?q=$name" | jq -r ".[0].user.did"`
|
||||
did="null"
|
||||
fi
|
||||
echo "{\"name\":\"$name\",\"did\":\"$did\"}," >> $d/user.json
|
||||
}
|
||||
|
||||
function l_users() {
|
||||
curl -X POST -H "Content-Type: application/json" -d "{\"username\":\"$name\",\"password\":\"$pass\",\"did\":\"$did\"}" $api/users
|
||||
#sleep 1
|
||||
}
|
||||
|
||||
function l_cards() {
|
||||
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\"}" $api/cards
|
||||
#sleep 1
|
||||
}
|
||||
|
||||
data=`curl -sL "$host_users"|jq .`
|
||||
n=`echo $data|jq length`
|
||||
n=$((n - 1))
|
||||
for ((i=0;i<=$n;i++))
|
||||
do
|
||||
|
||||
name=`echo $data|jq ".[$i]"|jq -r .username`
|
||||
id=`echo $data|jq ".[$i]"|jq -r .id`
|
||||
did=`echo $data|jq ".[$i]"|jq -r .did`
|
||||
|
||||
echo "{\"username\":\"$name\", \"password\":\"$pass\",\"did\":\"$did\"} localhost:8080/users"
|
||||
if [ "$1" = "-a" ];then
|
||||
l_users
|
||||
fi
|
||||
|
||||
data_card=`curl -sL "$host/users/$id/card?itemsPerPage=2550"`
|
||||
nn=`echo $data_card|jq length`
|
||||
nn=$((nn - 1))
|
||||
|
||||
if [ "$1" != "-s" ];then
|
||||
for ((ii=0;ii<=$nn;ii++))
|
||||
do
|
||||
card=`echo $data_card|jq -r ".[$ii].card"`
|
||||
s=`echo $data_card|jq -r ".[$ii].status"`
|
||||
cp=`echo $data_card|jq -r ".[$ii].cp"`
|
||||
echo "{\"owner\":$id,\"card\":\"$card\",\"status\":\"$s\",\"cp\":\"$cp\", \"password\":\"$pass\"} localhost:8080/cards"
|
||||
if [ "$1" = "-a" ];then
|
||||
l_cards
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user