1
0

Compare commits

..

11 Commits

Author SHA1 Message Date
a4a090b234 update docker 2025-07-20 12:51:53 +09:00
9222892c61 fix planet float 2024-08-01 07:01:19 +09:00
4c0c396086 add planet 2024-08-01 06:01:28 +09:00
a4cd0e0f9a fix 2024-07-26 12:31:08 +09:00
a01e86d8b3 fix game story 2024-06-08 01:18:36 +09:00
e508a50025 fix ue game lv 2024-06-02 00:38:55 +09:00
2b479451c1 fix card random 2024-05-17 10:03:59 +09:00
823dc8d89c cors 2024-04-25 18:16:10 +09:00
b3df3250bb fix comment system 2024-04-25 14:05:59 +09:00
336827433e add seven 2024-04-11 10:14:25 +09:00
1d5cb2ad9f update migrate 2024-04-06 03:58:54 +09:00
103 changed files with 49942 additions and 1764 deletions

8
.gitignore vendored
View File

@@ -1,10 +1,14 @@
t
api
.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 Normal file
View File

@@ -0,0 +1,3 @@
[submodule "scpt"]
path = scpt
url = git@git.syui.ai:ai/api_scpt

8
Dockerfile Normal file
View File

@@ -0,0 +1,8 @@
FROM archlinux
#RUN pacman -Syu --noconfirm
WORKDIR /app
COPY api /app/
ENTRYPOINT ["/app/api"]

0
app/data/keep Normal file
View File

View File

@@ -2,9 +2,14 @@
d=${0:a:h}
cd $d
su=5000
su=10000
go1.21.8 generate ./...
#go generate ./...
#PASS=`cat $f|jq -r .password` TOKEN=`cat $f|jq -r .token` go run -mod=mod main.go
go generate ./...
cp -rf $d/ent/openapi.json $d/tmp/
case $OSTYPE in
@@ -19,5 +24,11 @@ case $OSTYPE in
esac
cp -rf $d/tmp/ogent ent/
PASS=`cat token.json|jq -r .password` TOKEN=`cat token.json|jq -r .token` go build
#PASS=`cat token.json|jq -r .password` TOKEN=`cat token.json|jq -r .token` go run -mod=mod main.go
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 Normal file
View File

@@ -0,0 +1,11 @@
services:
api:
ports:
- 8188:8080
build:
context: .
restart: always
env_file:
- .env
volumes:
- ./app/data:/app/data

View File

@@ -1,94 +1,87 @@
### build
## 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
./build.zsh
```
### use
## 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 -X POST -H "Content-Type: application/json" -d '{"username":"syui",\"password\":\"$pass\"}' https://api.syui.ai/users
$ curl -sL $api/users/2
# onconflict
$ !!
$ curl -sL "$api/users?itemsPerPage=2000"
$ curl -sL https://api.syui.ai/users/1
$ curl -sL "$api/users/$uid/card?itemsPerPage=2550"
```
### post
```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"
$ 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
```
### ref
### patch
```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")
}
$ curl -X PATCH -H "Content-Type: application/json" -d "{\"author\":\"$username\", \"count\":$count,\"token\":\"$token\"}" $api/cards/$cid
// 削除の無効
// 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)
//}
$ curl -X PATCH -H "Content-Type: application/json" -d "{\"model\":true,\"model_limit\": 1,\"token\":\"$token\"}" -s $api/users/$uid
```
### 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
### delete
```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")
$ curl -X DELETE -H "Content-Type: application/json" -d "{'owner':\"$uid\"}" $api/cards/$cid
```

View File

@@ -96,8 +96,6 @@ var (
DefaultCp func() int
// DefaultURL holds the default value on creation for the "url" field.
DefaultURL string
// DefaultAuthor holds the default value on creation for the "author" field.
DefaultAuthor string
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
)

View File

@@ -219,10 +219,6 @@ func (cc *CardCreate) defaults() {
v := card.DefaultURL
cc.mutation.SetURL(v)
}
if _, ok := cc.mutation.Author(); !ok {
v := card.DefaultAuthor
cc.mutation.SetAuthor(v)
}
if _, ok := cc.mutation.CreatedAt(); !ok {
v := card.DefaultCreatedAt()
cc.mutation.SetCreatedAt(v)

View File

@@ -12,6 +12,8 @@ import (
"api/ent/card"
"api/ent/group"
"api/ent/ma"
"api/ent/sev"
"api/ent/ue"
"api/ent/user"
@@ -30,6 +32,10 @@ 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.
@@ -49,6 +55,8 @@ 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)
}
@@ -135,6 +143,8 @@ 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
@@ -158,6 +168,8 @@ 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
@@ -188,19 +200,21 @@ 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) {
c.Card.Use(hooks...)
c.Group.Use(hooks...)
c.Ue.Use(hooks...)
c.User.Use(hooks...)
for _, n := range []interface{ Use(...Hook) }{
c.Card, c.Group, c.Ma, c.Sev, c.Ue, c.User,
} {
n.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) {
c.Card.Intercept(interceptors...)
c.Group.Intercept(interceptors...)
c.Ue.Intercept(interceptors...)
c.User.Intercept(interceptors...)
for _, n := range []interface{ Intercept(...Interceptor) }{
c.Card, c.Group, c.Ma, c.Sev, c.Ue, c.User,
} {
n.Intercept(interceptors...)
}
}
// Mutate implements the ent.Mutator interface.
@@ -210,6 +224,10 @@ 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:
@@ -487,6 +505,274 @@ 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
@@ -746,6 +1032,38 @@ func (c *UserClient) QueryUe(u *User) *UeQuery {
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
@@ -774,9 +1092,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, Ue, User []ent.Hook
Card, Group, Ma, Sev, Ue, User []ent.Hook
}
inters struct {
Card, Group, Ue, User []ent.Interceptor
Card, Group, Ma, Sev, Ue, User []ent.Interceptor
}
)

View File

@@ -5,6 +5,8 @@ package ent
import (
"api/ent/card"
"api/ent/group"
"api/ent/ma"
"api/ent/sev"
"api/ent/ue"
"api/ent/user"
"context"
@@ -78,6 +80,8 @@ func checkColumn(table, column string) error {
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,
})

View File

@@ -32,6 +32,30 @@ 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)

389
ent/ma.go Normal file
View File

@@ -0,0 +1,389 @@
// 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 Normal file
View File

@@ -0,0 +1,269 @@
// 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 Normal file

File diff suppressed because it is too large Load Diff

627
ent/ma_create.go Normal file
View File

@@ -0,0 +1,627 @@
// 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)
}
}

88
ent/ma_delete.go Normal file
View File

@@ -0,0 +1,88 @@
// 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 Normal file
View File

@@ -0,0 +1,613 @@
// 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 Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -19,7 +19,7 @@ var (
{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, Default: "yui"},
{Name: "author", Type: field.TypeString, Nullable: true},
{Name: "created_at", Type: field.TypeTime, Nullable: true},
{Name: "user_card", Type: field.TypeInt},
}
@@ -56,6 +56,79 @@ 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},
@@ -77,6 +150,11 @@ var (
{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},
}
@@ -88,7 +166,7 @@ var (
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "ues_users_ue",
Columns: []*schema.Column{UesColumns[20]},
Columns: []*schema.Column{UesColumns[25]},
RefColumns: []*schema.Column{UsersColumns[0]},
OnDelete: schema.NoAction,
},
@@ -129,7 +207,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: "20240221"},
{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},
@@ -144,6 +222,20 @@ var (
{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: "group_users", Type: field.TypeInt, Nullable: true},
}
// UsersTable holds the schema information for the "users" table.
@@ -154,7 +246,7 @@ var (
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "users_groups_users",
Columns: []*schema.Column{UsersColumns[48]},
Columns: []*schema.Column{UsersColumns[62]},
RefColumns: []*schema.Column{GroupsColumns[0]},
OnDelete: schema.SetNull,
},
@@ -171,6 +263,8 @@ var (
Tables = []*schema.Table{
CardsTable,
GroupsTable,
MasTable,
SevsTable,
UesTable,
UsersTable,
}
@@ -178,6 +272,8 @@ var (
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
}

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

View File

@@ -9,6 +9,14 @@ type CreateGroupRes interface {
createGroupRes()
}
type CreateMaRes interface {
createMaRes()
}
type CreateSevRes interface {
createSevRes()
}
type CreateUeRes interface {
createUeRes()
}
@@ -25,6 +33,14 @@ type DeleteGroupRes interface {
deleteGroupRes()
}
type DeleteMaRes interface {
deleteMaRes()
}
type DeleteSevRes interface {
deleteSevRes()
}
type DeleteUeRes interface {
deleteUeRes()
}
@@ -45,6 +61,14 @@ type ListGroupUsersRes interface {
listGroupUsersRes()
}
type ListMaRes interface {
listMaRes()
}
type ListSevRes interface {
listSevRes()
}
type ListUeRes interface {
listUeRes()
}
@@ -53,10 +77,18 @@ type ListUserCardRes interface {
listUserCardRes()
}
type ListUserMaRes interface {
listUserMaRes()
}
type ListUserRes interface {
listUserRes()
}
type ListUserSevRes interface {
listUserSevRes()
}
type ListUserUeRes interface {
listUserUeRes()
}
@@ -73,6 +105,22 @@ type ReadGroupRes interface {
readGroupRes()
}
type ReadMaOwnerRes interface {
readMaOwnerRes()
}
type ReadMaRes interface {
readMaRes()
}
type ReadSevOwnerRes interface {
readSevOwnerRes()
}
type ReadSevRes interface {
readSevRes()
}
type ReadUeOwnerRes interface {
readUeOwnerRes()
}
@@ -93,6 +141,14 @@ type UpdateGroupRes interface {
updateGroupRes()
}
type UpdateMaRes interface {
updateMaRes()
}
type UpdateSevRes interface {
updateSevRes()
}
type UpdateUeRes interface {
updateUeRes()
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -141,6 +141,132 @@ 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,
@@ -261,6 +387,14 @@ 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)
@@ -393,6 +527,132 @@ 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,
@@ -513,6 +773,14 @@ 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)

View File

@@ -39,6 +39,34 @@ 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,
@@ -95,6 +123,34 @@ 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,

File diff suppressed because it is too large Load Diff

View File

@@ -121,6 +121,116 @@ func encodeCreateGroupResponse(response CreateGroupRes, w http.ResponseWriter, s
}
}
func encodeCreateMaResponse(response CreateMaRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *MaCreate:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
default:
return errors.Errorf("unexpected response type: %T", response)
}
}
func encodeCreateSevResponse(response CreateSevRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *SevCreate:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
default:
return errors.Errorf("unexpected response type: %T", response)
}
}
func encodeCreateUeResponse(response CreateUeRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *UeCreate:
@@ -353,6 +463,128 @@ func encodeDeleteGroupResponse(response DeleteGroupRes, w http.ResponseWriter, s
}
}
func encodeDeleteMaResponse(response DeleteMaRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *DeleteMaNoContent:
w.WriteHeader(204)
span.SetStatus(codes.Ok, http.StatusText(204))
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
default:
return errors.Errorf("unexpected response type: %T", response)
}
}
func encodeDeleteSevResponse(response DeleteSevRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *DeleteSevNoContent:
w.WriteHeader(204)
span.SetStatus(codes.Ok, http.StatusText(204))
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
default:
return errors.Errorf("unexpected response type: %T", response)
}
}
func encodeDeleteUeResponse(response DeleteUeRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *DeleteUeNoContent:
@@ -691,6 +923,142 @@ func encodeListGroupUsersResponse(response ListGroupUsersRes, w http.ResponseWri
}
}
func encodeListMaResponse(response ListMaRes, w http.ResponseWriter, span trace.Span) error {
w.Header().Set("Access-Control-Allow-Origin", "*")
switch response := response.(type) {
case *ListMaOKApplicationJSON:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
default:
return errors.Errorf("unexpected response type: %T", response)
}
}
func encodeListSevResponse(response ListSevRes, w http.ResponseWriter, span trace.Span) error {
w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai")
switch response := response.(type) {
case *ListSevOKApplicationJSON:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
default:
return errors.Errorf("unexpected response type: %T", response)
}
}
func encodeListUeResponse(response ListUeRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *ListUeOKApplicationJSON:
@@ -894,6 +1262,141 @@ func encodeListUserCardResponse(response ListUserCardRes, w http.ResponseWriter,
}
}
func encodeListUserMaResponse(response ListUserMaRes, w http.ResponseWriter, span trace.Span) error {
w.Header().Set("Access-Control-Allow-Origin", "*")
switch response := response.(type) {
case *ListUserMaOKApplicationJSON:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
default:
return errors.Errorf("unexpected response type: %T", response)
}
}
func encodeListUserSevResponse(response ListUserSevRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *ListUserSevOKApplicationJSON:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
default:
return errors.Errorf("unexpected response type: %T", response)
}
}
func encodeListUserUeResponse(response ListUserUeRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *ListUserUeOKApplicationJSON:
@@ -1164,6 +1667,278 @@ func encodeReadGroupResponse(response ReadGroupRes, w http.ResponseWriter, span
}
}
func encodeReadMaResponse(response ReadMaRes, w http.ResponseWriter, span trace.Span) error {
w.Header().Set("Access-Control-Allow-Origin", "*")
switch response := response.(type) {
case *MaRead:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
default:
return errors.Errorf("unexpected response type: %T", response)
}
}
func encodeReadMaOwnerResponse(response ReadMaOwnerRes, w http.ResponseWriter, span trace.Span) error {
w.Header().Set("Access-Control-Allow-Origin", "*")
switch response := response.(type) {
case *MaOwnerRead:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
default:
return errors.Errorf("unexpected response type: %T", response)
}
}
func encodeReadSevResponse(response ReadSevRes, w http.ResponseWriter, span trace.Span) error {
w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai")
switch response := response.(type) {
case *SevRead:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
default:
return errors.Errorf("unexpected response type: %T", response)
}
}
func encodeReadSevOwnerResponse(response ReadSevOwnerRes, w http.ResponseWriter, span trace.Span) error {
w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai")
switch response := response.(type) {
case *SevOwnerRead:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
default:
return errors.Errorf("unexpected response type: %T", response)
}
}
func encodeReadUeResponse(response ReadUeRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *UeRead:
@@ -1299,7 +2074,7 @@ func encodeReadUeOwnerResponse(response ReadUeOwnerRes, w http.ResponseWriter, s
}
func encodeReadUserResponse(response ReadUserRes, w http.ResponseWriter, span trace.Span) error {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai")
switch response := response.(type) {
case *UserRead:
w.Header().Set("Content-Type", "application/json")
@@ -1500,6 +2275,140 @@ func encodeUpdateGroupResponse(response UpdateGroupRes, w http.ResponseWriter, s
}
}
func encodeUpdateMaResponse(response UpdateMaRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *MaUpdate:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
default:
return errors.Errorf("unexpected response type: %T", response)
}
}
func encodeUpdateSevResponse(response UpdateSevRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *SevUpdate:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R400:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
span.SetStatus(codes.Error, http.StatusText(400))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R404:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(404)
span.SetStatus(codes.Error, http.StatusText(404))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R409:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
span.SetStatus(codes.Error, http.StatusText(409))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *R500:
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(500)
span.SetStatus(codes.Error, http.StatusText(500))
e := jx.GetEncoder()
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
default:
return errors.Errorf("unexpected response type: %T", response)
}
}
func encodeUpdateUeResponse(response UpdateUeRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *UeUpdate:

View File

@@ -239,6 +239,164 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
s.notAllowed(w, r, "GET")
}
return
}
}
}
case 'm': // Prefix: "mas"
if l := len("mas"); len(elem) >= l && elem[0:l] == "mas" {
elem = elem[l:]
} else {
break
}
if len(elem) == 0 {
switch r.Method {
case "GET":
s.handleListMaRequest([0]string{}, w, r)
case "POST":
s.handleCreateMaRequest([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.handleDeleteMaRequest([1]string{
args[0],
}, w, r)
case "GET":
s.handleReadMaRequest([1]string{
args[0],
}, w, r)
case "PATCH":
s.handleUpdateMaRequest([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.handleReadMaOwnerRequest([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
}
}
@@ -442,6 +600,46 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
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:]
@@ -770,6 +968,196 @@ 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" {
elem = elem[l:]
} else {
break
}
if len(elem) == 0 {
switch method {
case "GET":
r.name = "ListMa"
r.operationID = "listMa"
r.pathPattern = "/mas"
r.args = args
r.count = 0
return r, true
case "POST":
r.name = "CreateMa"
r.operationID = "createMa"
r.pathPattern = "/mas"
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 = "DeleteMa"
r.operationID = "deleteMa"
r.pathPattern = "/mas/{id}"
r.args = args
r.count = 1
return r, true
case "GET":
r.name = "ReadMa"
r.operationID = "readMa"
r.pathPattern = "/mas/{id}"
r.args = args
r.count = 1
return r, true
case "PATCH":
r.name = "UpdateMa"
r.operationID = "updateMa"
r.pathPattern = "/mas/{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: 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:]
@@ -1002,6 +1390,48 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
}
}
}
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:]

File diff suppressed because it is too large Load Diff

View File

@@ -20,6 +20,18 @@ 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.
@@ -44,6 +56,18 @@ 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.
@@ -86,6 +110,18 @@ 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.
@@ -104,6 +140,18 @@ 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.
@@ -128,6 +176,30 @@ 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.
@@ -158,6 +230,18 @@ 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.

View File

@@ -31,6 +31,24 @@ 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.
@@ -67,6 +85,24 @@ 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.
@@ -130,6 +166,24 @@ 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.
@@ -157,6 +211,24 @@ 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.
@@ -193,6 +265,42 @@ 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.
@@ -238,6 +346,24 @@ 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.

View File

@@ -3,9 +3,88 @@
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")
@@ -19,6 +98,35 @@ 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")
}
@@ -36,7 +144,36 @@ 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")
}
@@ -48,3 +185,204 @@ func (s ListUserUeOKApplicationJSON) Validate() error {
}
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
}

