1
0

name change

This commit is contained in:
syui 2024-02-21 16:06:08 +09:00
parent f7df1224e0
commit 5da7a10ac2
Signed by: syui
GPG Key ID: 5417CFEBAD92DF56
77 changed files with 883 additions and 315 deletions

2
.gitignore vendored
View File

@ -1,4 +1,5 @@
t
api
.env
*.json
*.sqlite
@ -7,4 +8,3 @@ tmp/card_limit.zsh
tmp/card_day.zsh
tmp/card_delete.zsh
memo.md
api

View File

@ -1 +1 @@
web: bin/t
web: bin/api

View File

@ -6,7 +6,18 @@ su=5000
go generate ./...
cp -rf $d/ent/openapi.json $d/tmp/
sed -i '' "s/255/$su/g" $d/ent/ogent/oas_parameters_gen.go
sed -i '' "s/255/$su/g" $d/ent/openapi.json
case $OSTYPE in
darwin*)
sed -i '' "s/255/$su/g" $d/ent/ogent/oas_parameters_gen.go
sed -i '' "s/255/$su/g" $d/ent/openapi.json
;;
linux*)
sed -i "s/255/$su/g" $d/ent/ogent/oas_parameters_gen.go
sed -i "s/255/$su/g" $d/ent/openapi.json
;;
esac
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

View File

@ -3,12 +3,13 @@
package ent
import (
"api/ent/card"
"api/ent/user"
"fmt"
"strings"
"t/ent/card"
"t/ent/user"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
@ -39,8 +40,9 @@ type Card struct {
CreatedAt time.Time `json:"created_at,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the CardQuery when eager-loading is set.
Edges CardEdges `json:"edges"`
user_card *int
Edges CardEdges `json:"edges"`
user_card *int
selectValues sql.SelectValues
}
// CardEdges holds the relations/edges for other nodes in the graph.
@ -79,7 +81,7 @@ func (*Card) scanValues(columns []string) ([]any, error) {
case card.ForeignKeys[0]: // user_card
values[i] = new(sql.NullInt64)
default:
return nil, fmt.Errorf("unexpected column %q for type Card", columns[i])
values[i] = new(sql.UnknownType)
}
}
return values, nil
@ -166,11 +168,19 @@ func (c *Card) assignValues(columns []string, values []any) error {
c.user_card = new(int)
*c.user_card = int(value.Int64)
}
default:
c.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Card.
// This includes values selected through modifiers, order, etc.
func (c *Card) Value(name string) (ent.Value, error) {
return c.selectValues.Get(name)
}
// QueryOwner queries the "owner" edge of the Card entity.
func (c *Card) QueryOwner() *UserQuery {
return NewCardClient(c.config).QueryOwner(c)

View File

@ -4,6 +4,9 @@ package card
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
@ -93,6 +96,80 @@ 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
)
// OrderOption defines the ordering options for the Card queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByPassword orders the results by the password field.
func ByPassword(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPassword, opts...).ToFunc()
}
// ByCard orders the results by the card field.
func ByCard(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCard, opts...).ToFunc()
}
// BySkill orders the results by the skill field.
func BySkill(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSkill, opts...).ToFunc()
}
// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStatus, opts...).ToFunc()
}
// ByToken orders the results by the token field.
func ByToken(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldToken, opts...).ToFunc()
}
// ByCp orders the results by the cp field.
func ByCp(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCp, opts...).ToFunc()
}
// ByURL orders the results by the url field.
func ByURL(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldURL, opts...).ToFunc()
}
// ByCount orders the results by the count field.
func ByCount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCount, opts...).ToFunc()
}
// ByAuthor orders the results by the author field.
func ByAuthor(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAuthor, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByOwnerField orders the results by owner field.
func ByOwnerField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newOwnerStep(), sql.OrderByField(field, opts...))
}
}
func newOwnerStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(OwnerInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn),
)
}

View File

@ -3,7 +3,7 @@
package card
import (
"t/ent/predicate"
"api/ent/predicate"
"time"
"entgo.io/ent/dialect/sql"
@ -759,11 +759,7 @@ func HasOwner() predicate.Card {
// HasOwnerWith applies the HasEdge predicate on the "owner" edge with a given conditions (other predicates).
func HasOwnerWith(preds ...predicate.User) predicate.Card {
return predicate.Card(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(OwnerInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn),
)
step := newOwnerStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)

View File

@ -3,11 +3,11 @@
package ent
import (
"api/ent/card"
"api/ent/user"
"context"
"errors"
"fmt"
"t/ent/card"
"t/ent/user"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
@ -219,6 +219,10 @@ 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)
@ -348,8 +352,8 @@ func (ccb *CardCreateBulk) Save(ctx context.Context) ([]*Card, error) {
return nil, err
}
builder.mutation = mutation
nodes[i], specs[i] = builder.createSpec()
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ccb.builders[i+1].mutation)
} else {

View File

@ -3,9 +3,9 @@
package ent
import (
"api/ent/card"
"api/ent/predicate"
"context"
"t/ent/card"
"t/ent/predicate"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"

View File

@ -3,12 +3,12 @@
package ent
import (
"api/ent/card"
"api/ent/predicate"
"api/ent/user"
"context"
"fmt"
"math"
"t/ent/card"
"t/ent/predicate"
"t/ent/user"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
@ -19,7 +19,7 @@ import (
type CardQuery struct {
config
ctx *QueryContext
order []OrderFunc
order []card.OrderOption
inters []Interceptor
predicates []predicate.Card
withOwner *UserQuery
@ -55,7 +55,7 @@ func (cq *CardQuery) Unique(unique bool) *CardQuery {
}
// Order specifies how the records should be ordered.
func (cq *CardQuery) Order(o ...OrderFunc) *CardQuery {
func (cq *CardQuery) Order(o ...card.OrderOption) *CardQuery {
cq.order = append(cq.order, o...)
return cq
}
@ -271,7 +271,7 @@ func (cq *CardQuery) Clone() *CardQuery {
return &CardQuery{
config: cq.config,
ctx: cq.ctx.Clone(),
order: append([]OrderFunc{}, cq.order...),
order: append([]card.OrderOption{}, cq.order...),
inters: append([]Interceptor{}, cq.inters...),
predicates: append([]predicate.Card{}, cq.predicates...),
withOwner: cq.withOwner.Clone(),

View File

@ -3,12 +3,12 @@
package ent
import (
"api/ent/card"
"api/ent/predicate"
"api/ent/user"
"context"
"errors"
"fmt"
"t/ent/card"
"t/ent/predicate"
"t/ent/user"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"

View File

@ -8,12 +8,12 @@ import (
"fmt"
"log"
"t/ent/migrate"
"api/ent/migrate"
"t/ent/card"
"t/ent/group"
"t/ent/ue"
"t/ent/user"
"api/ent/card"
"api/ent/group"
"api/ent/ue"
"api/ent/user"
"entgo.io/ent"
"entgo.io/ent/dialect"

View File

@ -3,14 +3,15 @@
package ent
import (
"api/ent/card"
"api/ent/group"
"api/ent/ue"
"api/ent/user"
"context"
"errors"
"fmt"
"reflect"
"t/ent/card"
"t/ent/group"
"t/ent/ue"
"t/ent/user"
"sync"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
@ -63,36 +64,32 @@ func NewTxContext(parent context.Context, tx *Tx) context.Context {
}
// OrderFunc applies an ordering on the sql selector.
// Deprecated: Use Asc/Desc functions or the package builders instead.
type OrderFunc func(*sql.Selector)
// columnChecker returns a function indicates if the column exists in the given column.
func columnChecker(table string) func(string) error {
checks := map[string]func(string) bool{
card.Table: card.ValidColumn,
group.Table: group.ValidColumn,
ue.Table: ue.ValidColumn,
user.Table: user.ValidColumn,
}
check, ok := checks[table]
if !ok {
return func(string) error {
return fmt.Errorf("unknown table %q", table)
}
}
return func(column string) error {
if !check(column) {
return fmt.Errorf("unknown column %q for table %q", column, table)
}
return nil
}
var (
initCheck sync.Once
columnCheck sql.ColumnCheck
)
// columnChecker checks if the column exists in the given table.
func checkColumn(table, column string) error {
initCheck.Do(func() {
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
card.Table: card.ValidColumn,
group.Table: group.ValidColumn,
ue.Table: ue.ValidColumn,
user.Table: user.ValidColumn,
})
})
return columnCheck(table, column)
}
// Asc applies the given fields in ASC order.
func Asc(fields ...string) OrderFunc {
func Asc(fields ...string) func(*sql.Selector) {
return func(s *sql.Selector) {
check := columnChecker(s.TableName())
for _, f := range fields {
if err := check(f); err != nil {
if err := checkColumn(s.TableName(), f); err != nil {
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
}
s.OrderBy(sql.Asc(s.C(f)))
@ -101,11 +98,10 @@ func Asc(fields ...string) OrderFunc {
}
// Desc applies the given fields in DESC order.
func Desc(fields ...string) OrderFunc {
func Desc(fields ...string) func(*sql.Selector) {
return func(s *sql.Selector) {
check := columnChecker(s.TableName())
for _, f := range fields {
if err := check(f); err != nil {
if err := checkColumn(s.TableName(), f); err != nil {
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
}
s.OrderBy(sql.Desc(s.C(f)))
@ -137,8 +133,7 @@ func Count() AggregateFunc {
// Max applies the "max" aggregation function on the given field of each group.
func Max(field string) AggregateFunc {
return func(s *sql.Selector) string {
check := columnChecker(s.TableName())
if err := check(field); err != nil {
if err := checkColumn(s.TableName(), field); err != nil {
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
return ""
}
@ -149,8 +144,7 @@ func Max(field string) AggregateFunc {
// Mean applies the "mean" aggregation function on the given field of each group.
func Mean(field string) AggregateFunc {
return func(s *sql.Selector) string {
check := columnChecker(s.TableName())
if err := check(field); err != nil {
if err := checkColumn(s.TableName(), field); err != nil {
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
return ""
}
@ -161,8 +155,7 @@ func Mean(field string) AggregateFunc {
// Min applies the "min" aggregation function on the given field of each group.
func Min(field string) AggregateFunc {
return func(s *sql.Selector) string {
check := columnChecker(s.TableName())
if err := check(field); err != nil {
if err := checkColumn(s.TableName(), field); err != nil {
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
return ""
}
@ -173,8 +166,7 @@ func Min(field string) AggregateFunc {
// Sum applies the "sum" aggregation function on the given field of each group.
func Sum(field string) AggregateFunc {
return func(s *sql.Selector) string {
check := columnChecker(s.TableName())
if err := check(field); err != nil {
if err := checkColumn(s.TableName(), field); err != nil {
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
return ""
}

View File

@ -3,12 +3,12 @@
package enttest
import (
"api/ent"
"context"
"t/ent"
// required by schema hooks.
_ "t/ent/runtime"
_ "api/ent/runtime"
"t/ent/migrate"
"api/ent/migrate"
"entgo.io/ent/dialect/sql/schema"
)

View File

@ -3,10 +3,11 @@
package ent
import (
"api/ent/group"
"fmt"
"strings"
"t/ent/group"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
@ -21,7 +22,8 @@ type Group struct {
Password string `json:"-"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the GroupQuery when eager-loading is set.
Edges GroupEdges `json:"edges"`
Edges GroupEdges `json:"edges"`
selectValues sql.SelectValues
}
// GroupEdges holds the relations/edges for other nodes in the graph.
@ -52,7 +54,7 @@ func (*Group) scanValues(columns []string) ([]any, error) {
case group.FieldName, group.FieldPassword:
values[i] = new(sql.NullString)
default:
return nil, fmt.Errorf("unexpected column %q for type Group", columns[i])
values[i] = new(sql.UnknownType)
}
}
return values, nil
@ -84,11 +86,19 @@ func (gr *Group) assignValues(columns []string, values []any) error {
} else if value.Valid {
gr.Password = value.String
}
default:
gr.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Group.
// This includes values selected through modifiers, order, etc.
func (gr *Group) Value(name string) (ent.Value, error) {
return gr.selectValues.Get(name)
}
// QueryUsers queries the "users" edge of the Group entity.
func (gr *Group) QueryUsers() *UserQuery {
return NewGroupClient(gr.config).QueryUsers(gr)

View File

@ -2,6 +2,11 @@
package group
import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the group type in the database.
Label = "group"
@ -45,3 +50,42 @@ var (
// PasswordValidator is a validator for the "password" field. It is called by the builders before save.
PasswordValidator func(string) error
)
// OrderOption defines the ordering options for the Group queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldName, opts...).ToFunc()
}
// ByPassword orders the results by the password field.
func ByPassword(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPassword, opts...).ToFunc()
}
// ByUsersCount orders the results by users count.
func ByUsersCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newUsersStep(), opts...)
}
}
// ByUsers orders the results by users terms.
func ByUsers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newUsersStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
func newUsersStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(UsersInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, UsersTable, UsersColumn),
)
}