File diff suppressed because it is too large Load Diff

View File

@@ -195,6 +195,20 @@ func NewCardOwnerRead(e *ent.User) *CardOwnerRead {
ret.GameEnd = NewOptBool(e.GameEnd)
ret.GameAccount = NewOptBool(e.GameAccount)
ret.GameLv = NewOptInt(e.GameLv)
ret.GameExp = NewOptInt(e.GameExp)
ret.GameStory = NewOptInt(e.GameStory)
ret.GameLimit = NewOptBool(e.GameLimit)
ret.Coin = NewOptInt(e.Coin)
ret.CoinOpen = NewOptBool(e.CoinOpen)
ret.CoinAt = NewOptDateTime(e.CoinAt)
ret.Planet = NewOptFloat64(e.Planet)
ret.PlanetAt = NewOptDateTime(e.PlanetAt)
ret.Login = NewOptBool(e.Login)
ret.LoginAt = NewOptDateTime(e.LoginAt)
ret.LocationX = NewOptInt(e.LocationX)
ret.LocationY = NewOptInt(e.LocationY)
ret.LocationZ = NewOptInt(e.LocationZ)
ret.LocationN = NewOptInt(e.LocationN)
return &ret
}
@@ -379,6 +393,20 @@ func NewGroupUsersList(e *ent.User) *GroupUsersList {
ret.GameEnd = NewOptBool(e.GameEnd)
ret.GameAccount = NewOptBool(e.GameAccount)
ret.GameLv = NewOptInt(e.GameLv)
ret.GameExp = NewOptInt(e.GameExp)
ret.GameStory = NewOptInt(e.GameStory)
ret.GameLimit = NewOptBool(e.GameLimit)
ret.Coin = NewOptInt(e.Coin)
ret.CoinOpen = NewOptBool(e.CoinOpen)
ret.CoinAt = NewOptDateTime(e.CoinAt)
ret.Planet = NewOptFloat64(e.Planet)
ret.PlanetAt = NewOptDateTime(e.PlanetAt)
ret.Login = NewOptBool(e.Login)
ret.LoginAt = NewOptDateTime(e.LoginAt)
ret.LocationX = NewOptInt(e.LocationX)
ret.LocationY = NewOptInt(e.LocationY)
ret.LocationZ = NewOptInt(e.LocationZ)
ret.LocationN = NewOptInt(e.LocationN)
return &ret
}
@@ -400,6 +428,518 @@ func (u *GroupUsersList) Elem() GroupUsersList {
return *u
}
func NewMaCreate(e *ent.Ma) *MaCreate {
if e == nil {
return nil
}
var ret MaCreate
ret.ID = e.ID
ret.Limit = NewOptBool(e.Limit)
ret.Count = NewOptInt(e.Count)
ret.Handle = NewOptString(e.Handle)
ret.Text = NewOptString(e.Text)
ret.Did = NewOptString(e.Did)
ret.Avatar = NewOptString(e.Avatar)
ret.Cid = NewOptString(e.Cid)
ret.URI = NewOptString(e.URI)
ret.CidRoot = NewOptString(e.CidRoot)
ret.URIRoot = NewOptString(e.URIRoot)
ret.Root = NewOptString(e.Root)
ret.Rkey = NewOptString(e.Rkey)
ret.BskyURL = NewOptString(e.BskyURL)
ret.Comment = NewOptString(e.Comment)
ret.Blog = NewOptString(e.Blog)
ret.BlogURL = NewOptString(e.BlogURL)
ret.Domain = NewOptString(e.Domain)
ret.Host = NewOptString(e.Host)
ret.Feed = NewOptString(e.Feed)
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
return &ret
}
func NewMaCreates(es []*ent.Ma) []MaCreate {
if len(es) == 0 {
return nil
}
r := make([]MaCreate, len(es))
for i, e := range es {
r[i] = NewMaCreate(e).Elem()
}
return r
}
func (m *MaCreate) Elem() MaCreate {
if m == nil {
return MaCreate{}
}
return *m
}
func NewMaList(e *ent.Ma) *MaList {
if e == nil {
return nil
}
var ret MaList
ret.ID = e.ID
ret.Limit = NewOptBool(e.Limit)
ret.Count = NewOptInt(e.Count)
ret.Handle = NewOptString(e.Handle)
ret.Text = NewOptString(e.Text)
ret.Did = NewOptString(e.Did)
ret.Avatar = NewOptString(e.Avatar)
ret.Cid = NewOptString(e.Cid)
ret.URI = NewOptString(e.URI)
ret.CidRoot = NewOptString(e.CidRoot)
ret.URIRoot = NewOptString(e.URIRoot)
ret.Root = NewOptString(e.Root)
ret.Rkey = NewOptString(e.Rkey)
ret.BskyURL = NewOptString(e.BskyURL)
ret.Comment = NewOptString(e.Comment)
ret.Blog = NewOptString(e.Blog)
ret.BlogURL = NewOptString(e.BlogURL)
ret.Domain = NewOptString(e.Domain)
ret.Host = NewOptString(e.Host)
ret.Feed = NewOptString(e.Feed)
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
return &ret
}
func NewMaLists(es []*ent.Ma) []MaList {
if len(es) == 0 {
return nil
}
r := make([]MaList, len(es))
for i, e := range es {
r[i] = NewMaList(e).Elem()
}
return r
}
func (m *MaList) Elem() MaList {
if m == nil {
return MaList{}
}
return *m
}
func NewMaRead(e *ent.Ma) *MaRead {
if e == nil {
return nil
}
var ret MaRead
ret.ID = e.ID
ret.Limit = NewOptBool(e.Limit)
ret.Count = NewOptInt(e.Count)
ret.Handle = NewOptString(e.Handle)
ret.Text = NewOptString(e.Text)
ret.Did = NewOptString(e.Did)
ret.Avatar = NewOptString(e.Avatar)
ret.Cid = NewOptString(e.Cid)
ret.URI = NewOptString(e.URI)
ret.CidRoot = NewOptString(e.CidRoot)
ret.URIRoot = NewOptString(e.URIRoot)
ret.Root = NewOptString(e.Root)
ret.Rkey = NewOptString(e.Rkey)
ret.BskyURL = NewOptString(e.BskyURL)
ret.Comment = NewOptString(e.Comment)
ret.Blog = NewOptString(e.Blog)
ret.BlogURL = NewOptString(e.BlogURL)
ret.Domain = NewOptString(e.Domain)
ret.Host = NewOptString(e.Host)
ret.Feed = NewOptString(e.Feed)
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
return &ret
}
func NewMaReads(es []*ent.Ma) []MaRead {
if len(es) == 0 {
return nil
}
r := make([]MaRead, len(es))
for i, e := range es {
r[i] = NewMaRead(e).Elem()
}
return r
}
func (m *MaRead) Elem() MaRead {
if m == nil {
return MaRead{}
}
return *m
}
func NewMaUpdate(e *ent.Ma) *MaUpdate {
if e == nil {
return nil
}
var ret MaUpdate
ret.ID = e.ID
ret.Limit = NewOptBool(e.Limit)
ret.Count = NewOptInt(e.Count)
ret.Handle = NewOptString(e.Handle)
ret.Text = NewOptString(e.Text)
ret.Did = NewOptString(e.Did)
ret.Avatar = NewOptString(e.Avatar)
ret.Cid = NewOptString(e.Cid)
ret.URI = NewOptString(e.URI)
ret.CidRoot = NewOptString(e.CidRoot)
ret.URIRoot = NewOptString(e.URIRoot)
ret.Root = NewOptString(e.Root)
ret.Rkey = NewOptString(e.Rkey)
ret.BskyURL = NewOptString(e.BskyURL)
ret.Comment = NewOptString(e.Comment)
ret.Blog = NewOptString(e.Blog)
ret.BlogURL = NewOptString(e.BlogURL)
ret.Domain = NewOptString(e.Domain)
ret.Host = NewOptString(e.Host)
ret.Feed = NewOptString(e.Feed)
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
return &ret
}
func NewMaUpdates(es []*ent.Ma) []MaUpdate {
if len(es) == 0 {
return nil
}
r := make([]MaUpdate, len(es))
for i, e := range es {
r[i] = NewMaUpdate(e).Elem()
}
return r
}
func (m *MaUpdate) Elem() MaUpdate {
if m == nil {
return MaUpdate{}
}
return *m
}
func NewMaOwnerRead(e *ent.User) *MaOwnerRead {
if e == nil {
return nil
}
var ret MaOwnerRead
ret.ID = e.ID
ret.Username = e.Username
ret.Did = NewOptString(e.Did)
ret.Member = NewOptBool(e.Member)
ret.Book = NewOptBool(e.Book)
ret.Manga = NewOptBool(e.Manga)
ret.Badge = NewOptBool(e.Badge)
ret.Bsky = NewOptBool(e.Bsky)
ret.Mastodon = NewOptBool(e.Mastodon)
ret.Delete = NewOptBool(e.Delete)
ret.Handle = NewOptBool(e.Handle)
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
ret.RaidAt = NewOptDateTime(e.RaidAt)
ret.ServerAt = NewOptDateTime(e.ServerAt)
ret.EggAt = NewOptDateTime(e.EggAt)
ret.Luck = NewOptInt(e.Luck)
ret.LuckAt = NewOptDateTime(e.LuckAt)
ret.Like = NewOptInt(e.Like)
ret.LikeRank = NewOptInt(e.LikeRank)
ret.LikeAt = NewOptDateTime(e.LikeAt)
ret.Fav = NewOptInt(e.Fav)
ret.Ten = NewOptBool(e.Ten)
ret.TenSu = NewOptInt(e.TenSu)
ret.TenKai = NewOptInt(e.TenKai)
ret.Aiten = NewOptInt(e.Aiten)
ret.TenCard = NewOptString(e.TenCard)
ret.TenDelete = NewOptString(e.TenDelete)
ret.TenPost = NewOptString(e.TenPost)
ret.TenGet = NewOptString(e.TenGet)
ret.TenAt = NewOptDateTime(e.TenAt)
ret.Next = NewOptString(e.Next)
ret.Room = NewOptInt(e.Room)
ret.Model = NewOptBool(e.Model)
ret.ModelAt = NewOptDateTime(e.ModelAt)
ret.ModelAttack = NewOptInt(e.ModelAttack)
ret.ModelLimit = NewOptInt(e.ModelLimit)
ret.ModelSkill = NewOptInt(e.ModelSkill)
ret.ModelMode = NewOptInt(e.ModelMode)
ret.ModelCritical = NewOptInt(e.ModelCritical)
ret.ModelCriticalD = NewOptInt(e.ModelCriticalD)
ret.Game = NewOptBool(e.Game)
ret.GameTest = NewOptBool(e.GameTest)
ret.GameEnd = NewOptBool(e.GameEnd)
ret.GameAccount = NewOptBool(e.GameAccount)
ret.GameLv = NewOptInt(e.GameLv)
ret.GameExp = NewOptInt(e.GameExp)
ret.GameStory = NewOptInt(e.GameStory)
ret.GameLimit = NewOptBool(e.GameLimit)
ret.Coin = NewOptInt(e.Coin)
ret.CoinOpen = NewOptBool(e.CoinOpen)
ret.CoinAt = NewOptDateTime(e.CoinAt)
ret.Planet = NewOptFloat64(e.Planet)
ret.PlanetAt = NewOptDateTime(e.PlanetAt)
ret.Login = NewOptBool(e.Login)
ret.LoginAt = NewOptDateTime(e.LoginAt)
ret.LocationX = NewOptInt(e.LocationX)
ret.LocationY = NewOptInt(e.LocationY)
ret.LocationZ = NewOptInt(e.LocationZ)
ret.LocationN = NewOptInt(e.LocationN)
return &ret
}
func NewMaOwnerReads(es []*ent.User) []MaOwnerRead {
if len(es) == 0 {
return nil
}
r := make([]MaOwnerRead, len(es))
for i, e := range es {
r[i] = NewMaOwnerRead(e).Elem()
}
return r
}
func (u *MaOwnerRead) Elem() MaOwnerRead {
if u == nil {
return MaOwnerRead{}
}
return *u
}
func NewSevCreate(e *ent.Sev) *SevCreate {
if e == nil {
return nil
}
var ret SevCreate
ret.ID = e.ID
ret.Limit = NewOptBool(e.Limit)
ret.Count = NewOptInt(e.Count)
ret.Handle = NewOptString(e.Handle)
ret.Did = NewOptString(e.Did)
ret.UID = NewOptInt(e.UID)
ret.Cid = NewOptInt(e.Cid)
ret.Cp = NewOptInt(e.Cp)
ret.Card = NewOptInt(e.Card)
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
return &ret
}
func NewSevCreates(es []*ent.Sev) []SevCreate {
if len(es) == 0 {
return nil
}
r := make([]SevCreate, len(es))
for i, e := range es {
r[i] = NewSevCreate(e).Elem()
}
return r
}
func (s *SevCreate) Elem() SevCreate {
if s == nil {
return SevCreate{}
}
return *s
}
func NewSevList(e *ent.Sev) *SevList {
if e == nil {
return nil
}
var ret SevList
ret.ID = e.ID
ret.Limit = NewOptBool(e.Limit)
ret.Count = NewOptInt(e.Count)
ret.Handle = NewOptString(e.Handle)
ret.Did = NewOptString(e.Did)
ret.UID = NewOptInt(e.UID)
ret.Cid = NewOptInt(e.Cid)
ret.Cp = NewOptInt(e.Cp)
ret.Card = NewOptInt(e.Card)
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
return &ret
}
func NewSevLists(es []*ent.Sev) []SevList {
if len(es) == 0 {
return nil
}
r := make([]SevList, len(es))
for i, e := range es {
r[i] = NewSevList(e).Elem()
}
return r
}
func (s *SevList) Elem() SevList {
if s == nil {
return SevList{}
}
return *s
}
func NewSevRead(e *ent.Sev) *SevRead {
if e == nil {
return nil
}
var ret SevRead
ret.ID = e.ID
ret.Limit = NewOptBool(e.Limit)
ret.Count = NewOptInt(e.Count)
ret.Handle = NewOptString(e.Handle)
ret.Did = NewOptString(e.Did)
ret.UID = NewOptInt(e.UID)
ret.Cid = NewOptInt(e.Cid)
ret.Cp = NewOptInt(e.Cp)
ret.Card = NewOptInt(e.Card)
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
return &ret
}
func NewSevReads(es []*ent.Sev) []SevRead {
if len(es) == 0 {
return nil
}
r := make([]SevRead, len(es))
for i, e := range es {
r[i] = NewSevRead(e).Elem()
}
return r
}
func (s *SevRead) Elem() SevRead {
if s == nil {
return SevRead{}
}
return *s
}
func NewSevUpdate(e *ent.Sev) *SevUpdate {
if e == nil {
return nil
}
var ret SevUpdate
ret.ID = e.ID
ret.Limit = NewOptBool(e.Limit)
ret.Count = NewOptInt(e.Count)
ret.Handle = NewOptString(e.Handle)
ret.Did = NewOptString(e.Did)
ret.UID = NewOptInt(e.UID)
ret.Cid = NewOptInt(e.Cid)
ret.Cp = NewOptInt(e.Cp)
ret.Card = NewOptInt(e.Card)
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
return &ret
}
func NewSevUpdates(es []*ent.Sev) []SevUpdate {
if len(es) == 0 {
return nil
}
r := make([]SevUpdate, len(es))
for i, e := range es {
r[i] = NewSevUpdate(e).Elem()
}
return r
}
func (s *SevUpdate) Elem() SevUpdate {
if s == nil {
return SevUpdate{}
}
return *s
}
func NewSevOwnerRead(e *ent.User) *SevOwnerRead {
if e == nil {
return nil
}
var ret SevOwnerRead
ret.ID = e.ID
ret.Username = e.Username
ret.Did = NewOptString(e.Did)
ret.Member = NewOptBool(e.Member)
ret.Book = NewOptBool(e.Book)
ret.Manga = NewOptBool(e.Manga)
ret.Badge = NewOptBool(e.Badge)
ret.Bsky = NewOptBool(e.Bsky)
ret.Mastodon = NewOptBool(e.Mastodon)
ret.Delete = NewOptBool(e.Delete)
ret.Handle = NewOptBool(e.Handle)
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
ret.RaidAt = NewOptDateTime(e.RaidAt)
ret.ServerAt = NewOptDateTime(e.ServerAt)
ret.EggAt = NewOptDateTime(e.EggAt)
ret.Luck = NewOptInt(e.Luck)
ret.LuckAt = NewOptDateTime(e.LuckAt)
ret.Like = NewOptInt(e.Like)
ret.LikeRank = NewOptInt(e.LikeRank)
ret.LikeAt = NewOptDateTime(e.LikeAt)
ret.Fav = NewOptInt(e.Fav)
ret.Ten = NewOptBool(e.Ten)
ret.TenSu = NewOptInt(e.TenSu)
ret.TenKai = NewOptInt(e.TenKai)
ret.Aiten = NewOptInt(e.Aiten)
ret.TenCard = NewOptString(e.TenCard)
ret.TenDelete = NewOptString(e.TenDelete)
ret.TenPost = NewOptString(e.TenPost)
ret.TenGet = NewOptString(e.TenGet)
ret.TenAt = NewOptDateTime(e.TenAt)
ret.Next = NewOptString(e.Next)
ret.Room = NewOptInt(e.Room)
ret.Model = NewOptBool(e.Model)
ret.ModelAt = NewOptDateTime(e.ModelAt)
ret.ModelAttack = NewOptInt(e.ModelAttack)
ret.ModelLimit = NewOptInt(e.ModelLimit)
ret.ModelSkill = NewOptInt(e.ModelSkill)
ret.ModelMode = NewOptInt(e.ModelMode)
ret.ModelCritical = NewOptInt(e.ModelCritical)
ret.ModelCriticalD = NewOptInt(e.ModelCriticalD)
ret.Game = NewOptBool(e.Game)
ret.GameTest = NewOptBool(e.GameTest)
ret.GameEnd = NewOptBool(e.GameEnd)
ret.GameAccount = NewOptBool(e.GameAccount)
ret.GameLv = NewOptInt(e.GameLv)
ret.GameExp = NewOptInt(e.GameExp)
ret.GameStory = NewOptInt(e.GameStory)
ret.GameLimit = NewOptBool(e.GameLimit)
ret.Coin = NewOptInt(e.Coin)
ret.CoinOpen = NewOptBool(e.CoinOpen)
ret.CoinAt = NewOptDateTime(e.CoinAt)
ret.Planet = NewOptFloat64(e.Planet)
ret.PlanetAt = NewOptDateTime(e.PlanetAt)
ret.Login = NewOptBool(e.Login)
ret.LoginAt = NewOptDateTime(e.LoginAt)
ret.LocationX = NewOptInt(e.LocationX)
ret.LocationY = NewOptInt(e.LocationY)
ret.LocationZ = NewOptInt(e.LocationZ)
ret.LocationN = NewOptInt(e.LocationN)
return &ret
}
func NewSevOwnerReads(es []*ent.User) []SevOwnerRead {
if len(es) == 0 {
return nil
}
r := make([]SevOwnerRead, len(es))
for i, e := range es {
r[i] = NewSevOwnerRead(e).Elem()
}
return r
}
func (u *SevOwnerRead) Elem() SevOwnerRead {
if u == nil {
return SevOwnerRead{}
}
return *u
}
func NewUeCreate(e *ent.Ue) *UeCreate {
if e == nil {
return nil
@@ -422,6 +962,11 @@ func NewUeCreate(e *ent.Ue) *UeCreate {
ret.LocationZ = NewOptInt(e.LocationZ)
ret.LocationN = NewOptInt(e.LocationN)
ret.Author = NewOptString(e.Author)
ret.GameLv = NewOptString(e.GameLv)
ret.GameExp = NewOptString(e.GameExp)
ret.GameID = NewOptString(e.GameID)
ret.GameStory = NewOptInt(e.GameStory)
ret.GameEp = NewOptString(e.GameEp)
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
return &ret
}
@@ -466,6 +1011,11 @@ func NewUeList(e *ent.Ue) *UeList {
ret.LocationZ = NewOptInt(e.LocationZ)
ret.LocationN = NewOptInt(e.LocationN)
ret.Author = NewOptString(e.Author)
ret.GameLv = NewOptString(e.GameLv)
ret.GameExp = NewOptString(e.GameExp)
ret.GameID = NewOptString(e.GameID)
ret.GameStory = NewOptInt(e.GameStory)
ret.GameEp = NewOptString(e.GameEp)
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
return &ret
}
@@ -510,6 +1060,11 @@ func NewUeRead(e *ent.Ue) *UeRead {
ret.LocationZ = NewOptInt(e.LocationZ)
ret.LocationN = NewOptInt(e.LocationN)
ret.Author = NewOptString(e.Author)
ret.GameLv = NewOptString(e.GameLv)
ret.GameExp = NewOptString(e.GameExp)
ret.GameID = NewOptString(e.GameID)
ret.GameStory = NewOptInt(e.GameStory)
ret.GameEp = NewOptString(e.GameEp)
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
return &ret
}
@@ -554,6 +1109,11 @@ func NewUeUpdate(e *ent.Ue) *UeUpdate {
ret.LocationZ = NewOptInt(e.LocationZ)
ret.LocationN = NewOptInt(e.LocationN)
ret.Author = NewOptString(e.Author)
ret.GameLv = NewOptString(e.GameLv)
ret.GameExp = NewOptString(e.GameExp)
ret.GameID = NewOptString(e.GameID)
ret.GameStory = NewOptInt(e.GameStory)
ret.GameEp = NewOptString(e.GameEp)
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
return &ret
}
@@ -627,6 +1187,20 @@ func NewUeOwnerRead(e *ent.User) *UeOwnerRead {
ret.GameEnd = NewOptBool(e.GameEnd)
ret.GameAccount = NewOptBool(e.GameAccount)
ret.GameLv = NewOptInt(e.GameLv)
ret.GameExp = NewOptInt(e.GameExp)
ret.GameStory = NewOptInt(e.GameStory)
ret.GameLimit = NewOptBool(e.GameLimit)
ret.Coin = NewOptInt(e.Coin)
ret.CoinOpen = NewOptBool(e.CoinOpen)
ret.CoinAt = NewOptDateTime(e.CoinAt)
ret.Planet = NewOptFloat64(e.Planet)
ret.PlanetAt = NewOptDateTime(e.PlanetAt)
ret.Login = NewOptBool(e.Login)
ret.LoginAt = NewOptDateTime(e.LoginAt)
ret.LocationX = NewOptInt(e.LocationX)
ret.LocationY = NewOptInt(e.LocationY)
ret.LocationZ = NewOptInt(e.LocationZ)
ret.LocationN = NewOptInt(e.LocationN)
return &ret
}
@@ -699,6 +1273,20 @@ func NewUserCreate(e *ent.User) *UserCreate {
ret.GameEnd = NewOptBool(e.GameEnd)
ret.GameAccount = NewOptBool(e.GameAccount)
ret.GameLv = NewOptInt(e.GameLv)
ret.GameExp = NewOptInt(e.GameExp)
ret.GameStory = NewOptInt(e.GameStory)
ret.GameLimit = NewOptBool(e.GameLimit)
ret.Coin = NewOptInt(e.Coin)
ret.CoinOpen = NewOptBool(e.CoinOpen)
ret.CoinAt = NewOptDateTime(e.CoinAt)
ret.Planet = NewOptFloat64(e.Planet)
ret.PlanetAt = NewOptDateTime(e.PlanetAt)
ret.Login = NewOptBool(e.Login)
ret.LoginAt = NewOptDateTime(e.LoginAt)
ret.LocationX = NewOptInt(e.LocationX)
ret.LocationY = NewOptInt(e.LocationY)
ret.LocationZ = NewOptInt(e.LocationZ)
ret.LocationN = NewOptInt(e.LocationN)
return &ret
}
@@ -771,6 +1359,20 @@ func NewUserList(e *ent.User) *UserList {
ret.GameEnd = NewOptBool(e.GameEnd)
ret.GameAccount = NewOptBool(e.GameAccount)
ret.GameLv = NewOptInt(e.GameLv)
ret.GameExp = NewOptInt(e.GameExp)
ret.GameStory = NewOptInt(e.GameStory)
ret.GameLimit = NewOptBool(e.GameLimit)
ret.Coin = NewOptInt(e.Coin)
ret.CoinOpen = NewOptBool(e.CoinOpen)
ret.CoinAt = NewOptDateTime(e.CoinAt)
ret.Planet = NewOptFloat64(e.Planet)
ret.PlanetAt = NewOptDateTime(e.PlanetAt)
ret.Login = NewOptBool(e.Login)
ret.LoginAt = NewOptDateTime(e.LoginAt)
ret.LocationX = NewOptInt(e.LocationX)
ret.LocationY = NewOptInt(e.LocationY)
ret.LocationZ = NewOptInt(e.LocationZ)
ret.LocationN = NewOptInt(e.LocationN)
return &ret
}
@@ -843,6 +1445,20 @@ func NewUserRead(e *ent.User) *UserRead {
ret.GameEnd = NewOptBool(e.GameEnd)
ret.GameAccount = NewOptBool(e.GameAccount)
ret.GameLv = NewOptInt(e.GameLv)
ret.GameExp = NewOptInt(e.GameExp)
ret.GameStory = NewOptInt(e.GameStory)
ret.GameLimit = NewOptBool(e.GameLimit)
ret.Coin = NewOptInt(e.Coin)
ret.CoinOpen = NewOptBool(e.CoinOpen)
ret.CoinAt = NewOptDateTime(e.CoinAt)
ret.Planet = NewOptFloat64(e.Planet)
ret.PlanetAt = NewOptDateTime(e.PlanetAt)
ret.Login = NewOptBool(e.Login)
ret.LoginAt = NewOptDateTime(e.LoginAt)
ret.LocationX = NewOptInt(e.LocationX)
ret.LocationY = NewOptInt(e.LocationY)
ret.LocationZ = NewOptInt(e.LocationZ)
ret.LocationN = NewOptInt(e.LocationN)
return &ret
}
@@ -915,6 +1531,20 @@ func NewUserUpdate(e *ent.User) *UserUpdate {
ret.GameEnd = NewOptBool(e.GameEnd)
ret.GameAccount = NewOptBool(e.GameAccount)
ret.GameLv = NewOptInt(e.GameLv)
ret.GameExp = NewOptInt(e.GameExp)
ret.GameStory = NewOptInt(e.GameStory)
ret.GameLimit = NewOptBool(e.GameLimit)
ret.Coin = NewOptInt(e.Coin)
ret.CoinOpen = NewOptBool(e.CoinOpen)
ret.CoinAt = NewOptDateTime(e.CoinAt)
ret.Planet = NewOptFloat64(e.Planet)
ret.PlanetAt = NewOptDateTime(e.PlanetAt)
ret.Login = NewOptBool(e.Login)
ret.LoginAt = NewOptDateTime(e.LoginAt)
ret.LocationX = NewOptInt(e.LocationX)
ret.LocationY = NewOptInt(e.LocationY)
ret.LocationZ = NewOptInt(e.LocationZ)
ret.LocationN = NewOptInt(e.LocationN)
return &ret
}
@@ -971,6 +1601,91 @@ func (c *UserCardList) Elem() UserCardList {
return *c
}
func NewUserMaList(e *ent.Ma) *UserMaList {
if e == nil {
return nil
}
var ret UserMaList
ret.ID = e.ID
ret.Limit = NewOptBool(e.Limit)
ret.Count = NewOptInt(e.Count)
ret.Handle = NewOptString(e.Handle)
ret.Text = NewOptString(e.Text)
ret.Did = NewOptString(e.Did)
ret.Avatar = NewOptString(e.Avatar)
ret.Cid = NewOptString(e.Cid)
ret.URI = NewOptString(e.URI)
ret.CidRoot = NewOptString(e.CidRoot)
ret.URIRoot = NewOptString(e.URIRoot)
ret.Root = NewOptString(e.Root)
ret.Rkey = NewOptString(e.Rkey)
ret.BskyURL = NewOptString(e.BskyURL)
ret.Comment = NewOptString(e.Comment)
ret.Blog = NewOptString(e.Blog)
ret.BlogURL = NewOptString(e.BlogURL)
ret.Domain = NewOptString(e.Domain)
ret.Host = NewOptString(e.Host)
ret.Feed = NewOptString(e.Feed)
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
return &ret
}
func NewUserMaLists(es []*ent.Ma) []UserMaList {
if len(es) == 0 {
return nil
}
r := make([]UserMaList, len(es))
for i, e := range es {
r[i] = NewUserMaList(e).Elem()
}
return r
}
func (m *UserMaList) Elem() UserMaList {
if m == nil {
return UserMaList{}
}
return *m
}
func NewUserSevList(e *ent.Sev) *UserSevList {
if e == nil {
return nil
}
var ret UserSevList
ret.ID = e.ID
ret.Limit = NewOptBool(e.Limit)
ret.Count = NewOptInt(e.Count)
ret.Handle = NewOptString(e.Handle)
ret.Did = NewOptString(e.Did)
ret.UID = NewOptInt(e.UID)
ret.Cid = NewOptInt(e.Cid)
ret.Cp = NewOptInt(e.Cp)
ret.Card = NewOptInt(e.Card)
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
return &ret
}
func NewUserSevLists(es []*ent.Sev) []UserSevList {
if len(es) == 0 {
return nil
}
r := make([]UserSevList, len(es))
for i, e := range es {
r[i] = NewUserSevList(e).Elem()
}
return r
}
func (s *UserSevList) Elem() UserSevList {
if s == nil {
return UserSevList{}
}
return *s
}
func NewUserUeList(e *ent.Ue) *UserUeList {
if e == nil {
return nil
@@ -993,6 +1708,11 @@ func NewUserUeList(e *ent.Ue) *UserUeList {
ret.LocationZ = NewOptInt(e.LocationZ)
ret.LocationN = NewOptInt(e.LocationN)
ret.Author = NewOptString(e.Author)
ret.GameLv = NewOptString(e.GameLv)
ret.GameExp = NewOptString(e.GameExp)
ret.GameID = NewOptString(e.GameID)
ret.GameStory = NewOptInt(e.GameStory)
ret.GameEp = NewOptString(e.GameEp)
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
return &ret
}

File diff suppressed because it is too large Load Diff

View File

@@ -12,6 +12,12 @@ 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)

View File

@@ -1,8 +1,3 @@
// +build tools
// +build tools
// +build tools
// +build tools
// +build tools
// Code generated by ent, DO NOT EDIT.
package ent
@@ -10,7 +5,9 @@ package ent
import (
"api/ent/card"
"api/ent/group"
"api/ent/ma"
"api/ent/schema"
"api/ent/sev"
"api/ent/ue"
"api/ent/user"
"time"
@@ -46,10 +43,6 @@ func init() {
cardDescURL := cardFields[6].Descriptor()
// card.DefaultURL holds the default value on creation for the url field.
card.DefaultURL = cardDescURL.Default.(string)
// cardDescAuthor is the schema descriptor for author field.
cardDescAuthor := cardFields[8].Descriptor()
// card.DefaultAuthor holds the default value on creation for the author field.
card.DefaultAuthor = cardDescAuthor.Default.(string)
// cardDescCreatedAt is the schema descriptor for created_at field.
cardDescCreatedAt := cardFields[9].Descriptor()
// card.DefaultCreatedAt holds the default value on creation for the created_at field.
@@ -60,6 +53,34 @@ 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.
@@ -79,7 +100,7 @@ func init() {
// 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[18].Descriptor()
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()
@@ -194,4 +215,28 @@ func init() {
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)
}

View File

@@ -30,35 +30,14 @@ func (Card) Fields() []ent.Field {
field.Int("card").
DefaultFunc(func() int {
rand.Seed(time.Now().UnixNano())
var a = rand.Intn(10)
var a = rand.Intn(20)
if a == 1 {
card = rand.Intn(16)
card = rand.Intn(3) + 123
} else if a == 2 {
card = rand.Intn(14) + 1
} else {
card = 0
}
if card == 13 {
card = 29
}
// 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
}
//var card = rand.Intn(91)
return card
}).
Optional(),
@@ -66,7 +45,7 @@ func (Card) Fields() []ent.Field {
field.String("skill").
DefaultFunc(func() string {
rand.Seed(time.Now().UnixNano())
var a = rand.Intn(12)
var a = rand.Intn(30)
if a == 1 {
skill = "critical"
} else {
@@ -83,7 +62,7 @@ func (Card) Fields() []ent.Field {
//Immutable().
DefaultFunc(func() string {
rand.Seed(time.Now().UnixNano())
var a = rand.Intn(10)
var a = rand.Intn(40)
if a == 1 {
super = "super"
} else {

104
ent/schema/manga.go Normal file
View File

@@ -0,0 +1,104 @@
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(),
}
}

71
ent/schema/seven.go Normal file
View File

@@ -0,0 +1,71 @@
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(),
}
}

View File

@@ -75,6 +75,21 @@ func (Ue) Fields() []ent.Field {
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().

View File

@@ -217,6 +217,61 @@ func (User) Fields() []ent.Field {
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(),
}
}
@@ -231,6 +286,8 @@ 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 Normal file
View File

@@ -0,0 +1,268 @@
// 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 Normal file
View File

@@ -0,0 +1,181 @@
// 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 Normal file
View File

@@ -0,0 +1,831 @@
// 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())
})
}

429
ent/sev_create.go Normal file
View File

@@ -0,0 +1,429 @@
// 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)
}
}

88
ent/sev_delete.go Normal file
View File

@@ -0,0 +1,88 @@
// 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 Normal file
View File

@@ -0,0 +1,613 @@
// 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)
}

917
ent/sev_update.go Normal file
View File

@@ -0,0 +1,917 @@
// 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
}

View File

@@ -16,6 +16,10 @@ 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.
@@ -153,6 +157,8 @@ 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)
}