View File

@ -3,7 +3,7 @@
package group
import (
"t/ent/predicate"
"api/ent/predicate"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
@ -208,11 +208,7 @@ func HasUsers() predicate.Group {
// HasUsersWith applies the HasEdge predicate on the "users" edge with a given conditions (other predicates).
func HasUsersWith(preds ...predicate.User) predicate.Group {
return predicate.Group(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(UsersInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, UsersTable, UsersColumn),
)
step := newUsersStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)

View File

@ -3,11 +3,11 @@
package ent
import (
"api/ent/group"
"api/ent/user"
"context"
"errors"
"fmt"
"t/ent/group"
"t/ent/user"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@ -168,8 +168,8 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) {
return nil, err
}
builder.mutation = mutation
nodes[i], specs[i] = builder.createSpec()
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, gcb.builders[i+1].mutation)
} else {

View File

@ -3,9 +3,9 @@
package ent
import (
"api/ent/group"
"api/ent/predicate"
"context"
"t/ent/group"
"t/ent/predicate"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"

View File

@ -3,13 +3,13 @@
package ent
import (
"api/ent/group"
"api/ent/predicate"
"api/ent/user"
"context"
"database/sql/driver"
"fmt"
"math"
"t/ent/group"
"t/ent/predicate"
"t/ent/user"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
@ -20,7 +20,7 @@ import (
type GroupQuery struct {
config
ctx *QueryContext
order []OrderFunc
order []group.OrderOption
inters []Interceptor
predicates []predicate.Group
withUsers *UserQuery
@ -55,7 +55,7 @@ func (gq *GroupQuery) Unique(unique bool) *GroupQuery {
}
// Order specifies how the records should be ordered.
func (gq *GroupQuery) Order(o ...OrderFunc) *GroupQuery {
func (gq *GroupQuery) Order(o ...group.OrderOption) *GroupQuery {
gq.order = append(gq.order, o...)
return gq
}
@ -271,7 +271,7 @@ func (gq *GroupQuery) Clone() *GroupQuery {
return &GroupQuery{
config: gq.config,
ctx: gq.ctx.Clone(),
order: append([]OrderFunc{}, gq.order...),
order: append([]group.OrderOption{}, gq.order...),
inters: append([]Interceptor{}, gq.inters...),
predicates: append([]predicate.Group{}, gq.predicates...),
withUsers: gq.withUsers.Clone(),
@ -414,7 +414,7 @@ func (gq *GroupQuery) loadUsers(ctx context.Context, query *UserQuery, nodes []*
}
query.withFKs = true
query.Where(predicate.User(func(s *sql.Selector) {
s.Where(sql.InValues(group.UsersColumn, fks...))
s.Where(sql.InValues(s.C(group.UsersColumn), fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
@ -427,7 +427,7 @@ func (gq *GroupQuery) loadUsers(ctx context.Context, query *UserQuery, nodes []*
}
node, ok := nodeids[*fk]
if !ok {
return fmt.Errorf(`unexpected foreign-key "group_users" returned %v for node %v`, *fk, n.ID)
return fmt.Errorf(`unexpected referenced foreign-key "group_users" returned %v for node %v`, *fk, n.ID)
}
assign(node, n)
}

View File

@ -3,12 +3,12 @@
package ent
import (
"api/ent/group"
"api/ent/predicate"
"api/ent/user"
"context"
"errors"
"fmt"
"t/ent/group"
"t/ent/predicate"
"t/ent/user"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"

View File

@ -3,9 +3,9 @@
package hook
import (
"api/ent"
"context"
"fmt"
"t/ent"
)
// The CardFunc type is an adapter to allow the use of ordinary

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},
{Name: "author", Type: field.TypeString, Nullable: true, Default: "yui"},
{Name: "created_at", Type: field.TypeTime, Nullable: true},
{Name: "user_card", Type: field.TypeInt},
}
@ -129,7 +129,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: "20240213"},
{Name: "next", Type: field.TypeString, Nullable: true, Default: "20240221"},
{Name: "room", Type: field.TypeInt, Nullable: true},
{Name: "model", Type: field.TypeBool, Nullable: true},
{Name: "model_at", Type: field.TypeTime, Nullable: true},

View File

@ -3,15 +3,15 @@
package ent
import (
"api/ent/card"
"api/ent/group"
"api/ent/predicate"
"api/ent/ue"
"api/ent/user"
"context"
"errors"
"fmt"
"sync"
"t/ent/card"
"t/ent/group"
"t/ent/predicate"
"t/ent/ue"
"t/ent/user"
"time"
"entgo.io/ent"

View File

@ -6,11 +6,11 @@ import (
"context"
"net/http"
"t/ent"
"t/ent/card"
"t/ent/group"
"t/ent/ue"
"t/ent/user"
"api/ent"
"api/ent/card"
"api/ent/group"
"api/ent/ue"
"api/ent/user"
"os"
"github.com/go-faster/jx"
)
@ -198,8 +198,8 @@ func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, param
// DeleteCard handles DELETE /cards/{id} requests.
func (h *OgentHandler) DeleteCard(ctx context.Context, params DeleteCardParams) (DeleteCardRes, error) {
err := h.client.Card.DeleteOneID(params.ID).Exec(ctx)
//err := h.client.Card.DeleteOneID(0).Exec(ctx)
//err := h.client.Card.DeleteOneID(params.ID).Exec(ctx)
err := h.client.Card.DeleteOneID(0).Exec(ctx)
if err != nil {
switch {
case ent.IsNotFound(err):

View File

@ -2,7 +2,7 @@
package ogent
import "t/ent"
import "api/ent"
func NewCardCreate(e *ent.Card) *CardCreate {
if e == nil {

View File

@ -1,13 +1,18 @@
// +build tools
// +build tools
// +build tools
// +build tools
// +build tools
// Code generated by ent, DO NOT EDIT.
package ent
import (
"t/ent/card"
"t/ent/group"
"t/ent/schema"
"t/ent/ue"
"t/ent/user"
"api/ent/card"
"api/ent/group"
"api/ent/schema"
"api/ent/ue"
"api/ent/user"
"time"
)
@ -41,6 +46,10 @@ 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.

View File

@ -2,9 +2,9 @@
package runtime
// The schema-stitching logic is generated in t/ent/runtime.go
// The schema-stitching logic is generated in api/ent/runtime.go
const (
Version = "v0.11.10" // Version of ent codegen.
Sum = "h1:iqn32ybY5HRW3xSAyMNdNKpZhKgMf1Zunsej9yPKUI8=" // Sum of ent codegen.
Version = "v0.12.2" // Version of ent codegen.
Sum = "h1:Ndl/JvCX76xCtUDlrUfMnOKBRodAtxE5yfGYxjbOxmM=" // Sum of ent codegen.
)

View File

@ -3,12 +3,13 @@
package ent
import (
"api/ent/ue"
"api/ent/user"
"fmt"
"strings"
"t/ent/ue"
"t/ent/user"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
@ -57,8 +58,9 @@ type Ue struct {
CreatedAt time.Time `json:"created_at,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the UeQuery when eager-loading is set.
Edges UeEdges `json:"edges"`
user_ue *int
Edges UeEdges `json:"edges"`
user_ue *int
selectValues sql.SelectValues
}
// UeEdges holds the relations/edges for other nodes in the graph.
@ -99,7 +101,7 @@ func (*Ue) scanValues(columns []string) ([]any, error) {
case ue.ForeignKeys[0]: // user_ue
values[i] = new(sql.NullInt64)
default:
return nil, fmt.Errorf("unexpected column %q for type Ue", columns[i])
values[i] = new(sql.UnknownType)
}
}
return values, nil
@ -240,11 +242,19 @@ func (u *Ue) assignValues(columns []string, values []any) error {
u.user_ue = new(int)
*u.user_ue = int(value.Int64)
}
default:
u.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Ue.
// This includes values selected through modifiers, order, etc.
func (u *Ue) Value(name string) (ent.Value, error) {
return u.selectValues.Get(name)
}
// QueryOwner queries the "owner" edge of the Ue entity.
func (u *Ue) QueryOwner() *UserQuery {
return NewUeClient(u.config).QueryOwner(u)

View File

@ -4,6 +4,9 @@ package ue
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
@ -119,3 +122,120 @@ var (
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
)
// OrderOption defines the ordering options for the Ue queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByLimit orders the results by the limit field.
func ByLimit(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLimit, opts...).ToFunc()
}
// ByLimitBoss orders the results by the limit_boss field.
func ByLimitBoss(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLimitBoss, opts...).ToFunc()
}
// ByLimitItem orders the results by the limit_item field.
func ByLimitItem(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLimitItem, opts...).ToFunc()
}
// ByPassword orders the results by the password field.
func ByPassword(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPassword, opts...).ToFunc()
}
// ByLv orders the results by the lv field.
func ByLv(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLv, opts...).ToFunc()
}
// ByLvPoint orders the results by the lv_point field.
func ByLvPoint(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLvPoint, opts...).ToFunc()
}
// ByModel orders the results by the model field.
func ByModel(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldModel, opts...).ToFunc()
}
// BySword orders the results by the sword field.
func BySword(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSword, opts...).ToFunc()
}
// ByCard orders the results by the card field.
func ByCard(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCard, opts...).ToFunc()
}
// ByMode orders the results by the mode field.
func ByMode(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMode, opts...).ToFunc()
}
// ByToken orders the results by the token field.
func ByToken(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldToken, opts...).ToFunc()
}
// ByCp orders the results by the cp field.
func ByCp(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCp, opts...).ToFunc()
}
// ByCount orders the results by the count field.
func ByCount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCount, opts...).ToFunc()
}
// ByLocationX orders the results by the location_x field.
func ByLocationX(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLocationX, opts...).ToFunc()
}
// ByLocationY orders the results by the location_y field.
func ByLocationY(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLocationY, opts...).ToFunc()
}
// ByLocationZ orders the results by the location_z field.
func ByLocationZ(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLocationZ, opts...).ToFunc()
}
// ByLocationN orders the results by the location_n field.
func ByLocationN(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLocationN, opts...).ToFunc()
}
// ByAuthor orders the results by the author field.
func ByAuthor(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAuthor, opts...).ToFunc()
}
// 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),
)
}

View File

@ -3,7 +3,7 @@
package ue
import (
"t/ent/predicate"
"api/ent/predicate"
"time"
"entgo.io/ent/dialect/sql"
@ -1114,11 +1114,7 @@ func HasOwner() predicate.Ue {
// HasOwnerWith applies the HasEdge predicate on the "owner" edge with a given conditions (other predicates).
func HasOwnerWith(preds ...predicate.User) predicate.Ue {
return predicate.Ue(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(OwnerInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn),
)
step := newOwnerStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)

View File

@ -3,11 +3,11 @@
package ent
import (
"api/ent/ue"
"api/ent/user"
"context"
"errors"
"fmt"
"t/ent/ue"
"t/ent/user"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
@ -502,8 +502,8 @@ func (ucb *UeCreateBulk) Save(ctx context.Context) ([]*Ue, error) {
return nil, err
}
builder.mutation = mutation
nodes[i], specs[i] = builder.createSpec()
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation)
} else {

View File

@ -3,9 +3,9 @@
package ent
import (
"api/ent/predicate"
"api/ent/ue"
"context"
"t/ent/predicate"
"t/ent/ue"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"

View File

@ -3,12 +3,12 @@
package ent
import (
"api/ent/predicate"
"api/ent/ue"
"api/ent/user"
"context"
"fmt"
"math"
"t/ent/predicate"
"t/ent/ue"
"t/ent/user"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
@ -19,7 +19,7 @@ import (
type UeQuery struct {
config
ctx *QueryContext
order []OrderFunc
order []ue.OrderOption
inters []Interceptor
predicates []predicate.Ue
withOwner *UserQuery
@ -55,7 +55,7 @@ func (uq *UeQuery) Unique(unique bool) *UeQuery {
}
// Order specifies how the records should be ordered.
func (uq *UeQuery) Order(o ...OrderFunc) *UeQuery {
func (uq *UeQuery) Order(o ...ue.OrderOption) *UeQuery {
uq.order = append(uq.order, o...)
return uq
}
@ -271,7 +271,7 @@ func (uq *UeQuery) Clone() *UeQuery {
return &UeQuery{
config: uq.config,
ctx: uq.ctx.Clone(),
order: append([]OrderFunc{}, uq.order...),
order: append([]ue.OrderOption{}, uq.order...),
inters: append([]Interceptor{}, uq.inters...),
predicates: append([]predicate.Ue{}, uq.predicates...),
withOwner: uq.withOwner.Clone(),

View File

@ -3,12 +3,12 @@
package ent
import (
"api/ent/predicate"
"api/ent/ue"
"api/ent/user"
"context"
"errors"
"fmt"
"t/ent/predicate"
"t/ent/ue"
"t/ent/user"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"

View File

@ -3,11 +3,12 @@
package ent
import (
"api/ent/user"
"fmt"
"strings"
"t/ent/user"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
@ -112,8 +113,9 @@ type User struct {
GameLv int `json:"game_lv,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the UserQuery when eager-loading is set.
Edges UserEdges `json:"edges"`
group_users *int
Edges UserEdges `json:"edges"`
group_users *int
selectValues sql.SelectValues
}
// UserEdges holds the relations/edges for other nodes in the graph.
@ -161,7 +163,7 @@ func (*User) scanValues(columns []string) ([]any, error) {
case user.ForeignKeys[0]: // group_users
values[i] = new(sql.NullInt64)
default:
return nil, fmt.Errorf("unexpected column %q for type User", columns[i])
values[i] = new(sql.UnknownType)
}
}
return values, nil
@ -470,11 +472,19 @@ func (u *User) assignValues(columns []string, values []any) error {
u.group_users = new(int)
*u.group_users = int(value.Int64)
}
default:
u.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the User.
// This includes values selected through modifiers, order, etc.
func (u *User) Value(name string) (ent.Value, error) {
return u.selectValues.Get(name)
}
// QueryCard queries the "card" edge of the User entity.
func (u *User) QueryCard() *CardQuery {
return NewUserClient(u.config).QueryCard(u)

View File

@ -4,6 +4,9 @@ package user
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
@ -250,3 +253,288 @@ var (
// DefaultGameAccount holds the default value on creation for the "game_account" field.
DefaultGameAccount bool
)
// OrderOption defines the ordering options for the User queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByUsername orders the results by the username field.
func ByUsername(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUsername, opts...).ToFunc()
}
// ByDid orders the results by the did field.
func ByDid(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDid, opts...).ToFunc()
}
// ByMember orders the results by the member field.
func ByMember(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMember, opts...).ToFunc()
}
// ByBook orders the results by the book field.
func ByBook(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldBook, opts...).ToFunc()
}
// ByManga orders the results by the manga field.
func ByManga(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldManga, opts...).ToFunc()
}
// ByBadge orders the results by the badge field.
func ByBadge(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldBadge, opts...).ToFunc()
}
// ByBsky orders the results by the bsky field.
func ByBsky(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldBsky, opts...).ToFunc()
}
// ByMastodon orders the results by the mastodon field.
func ByMastodon(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMastodon, opts...).ToFunc()
}
// ByDelete orders the results by the delete field.
func ByDelete(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDelete, opts...).ToFunc()
}
// ByHandle orders the results by the handle field.
func ByHandle(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldHandle, opts...).ToFunc()
}
// ByToken orders the results by the token field.
func ByToken(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldToken, opts...).ToFunc()
}
// ByPassword orders the results by the password field.
func ByPassword(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPassword, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByUpdatedAt orders the results by the updated_at field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}
// ByRaidAt orders the results by the raid_at field.
func ByRaidAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRaidAt, opts...).ToFunc()
}
// ByServerAt orders the results by the server_at field.
func ByServerAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldServerAt, opts...).ToFunc()
}
// ByEggAt orders the results by the egg_at field.
func ByEggAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldEggAt, opts...).ToFunc()
}
// ByLuck orders the results by the luck field.
func ByLuck(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLuck, opts...).ToFunc()
}
// ByLuckAt orders the results by the luck_at field.
func ByLuckAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLuckAt, opts...).ToFunc()
}
// ByLike orders the results by the like field.
func ByLike(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLike, opts...).ToFunc()
}
// ByLikeRank orders the results by the like_rank field.
func ByLikeRank(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLikeRank, opts...).ToFunc()
}
// ByLikeAt orders the results by the like_at field.
func ByLikeAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLikeAt, opts...).ToFunc()
}
// ByFav orders the results by the fav field.
func ByFav(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldFav, opts...).ToFunc()
}
// ByTen orders the results by the ten field.
func ByTen(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTen, opts...).ToFunc()
}
// ByTenSu orders the results by the ten_su field.
func ByTenSu(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTenSu, opts...).ToFunc()
}
// ByTenKai orders the results by the ten_kai field.
func ByTenKai(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTenKai, opts...).ToFunc()
}
// ByAiten orders the results by the aiten field.
func ByAiten(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAiten, opts...).ToFunc()
}
// ByTenCard orders the results by the ten_card field.
func ByTenCard(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTenCard, opts...).ToFunc()
}
// ByTenDelete orders the results by the ten_delete field.
func ByTenDelete(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTenDelete, opts...).ToFunc()
}
// ByTenPost orders the results by the ten_post field.
func ByTenPost(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTenPost, opts...).ToFunc()
}
// ByTenGet orders the results by the ten_get field.
func ByTenGet(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTenGet, opts...).ToFunc()
}
// ByTenAt orders the results by the ten_at field.
func ByTenAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTenAt, opts...).ToFunc()
}
// ByNext orders the results by the next field.
func ByNext(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldNext, opts...).ToFunc()
}
// ByRoom orders the results by the room field.
func ByRoom(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRoom, opts...).ToFunc()
}
// ByModel orders the results by the model field.
func ByModel(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldModel, opts...).ToFunc()
}
// ByModelAt orders the results by the model_at field.
func ByModelAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldModelAt, opts...).ToFunc()
}
// ByModelAttack orders the results by the model_attack field.
func ByModelAttack(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldModelAttack, opts...).ToFunc()
}
// ByModelLimit orders the results by the model_limit field.
func ByModelLimit(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldModelLimit, opts...).ToFunc()
}
// ByModelSkill orders the results by the model_skill field.
func ByModelSkill(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldModelSkill, opts...).ToFunc()
}
// ByModelMode orders the results by the model_mode field.
func ByModelMode(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldModelMode, opts...).ToFunc()
}
// ByModelCritical orders the results by the model_critical field.
func ByModelCritical(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldModelCritical, opts...).ToFunc()
}
// ByModelCriticalD orders the results by the model_critical_d field.
func ByModelCriticalD(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldModelCriticalD, opts...).ToFunc()
}
// ByGame orders the results by the game field.
func ByGame(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldGame, opts...).ToFunc()
}
// ByGameTest orders the results by the game_test field.
func ByGameTest(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldGameTest, opts...).ToFunc()
}
// ByGameEnd orders the results by the game_end field.
func ByGameEnd(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldGameEnd, opts...).ToFunc()
}
// ByGameAccount orders the results by the game_account field.
func ByGameAccount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldGameAccount, opts...).ToFunc()
}
// ByGameLv orders the results by the game_lv field.
func ByGameLv(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldGameLv, opts...).ToFunc()
}
// ByCardCount orders the results by card count.
func ByCardCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newCardStep(), opts...)
}
}
// ByCard orders the results by card terms.
func ByCard(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newCardStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByUeCount orders the results by ue count.
func ByUeCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newUeStep(), opts...)
}
}
// ByUe orders the results by ue terms.
func ByUe(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newUeStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
func newCardStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(CardInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, CardTable, CardColumn),
)
}
func newUeStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(UeInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, UeTable, UeColumn),
)
}

View File

@ -3,7 +3,7 @@
package user
import (
"t/ent/predicate"
"api/ent/predicate"
"time"
"entgo.io/ent/dialect/sql"
@ -2439,11 +2439,7 @@ func HasCard() predicate.User {
// HasCardWith applies the HasEdge predicate on the "card" edge with a given conditions (other predicates).
func HasCardWith(preds ...predicate.Card) predicate.User {
return predicate.User(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(CardInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, CardTable, CardColumn),
)
step := newCardStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
@ -2466,11 +2462,7 @@ func HasUe() predicate.User {
// HasUeWith applies the HasEdge predicate on the "ue" edge with a given conditions (other predicates).
func HasUeWith(preds ...predicate.Ue) predicate.User {
return predicate.User(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(UeInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, UeTable, UeColumn),
)
step := newUeStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)

View File

@ -3,12 +3,12 @@
package ent
import (
"api/ent/card"
"api/ent/ue"
"api/ent/user"
"context"
"errors"
"fmt"
"t/ent/card"
"t/ent/ue"
"t/ent/user"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
@ -1110,8 +1110,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
return nil, err
}
builder.mutation = mutation
nodes[i], specs[i] = builder.createSpec()
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation)
} else {

View File

@ -3,9 +3,9 @@
package ent
import (
"api/ent/predicate"
"api/ent/user"
"context"
"t/ent/predicate"
"t/ent/user"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"

View File

@ -3,14 +3,14 @@
package ent
import (
"api/ent/card"
"api/ent/predicate"
"api/ent/ue"
"api/ent/user"
"context"
"database/sql/driver"
"fmt"
"math"
"t/ent/card"
"t/ent/predicate"
"t/ent/ue"
"t/ent/user"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
@ -21,7 +21,7 @@ import (
type UserQuery struct {
config
ctx *QueryContext
order []OrderFunc
order []user.OrderOption
inters []Interceptor
predicates []predicate.User
withCard *CardQuery
@ -58,7 +58,7 @@ func (uq *UserQuery) Unique(unique bool) *UserQuery {
}
// Order specifies how the records should be ordered.
func (uq *UserQuery) Order(o ...OrderFunc) *UserQuery {
func (uq *UserQuery) Order(o ...user.OrderOption) *UserQuery {
uq.order = append(uq.order, o...)
return uq
}
@ -296,7 +296,7 @@ func (uq *UserQuery) Clone() *UserQuery {
return &UserQuery{
config: uq.config,
ctx: uq.ctx.Clone(),
order: append([]OrderFunc{}, uq.order...),
order: append([]user.OrderOption{}, uq.order...),
inters: append([]Interceptor{}, uq.inters...),
predicates: append([]predicate.User{}, uq.predicates...),
withCard: uq.withCard.Clone(),
@ -463,7 +463,7 @@ func (uq *UserQuery) loadCard(ctx context.Context, query *CardQuery, nodes []*Us
}
query.withFKs = true
query.Where(predicate.Card(func(s *sql.Selector) {
s.Where(sql.InValues(user.CardColumn, fks...))
s.Where(sql.InValues(s.C(user.CardColumn), fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
@ -476,7 +476,7 @@ func (uq *UserQuery) loadCard(ctx context.Context, query *CardQuery, nodes []*Us
}
node, ok := nodeids[*fk]
if !ok {
return fmt.Errorf(`unexpected foreign-key "user_card" returned %v for node %v`, *fk, n.ID)
return fmt.Errorf(`unexpected referenced foreign-key "user_card" returned %v for node %v`, *fk, n.ID)
}
assign(node, n)
}
@ -494,7 +494,7 @@ func (uq *UserQuery) loadUe(ctx context.Context, query *UeQuery, nodes []*User,
}
query.withFKs = true
query.Where(predicate.Ue(func(s *sql.Selector) {
s.Where(sql.InValues(user.UeColumn, fks...))
s.Where(sql.InValues(s.C(user.UeColumn), fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
@ -507,7 +507,7 @@ func (uq *UserQuery) loadUe(ctx context.Context, query *UeQuery, nodes []*User,
}
node, ok := nodeids[*fk]
if !ok {
return fmt.Errorf(`unexpected foreign-key "user_ue" returned %v for node %v`, *fk, n.ID)
return fmt.Errorf(`unexpected referenced foreign-key "user_ue" returned %v for node %v`, *fk, n.ID)
}
assign(node, n)
}

View File

@ -3,13 +3,13 @@
package ent
import (
"api/ent/card"
"api/ent/predicate"
"api/ent/ue"
"api/ent/user"
"context"
"errors"
"fmt"
"t/ent/card"
"t/ent/predicate"
"t/ent/ue"
"t/ent/user"
"time"
"entgo.io/ent/dialect/sql"

29
go.mod
View File

@ -1,15 +1,16 @@
module t
module api
go 1.19
go 1.21
toolchain go1.21.7
//replace ariga.io/ogent => ../../
require (
entgo.io/ent v0.11.10
entgo.io/ent v0.12.2
github.com/go-faster/errors v0.6.1
github.com/go-faster/jx v0.42.0-alpha.1
github.com/mattn/go-sqlite3 v1.14.16
github.com/mazen160/go-random v0.0.0-20210308102632-d2b501c85c03
github.com/ogen-go/ogen v0.59.0
go.opentelemetry.io/otel v1.13.0
go.opentelemetry.io/otel/metric v0.36.0
@ -18,10 +19,9 @@ require (
)
require (
ariga.io/atlas v0.9.2-0.20230303073438-03a4779a6338 // indirect
ariga.io/entviz v0.0.0-20230125130633-6c9be8e08c7c // indirect
ariga.io/ogent v0.0.0-20230309073626-8dc564a6a73e // indirect
entgo.io/contrib v0.3.5 // indirect
ariga.io/atlas v0.10.0 // indirect
ariga.io/ogent v0.0.0-20230621041143-ed3e5d4da458 // indirect
entgo.io/contrib v0.4.5 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/dlclark/regexp2 v1.8.0 // indirect
@ -31,28 +31,21 @@ require (
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/inflect v0.19.0 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/hcl/v2 v2.15.0 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/kyokomi/lottery v1.2.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/stoewer/go-strcase v1.2.0 // indirect
github.com/zclconf/go-cty v1.12.1 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/exp v0.0.0-20230206171751-46f607a40771 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/tools v0.6.1-0.20230222164832-25d2519c8696 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

83
go.sum
View File

@ -1,24 +1,23 @@
ariga.io/atlas v0.9.1 h1:EpoPMnwsQG0vn9c0sYExpwSYtr7bvuSUXzQclU2pMjc=
ariga.io/atlas v0.9.1/go.mod h1:T230JFcENj4ZZzMkZrXFDSkv+2kXkUgpJ5FQQ5hMcKU=
ariga.io/atlas v0.9.2-0.20230303073438-03a4779a6338 h1:8kmSV3mbQKn0niZ/EdE11uhFvFKiW1VlaqVBIYOyahM=
ariga.io/atlas v0.9.2-0.20230303073438-03a4779a6338/go.mod h1:T230JFcENj4ZZzMkZrXFDSkv+2kXkUgpJ5FQQ5hMcKU=
ariga.io/entviz v0.0.0-20230125130633-6c9be8e08c7c h1:7FbOjKKWKqD7FZXQq3qWcRlvGFO1LGYvVZIWQ2D9Evs=
ariga.io/entviz v0.0.0-20230125130633-6c9be8e08c7c/go.mod h1:wArXZPqbbWBcOmkqwmIF6hIcW+3T1NLDde0iRhW6an8=
ariga.io/ogent v0.0.0-20230309073626-8dc564a6a73e h1:8mxC+4Y7pVKgfoUJIMdChrS95d+TcJ6xuhw49nVYIAY=
ariga.io/ogent v0.0.0-20230309073626-8dc564a6a73e/go.mod h1:95vCbvAYAW6NsWUrSL23k2SQykuf/yjellmwV1X+svI=
entgo.io/contrib v0.3.5 h1:wY85TgRp3j5ix/SZ9IE6Ob5lObHFmVUYH0ZFw1D5Hzc=
entgo.io/contrib v0.3.5/go.mod h1:R5HiFszVD8OVOZKFGRbqYogRxK7z1ruzWyEEesjQwE0=
entgo.io/ent v0.11.9 h1:dbbCkAiPVTRBIJwoZctiSYjB7zxQIBOzVSU5H9VYIQI=
entgo.io/ent v0.11.9/go.mod h1:KWHOcDZn1xk3mz3ipWdKrQpMvwqa/9B69TUuAPP9W6g=
ariga.io/atlas v0.10.0 h1:B1aCP6gSDQET6j8ybn7m6MArjQuoLH5d4DQBT+NP5k8=
ariga.io/atlas v0.10.0/go.mod h1:+TR129FJZ5Lvzms6dvCeGWh1yR6hMvmXBhug4hrNIGk=
ariga.io/ogent v0.0.0-20230621041143-ed3e5d4da458 h1:FShFeMszKX8VcySiTRgshmj98jQWMv2GjQgMJcHJJi4=
ariga.io/ogent v0.0.0-20230621041143-ed3e5d4da458/go.mod h1:95vCbvAYAW6NsWUrSL23k2SQykuf/yjellmwV1X+svI=
entgo.io/contrib v0.4.5 h1:BFaOHwFLE8WZjVJadP0XHCIaxgcC1BAtUvAyw7M/GHk=
entgo.io/contrib v0.4.5/go.mod h1:wpZyq2DJgthugFvDBlaqMXj9mV4/9ebyGEn7xlTVQqE=
entgo.io/ent v0.11.10 h1:iqn32ybY5HRW3xSAyMNdNKpZhKgMf1Zunsej9yPKUI8=
entgo.io/ent v0.11.10/go.mod h1:mzTZ0trE+jCQw/fnzijbm5Mck/l8Gbg7gC/+L1COyzM=
entgo.io/ent v0.12.2 h1:Ndl/JvCX76xCtUDlrUfMnOKBRodAtxE5yfGYxjbOxmM=
entgo.io/ent v0.12.2/go.mod h1:OA1Y5bNE8EtlxKv4IyzWwt4jgvGbkoKMcwp668iEKQE=
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
github.com/Khan/genqlient v0.5.0 h1:TMZJ+tl/BpbmGyIBiXzKzUftDhw4ZWxQZ+1ydn0gyII=
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@ -41,60 +40,48 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4=
github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4=
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/hcl/v2 v2.15.0 h1:CPDXO6+uORPjKflkWCCwoWc9uRp+zSIPcCQ+BrxV7m8=
github.com/hashicorp/hcl/v2 v2.15.0/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4=
github.com/kyokomi/lottery v1.2.0 h1:oW9YxYv5j/nu/Kkf8K5tu7Vn8dAoZTjluDxihTPX/68=
github.com/kyokomi/lottery v1.2.0/go.mod h1:TkKpJrFrOJNHpblUqYu0bAQWil3NMwKMBluHyqFfU6Y=
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/mazen160/go-random v0.0.0-20210308102632-d2b501c85c03 h1:iM7JTVzKOYKWjzhGcgHAgFVQt5QfiHIVrRUaWPfh0Q4=
github.com/mazen160/go-random v0.0.0-20210308102632-d2b501c85c03/go.mod h1:APoDd0B2pYeB5kU/g7Mw14mFsljp5HfzrC7arsKbi8U=
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
github.com/ogen-go/ogen v0.59.0 h1:9aSSZ1KCLJIcRyjkO7IHrG0vAI6l1BO877LwTbMcX+k=
github.com/ogen-go/ogen v0.59.0/go.mod h1:0MHLcWEbxwdvR+R9E05paQSRh/2vHtVSJgKqmwYyW8M=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU=
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/vektah/gqlparser/v2 v2.4.5 h1:C02NsyEsL4TXJB7ndonqTfuQOL4XPIu0aAWugdmTgmc=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY=
github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA=
go.opentelemetry.io/otel v1.13.0 h1:1ZAKnNQKwBBxFtww/GwxNUyTf0AxkZzrukO8MeXqe4Y=
@ -106,47 +93,32 @@ go.opentelemetry.io/otel/trace v1.13.0/go.mod h1:muCvmmO9KKpvuXSf3KKAXXB2ygNYHQ+
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20230206171751-46f607a40771 h1:xP7rWLUr1e1n2xkK5YB4LI0hPEy3LJC6Wk+D4pGlOJg=
golang.org/x/exp v0.0.0-20230206171751-46f607a40771/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs=
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.6.1-0.20230222164832-25d2519c8696 h1:8985/C5IvACpd9DDXckSnjSBLKDgbxXiyODgi94zOPM=
golang.org/x/tools v0.6.1-0.20230222164832-25d2519c8696/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4=
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@ -155,3 +127,4 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -5,8 +5,8 @@ import (
"log"
"net/http"
"t/ent"
"t/ent/ogent"
"api/ent"
"api/ent/ogent"
"entgo.io/ent/dialect"
_ "github.com/mattn/go-sqlite3"
"entgo.io/ent/dialect/sql/schema"
@ -52,7 +52,6 @@ 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

@ -1,3 +0,0 @@
#!/bin/zsh
d=${0:a:h}
PASS=`cat token.json|jq -r .password` go run -mod=mod main.go

View File

@ -27,6 +27,5 @@ do
s=`echo $data|jq -r ".[$i].status"`
cp=`echo $data|jq -r ".[$i].cp"`
skill=`echo $data|jq -r ".[$i].skill"`
author=`echo $data|jq -r ".[$i].author"`
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id_n,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\",\"skill\":\"$skill\",\"author\":\"$author\"}" -sL $host/cards
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

@ -15,6 +15,5 @@ else
s=true
fi
token=`cat ~/.config/atr/api_card.json|jq -r .token`
curl -X PATCH -H "Content-Type: application/json" -d "{\"delete\":$s,\"token\":\"$token\"}" -s $host/users/$id

23
scpt/card_day.zsh Executable file
View File

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

23
scpt/card_delete.zsh Executable file
View File

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

24
scpt/card_limit.zsh Executable file
View File

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

14
scpt/model_account.zsh Executable file
View File

@ -0,0 +1,14 @@
#!/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,17 +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
curl -X PATCH -H "Content-Type: application/json" -d "{\"model_critical\":1, \"token\":\"$token\"}" -s $host/users/$id

View File

@ -6,11 +6,11 @@ import (
"context"
"net/http"
"t/ent"
"t/ent/card"
"t/ent/group"
"t/ent/ue"
"t/ent/user"
"api/ent"
"api/ent/card"
"api/ent/group"
"api/ent/ue"
"api/ent/user"
"os"
"github.com/go-faster/jx"
)
@ -198,8 +198,8 @@ func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, param
// DeleteCard handles DELETE /cards/{id} requests.
func (h *OgentHandler) DeleteCard(ctx context.Context, params DeleteCardParams) (DeleteCardRes, error) {
err := h.client.Card.DeleteOneID(params.ID).Exec(ctx)
//err := h.client.Card.DeleteOneID(0).Exec(ctx)
//err := h.client.Card.DeleteOneID(params.ID).Exec(ctx)
err := h.client.Card.DeleteOneID(0).Exec(ctx)
if err != nil {
switch {
case ent.IsNotFound(err):

View File

@ -1,24 +0,0 @@
#!/bin/zsh
host=https://api.syui.ai
uid=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id`
did=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .did`
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
card=36
cp=`echo $(($RANDOM % 1000 + 400))`
s=$(($RANDOM % 7))
if [ $s -eq 1 ];then
s=super
skill=post
plus=$(($RANDOM % 1000 + 300))
cp=$((cp + plus))
else
s=normal
skill=ten
fi
tmp=`curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$uid,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\",\"skill\":\"$skill\"}" -sL $host/cards`
card=`echo $tmp|jq -r .card`
cp=`echo $tmp|jq -r .cp`
body="[card]\nid : $card\ncp : $cp"
atr @ $did -p "`echo $body`"