View File

@@ -54,6 +54,16 @@ type Ue struct {
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.
@@ -92,9 +102,9 @@ func (*Ue) scanValues(columns []string) ([]any, error) {
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:
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:
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)
@@ -229,6 +239,36 @@ func (u *Ue) assignValues(columns []string, values []any) error {
} 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])
@@ -335,6 +375,21 @@ func (u *Ue) String() string {
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(')')

View File

@@ -50,6 +50,16 @@ const (
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.
@@ -86,6 +96,11 @@ var Columns = []string{
FieldLocationZ,
FieldLocationN,
FieldAuthor,
FieldGameLv,
FieldGameExp,
FieldGameID,
FieldGameStory,
FieldGameEp,
FieldCreatedAt,
}
@@ -221,6 +236,31 @@ 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()

View File

@@ -145,6 +145,31 @@ func Author(v string) predicate.Ue {
return predicate.Ue(sql.FieldEQ(FieldAuthor, v))
}
// GameLv applies equality check predicate on the "game_lv" field. It's identical to GameLvEQ.
func GameLv(v string) predicate.Ue {
return predicate.Ue(sql.FieldEQ(FieldGameLv, v))
}
// GameExp applies equality check predicate on the "game_exp" field. It's identical to GameExpEQ.
func GameExp(v string) predicate.Ue {
return predicate.Ue(sql.FieldEQ(FieldGameExp, v))
}
// GameID applies equality check predicate on the "game_id" field. It's identical to GameIDEQ.
func GameID(v string) predicate.Ue {
return predicate.Ue(sql.FieldEQ(FieldGameID, v))
}
// GameStory applies equality check predicate on the "game_story" field. It's identical to GameStoryEQ.
func GameStory(v int) predicate.Ue {
return predicate.Ue(sql.FieldEQ(FieldGameStory, v))
}
// GameEp applies equality check predicate on the "game_ep" field. It's identical to GameEpEQ.
func GameEp(v string) predicate.Ue {
return predicate.Ue(sql.FieldEQ(FieldGameEp, v))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.Ue {
return predicate.Ue(sql.FieldEQ(FieldCreatedAt, v))
@@ -1050,6 +1075,356 @@ func AuthorContainsFold(v string) predicate.Ue {
return predicate.Ue(sql.FieldContainsFold(FieldAuthor, v))
}
// GameLvEQ applies the EQ predicate on the "game_lv" field.
func GameLvEQ(v string) predicate.Ue {
return predicate.Ue(sql.FieldEQ(FieldGameLv, v))
}
// GameLvNEQ applies the NEQ predicate on the "game_lv" field.
func GameLvNEQ(v string) predicate.Ue {
return predicate.Ue(sql.FieldNEQ(FieldGameLv, v))
}
// GameLvIn applies the In predicate on the "game_lv" field.
func GameLvIn(vs ...string) predicate.Ue {
return predicate.Ue(sql.FieldIn(FieldGameLv, vs...))
}
// GameLvNotIn applies the NotIn predicate on the "game_lv" field.
func GameLvNotIn(vs ...string) predicate.Ue {
return predicate.Ue(sql.FieldNotIn(FieldGameLv, vs...))
}
// GameLvGT applies the GT predicate on the "game_lv" field.
func GameLvGT(v string) predicate.Ue {
return predicate.Ue(sql.FieldGT(FieldGameLv, v))
}
// GameLvGTE applies the GTE predicate on the "game_lv" field.
func GameLvGTE(v string) predicate.Ue {
return predicate.Ue(sql.FieldGTE(FieldGameLv, v))
}
// GameLvLT applies the LT predicate on the "game_lv" field.
func GameLvLT(v string) predicate.Ue {
return predicate.Ue(sql.FieldLT(FieldGameLv, v))
}
// GameLvLTE applies the LTE predicate on the "game_lv" field.
func GameLvLTE(v string) predicate.Ue {
return predicate.Ue(sql.FieldLTE(FieldGameLv, v))
}
// GameLvContains applies the Contains predicate on the "game_lv" field.
func GameLvContains(v string) predicate.Ue {
return predicate.Ue(sql.FieldContains(FieldGameLv, v))
}
// GameLvHasPrefix applies the HasPrefix predicate on the "game_lv" field.
func GameLvHasPrefix(v string) predicate.Ue {
return predicate.Ue(sql.FieldHasPrefix(FieldGameLv, v))
}
// GameLvHasSuffix applies the HasSuffix predicate on the "game_lv" field.
func GameLvHasSuffix(v string) predicate.Ue {
return predicate.Ue(sql.FieldHasSuffix(FieldGameLv, v))
}
// GameLvIsNil applies the IsNil predicate on the "game_lv" field.
func GameLvIsNil() predicate.Ue {
return predicate.Ue(sql.FieldIsNull(FieldGameLv))
}
// GameLvNotNil applies the NotNil predicate on the "game_lv" field.
func GameLvNotNil() predicate.Ue {
return predicate.Ue(sql.FieldNotNull(FieldGameLv))
}
// GameLvEqualFold applies the EqualFold predicate on the "game_lv" field.
func GameLvEqualFold(v string) predicate.Ue {
return predicate.Ue(sql.FieldEqualFold(FieldGameLv, v))
}
// GameLvContainsFold applies the ContainsFold predicate on the "game_lv" field.
func GameLvContainsFold(v string) predicate.Ue {
return predicate.Ue(sql.FieldContainsFold(FieldGameLv, v))
}
// GameExpEQ applies the EQ predicate on the "game_exp" field.
func GameExpEQ(v string) predicate.Ue {
return predicate.Ue(sql.FieldEQ(FieldGameExp, v))
}
// GameExpNEQ applies the NEQ predicate on the "game_exp" field.
func GameExpNEQ(v string) predicate.Ue {
return predicate.Ue(sql.FieldNEQ(FieldGameExp, v))
}
// GameExpIn applies the In predicate on the "game_exp" field.
func GameExpIn(vs ...string) predicate.Ue {
return predicate.Ue(sql.FieldIn(FieldGameExp, vs...))
}
// GameExpNotIn applies the NotIn predicate on the "game_exp" field.
func GameExpNotIn(vs ...string) predicate.Ue {
return predicate.Ue(sql.FieldNotIn(FieldGameExp, vs...))
}
// GameExpGT applies the GT predicate on the "game_exp" field.
func GameExpGT(v string) predicate.Ue {
return predicate.Ue(sql.FieldGT(FieldGameExp, v))
}
// GameExpGTE applies the GTE predicate on the "game_exp" field.
func GameExpGTE(v string) predicate.Ue {
return predicate.Ue(sql.FieldGTE(FieldGameExp, v))
}
// GameExpLT applies the LT predicate on the "game_exp" field.
func GameExpLT(v string) predicate.Ue {
return predicate.Ue(sql.FieldLT(FieldGameExp, v))
}
// GameExpLTE applies the LTE predicate on the "game_exp" field.
func GameExpLTE(v string) predicate.Ue {
return predicate.Ue(sql.FieldLTE(FieldGameExp, v))
}
// GameExpContains applies the Contains predicate on the "game_exp" field.
func GameExpContains(v string) predicate.Ue {
return predicate.Ue(sql.FieldContains(FieldGameExp, v))
}
// GameExpHasPrefix applies the HasPrefix predicate on the "game_exp" field.
func GameExpHasPrefix(v string) predicate.Ue {
return predicate.Ue(sql.FieldHasPrefix(FieldGameExp, v))
}
// GameExpHasSuffix applies the HasSuffix predicate on the "game_exp" field.
func GameExpHasSuffix(v string) predicate.Ue {
return predicate.Ue(sql.FieldHasSuffix(FieldGameExp, v))
}
// GameExpIsNil applies the IsNil predicate on the "game_exp" field.
func GameExpIsNil() predicate.Ue {
return predicate.Ue(sql.FieldIsNull(FieldGameExp))
}
// GameExpNotNil applies the NotNil predicate on the "game_exp" field.
func GameExpNotNil() predicate.Ue {
return predicate.Ue(sql.FieldNotNull(FieldGameExp))
}
// GameExpEqualFold applies the EqualFold predicate on the "game_exp" field.
func GameExpEqualFold(v string) predicate.Ue {
return predicate.Ue(sql.FieldEqualFold(FieldGameExp, v))
}
// GameExpContainsFold applies the ContainsFold predicate on the "game_exp" field.
func GameExpContainsFold(v string) predicate.Ue {
return predicate.Ue(sql.FieldContainsFold(FieldGameExp, v))
}
// GameIDEQ applies the EQ predicate on the "game_id" field.
func GameIDEQ(v string) predicate.Ue {
return predicate.Ue(sql.FieldEQ(FieldGameID, v))
}
// GameIDNEQ applies the NEQ predicate on the "game_id" field.
func GameIDNEQ(v string) predicate.Ue {
return predicate.Ue(sql.FieldNEQ(FieldGameID, v))
}
// GameIDIn applies the In predicate on the "game_id" field.
func GameIDIn(vs ...string) predicate.Ue {
return predicate.Ue(sql.FieldIn(FieldGameID, vs...))
}
// GameIDNotIn applies the NotIn predicate on the "game_id" field.
func GameIDNotIn(vs ...string) predicate.Ue {
return predicate.Ue(sql.FieldNotIn(FieldGameID, vs...))
}
// GameIDGT applies the GT predicate on the "game_id" field.
func GameIDGT(v string) predicate.Ue {
return predicate.Ue(sql.FieldGT(FieldGameID, v))
}
// GameIDGTE applies the GTE predicate on the "game_id" field.
func GameIDGTE(v string) predicate.Ue {
return predicate.Ue(sql.FieldGTE(FieldGameID, v))
}
// GameIDLT applies the LT predicate on the "game_id" field.
func GameIDLT(v string) predicate.Ue {
return predicate.Ue(sql.FieldLT(FieldGameID, v))
}
// GameIDLTE applies the LTE predicate on the "game_id" field.
func GameIDLTE(v string) predicate.Ue {
return predicate.Ue(sql.FieldLTE(FieldGameID, v))
}
// GameIDContains applies the Contains predicate on the "game_id" field.
func GameIDContains(v string) predicate.Ue {
return predicate.Ue(sql.FieldContains(FieldGameID, v))
}
// GameIDHasPrefix applies the HasPrefix predicate on the "game_id" field.
func GameIDHasPrefix(v string) predicate.Ue {
return predicate.Ue(sql.FieldHasPrefix(FieldGameID, v))
}
// GameIDHasSuffix applies the HasSuffix predicate on the "game_id" field.
func GameIDHasSuffix(v string) predicate.Ue {
return predicate.Ue(sql.FieldHasSuffix(FieldGameID, v))
}
// GameIDIsNil applies the IsNil predicate on the "game_id" field.
func GameIDIsNil() predicate.Ue {
return predicate.Ue(sql.FieldIsNull(FieldGameID))
}
// GameIDNotNil applies the NotNil predicate on the "game_id" field.
func GameIDNotNil() predicate.Ue {
return predicate.Ue(sql.FieldNotNull(FieldGameID))
}
// GameIDEqualFold applies the EqualFold predicate on the "game_id" field.
func GameIDEqualFold(v string) predicate.Ue {
return predicate.Ue(sql.FieldEqualFold(FieldGameID, v))
}
// GameIDContainsFold applies the ContainsFold predicate on the "game_id" field.
func GameIDContainsFold(v string) predicate.Ue {
return predicate.Ue(sql.FieldContainsFold(FieldGameID, v))
}
// GameStoryEQ applies the EQ predicate on the "game_story" field.
func GameStoryEQ(v int) predicate.Ue {
return predicate.Ue(sql.FieldEQ(FieldGameStory, v))
}
// GameStoryNEQ applies the NEQ predicate on the "game_story" field.
func GameStoryNEQ(v int) predicate.Ue {
return predicate.Ue(sql.FieldNEQ(FieldGameStory, v))
}
// GameStoryIn applies the In predicate on the "game_story" field.
func GameStoryIn(vs ...int) predicate.Ue {
return predicate.Ue(sql.FieldIn(FieldGameStory, vs...))
}
// GameStoryNotIn applies the NotIn predicate on the "game_story" field.
func GameStoryNotIn(vs ...int) predicate.Ue {
return predicate.Ue(sql.FieldNotIn(FieldGameStory, vs...))
}
// GameStoryGT applies the GT predicate on the "game_story" field.
func GameStoryGT(v int) predicate.Ue {
return predicate.Ue(sql.FieldGT(FieldGameStory, v))
}
// GameStoryGTE applies the GTE predicate on the "game_story" field.
func GameStoryGTE(v int) predicate.Ue {
return predicate.Ue(sql.FieldGTE(FieldGameStory, v))
}
// GameStoryLT applies the LT predicate on the "game_story" field.
func GameStoryLT(v int) predicate.Ue {
return predicate.Ue(sql.FieldLT(FieldGameStory, v))
}
// GameStoryLTE applies the LTE predicate on the "game_story" field.
func GameStoryLTE(v int) predicate.Ue {
return predicate.Ue(sql.FieldLTE(FieldGameStory, v))
}
// GameStoryIsNil applies the IsNil predicate on the "game_story" field.
func GameStoryIsNil() predicate.Ue {
return predicate.Ue(sql.FieldIsNull(FieldGameStory))
}
// GameStoryNotNil applies the NotNil predicate on the "game_story" field.
func GameStoryNotNil() predicate.Ue {
return predicate.Ue(sql.FieldNotNull(FieldGameStory))
}
// GameEpEQ applies the EQ predicate on the "game_ep" field.
func GameEpEQ(v string) predicate.Ue {
return predicate.Ue(sql.FieldEQ(FieldGameEp, v))
}
// GameEpNEQ applies the NEQ predicate on the "game_ep" field.
func GameEpNEQ(v string) predicate.Ue {
return predicate.Ue(sql.FieldNEQ(FieldGameEp, v))
}
// GameEpIn applies the In predicate on the "game_ep" field.
func GameEpIn(vs ...string) predicate.Ue {
return predicate.Ue(sql.FieldIn(FieldGameEp, vs...))
}
// GameEpNotIn applies the NotIn predicate on the "game_ep" field.
func GameEpNotIn(vs ...string) predicate.Ue {
return predicate.Ue(sql.FieldNotIn(FieldGameEp, vs...))
}
// GameEpGT applies the GT predicate on the "game_ep" field.
func GameEpGT(v string) predicate.Ue {
return predicate.Ue(sql.FieldGT(FieldGameEp, v))
}
// GameEpGTE applies the GTE predicate on the "game_ep" field.
func GameEpGTE(v string) predicate.Ue {
return predicate.Ue(sql.FieldGTE(FieldGameEp, v))
}
// GameEpLT applies the LT predicate on the "game_ep" field.
func GameEpLT(v string) predicate.Ue {
return predicate.Ue(sql.FieldLT(FieldGameEp, v))
}
// GameEpLTE applies the LTE predicate on the "game_ep" field.
func GameEpLTE(v string) predicate.Ue {
return predicate.Ue(sql.FieldLTE(FieldGameEp, v))
}
// GameEpContains applies the Contains predicate on the "game_ep" field.
func GameEpContains(v string) predicate.Ue {
return predicate.Ue(sql.FieldContains(FieldGameEp, v))
}
// GameEpHasPrefix applies the HasPrefix predicate on the "game_ep" field.
func GameEpHasPrefix(v string) predicate.Ue {
return predicate.Ue(sql.FieldHasPrefix(FieldGameEp, v))
}
// GameEpHasSuffix applies the HasSuffix predicate on the "game_ep" field.
func GameEpHasSuffix(v string) predicate.Ue {
return predicate.Ue(sql.FieldHasSuffix(FieldGameEp, v))
}
// GameEpIsNil applies the IsNil predicate on the "game_ep" field.
func GameEpIsNil() predicate.Ue {
return predicate.Ue(sql.FieldIsNull(FieldGameEp))
}
// GameEpNotNil applies the NotNil predicate on the "game_ep" field.
func GameEpNotNil() predicate.Ue {
return predicate.Ue(sql.FieldNotNull(FieldGameEp))
}
// GameEpEqualFold applies the EqualFold predicate on the "game_ep" field.
func GameEpEqualFold(v string) predicate.Ue {
return predicate.Ue(sql.FieldEqualFold(FieldGameEp, v))
}
// GameEpContainsFold applies the ContainsFold predicate on the "game_ep" field.
func GameEpContainsFold(v string) predicate.Ue {
return predicate.Ue(sql.FieldContainsFold(FieldGameEp, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.Ue {
return predicate.Ue(sql.FieldEQ(FieldCreatedAt, v))

View File

@@ -265,6 +265,76 @@ func (uc *UeCreate) SetNillableAuthor(s *string) *UeCreate {
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)
@@ -454,6 +524,26 @@ func (uc *UeCreate) createSpec() (*Ue, *sqlgraph.CreateSpec) {
_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

View File

@@ -445,6 +445,113 @@ func (uu *UeUpdate) ClearAuthor() *UeUpdate {
return uu
}
// SetGameLv sets the "game_lv" field.
func (uu *UeUpdate) SetGameLv(s string) *UeUpdate {
uu.mutation.SetGameLv(s)
return uu
}
// SetNillableGameLv sets the "game_lv" field if the given value is not nil.
func (uu *UeUpdate) SetNillableGameLv(s *string) *UeUpdate {
if s != nil {
uu.SetGameLv(*s)
}
return uu
}
// ClearGameLv clears the value of the "game_lv" field.
func (uu *UeUpdate) ClearGameLv() *UeUpdate {
uu.mutation.ClearGameLv()
return uu
}
// SetGameExp sets the "game_exp" field.
func (uu *UeUpdate) SetGameExp(s string) *UeUpdate {
uu.mutation.SetGameExp(s)
return uu
}
// SetNillableGameExp sets the "game_exp" field if the given value is not nil.
func (uu *UeUpdate) SetNillableGameExp(s *string) *UeUpdate {
if s != nil {
uu.SetGameExp(*s)
}
return uu
}
// ClearGameExp clears the value of the "game_exp" field.
func (uu *UeUpdate) ClearGameExp() *UeUpdate {
uu.mutation.ClearGameExp()
return uu
}
// SetGameID sets the "game_id" field.
func (uu *UeUpdate) SetGameID(s string) *UeUpdate {
uu.mutation.SetGameID(s)
return uu
}
// SetNillableGameID sets the "game_id" field if the given value is not nil.
func (uu *UeUpdate) SetNillableGameID(s *string) *UeUpdate {
if s != nil {
uu.SetGameID(*s)
}
return uu
}
// ClearGameID clears the value of the "game_id" field.
func (uu *UeUpdate) ClearGameID() *UeUpdate {
uu.mutation.ClearGameID()
return uu
}
// SetGameStory sets the "game_story" field.
func (uu *UeUpdate) SetGameStory(i int) *UeUpdate {
uu.mutation.ResetGameStory()
uu.mutation.SetGameStory(i)
return uu
}
// SetNillableGameStory sets the "game_story" field if the given value is not nil.
func (uu *UeUpdate) SetNillableGameStory(i *int) *UeUpdate {
if i != nil {
uu.SetGameStory(*i)
}
return uu
}
// AddGameStory adds i to the "game_story" field.
func (uu *UeUpdate) AddGameStory(i int) *UeUpdate {
uu.mutation.AddGameStory(i)
return uu
}
// ClearGameStory clears the value of the "game_story" field.
func (uu *UeUpdate) ClearGameStory() *UeUpdate {
uu.mutation.ClearGameStory()
return uu
}
// SetGameEp sets the "game_ep" field.
func (uu *UeUpdate) SetGameEp(s string) *UeUpdate {
uu.mutation.SetGameEp(s)
return uu
}
// SetNillableGameEp sets the "game_ep" field if the given value is not nil.
func (uu *UeUpdate) SetNillableGameEp(s *string) *UeUpdate {
if s != nil {
uu.SetGameEp(*s)
}
return uu
}
// ClearGameEp clears the value of the "game_ep" field.
func (uu *UeUpdate) ClearGameEp() *UeUpdate {
uu.mutation.ClearGameEp()
return uu
}
// SetOwnerID sets the "owner" edge to the User entity by ID.
func (uu *UeUpdate) SetOwnerID(id int) *UeUpdate {
uu.mutation.SetOwnerID(id)
@@ -649,6 +756,39 @@ func (uu *UeUpdate) sqlSave(ctx context.Context) (n int, err error) {
if uu.mutation.AuthorCleared() {
_spec.ClearField(ue.FieldAuthor, field.TypeString)
}
if value, ok := uu.mutation.GameLv(); ok {
_spec.SetField(ue.FieldGameLv, field.TypeString, value)
}
if uu.mutation.GameLvCleared() {
_spec.ClearField(ue.FieldGameLv, field.TypeString)
}
if value, ok := uu.mutation.GameExp(); ok {
_spec.SetField(ue.FieldGameExp, field.TypeString, value)
}
if uu.mutation.GameExpCleared() {
_spec.ClearField(ue.FieldGameExp, field.TypeString)
}
if value, ok := uu.mutation.GameID(); ok {
_spec.SetField(ue.FieldGameID, field.TypeString, value)
}
if uu.mutation.GameIDCleared() {
_spec.ClearField(ue.FieldGameID, field.TypeString)
}
if value, ok := uu.mutation.GameStory(); ok {
_spec.SetField(ue.FieldGameStory, field.TypeInt, value)
}
if value, ok := uu.mutation.AddedGameStory(); ok {
_spec.AddField(ue.FieldGameStory, field.TypeInt, value)
}
if uu.mutation.GameStoryCleared() {
_spec.ClearField(ue.FieldGameStory, field.TypeInt)
}
if value, ok := uu.mutation.GameEp(); ok {
_spec.SetField(ue.FieldGameEp, field.TypeString, value)
}
if uu.mutation.GameEpCleared() {
_spec.ClearField(ue.FieldGameEp, field.TypeString)
}
if uu.mutation.CreatedAtCleared() {
_spec.ClearField(ue.FieldCreatedAt, field.TypeTime)
}
@@ -1118,6 +1258,113 @@ func (uuo *UeUpdateOne) ClearAuthor() *UeUpdateOne {
return uuo
}
// SetGameLv sets the "game_lv" field.
func (uuo *UeUpdateOne) SetGameLv(s string) *UeUpdateOne {
uuo.mutation.SetGameLv(s)
return uuo
}
// SetNillableGameLv sets the "game_lv" field if the given value is not nil.
func (uuo *UeUpdateOne) SetNillableGameLv(s *string) *UeUpdateOne {
if s != nil {
uuo.SetGameLv(*s)
}
return uuo
}
// ClearGameLv clears the value of the "game_lv" field.
func (uuo *UeUpdateOne) ClearGameLv() *UeUpdateOne {
uuo.mutation.ClearGameLv()
return uuo
}
// SetGameExp sets the "game_exp" field.
func (uuo *UeUpdateOne) SetGameExp(s string) *UeUpdateOne {
uuo.mutation.SetGameExp(s)
return uuo
}
// SetNillableGameExp sets the "game_exp" field if the given value is not nil.
func (uuo *UeUpdateOne) SetNillableGameExp(s *string) *UeUpdateOne {
if s != nil {
uuo.SetGameExp(*s)
}
return uuo
}
// ClearGameExp clears the value of the "game_exp" field.
func (uuo *UeUpdateOne) ClearGameExp() *UeUpdateOne {
uuo.mutation.ClearGameExp()
return uuo
}
// SetGameID sets the "game_id" field.
func (uuo *UeUpdateOne) SetGameID(s string) *UeUpdateOne {
uuo.mutation.SetGameID(s)
return uuo
}
// SetNillableGameID sets the "game_id" field if the given value is not nil.
func (uuo *UeUpdateOne) SetNillableGameID(s *string) *UeUpdateOne {
if s != nil {
uuo.SetGameID(*s)
}
return uuo
}
// ClearGameID clears the value of the "game_id" field.
func (uuo *UeUpdateOne) ClearGameID() *UeUpdateOne {
uuo.mutation.ClearGameID()
return uuo
}
// SetGameStory sets the "game_story" field.
func (uuo *UeUpdateOne) SetGameStory(i int) *UeUpdateOne {
uuo.mutation.ResetGameStory()
uuo.mutation.SetGameStory(i)
return uuo
}
// SetNillableGameStory sets the "game_story" field if the given value is not nil.
func (uuo *UeUpdateOne) SetNillableGameStory(i *int) *UeUpdateOne {
if i != nil {
uuo.SetGameStory(*i)
}
return uuo
}
// AddGameStory adds i to the "game_story" field.
func (uuo *UeUpdateOne) AddGameStory(i int) *UeUpdateOne {
uuo.mutation.AddGameStory(i)
return uuo
}
// ClearGameStory clears the value of the "game_story" field.
func (uuo *UeUpdateOne) ClearGameStory() *UeUpdateOne {
uuo.mutation.ClearGameStory()
return uuo
}
// SetGameEp sets the "game_ep" field.
func (uuo *UeUpdateOne) SetGameEp(s string) *UeUpdateOne {
uuo.mutation.SetGameEp(s)
return uuo
}
// SetNillableGameEp sets the "game_ep" field if the given value is not nil.
func (uuo *UeUpdateOne) SetNillableGameEp(s *string) *UeUpdateOne {
if s != nil {
uuo.SetGameEp(*s)
}
return uuo
}
// ClearGameEp clears the value of the "game_ep" field.
func (uuo *UeUpdateOne) ClearGameEp() *UeUpdateOne {
uuo.mutation.ClearGameEp()
return uuo
}
// SetOwnerID sets the "owner" edge to the User entity by ID.
func (uuo *UeUpdateOne) SetOwnerID(id int) *UeUpdateOne {
uuo.mutation.SetOwnerID(id)
@@ -1352,6 +1599,39 @@ func (uuo *UeUpdateOne) sqlSave(ctx context.Context) (_node *Ue, err error) {
if uuo.mutation.AuthorCleared() {
_spec.ClearField(ue.FieldAuthor, field.TypeString)
}
if value, ok := uuo.mutation.GameLv(); ok {
_spec.SetField(ue.FieldGameLv, field.TypeString, value)
}
if uuo.mutation.GameLvCleared() {
_spec.ClearField(ue.FieldGameLv, field.TypeString)
}
if value, ok := uuo.mutation.GameExp(); ok {
_spec.SetField(ue.FieldGameExp, field.TypeString, value)
}
if uuo.mutation.GameExpCleared() {
_spec.ClearField(ue.FieldGameExp, field.TypeString)
}
if value, ok := uuo.mutation.GameID(); ok {
_spec.SetField(ue.FieldGameID, field.TypeString, value)
}
if uuo.mutation.GameIDCleared() {
_spec.ClearField(ue.FieldGameID, field.TypeString)
}
if value, ok := uuo.mutation.GameStory(); ok {
_spec.SetField(ue.FieldGameStory, field.TypeInt, value)
}
if value, ok := uuo.mutation.AddedGameStory(); ok {
_spec.AddField(ue.FieldGameStory, field.TypeInt, value)
}
if uuo.mutation.GameStoryCleared() {
_spec.ClearField(ue.FieldGameStory, field.TypeInt)
}
if value, ok := uuo.mutation.GameEp(); ok {
_spec.SetField(ue.FieldGameEp, field.TypeString, value)
}
if uuo.mutation.GameEpCleared() {
_spec.ClearField(ue.FieldGameEp, field.TypeString)
}
if uuo.mutation.CreatedAtCleared() {
_spec.ClearField(ue.FieldCreatedAt, field.TypeTime)
}

View File

@@ -111,6 +111,34 @@ type User struct {
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"`
@@ -124,9 +152,13 @@ type UserEdges struct {
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 [2]bool
loadedTypes [4]bool
}
// CardOrErr returns the Card value or an error if the edge
@@ -147,18 +179,38 @@ func (e UserEdges) UeOrErr() ([]*Ue, error) {
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:
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:
values[i] = new(sql.NullBool)
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:
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:
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:
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:
values[i] = new(sql.NullTime)
case user.ForeignKeys[0]: // group_users
values[i] = new(sql.NullInt64)
@@ -465,6 +517,90 @@ func (u *User) assignValues(columns []string, values []any) error {
} 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)
@@ -495,6 +631,16 @@ 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.
@@ -656,6 +802,48 @@ func (u *User) String() string {
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()
}

View File

@@ -108,10 +108,42 @@ const (
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.
@@ -128,6 +160,20 @@ const (
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.
@@ -180,6 +226,20 @@ var Columns = []string{
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"
@@ -252,6 +312,18 @@ var (
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.
@@ -497,6 +569,76 @@ 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) {
@@ -524,6 +666,34 @@ func ByUe(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
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),
@@ -538,3 +708,17 @@ func newUeStep() *sqlgraph.Step {
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),
)
}

View File

@@ -290,6 +290,76 @@ func GameLv(v int) predicate.User {
return predicate.User(sql.FieldEQ(FieldGameLv, v))
}
// GameExp applies equality check predicate on the "game_exp" field. It's identical to GameExpEQ.
func GameExp(v int) predicate.User {
return predicate.User(sql.FieldEQ(FieldGameExp, v))
}
// GameStory applies equality check predicate on the "game_story" field. It's identical to GameStoryEQ.
func GameStory(v int) predicate.User {
return predicate.User(sql.FieldEQ(FieldGameStory, v))
}
// GameLimit applies equality check predicate on the "game_limit" field. It's identical to GameLimitEQ.
func GameLimit(v bool) predicate.User {
return predicate.User(sql.FieldEQ(FieldGameLimit, v))
}
// Coin applies equality check predicate on the "coin" field. It's identical to CoinEQ.
func Coin(v int) predicate.User {
return predicate.User(sql.FieldEQ(FieldCoin, v))
}
// CoinOpen applies equality check predicate on the "coin_open" field. It's identical to CoinOpenEQ.
func CoinOpen(v bool) predicate.User {
return predicate.User(sql.FieldEQ(FieldCoinOpen, v))
}
// CoinAt applies equality check predicate on the "coin_at" field. It's identical to CoinAtEQ.
func CoinAt(v time.Time) predicate.User {
return predicate.User(sql.FieldEQ(FieldCoinAt, v))
}
// Planet applies equality check predicate on the "planet" field. It's identical to PlanetEQ.
func Planet(v float64) predicate.User {
return predicate.User(sql.FieldEQ(FieldPlanet, v))
}
// PlanetAt applies equality check predicate on the "planet_at" field. It's identical to PlanetAtEQ.
func PlanetAt(v time.Time) predicate.User {
return predicate.User(sql.FieldEQ(FieldPlanetAt, v))
}
// Login applies equality check predicate on the "login" field. It's identical to LoginEQ.
func Login(v bool) predicate.User {
return predicate.User(sql.FieldEQ(FieldLogin, v))
}
// LoginAt applies equality check predicate on the "login_at" field. It's identical to LoginAtEQ.
func LoginAt(v time.Time) predicate.User {
return predicate.User(sql.FieldEQ(FieldLoginAt, v))
}
// LocationX applies equality check predicate on the "location_x" field. It's identical to LocationXEQ.
func LocationX(v int) predicate.User {
return predicate.User(sql.FieldEQ(FieldLocationX, v))
}
// LocationY applies equality check predicate on the "location_y" field. It's identical to LocationYEQ.
func LocationY(v int) predicate.User {
return predicate.User(sql.FieldEQ(FieldLocationY, v))
}
// LocationZ applies equality check predicate on the "location_z" field. It's identical to LocationZEQ.
func LocationZ(v int) predicate.User {
return predicate.User(sql.FieldEQ(FieldLocationZ, v))
}
// LocationN applies equality check predicate on the "location_n" field. It's identical to LocationNEQ.
func LocationN(v int) predicate.User {
return predicate.User(sql.FieldEQ(FieldLocationN, v))
}
// UsernameEQ applies the EQ predicate on the "username" field.
func UsernameEQ(v string) predicate.User {
return predicate.User(sql.FieldEQ(FieldUsername, v))
@@ -2425,6 +2495,616 @@ func GameLvNotNil() predicate.User {
return predicate.User(sql.FieldNotNull(FieldGameLv))
}
// GameExpEQ applies the EQ predicate on the "game_exp" field.
func GameExpEQ(v int) predicate.User {
return predicate.User(sql.FieldEQ(FieldGameExp, v))
}
// GameExpNEQ applies the NEQ predicate on the "game_exp" field.
func GameExpNEQ(v int) predicate.User {
return predicate.User(sql.FieldNEQ(FieldGameExp, v))
}
// GameExpIn applies the In predicate on the "game_exp" field.
func GameExpIn(vs ...int) predicate.User {
return predicate.User(sql.FieldIn(FieldGameExp, vs...))
}
// GameExpNotIn applies the NotIn predicate on the "game_exp" field.
func GameExpNotIn(vs ...int) predicate.User {
return predicate.User(sql.FieldNotIn(FieldGameExp, vs...))
}
// GameExpGT applies the GT predicate on the "game_exp" field.
func GameExpGT(v int) predicate.User {
return predicate.User(sql.FieldGT(FieldGameExp, v))
}
// GameExpGTE applies the GTE predicate on the "game_exp" field.
func GameExpGTE(v int) predicate.User {
return predicate.User(sql.FieldGTE(FieldGameExp, v))
}
// GameExpLT applies the LT predicate on the "game_exp" field.
func GameExpLT(v int) predicate.User {
return predicate.User(sql.FieldLT(FieldGameExp, v))
}
// GameExpLTE applies the LTE predicate on the "game_exp" field.
func GameExpLTE(v int) predicate.User {
return predicate.User(sql.FieldLTE(FieldGameExp, v))
}
// GameExpIsNil applies the IsNil predicate on the "game_exp" field.
func GameExpIsNil() predicate.User {
return predicate.User(sql.FieldIsNull(FieldGameExp))
}
// GameExpNotNil applies the NotNil predicate on the "game_exp" field.
func GameExpNotNil() predicate.User {
return predicate.User(sql.FieldNotNull(FieldGameExp))
}
// GameStoryEQ applies the EQ predicate on the "game_story" field.
func GameStoryEQ(v int) predicate.User {
return predicate.User(sql.FieldEQ(FieldGameStory, v))
}
// GameStoryNEQ applies the NEQ predicate on the "game_story" field.
func GameStoryNEQ(v int) predicate.User {
return predicate.User(sql.FieldNEQ(FieldGameStory, v))
}
// GameStoryIn applies the In predicate on the "game_story" field.
func GameStoryIn(vs ...int) predicate.User {
return predicate.User(sql.FieldIn(FieldGameStory, vs...))
}
// GameStoryNotIn applies the NotIn predicate on the "game_story" field.
func GameStoryNotIn(vs ...int) predicate.User {
return predicate.User(sql.FieldNotIn(FieldGameStory, vs...))
}
// GameStoryGT applies the GT predicate on the "game_story" field.
func GameStoryGT(v int) predicate.User {
return predicate.User(sql.FieldGT(FieldGameStory, v))
}
// GameStoryGTE applies the GTE predicate on the "game_story" field.
func GameStoryGTE(v int) predicate.User {
return predicate.User(sql.FieldGTE(FieldGameStory, v))
}
// GameStoryLT applies the LT predicate on the "game_story" field.
func GameStoryLT(v int) predicate.User {
return predicate.User(sql.FieldLT(FieldGameStory, v))
}
// GameStoryLTE applies the LTE predicate on the "game_story" field.
func GameStoryLTE(v int) predicate.User {
return predicate.User(sql.FieldLTE(FieldGameStory, v))
}
// GameStoryIsNil applies the IsNil predicate on the "game_story" field.
func GameStoryIsNil() predicate.User {
return predicate.User(sql.FieldIsNull(FieldGameStory))
}
// GameStoryNotNil applies the NotNil predicate on the "game_story" field.
func GameStoryNotNil() predicate.User {
return predicate.User(sql.FieldNotNull(FieldGameStory))
}
// GameLimitEQ applies the EQ predicate on the "game_limit" field.
func GameLimitEQ(v bool) predicate.User {
return predicate.User(sql.FieldEQ(FieldGameLimit, v))
}
// GameLimitNEQ applies the NEQ predicate on the "game_limit" field.
func GameLimitNEQ(v bool) predicate.User {
return predicate.User(sql.FieldNEQ(FieldGameLimit, v))
}
// GameLimitIsNil applies the IsNil predicate on the "game_limit" field.
func GameLimitIsNil() predicate.User {
return predicate.User(sql.FieldIsNull(FieldGameLimit))
}
// GameLimitNotNil applies the NotNil predicate on the "game_limit" field.
func GameLimitNotNil() predicate.User {
return predicate.User(sql.FieldNotNull(FieldGameLimit))
}
// CoinEQ applies the EQ predicate on the "coin" field.
func CoinEQ(v int) predicate.User {
return predicate.User(sql.FieldEQ(FieldCoin, v))
}
// CoinNEQ applies the NEQ predicate on the "coin" field.
func CoinNEQ(v int) predicate.User {
return predicate.User(sql.FieldNEQ(FieldCoin, v))
}
// CoinIn applies the In predicate on the "coin" field.
func CoinIn(vs ...int) predicate.User {
return predicate.User(sql.FieldIn(FieldCoin, vs...))
}
// CoinNotIn applies the NotIn predicate on the "coin" field.
func CoinNotIn(vs ...int) predicate.User {
return predicate.User(sql.FieldNotIn(FieldCoin, vs...))
}
// CoinGT applies the GT predicate on the "coin" field.
func CoinGT(v int) predicate.User {
return predicate.User(sql.FieldGT(FieldCoin, v))
}
// CoinGTE applies the GTE predicate on the "coin" field.
func CoinGTE(v int) predicate.User {
return predicate.User(sql.FieldGTE(FieldCoin, v))
}
// CoinLT applies the LT predicate on the "coin" field.
func CoinLT(v int) predicate.User {
return predicate.User(sql.FieldLT(FieldCoin, v))
}
// CoinLTE applies the LTE predicate on the "coin" field.
func CoinLTE(v int) predicate.User {
return predicate.User(sql.FieldLTE(FieldCoin, v))
}
// CoinIsNil applies the IsNil predicate on the "coin" field.
func CoinIsNil() predicate.User {
return predicate.User(sql.FieldIsNull(FieldCoin))
}
// CoinNotNil applies the NotNil predicate on the "coin" field.
func CoinNotNil() predicate.User {
return predicate.User(sql.FieldNotNull(FieldCoin))
}
// CoinOpenEQ applies the EQ predicate on the "coin_open" field.
func CoinOpenEQ(v bool) predicate.User {
return predicate.User(sql.FieldEQ(FieldCoinOpen, v))
}
// CoinOpenNEQ applies the NEQ predicate on the "coin_open" field.
func CoinOpenNEQ(v bool) predicate.User {
return predicate.User(sql.FieldNEQ(FieldCoinOpen, v))
}
// CoinOpenIsNil applies the IsNil predicate on the "coin_open" field.
func CoinOpenIsNil() predicate.User {
return predicate.User(sql.FieldIsNull(FieldCoinOpen))
}
// CoinOpenNotNil applies the NotNil predicate on the "coin_open" field.
func CoinOpenNotNil() predicate.User {
return predicate.User(sql.FieldNotNull(FieldCoinOpen))
}
// CoinAtEQ applies the EQ predicate on the "coin_at" field.
func CoinAtEQ(v time.Time) predicate.User {
return predicate.User(sql.FieldEQ(FieldCoinAt, v))
}
// CoinAtNEQ applies the NEQ predicate on the "coin_at" field.
func CoinAtNEQ(v time.Time) predicate.User {
return predicate.User(sql.FieldNEQ(FieldCoinAt, v))
}
// CoinAtIn applies the In predicate on the "coin_at" field.
func CoinAtIn(vs ...time.Time) predicate.User {
return predicate.User(sql.FieldIn(FieldCoinAt, vs...))
}
// CoinAtNotIn applies the NotIn predicate on the "coin_at" field.
func CoinAtNotIn(vs ...time.Time) predicate.User {
return predicate.User(sql.FieldNotIn(FieldCoinAt, vs...))
}
// CoinAtGT applies the GT predicate on the "coin_at" field.
func CoinAtGT(v time.Time) predicate.User {
return predicate.User(sql.FieldGT(FieldCoinAt, v))
}
// CoinAtGTE applies the GTE predicate on the "coin_at" field.
func CoinAtGTE(v time.Time) predicate.User {
return predicate.User(sql.FieldGTE(FieldCoinAt, v))
}
// CoinAtLT applies the LT predicate on the "coin_at" field.
func CoinAtLT(v time.Time) predicate.User {
return predicate.User(sql.FieldLT(FieldCoinAt, v))
}
// CoinAtLTE applies the LTE predicate on the "coin_at" field.
func CoinAtLTE(v time.Time) predicate.User {
return predicate.User(sql.FieldLTE(FieldCoinAt, v))
}
// CoinAtIsNil applies the IsNil predicate on the "coin_at" field.
func CoinAtIsNil() predicate.User {
return predicate.User(sql.FieldIsNull(FieldCoinAt))
}
// CoinAtNotNil applies the NotNil predicate on the "coin_at" field.
func CoinAtNotNil() predicate.User {
return predicate.User(sql.FieldNotNull(FieldCoinAt))
}
// PlanetEQ applies the EQ predicate on the "planet" field.
func PlanetEQ(v float64) predicate.User {
return predicate.User(sql.FieldEQ(FieldPlanet, v))
}
// PlanetNEQ applies the NEQ predicate on the "planet" field.
func PlanetNEQ(v float64) predicate.User {
return predicate.User(sql.FieldNEQ(FieldPlanet, v))
}
// PlanetIn applies the In predicate on the "planet" field.
func PlanetIn(vs ...float64) predicate.User {
return predicate.User(sql.FieldIn(FieldPlanet, vs...))
}
// PlanetNotIn applies the NotIn predicate on the "planet" field.
func PlanetNotIn(vs ...float64) predicate.User {
return predicate.User(sql.FieldNotIn(FieldPlanet, vs...))
}
// PlanetGT applies the GT predicate on the "planet" field.
func PlanetGT(v float64) predicate.User {
return predicate.User(sql.FieldGT(FieldPlanet, v))
}
// PlanetGTE applies the GTE predicate on the "planet" field.
func PlanetGTE(v float64) predicate.User {
return predicate.User(sql.FieldGTE(FieldPlanet, v))
}
// PlanetLT applies the LT predicate on the "planet" field.
func PlanetLT(v float64) predicate.User {
return predicate.User(sql.FieldLT(FieldPlanet, v))
}
// PlanetLTE applies the LTE predicate on the "planet" field.
func PlanetLTE(v float64) predicate.User {
return predicate.User(sql.FieldLTE(FieldPlanet, v))
}
// PlanetIsNil applies the IsNil predicate on the "planet" field.
func PlanetIsNil() predicate.User {
return predicate.User(sql.FieldIsNull(FieldPlanet))
}
// PlanetNotNil applies the NotNil predicate on the "planet" field.
func PlanetNotNil() predicate.User {
return predicate.User(sql.FieldNotNull(FieldPlanet))
}
// PlanetAtEQ applies the EQ predicate on the "planet_at" field.
func PlanetAtEQ(v time.Time) predicate.User {
return predicate.User(sql.FieldEQ(FieldPlanetAt, v))
}
// PlanetAtNEQ applies the NEQ predicate on the "planet_at" field.
func PlanetAtNEQ(v time.Time) predicate.User {
return predicate.User(sql.FieldNEQ(FieldPlanetAt, v))
}
// PlanetAtIn applies the In predicate on the "planet_at" field.
func PlanetAtIn(vs ...time.Time) predicate.User {
return predicate.User(sql.FieldIn(FieldPlanetAt, vs...))
}
// PlanetAtNotIn applies the NotIn predicate on the "planet_at" field.
func PlanetAtNotIn(vs ...time.Time) predicate.User {
return predicate.User(sql.FieldNotIn(FieldPlanetAt, vs...))
}
// PlanetAtGT applies the GT predicate on the "planet_at" field.
func PlanetAtGT(v time.Time) predicate.User {
return predicate.User(sql.FieldGT(FieldPlanetAt, v))
}
// PlanetAtGTE applies the GTE predicate on the "planet_at" field.
func PlanetAtGTE(v time.Time) predicate.User {
return predicate.User(sql.FieldGTE(FieldPlanetAt, v))
}
// PlanetAtLT applies the LT predicate on the "planet_at" field.
func PlanetAtLT(v time.Time) predicate.User {
return predicate.User(sql.FieldLT(FieldPlanetAt, v))
}
// PlanetAtLTE applies the LTE predicate on the "planet_at" field.
func PlanetAtLTE(v time.Time) predicate.User {
return predicate.User(sql.FieldLTE(FieldPlanetAt, v))
}
// PlanetAtIsNil applies the IsNil predicate on the "planet_at" field.
func PlanetAtIsNil() predicate.User {
return predicate.User(sql.FieldIsNull(FieldPlanetAt))
}
// PlanetAtNotNil applies the NotNil predicate on the "planet_at" field.
func PlanetAtNotNil() predicate.User {
return predicate.User(sql.FieldNotNull(FieldPlanetAt))
}
// LoginEQ applies the EQ predicate on the "login" field.
func LoginEQ(v bool) predicate.User {
return predicate.User(sql.FieldEQ(FieldLogin, v))
}
// LoginNEQ applies the NEQ predicate on the "login" field.
func LoginNEQ(v bool) predicate.User {
return predicate.User(sql.FieldNEQ(FieldLogin, v))
}
// LoginIsNil applies the IsNil predicate on the "login" field.
func LoginIsNil() predicate.User {
return predicate.User(sql.FieldIsNull(FieldLogin))
}
// LoginNotNil applies the NotNil predicate on the "login" field.
func LoginNotNil() predicate.User {
return predicate.User(sql.FieldNotNull(FieldLogin))
}
// LoginAtEQ applies the EQ predicate on the "login_at" field.
func LoginAtEQ(v time.Time) predicate.User {
return predicate.User(sql.FieldEQ(FieldLoginAt, v))
}
// LoginAtNEQ applies the NEQ predicate on the "login_at" field.
func LoginAtNEQ(v time.Time) predicate.User {
return predicate.User(sql.FieldNEQ(FieldLoginAt, v))
}
// LoginAtIn applies the In predicate on the "login_at" field.
func LoginAtIn(vs ...time.Time) predicate.User {
return predicate.User(sql.FieldIn(FieldLoginAt, vs...))
}
// LoginAtNotIn applies the NotIn predicate on the "login_at" field.
func LoginAtNotIn(vs ...time.Time) predicate.User {
return predicate.User(sql.FieldNotIn(FieldLoginAt, vs...))
}
// LoginAtGT applies the GT predicate on the "login_at" field.
func LoginAtGT(v time.Time) predicate.User {
return predicate.User(sql.FieldGT(FieldLoginAt, v))
}
// LoginAtGTE applies the GTE predicate on the "login_at" field.
func LoginAtGTE(v time.Time) predicate.User {
return predicate.User(sql.FieldGTE(FieldLoginAt, v))
}
// LoginAtLT applies the LT predicate on the "login_at" field.
func LoginAtLT(v time.Time) predicate.User {
return predicate.User(sql.FieldLT(FieldLoginAt, v))
}
// LoginAtLTE applies the LTE predicate on the "login_at" field.
func LoginAtLTE(v time.Time) predicate.User {
return predicate.User(sql.FieldLTE(FieldLoginAt, v))
}
// LoginAtIsNil applies the IsNil predicate on the "login_at" field.
func LoginAtIsNil() predicate.User {
return predicate.User(sql.FieldIsNull(FieldLoginAt))
}
// LoginAtNotNil applies the NotNil predicate on the "login_at" field.
func LoginAtNotNil() predicate.User {
return predicate.User(sql.FieldNotNull(FieldLoginAt))
}
// LocationXEQ applies the EQ predicate on the "location_x" field.
func LocationXEQ(v int) predicate.User {
return predicate.User(sql.FieldEQ(FieldLocationX, v))
}
// LocationXNEQ applies the NEQ predicate on the "location_x" field.
func LocationXNEQ(v int) predicate.User {
return predicate.User(sql.FieldNEQ(FieldLocationX, v))
}
// LocationXIn applies the In predicate on the "location_x" field.
func LocationXIn(vs ...int) predicate.User {
return predicate.User(sql.FieldIn(FieldLocationX, vs...))
}
// LocationXNotIn applies the NotIn predicate on the "location_x" field.
func LocationXNotIn(vs ...int) predicate.User {
return predicate.User(sql.FieldNotIn(FieldLocationX, vs...))
}
// LocationXGT applies the GT predicate on the "location_x" field.
func LocationXGT(v int) predicate.User {
return predicate.User(sql.FieldGT(FieldLocationX, v))
}
// LocationXGTE applies the GTE predicate on the "location_x" field.
func LocationXGTE(v int) predicate.User {
return predicate.User(sql.FieldGTE(FieldLocationX, v))
}
// LocationXLT applies the LT predicate on the "location_x" field.
func LocationXLT(v int) predicate.User {
return predicate.User(sql.FieldLT(FieldLocationX, v))
}
// LocationXLTE applies the LTE predicate on the "location_x" field.
func LocationXLTE(v int) predicate.User {
return predicate.User(sql.FieldLTE(FieldLocationX, v))
}
// LocationXIsNil applies the IsNil predicate on the "location_x" field.
func LocationXIsNil() predicate.User {
return predicate.User(sql.FieldIsNull(FieldLocationX))
}
// LocationXNotNil applies the NotNil predicate on the "location_x" field.
func LocationXNotNil() predicate.User {
return predicate.User(sql.FieldNotNull(FieldLocationX))
}
// LocationYEQ applies the EQ predicate on the "location_y" field.
func LocationYEQ(v int) predicate.User {
return predicate.User(sql.FieldEQ(FieldLocationY, v))
}
// LocationYNEQ applies the NEQ predicate on the "location_y" field.
func LocationYNEQ(v int) predicate.User {
return predicate.User(sql.FieldNEQ(FieldLocationY, v))
}
// LocationYIn applies the In predicate on the "location_y" field.
func LocationYIn(vs ...int) predicate.User {
return predicate.User(sql.FieldIn(FieldLocationY, vs...))
}
// LocationYNotIn applies the NotIn predicate on the "location_y" field.
func LocationYNotIn(vs ...int) predicate.User {
return predicate.User(sql.FieldNotIn(FieldLocationY, vs...))
}
// LocationYGT applies the GT predicate on the "location_y" field.
func LocationYGT(v int) predicate.User {
return predicate.User(sql.FieldGT(FieldLocationY, v))
}
// LocationYGTE applies the GTE predicate on the "location_y" field.
func LocationYGTE(v int) predicate.User {
return predicate.User(sql.FieldGTE(FieldLocationY, v))
}
// LocationYLT applies the LT predicate on the "location_y" field.
func LocationYLT(v int) predicate.User {
return predicate.User(sql.FieldLT(FieldLocationY, v))
}
// LocationYLTE applies the LTE predicate on the "location_y" field.
func LocationYLTE(v int) predicate.User {
return predicate.User(sql.FieldLTE(FieldLocationY, v))
}
// LocationYIsNil applies the IsNil predicate on the "location_y" field.
func LocationYIsNil() predicate.User {
return predicate.User(sql.FieldIsNull(FieldLocationY))
}
// LocationYNotNil applies the NotNil predicate on the "location_y" field.
func LocationYNotNil() predicate.User {
return predicate.User(sql.FieldNotNull(FieldLocationY))
}
// LocationZEQ applies the EQ predicate on the "location_z" field.
func LocationZEQ(v int) predicate.User {
return predicate.User(sql.FieldEQ(FieldLocationZ, v))
}
// LocationZNEQ applies the NEQ predicate on the "location_z" field.
func LocationZNEQ(v int) predicate.User {
return predicate.User(sql.FieldNEQ(FieldLocationZ, v))
}
// LocationZIn applies the In predicate on the "location_z" field.
func LocationZIn(vs ...int) predicate.User {
return predicate.User(sql.FieldIn(FieldLocationZ, vs...))
}
// LocationZNotIn applies the NotIn predicate on the "location_z" field.
func LocationZNotIn(vs ...int) predicate.User {
return predicate.User(sql.FieldNotIn(FieldLocationZ, vs...))
}
// LocationZGT applies the GT predicate on the "location_z" field.
func LocationZGT(v int) predicate.User {
return predicate.User(sql.FieldGT(FieldLocationZ, v))
}
// LocationZGTE applies the GTE predicate on the "location_z" field.
func LocationZGTE(v int) predicate.User {
return predicate.User(sql.FieldGTE(FieldLocationZ, v))
}
// LocationZLT applies the LT predicate on the "location_z" field.
func LocationZLT(v int) predicate.User {
return predicate.User(sql.FieldLT(FieldLocationZ, v))
}
// LocationZLTE applies the LTE predicate on the "location_z" field.
func LocationZLTE(v int) predicate.User {
return predicate.User(sql.FieldLTE(FieldLocationZ, v))
}
// LocationZIsNil applies the IsNil predicate on the "location_z" field.
func LocationZIsNil() predicate.User {
return predicate.User(sql.FieldIsNull(FieldLocationZ))
}
// LocationZNotNil applies the NotNil predicate on the "location_z" field.
func LocationZNotNil() predicate.User {
return predicate.User(sql.FieldNotNull(FieldLocationZ))
}
// LocationNEQ applies the EQ predicate on the "location_n" field.
func LocationNEQ(v int) predicate.User {
return predicate.User(sql.FieldEQ(FieldLocationN, v))
}
// LocationNNEQ applies the NEQ predicate on the "location_n" field.
func LocationNNEQ(v int) predicate.User {
return predicate.User(sql.FieldNEQ(FieldLocationN, v))
}
// LocationNIn applies the In predicate on the "location_n" field.
func LocationNIn(vs ...int) predicate.User {
return predicate.User(sql.FieldIn(FieldLocationN, vs...))
}
// LocationNNotIn applies the NotIn predicate on the "location_n" field.
func LocationNNotIn(vs ...int) predicate.User {
return predicate.User(sql.FieldNotIn(FieldLocationN, vs...))
}
// LocationNGT applies the GT predicate on the "location_n" field.
func LocationNGT(v int) predicate.User {
return predicate.User(sql.FieldGT(FieldLocationN, v))
}
// LocationNGTE applies the GTE predicate on the "location_n" field.
func LocationNGTE(v int) predicate.User {
return predicate.User(sql.FieldGTE(FieldLocationN, v))
}
// LocationNLT applies the LT predicate on the "location_n" field.
func LocationNLT(v int) predicate.User {
return predicate.User(sql.FieldLT(FieldLocationN, v))
}
// LocationNLTE applies the LTE predicate on the "location_n" field.
func LocationNLTE(v int) predicate.User {
return predicate.User(sql.FieldLTE(FieldLocationN, v))
}
// LocationNIsNil applies the IsNil predicate on the "location_n" field.
func LocationNIsNil() predicate.User {
return predicate.User(sql.FieldIsNull(FieldLocationN))
}
// LocationNNotNil applies the NotNil predicate on the "location_n" field.
func LocationNNotNil() predicate.User {
return predicate.User(sql.FieldNotNull(FieldLocationN))
}
// HasCard applies the HasEdge predicate on the "card" edge.
func HasCard() predicate.User {
return predicate.User(func(s *sql.Selector) {
@@ -2471,6 +3151,52 @@ func HasUeWith(preds ...predicate.Ue) predicate.User {
})
}
// HasMa applies the HasEdge predicate on the "ma" edge.
func HasMa() predicate.User {
return predicate.User(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, MaTable, MaColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasMaWith applies the HasEdge predicate on the "ma" edge with a given conditions (other predicates).
func HasMaWith(preds ...predicate.Ma) predicate.User {
return predicate.User(func(s *sql.Selector) {
step := newMaStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// HasSev applies the HasEdge predicate on the "sev" edge.
func HasSev() predicate.User {
return predicate.User(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, SevTable, SevColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasSevWith applies the HasEdge predicate on the "sev" edge with a given conditions (other predicates).
func HasSevWith(preds ...predicate.Sev) predicate.User {
return predicate.User(func(s *sql.Selector) {
step := newSevStep()
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.User) predicate.User {
return predicate.User(func(s *sql.Selector) {

View File

@@ -4,6 +4,8 @@ package ent
import (
"api/ent/card"
"api/ent/ma"
"api/ent/sev"
"api/ent/ue"
"api/ent/user"
"context"
@@ -664,6 +666,202 @@ func (uc *UserCreate) SetNillableGameLv(i *int) *UserCreate {
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...)
@@ -694,6 +892,36 @@ func (uc *UserCreate) AddUe(u ...*Ue) *UserCreate {
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
@@ -817,6 +1045,30 @@ func (uc *UserCreate) defaults() {
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.
@@ -1051,6 +1303,62 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
_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,
@@ -1083,6 +1391,38 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
}
_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
}

View File

@@ -4,7 +4,9 @@ package ent
import (
"api/ent/card"
"api/ent/ma"
"api/ent/predicate"
"api/ent/sev"
"api/ent/ue"
"api/ent/user"
"context"
@@ -26,6 +28,8 @@ type UserQuery struct {
predicates []predicate.User
withCard *CardQuery
withUe *UeQuery
withMa *MaQuery
withSev *SevQuery
withFKs bool
// intermediate query (i.e. traversal path).
sql *sql.Selector
@@ -107,6 +111,50 @@ func (uq *UserQuery) QueryUe() *UeQuery {
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) {
@@ -301,6 +349,8 @@ func (uq *UserQuery) Clone() *UserQuery {
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,
@@ -329,6 +379,28 @@ func (uq *UserQuery) WithUe(opts ...func(*UeQuery)) *UserQuery {
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.
//
@@ -408,9 +480,11 @@ func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e
nodes = []*User{}
withFKs = uq.withFKs
_spec = uq.querySpec()
loadedTypes = [2]bool{
loadedTypes = [4]bool{
uq.withCard != nil,
uq.withUe != nil,
uq.withMa != nil,
uq.withSev != nil,
}
)
if withFKs {
@@ -448,6 +522,20 @@ func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e
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
}
@@ -513,6 +601,68 @@ func (uq *UserQuery) loadUe(ctx context.Context, query *UeQuery, nodes []*User,
}
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)
}
assign(node, n)
}
return nil
}
func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) {
_spec := uq.querySpec()

File diff suppressed because it is too large Load Diff

2
go.mod
View File

@@ -2,8 +2,6 @@ module api
go 1.21
toolchain go1.21.7
//replace ariga.io/ogent => ../../
require (

BIN
icon/api.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 KiB

After

Width:  |  Height:  |  Size: 49 KiB

BIN
icon/db.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@@ -52,6 +52,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?mode=memory&cache=shared&_fk=1")
if err != nil {
log.Fatal(err)

View File

@@ -2,8 +2,7 @@
<img src="./icon/card.png" width="100">
- name : ai api
- base : [go](https://go.dev/)
- name : ai `api`
- host : [card.syui.ai](https://card.syui.ai)
```sh

1
scpt Submodule

Submodule scpt added at 87e087752d

View File

@@ -1,31 +0,0 @@
#!/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

View File

@@ -1,21 +0,0 @@
#!/bin/zsh
host=https://api.syui.ai
token=`cat ~/.config/atr/api_card.json|jq -r .token`
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
if [ -z "$1" ];then
exit
fi
if [ -z "$2" ];then
did=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.did == \"$1\")"|jq -r .id`
echo $did
exit
fi
echo old-id new-id
read
echo account delete $1 token
curl -X PATCH -H "Content-Type: application/json" -d "{\"delete\":true,\"token\":\"$token\"}" -s $host/users/$1
echo account refresh $2 token
curl -X PATCH -H "Content-Type: application/json" -d "{\"delete\":false,\"token\":\"$token\"}" -s $host/users/$2

View File

@@ -1,19 +0,0 @@
#!/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
s=$2
if [ -n "$2" ];then
s=$2
else
s=true
fi
curl -X PATCH -H "Content-Type: application/json" -d "{\"delete\":$s,\"token\":\"$token\"}" -s $host/users/$id

View File

@@ -1,27 +0,0 @@
#!/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

View File

@@ -1,25 +0,0 @@
#!/bin/zsh
host=https://api.syui.ai
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
echo username card cp
read
if [ -z "$1" ];then
exit
fi
if [ -z "$2" ];then
exit
fi
if [ -z "$3" ];then
exit
fi
id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id`
card=$2
cp=$3
s=normal
skill=normal
count=1
author=ai
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\",\"skill\":\"$skill\",\"count\":$count,\"author\":\"$author\"}" -sL $host/cards

View File

@@ -1,17 +0,0 @@
#!/bin/zsh
host=https://api.syui.ai
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
if [ -z "$1" ];then
exit
fi
echo username
read
id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id`
card=7
cp=$(($RANDOM % 1000 + 400))
s=yui
skill=model
st=$s
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\",\"skill\":\"$skill\"}" -sL $host/cards

View File

@@ -1,16 +0,0 @@
#!/bin/zsh
host=https://api.syui.ai
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
if [ -z "$1" ];then
exit
fi
echo username
read
id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id`
card=45
cp=0
s=super
skill=badge
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\",\"skill\":\"$skill\"}" -sL $host/cards

View File

@@ -1,15 +0,0 @@
#!/bin/zsh
host=https://api.syui.ai
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
if [ -z "$1" ];then
exit
fi
echo username
read
id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id`
card=43
cp=0
s=book
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\"}" -sL $host/cards

View File

@@ -1,21 +0,0 @@
#!/bin/zsh
case $OSTYPE in
darwin*)
alias date="/opt/homebrew/bin/gdate"
;;
esac
echo cid
read cid
card_status=book
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"`
book=`echo $data|jq ".[]|select(.book == true)|.book"`
id=`echo $data|jq ".[]|select(.fav != 0)|.id"`
echo $book
curl -X PATCH -H "Content-Type: application/json" -d "{\"status\":\"$card_status\",\"token\":\"$token\"}" $host/cards/$cid

View File

@@ -1,28 +0,0 @@
#!/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))
count=1
for ((i=0;i<=$n;i++))
do
username=`echo $data|jq ".[$i]"|jq -r .username`
uid=`echo $data|jq ".[$i]"|jq -r .id`
acard=`curl -sL "$host/users/$uid/card?itemsPerPage=3000"|jq ".[0]"`
cid=`echo $acard|jq -r .id`
curl -X PATCH -H "Content-Type: application/json" -d "{\"author\":\"$username\", \"count\":$count,\"token\":\"$token\"}" $host/cards/$cid
done

View File

@@ -1,23 +0,0 @@
#!/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"
data=`curl -sL "$host_users"|jq .`
nd=`date +"%Y%m%d"`
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`
echo "{\"next\":\"$nd\"} -s $host/users/$id"
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\",\"token\":\"$token\"}" -s $host/users/$id
done

View File

@@ -1,23 +0,0 @@
#!/bin/zsh
if [ -z "$1" ];then
exit
fi
echo delete-id
read
id=$1
data=`curl -sL "https://api.syui.ai/users/$id/card?itemsPerPage=2550"`
token=`cat ~/.config/atr/api_card.json|jq -r .token`
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
n=`echo $data|jq length`
n=$((n - 1))
for ((i=0;i<=$n;i++))
do
card_id=`echo $data|jq -r ".[$i].id"`
echo $card
curl -X DELETE -H "Content-Type: application/json" -d "{\"owner\":$id,\"password\":\"$pass\"}" https://api.syui.ai/cards/$card_id
done
#curl -X DELETE -H "Content-Type: application/json" https://api.syui.ai/users/$id

View File

@@ -1,20 +0,0 @@
#!/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

View File

@@ -1,29 +0,0 @@
#!/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

View File

@@ -1,33 +0,0 @@
#!/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

View File

@@ -1,24 +0,0 @@
#!/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'`
#updated_at_n=`date --iso-8601=seconds`
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`
echo "{\"updated_at\":\"$updated_at_n\"} -s $host/users/$id"
curl -X PATCH -H "Content-Type: application/json" -d "{\"raid_at\": \"$updated_at_n\",\"updated_at\":\"$updated_at_n\",\"token\":\"$token\",\"ten_at\":\"$updated_at_n\"}" -s $host/users/$id
done

View File

@@ -1,46 +0,0 @@
#!/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 "{\"token\":\"$token\", \"ten_su\": 0}" -s $host/users/$id
else
curl -X PATCH -H "Content-Type: application/json" -d "{\"ten_at\":\"$updated_at_n\", \"token\": \"$token\", \"raid_at\":\"$raid_at_n\"}" -s $host/users/$id
#curl -X PATCH -H "Content-Type: application/json" -d "{\"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"luck_at\": \"$updated_at_n\",\"egg_at\": \"$updated_at_n\", \"token\": \"$token\"}" -s $host/users/$id
#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 "{\"username\":\"$name\",\"id\":\"$id\"}"
if [ $n -ne $i ];then
echo ","
fi
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\", \"luck_at\": \"$now_at\",\"ten_at\":\"$updated_at_n\", \"token\": \"$token\"}" -s $host/users/$id
fi
done

View File

@@ -1,32 +0,0 @@
#!/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'`
#updated_at_n=`date --iso-8601=seconds`
data=`curl -sL "$host_users"|jq .`
while true
do
for ((id=1221;id<=1230;id++))
do
t=`curl -sL $host/users/$id|jq .code`
sleep 3
if [ $t -ne 404 ];then
echo ok
curl -X PATCH -H "Content-Type: application/json" -d "{\"raid_at\": \"$updated_at_n\",\"updated_at\":\"$updated_at_n\",\"token\":\"$token\",\"ten_at\":\"$updated_at_n\"}" -s $host/users/$id
else
echo $t
fi
done
done

View File

@@ -1,20 +0,0 @@
#!/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'`
#updated_at_n=`date --iso-8601=seconds`
data=`curl -sL "$host_users"|jq .`
if [ -z "$1" ];then
exit
fi
id=$1
curl -X PATCH -H "Content-Type: application/json" -d "{\"raid_at\": \"$updated_at_n\",\"updated_at\":\"$updated_at_n\",\"token\":\"$token\",\"ten_at\":\"$updated_at_n\"}" -s $host/users/$id

View File

@@ -1,38 +0,0 @@
#!/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 [ -z "$1" ];then
echo card
read card
else
echo card=$1
read
card=$1
fi
for ((i=0;i<=$n;i++))
do
name=`echo $data|jq ".[$i]"|jq -r .username`
id=`echo $data|jq ".[$i]"|jq -r .id`
data_uu=`curl -sL "$host/users/$id/card?itemsPerPage=4000"`
card_check=`echo $data_uu|jq -r ".[]|select(.card == $card)"`
if [ -n "$card_check" ];then
echo $name
fi
done

View File

@@ -1,69 +0,0 @@
#!/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

View File

@@ -1,83 +0,0 @@
#!/bin/zsh
case $OSTYPE in
darwin*)
alias date="/opt/homebrew/bin/gdate"
;;
esac
username=ai
id=2
host=https://api.syui.ai
token=`cat ~/.config/atr/api_card.json|jq -r .token`
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
host_users="$host/users?itemsPerPage=255"
data=`curl -sL "$host_users"|jq .`
nd=`date +"%Y%m%d"`
nd=20230101
#title=card_patch
#echo $title
#card_id=1
#curl -X PATCH -H "Content-Type: application/json" -d "{\"cp\":1,\"token\":\"$token\"}" $host/cards/$card_id
#read
#
## card pass
echo "\ntest get card (no password)"
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id}" $host/cards
echo "\ntest select card (no password)"
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":0,\"status\":\"normal\",\"cp\":1}" $host/cards
echo "\ntest select card (yes password)"
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":0,\"status\":\"normal\",\"cp\":1,\"password\":\"$pass\"}" $host/cards
## token
echo "\ntest token (no token)"
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"1\"}" -s $host/users/$id
echo "\ntest token (yes token)"
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\",\"token\":\"$token\"}" -s $host/users/$id
exit
read
## users
curl -sL "$host/users?itemsPerPage=2550"|jq .
read
curl -sL "$host/users/$id?itemsPerPage=2550"|jq .
read
curl -sL "$host/users/$id/card?itemsPerPage=2550"|jq .
read
## cards
curl -sL "$host/cards?itemsPerPage=2550"|jq .
read
read
## delete
echo "\ntest delete"
data=`curl -sL https://api.syui.ai/users/$id/card`
n=`echo $data|jq length`
n=$((n - 1))
for ((i=0;i<=$n;i++))
do
card=`echo $data|jq -r ".[$i].id"`
echo "\ncard id : $card"
curl -X DELETE -H "Content-Type: application/json" -d "{'owner':\"$id\"}" $host/cards/$card
done
curl -X DELETE -H "Content-Type: application/json" https://api.syui.ai/users/$id
## card select
echo "\ntest select card (no password)"
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":0,\"status\":\"normal\",\"cp\":1}" $host/cards
echo "\ntest get card (no password)"
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id}" $host/cards
#echo "\ntest get card (yes password)"
#curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"password\":\"$pass\"}" $host/cards
## create user
echo "\ntest create user (no password)"
curl -X POST -H "Content-Type: application/json" -d "{\"username\":\"test\"}" $host/users

View File

@@ -1,13 +0,0 @@
#!/bin/zsh
host=https://api.syui.ai
token=`cat ~/.config/atr/api_card.json|jq -r .token`
username=ai
id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$username\")"|jq -r .id`
curl -sL $host/users/$id
read
echo $id
o=true
echo $o
curl -X PATCH -H "Content-Type: application/json" -d "{\"game\":true, \"game_test\":$o, \"game_end\":$o, \"token\":\"$token\"}" -s $host/users/$id

View File

@@ -1,14 +0,0 @@
#!/bin/zsh
host=https://api.syui.ai
token=`cat ~/.config/atr/api_card.json|jq -r .token`
if [ -z "$1" ];then
exit
fi
echo username
read
id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id`
echo $id
read
curl -X PATCH -H "Content-Type: application/json" -d "{\"model_mode\":1, \"model_skill\":1,\"model_attack\":1,\"model_limit\":1,\"model_critical\":1,\"model_critical_d\":10, \"model\":true,\"token\":\"$token\"}" -s $host/users/$id

View File

@@ -1,33 +0,0 @@
#!/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))
for ((i=0;i<=$n;i++))
do
name=`echo $data|jq ".[$i]"|jq -r .username`
id=`echo $data|jq ".[$i]"|jq -r .id`
model=`echo $data|jq ".[$i]"|jq -r .model`
#echo $model
if [ "$model" = false ];then
card=`curl -sL "$host/users/$id/card?itemsPerPage=2550"|jq -r ".[]|select(.skill == \"model\")"`
if [ -n "$card" ];then
echo "\n[${id}] $name"
curl -X PATCH -H "Content-Type: application/json" -d "{\"model\":true,\"model_limit\": 1,\"token\":\"$token\"}" -s $host/users/$id
fi
fi
done

View File

@@ -1,75 +0,0 @@
#!/bin/zsh
case $OSTYPE in
darwin*)
alias date="/opt/homebrew/bin/gdate"
;;
esac
u=ai
s=normal
host=https://api.syui.ai
token=`cat ~/.config/atr/api_card.json|jq -r .token`
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
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"`
card=0
cp=0
body="next[y]"
id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$u\")"|jq -r .id`
echo $id
#echo no token
#curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"ten_su\": 1, \"luck_at\": \"$now_at\", \"ten_at\": \"$updated_at_n\"}" -s $host/users/$id
#echo $body
#read
#
#echo yes token
#echo $token
#curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"ten_su\": 1, \"luck_at\": \"$now_at\", \"ten_at\": \"$updated_at_n\",\"token\": \"$token\"}" -s $host/users/$id
#echo $body
#read
#
#echo account delete id no token
#curl -X PATCH -H "Content-Type: application/json" -d "{\"delete\":true}" -s $host/users/381
#echo $body
#read
#
#echo account delete id token
#curl -X PATCH -H "Content-Type: application/json" -d "{\"delete\":false,\"token\":\"$token\"}" -s $host/users/381
#echo $body
#read
#
#echo add card no pass
#curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":$card,\"status\":\"$s\",\"cp\":$cp}" -sL $host/cards
#echo $body
#read
#
#echo add card no pass
#echo $id
#curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\"}" -sL $host/cards
#echo $body
#read
#
#echo add user
#curl -X POST -H "Content-Type: application/json" -d "{\"username\":\"test\",\"did\":\"t\"}" -s "$host/users"
#echo $body
#read
#
#echo add user pass
#curl -X POST -H "Content-Type: application/json" -d "{\"username\":\"test\",\"did\":\"t\",\"password\":\"$pass\"}" -s "$host/users"
#echo $body
#read
#echo card draw no pass
#curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id}" -s $host/cards
#echo $body
#read
#
#echo card draw ok pass
#curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"password\":\"$pass\"}" -s $host/cards
#echo $body
#read

View File

@@ -1,18 +0,0 @@
#!/bin/zsh
host=https://api.syui.ai
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
if [ -z "$1" ];then
exit
fi
echo username
read
id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id`
card=0
model=0
sword=0
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":$card, \"model\":$model,\"sword\":$sword,\"password\":\"$pass\"}" -sL $host/ues
curl -sL api.syui.ai/users/$id/ue

View File

@@ -1,21 +0,0 @@
#!/bin/zsh
username=$1
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`
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
host_users="$host/users?itemsPerPage=255"
data=`curl -sL "$host_users"|jq .`
nd=`date +"%Y%m%d"`
nd=20230101
id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id`
echo username did
read
curl -X PATCH -H "Content-Type: application/json" -d "{\"did\":\"$2\",\"token\":\"$token\"}" -s $host/users/$id

View File

@@ -1,37 +0,0 @@
#!/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"
data=`curl -sL "$host_users"|jq .`
n=`echo $data|jq length`
n=$((n - 1))
f=~/ai/card/public/json/user.json
if [ -f $f ];then
rm $f
fi
echo "{" >! $f
for ((i=0;i<=$n;i++))
do
name=`echo $data|jq ".[$i]"|jq -r .username`
id=`echo $data|jq ".[$i]"|jq -r .id`
j="\"$name\":$id"
j="\"$name\":\"$id\""
if [ $n -ne $i ];then
j="${j},"
fi
echo $j
echo $j >> $f
done
echo "}" >> $f
cat $f|jq .

Some files were not shown because too many files have changed in this diff Show More