2283 lines
79 KiB
Go
2283 lines
79 KiB
Go
// ENT数据库文件,请勿编辑。
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"log"
|
|
"reflect"
|
|
|
|
"likedream-goframe/internal/ent/migrate"
|
|
|
|
"likedream-goframe/internal/ent/cpimage"
|
|
"likedream-goframe/internal/ent/cpschool"
|
|
"likedream-goframe/internal/ent/cptask"
|
|
"likedream-goframe/internal/ent/cptasklog"
|
|
"likedream-goframe/internal/ent/cpuser"
|
|
"likedream-goframe/internal/ent/sysagent"
|
|
"likedream-goframe/internal/ent/syscard"
|
|
"likedream-goframe/internal/ent/sysmenu"
|
|
"likedream-goframe/internal/ent/sysrole"
|
|
"likedream-goframe/internal/ent/sysuser"
|
|
"likedream-goframe/internal/ent/sysuserlog"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect"
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
)
|
|
|
|
// Client is the client that holds all ent builders.
|
|
type Client struct {
|
|
config
|
|
// Schema is the client for creating, migrating and dropping schema.
|
|
Schema *migrate.Schema
|
|
// CpImage is the client for interacting with the CpImage builders.
|
|
CpImage *CpImageClient
|
|
// CpSchool is the client for interacting with the CpSchool builders.
|
|
CpSchool *CpSchoolClient
|
|
// CpTask is the client for interacting with the CpTask builders.
|
|
CpTask *CpTaskClient
|
|
// CpTaskLog is the client for interacting with the CpTaskLog builders.
|
|
CpTaskLog *CpTaskLogClient
|
|
// CpUser is the client for interacting with the CpUser builders.
|
|
CpUser *CpUserClient
|
|
// SysAgent is the client for interacting with the SysAgent builders.
|
|
SysAgent *SysAgentClient
|
|
// SysCard is the client for interacting with the SysCard builders.
|
|
SysCard *SysCardClient
|
|
// SysMenu is the client for interacting with the SysMenu builders.
|
|
SysMenu *SysMenuClient
|
|
// SysRole is the client for interacting with the SysRole builders.
|
|
SysRole *SysRoleClient
|
|
// SysUser is the client for interacting with the SysUser builders.
|
|
SysUser *SysUserClient
|
|
// SysUserLog is the client for interacting with the SysUserLog builders.
|
|
SysUserLog *SysUserLogClient
|
|
}
|
|
|
|
// NewClient creates a new client configured with the given options.
|
|
func NewClient(opts ...Option) *Client {
|
|
client := &Client{config: newConfig(opts...)}
|
|
client.init()
|
|
return client
|
|
}
|
|
|
|
func (c *Client) init() {
|
|
c.Schema = migrate.NewSchema(c.driver)
|
|
c.CpImage = NewCpImageClient(c.config)
|
|
c.CpSchool = NewCpSchoolClient(c.config)
|
|
c.CpTask = NewCpTaskClient(c.config)
|
|
c.CpTaskLog = NewCpTaskLogClient(c.config)
|
|
c.CpUser = NewCpUserClient(c.config)
|
|
c.SysAgent = NewSysAgentClient(c.config)
|
|
c.SysCard = NewSysCardClient(c.config)
|
|
c.SysMenu = NewSysMenuClient(c.config)
|
|
c.SysRole = NewSysRoleClient(c.config)
|
|
c.SysUser = NewSysUserClient(c.config)
|
|
c.SysUserLog = NewSysUserLogClient(c.config)
|
|
}
|
|
|
|
type (
|
|
// config is the configuration for the client and its builder.
|
|
config struct {
|
|
// driver used for executing database requests.
|
|
driver dialect.Driver
|
|
// debug enable a debug logging.
|
|
debug bool
|
|
// log used for logging on debug mode.
|
|
log func(...any)
|
|
// hooks to execute on mutations.
|
|
hooks *hooks
|
|
// interceptors to execute on queries.
|
|
inters *inters
|
|
}
|
|
// Option function to configure the client.
|
|
Option func(*config)
|
|
)
|
|
|
|
// newConfig creates a new config for the client.
|
|
func newConfig(opts ...Option) config {
|
|
cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}}
|
|
cfg.options(opts...)
|
|
return cfg
|
|
}
|
|
|
|
// options applies the options on the config object.
|
|
func (c *config) options(opts ...Option) {
|
|
for _, opt := range opts {
|
|
opt(c)
|
|
}
|
|
if c.debug {
|
|
c.driver = dialect.Debug(c.driver, c.log)
|
|
}
|
|
}
|
|
|
|
// Debug enables debug logging on the ent.Driver.
|
|
func Debug() Option {
|
|
return func(c *config) {
|
|
c.debug = true
|
|
}
|
|
}
|
|
|
|
// Log sets the logging function for debug mode.
|
|
func Log(fn func(...any)) Option {
|
|
return func(c *config) {
|
|
c.log = fn
|
|
}
|
|
}
|
|
|
|
// Driver configures the client driver.
|
|
func Driver(driver dialect.Driver) Option {
|
|
return func(c *config) {
|
|
c.driver = driver
|
|
}
|
|
}
|
|
|
|
// Open opens a database/sql.DB specified by the driver name and
|
|
// the data source name, and returns a new client attached to it.
|
|
// Optional parameters can be added for configuring the client.
|
|
func Open(driverName, dataSourceName string, options ...Option) (*Client, error) {
|
|
switch driverName {
|
|
case dialect.MySQL, dialect.Postgres, dialect.SQLite:
|
|
drv, err := sql.Open(driverName, dataSourceName)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return NewClient(append(options, Driver(drv))...), nil
|
|
default:
|
|
return nil, fmt.Errorf("unsupported driver: %q", driverName)
|
|
}
|
|
}
|
|
|
|
// ErrTxStarted is returned when trying to start a new transaction from a transactional client.
|
|
var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction")
|
|
|
|
// Tx returns a new transactional client. The provided context
|
|
// is used until the transaction is committed or rolled back.
|
|
func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
|
if _, ok := c.driver.(*txDriver); ok {
|
|
return nil, ErrTxStarted
|
|
}
|
|
tx, err := newTx(ctx, c.driver)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("ent: starting a transaction: %w", err)
|
|
}
|
|
cfg := c.config
|
|
cfg.driver = tx
|
|
return &Tx{
|
|
ctx: ctx,
|
|
config: cfg,
|
|
CpImage: NewCpImageClient(cfg),
|
|
CpSchool: NewCpSchoolClient(cfg),
|
|
CpTask: NewCpTaskClient(cfg),
|
|
CpTaskLog: NewCpTaskLogClient(cfg),
|
|
CpUser: NewCpUserClient(cfg),
|
|
SysAgent: NewSysAgentClient(cfg),
|
|
SysCard: NewSysCardClient(cfg),
|
|
SysMenu: NewSysMenuClient(cfg),
|
|
SysRole: NewSysRoleClient(cfg),
|
|
SysUser: NewSysUserClient(cfg),
|
|
SysUserLog: NewSysUserLogClient(cfg),
|
|
}, nil
|
|
}
|
|
|
|
// BeginTx returns a transactional client with specified options.
|
|
func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
|
|
if _, ok := c.driver.(*txDriver); ok {
|
|
return nil, errors.New("ent: cannot start a transaction within a transaction")
|
|
}
|
|
tx, err := c.driver.(interface {
|
|
BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error)
|
|
}).BeginTx(ctx, opts)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("ent: starting a transaction: %w", err)
|
|
}
|
|
cfg := c.config
|
|
cfg.driver = &txDriver{tx: tx, drv: c.driver}
|
|
return &Tx{
|
|
ctx: ctx,
|
|
config: cfg,
|
|
CpImage: NewCpImageClient(cfg),
|
|
CpSchool: NewCpSchoolClient(cfg),
|
|
CpTask: NewCpTaskClient(cfg),
|
|
CpTaskLog: NewCpTaskLogClient(cfg),
|
|
CpUser: NewCpUserClient(cfg),
|
|
SysAgent: NewSysAgentClient(cfg),
|
|
SysCard: NewSysCardClient(cfg),
|
|
SysMenu: NewSysMenuClient(cfg),
|
|
SysRole: NewSysRoleClient(cfg),
|
|
SysUser: NewSysUserClient(cfg),
|
|
SysUserLog: NewSysUserLogClient(cfg),
|
|
}, nil
|
|
}
|
|
|
|
// Debug returns a new debug-client. It's used to get verbose logging on specific operations.
|
|
//
|
|
// client.Debug().
|
|
// CpImage.
|
|
// Query().
|
|
// Count(ctx)
|
|
func (c *Client) Debug() *Client {
|
|
if c.debug {
|
|
return c
|
|
}
|
|
cfg := c.config
|
|
cfg.driver = dialect.Debug(c.driver, c.log)
|
|
client := &Client{config: cfg}
|
|
client.init()
|
|
return client
|
|
}
|
|
|
|
// Close closes the database connection and prevents new queries from starting.
|
|
func (c *Client) Close() error {
|
|
return c.driver.Close()
|
|
}
|
|
|
|
// Use adds the mutation hooks to all the entity clients.
|
|
// In order to add hooks to a specific client, call: `client.Node.Use(...)`.
|
|
func (c *Client) Use(hooks ...Hook) {
|
|
for _, n := range []interface{ Use(...Hook) }{
|
|
c.CpImage, c.CpSchool, c.CpTask, c.CpTaskLog, c.CpUser, c.SysAgent, c.SysCard,
|
|
c.SysMenu, c.SysRole, c.SysUser, c.SysUserLog,
|
|
} {
|
|
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) {
|
|
for _, n := range []interface{ Intercept(...Interceptor) }{
|
|
c.CpImage, c.CpSchool, c.CpTask, c.CpTaskLog, c.CpUser, c.SysAgent, c.SysCard,
|
|
c.SysMenu, c.SysRole, c.SysUser, c.SysUserLog,
|
|
} {
|
|
n.Intercept(interceptors...)
|
|
}
|
|
}
|
|
|
|
// Mutate implements the ent.Mutator interface.
|
|
func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
|
|
switch m := m.(type) {
|
|
case *CpImageMutation:
|
|
return c.CpImage.mutate(ctx, m)
|
|
case *CpSchoolMutation:
|
|
return c.CpSchool.mutate(ctx, m)
|
|
case *CpTaskMutation:
|
|
return c.CpTask.mutate(ctx, m)
|
|
case *CpTaskLogMutation:
|
|
return c.CpTaskLog.mutate(ctx, m)
|
|
case *CpUserMutation:
|
|
return c.CpUser.mutate(ctx, m)
|
|
case *SysAgentMutation:
|
|
return c.SysAgent.mutate(ctx, m)
|
|
case *SysCardMutation:
|
|
return c.SysCard.mutate(ctx, m)
|
|
case *SysMenuMutation:
|
|
return c.SysMenu.mutate(ctx, m)
|
|
case *SysRoleMutation:
|
|
return c.SysRole.mutate(ctx, m)
|
|
case *SysUserMutation:
|
|
return c.SysUser.mutate(ctx, m)
|
|
case *SysUserLogMutation:
|
|
return c.SysUserLog.mutate(ctx, m)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown mutation type %T", m)
|
|
}
|
|
}
|
|
|
|
// CpImageClient is a client for the CpImage schema.
|
|
type CpImageClient struct {
|
|
config
|
|
}
|
|
|
|
// NewCpImageClient returns a client for the CpImage from the given config.
|
|
func NewCpImageClient(c config) *CpImageClient {
|
|
return &CpImageClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `cpimage.Hooks(f(g(h())))`.
|
|
func (c *CpImageClient) Use(hooks ...Hook) {
|
|
c.hooks.CpImage = append(c.hooks.CpImage, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `cpimage.Intercept(f(g(h())))`.
|
|
func (c *CpImageClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.CpImage = append(c.inters.CpImage, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a CpImage entity.
|
|
func (c *CpImageClient) Create() *CpImageCreate {
|
|
mutation := newCpImageMutation(c.config, OpCreate)
|
|
return &CpImageCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of CpImage entities.
|
|
func (c *CpImageClient) CreateBulk(builders ...*CpImageCreate) *CpImageCreateBulk {
|
|
return &CpImageCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
|
// a builder and applies setFunc on it.
|
|
func (c *CpImageClient) MapCreateBulk(slice any, setFunc func(*CpImageCreate, int)) *CpImageCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &CpImageCreateBulk{err: fmt.Errorf("calling to CpImageClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*CpImageCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &CpImageCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for CpImage.
|
|
func (c *CpImageClient) Update() *CpImageUpdate {
|
|
mutation := newCpImageMutation(c.config, OpUpdate)
|
|
return &CpImageUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *CpImageClient) UpdateOne(_m *CpImage) *CpImageUpdateOne {
|
|
mutation := newCpImageMutation(c.config, OpUpdateOne, withCpImage(_m))
|
|
return &CpImageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *CpImageClient) UpdateOneID(id int64) *CpImageUpdateOne {
|
|
mutation := newCpImageMutation(c.config, OpUpdateOne, withCpImageID(id))
|
|
return &CpImageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for CpImage.
|
|
func (c *CpImageClient) Delete() *CpImageDelete {
|
|
mutation := newCpImageMutation(c.config, OpDelete)
|
|
return &CpImageDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *CpImageClient) DeleteOne(_m *CpImage) *CpImageDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *CpImageClient) DeleteOneID(id int64) *CpImageDeleteOne {
|
|
builder := c.Delete().Where(cpimage.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &CpImageDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for CpImage.
|
|
func (c *CpImageClient) Query() *CpImageQuery {
|
|
return &CpImageQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeCpImage},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a CpImage entity by its id.
|
|
func (c *CpImageClient) Get(ctx context.Context, id int64) (*CpImage, error) {
|
|
return c.Query().Where(cpimage.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *CpImageClient) GetX(ctx context.Context, id int64) *CpImage {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryUser queries the user edge of a CpImage.
|
|
func (c *CpImageClient) QueryUser(_m *CpImage) *SysUserQuery {
|
|
query := (&SysUserClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(cpimage.Table, cpimage.FieldID, id),
|
|
sqlgraph.To(sysuser.Table, sysuser.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, cpimage.UserTable, cpimage.UserColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *CpImageClient) Hooks() []Hook {
|
|
hooks := c.hooks.CpImage
|
|
return append(hooks[:len(hooks):len(hooks)], cpimage.Hooks[:]...)
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *CpImageClient) Interceptors() []Interceptor {
|
|
return c.inters.CpImage
|
|
}
|
|
|
|
func (c *CpImageClient) mutate(ctx context.Context, m *CpImageMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&CpImageCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&CpImageUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&CpImageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&CpImageDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown CpImage mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// CpSchoolClient is a client for the CpSchool schema.
|
|
type CpSchoolClient struct {
|
|
config
|
|
}
|
|
|
|
// NewCpSchoolClient returns a client for the CpSchool from the given config.
|
|
func NewCpSchoolClient(c config) *CpSchoolClient {
|
|
return &CpSchoolClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `cpschool.Hooks(f(g(h())))`.
|
|
func (c *CpSchoolClient) Use(hooks ...Hook) {
|
|
c.hooks.CpSchool = append(c.hooks.CpSchool, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `cpschool.Intercept(f(g(h())))`.
|
|
func (c *CpSchoolClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.CpSchool = append(c.inters.CpSchool, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a CpSchool entity.
|
|
func (c *CpSchoolClient) Create() *CpSchoolCreate {
|
|
mutation := newCpSchoolMutation(c.config, OpCreate)
|
|
return &CpSchoolCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of CpSchool entities.
|
|
func (c *CpSchoolClient) CreateBulk(builders ...*CpSchoolCreate) *CpSchoolCreateBulk {
|
|
return &CpSchoolCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
|
// a builder and applies setFunc on it.
|
|
func (c *CpSchoolClient) MapCreateBulk(slice any, setFunc func(*CpSchoolCreate, int)) *CpSchoolCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &CpSchoolCreateBulk{err: fmt.Errorf("calling to CpSchoolClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*CpSchoolCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &CpSchoolCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for CpSchool.
|
|
func (c *CpSchoolClient) Update() *CpSchoolUpdate {
|
|
mutation := newCpSchoolMutation(c.config, OpUpdate)
|
|
return &CpSchoolUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *CpSchoolClient) UpdateOne(_m *CpSchool) *CpSchoolUpdateOne {
|
|
mutation := newCpSchoolMutation(c.config, OpUpdateOne, withCpSchool(_m))
|
|
return &CpSchoolUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *CpSchoolClient) UpdateOneID(id string) *CpSchoolUpdateOne {
|
|
mutation := newCpSchoolMutation(c.config, OpUpdateOne, withCpSchoolID(id))
|
|
return &CpSchoolUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for CpSchool.
|
|
func (c *CpSchoolClient) Delete() *CpSchoolDelete {
|
|
mutation := newCpSchoolMutation(c.config, OpDelete)
|
|
return &CpSchoolDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *CpSchoolClient) DeleteOne(_m *CpSchool) *CpSchoolDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *CpSchoolClient) DeleteOneID(id string) *CpSchoolDeleteOne {
|
|
builder := c.Delete().Where(cpschool.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &CpSchoolDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for CpSchool.
|
|
func (c *CpSchoolClient) Query() *CpSchoolQuery {
|
|
return &CpSchoolQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeCpSchool},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a CpSchool entity by its id.
|
|
func (c *CpSchoolClient) Get(ctx context.Context, id string) (*CpSchool, error) {
|
|
return c.Query().Where(cpschool.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *CpSchoolClient) GetX(ctx context.Context, id string) *CpSchool {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryCpusers queries the cpusers edge of a CpSchool.
|
|
func (c *CpSchoolClient) QueryCpusers(_m *CpSchool) *CpUserQuery {
|
|
query := (&CpUserClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(cpschool.Table, cpschool.FieldID, id),
|
|
sqlgraph.To(cpuser.Table, cpuser.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, cpschool.CpusersTable, cpschool.CpusersColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *CpSchoolClient) Hooks() []Hook {
|
|
return c.hooks.CpSchool
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *CpSchoolClient) Interceptors() []Interceptor {
|
|
return c.inters.CpSchool
|
|
}
|
|
|
|
func (c *CpSchoolClient) mutate(ctx context.Context, m *CpSchoolMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&CpSchoolCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&CpSchoolUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&CpSchoolUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&CpSchoolDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown CpSchool mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// CpTaskClient is a client for the CpTask schema.
|
|
type CpTaskClient struct {
|
|
config
|
|
}
|
|
|
|
// NewCpTaskClient returns a client for the CpTask from the given config.
|
|
func NewCpTaskClient(c config) *CpTaskClient {
|
|
return &CpTaskClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `cptask.Hooks(f(g(h())))`.
|
|
func (c *CpTaskClient) Use(hooks ...Hook) {
|
|
c.hooks.CpTask = append(c.hooks.CpTask, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `cptask.Intercept(f(g(h())))`.
|
|
func (c *CpTaskClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.CpTask = append(c.inters.CpTask, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a CpTask entity.
|
|
func (c *CpTaskClient) Create() *CpTaskCreate {
|
|
mutation := newCpTaskMutation(c.config, OpCreate)
|
|
return &CpTaskCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of CpTask entities.
|
|
func (c *CpTaskClient) CreateBulk(builders ...*CpTaskCreate) *CpTaskCreateBulk {
|
|
return &CpTaskCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
|
// a builder and applies setFunc on it.
|
|
func (c *CpTaskClient) MapCreateBulk(slice any, setFunc func(*CpTaskCreate, int)) *CpTaskCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &CpTaskCreateBulk{err: fmt.Errorf("calling to CpTaskClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*CpTaskCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &CpTaskCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for CpTask.
|
|
func (c *CpTaskClient) Update() *CpTaskUpdate {
|
|
mutation := newCpTaskMutation(c.config, OpUpdate)
|
|
return &CpTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *CpTaskClient) UpdateOne(_m *CpTask) *CpTaskUpdateOne {
|
|
mutation := newCpTaskMutation(c.config, OpUpdateOne, withCpTask(_m))
|
|
return &CpTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *CpTaskClient) UpdateOneID(id int64) *CpTaskUpdateOne {
|
|
mutation := newCpTaskMutation(c.config, OpUpdateOne, withCpTaskID(id))
|
|
return &CpTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for CpTask.
|
|
func (c *CpTaskClient) Delete() *CpTaskDelete {
|
|
mutation := newCpTaskMutation(c.config, OpDelete)
|
|
return &CpTaskDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *CpTaskClient) DeleteOne(_m *CpTask) *CpTaskDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *CpTaskClient) DeleteOneID(id int64) *CpTaskDeleteOne {
|
|
builder := c.Delete().Where(cptask.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &CpTaskDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for CpTask.
|
|
func (c *CpTaskClient) Query() *CpTaskQuery {
|
|
return &CpTaskQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeCpTask},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a CpTask entity by its id.
|
|
func (c *CpTaskClient) Get(ctx context.Context, id int64) (*CpTask, error) {
|
|
return c.Query().Where(cptask.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *CpTaskClient) GetX(ctx context.Context, id int64) *CpTask {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryCpUser queries the cp_user edge of a CpTask.
|
|
func (c *CpTaskClient) QueryCpUser(_m *CpTask) *CpUserQuery {
|
|
query := (&CpUserClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(cptask.Table, cptask.FieldID, id),
|
|
sqlgraph.To(cpuser.Table, cpuser.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, cptask.CpUserTable, cptask.CpUserColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QuerySysUser queries the sys_user edge of a CpTask.
|
|
func (c *CpTaskClient) QuerySysUser(_m *CpTask) *SysUserQuery {
|
|
query := (&SysUserClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(cptask.Table, cptask.FieldID, id),
|
|
sqlgraph.To(sysuser.Table, sysuser.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, cptask.SysUserTable, cptask.SysUserColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryCpTaskLogs queries the cp_task_logs edge of a CpTask.
|
|
func (c *CpTaskClient) QueryCpTaskLogs(_m *CpTask) *CpTaskLogQuery {
|
|
query := (&CpTaskLogClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(cptask.Table, cptask.FieldID, id),
|
|
sqlgraph.To(cptasklog.Table, cptasklog.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, cptask.CpTaskLogsTable, cptask.CpTaskLogsColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *CpTaskClient) Hooks() []Hook {
|
|
return c.hooks.CpTask
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *CpTaskClient) Interceptors() []Interceptor {
|
|
return c.inters.CpTask
|
|
}
|
|
|
|
func (c *CpTaskClient) mutate(ctx context.Context, m *CpTaskMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&CpTaskCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&CpTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&CpTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&CpTaskDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown CpTask mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// CpTaskLogClient is a client for the CpTaskLog schema.
|
|
type CpTaskLogClient struct {
|
|
config
|
|
}
|
|
|
|
// NewCpTaskLogClient returns a client for the CpTaskLog from the given config.
|
|
func NewCpTaskLogClient(c config) *CpTaskLogClient {
|
|
return &CpTaskLogClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `cptasklog.Hooks(f(g(h())))`.
|
|
func (c *CpTaskLogClient) Use(hooks ...Hook) {
|
|
c.hooks.CpTaskLog = append(c.hooks.CpTaskLog, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `cptasklog.Intercept(f(g(h())))`.
|
|
func (c *CpTaskLogClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.CpTaskLog = append(c.inters.CpTaskLog, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a CpTaskLog entity.
|
|
func (c *CpTaskLogClient) Create() *CpTaskLogCreate {
|
|
mutation := newCpTaskLogMutation(c.config, OpCreate)
|
|
return &CpTaskLogCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of CpTaskLog entities.
|
|
func (c *CpTaskLogClient) CreateBulk(builders ...*CpTaskLogCreate) *CpTaskLogCreateBulk {
|
|
return &CpTaskLogCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
|
// a builder and applies setFunc on it.
|
|
func (c *CpTaskLogClient) MapCreateBulk(slice any, setFunc func(*CpTaskLogCreate, int)) *CpTaskLogCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &CpTaskLogCreateBulk{err: fmt.Errorf("calling to CpTaskLogClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*CpTaskLogCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &CpTaskLogCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for CpTaskLog.
|
|
func (c *CpTaskLogClient) Update() *CpTaskLogUpdate {
|
|
mutation := newCpTaskLogMutation(c.config, OpUpdate)
|
|
return &CpTaskLogUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *CpTaskLogClient) UpdateOne(_m *CpTaskLog) *CpTaskLogUpdateOne {
|
|
mutation := newCpTaskLogMutation(c.config, OpUpdateOne, withCpTaskLog(_m))
|
|
return &CpTaskLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *CpTaskLogClient) UpdateOneID(id int64) *CpTaskLogUpdateOne {
|
|
mutation := newCpTaskLogMutation(c.config, OpUpdateOne, withCpTaskLogID(id))
|
|
return &CpTaskLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for CpTaskLog.
|
|
func (c *CpTaskLogClient) Delete() *CpTaskLogDelete {
|
|
mutation := newCpTaskLogMutation(c.config, OpDelete)
|
|
return &CpTaskLogDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *CpTaskLogClient) DeleteOne(_m *CpTaskLog) *CpTaskLogDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *CpTaskLogClient) DeleteOneID(id int64) *CpTaskLogDeleteOne {
|
|
builder := c.Delete().Where(cptasklog.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &CpTaskLogDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for CpTaskLog.
|
|
func (c *CpTaskLogClient) Query() *CpTaskLogQuery {
|
|
return &CpTaskLogQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeCpTaskLog},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a CpTaskLog entity by its id.
|
|
func (c *CpTaskLogClient) Get(ctx context.Context, id int64) (*CpTaskLog, error) {
|
|
return c.Query().Where(cptasklog.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *CpTaskLogClient) GetX(ctx context.Context, id int64) *CpTaskLog {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryCpTask queries the cp_task edge of a CpTaskLog.
|
|
func (c *CpTaskLogClient) QueryCpTask(_m *CpTaskLog) *CpTaskQuery {
|
|
query := (&CpTaskClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(cptasklog.Table, cptasklog.FieldID, id),
|
|
sqlgraph.To(cptask.Table, cptask.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, cptasklog.CpTaskTable, cptasklog.CpTaskColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QuerySystemUser queries the system_user edge of a CpTaskLog.
|
|
func (c *CpTaskLogClient) QuerySystemUser(_m *CpTaskLog) *SysUserQuery {
|
|
query := (&SysUserClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(cptasklog.Table, cptasklog.FieldID, id),
|
|
sqlgraph.To(sysuser.Table, sysuser.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, cptasklog.SystemUserTable, cptasklog.SystemUserColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryCpUser queries the cp_user edge of a CpTaskLog.
|
|
func (c *CpTaskLogClient) QueryCpUser(_m *CpTaskLog) *CpUserQuery {
|
|
query := (&CpUserClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(cptasklog.Table, cptasklog.FieldID, id),
|
|
sqlgraph.To(cpuser.Table, cpuser.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, cptasklog.CpUserTable, cptasklog.CpUserColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *CpTaskLogClient) Hooks() []Hook {
|
|
return c.hooks.CpTaskLog
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *CpTaskLogClient) Interceptors() []Interceptor {
|
|
return c.inters.CpTaskLog
|
|
}
|
|
|
|
func (c *CpTaskLogClient) mutate(ctx context.Context, m *CpTaskLogMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&CpTaskLogCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&CpTaskLogUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&CpTaskLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&CpTaskLogDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown CpTaskLog mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// CpUserClient is a client for the CpUser schema.
|
|
type CpUserClient struct {
|
|
config
|
|
}
|
|
|
|
// NewCpUserClient returns a client for the CpUser from the given config.
|
|
func NewCpUserClient(c config) *CpUserClient {
|
|
return &CpUserClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `cpuser.Hooks(f(g(h())))`.
|
|
func (c *CpUserClient) Use(hooks ...Hook) {
|
|
c.hooks.CpUser = append(c.hooks.CpUser, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `cpuser.Intercept(f(g(h())))`.
|
|
func (c *CpUserClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.CpUser = append(c.inters.CpUser, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a CpUser entity.
|
|
func (c *CpUserClient) Create() *CpUserCreate {
|
|
mutation := newCpUserMutation(c.config, OpCreate)
|
|
return &CpUserCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of CpUser entities.
|
|
func (c *CpUserClient) CreateBulk(builders ...*CpUserCreate) *CpUserCreateBulk {
|
|
return &CpUserCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
|
// a builder and applies setFunc on it.
|
|
func (c *CpUserClient) MapCreateBulk(slice any, setFunc func(*CpUserCreate, int)) *CpUserCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &CpUserCreateBulk{err: fmt.Errorf("calling to CpUserClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*CpUserCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &CpUserCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for CpUser.
|
|
func (c *CpUserClient) Update() *CpUserUpdate {
|
|
mutation := newCpUserMutation(c.config, OpUpdate)
|
|
return &CpUserUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *CpUserClient) UpdateOne(_m *CpUser) *CpUserUpdateOne {
|
|
mutation := newCpUserMutation(c.config, OpUpdateOne, withCpUser(_m))
|
|
return &CpUserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *CpUserClient) UpdateOneID(id int64) *CpUserUpdateOne {
|
|
mutation := newCpUserMutation(c.config, OpUpdateOne, withCpUserID(id))
|
|
return &CpUserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for CpUser.
|
|
func (c *CpUserClient) Delete() *CpUserDelete {
|
|
mutation := newCpUserMutation(c.config, OpDelete)
|
|
return &CpUserDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *CpUserClient) DeleteOne(_m *CpUser) *CpUserDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *CpUserClient) DeleteOneID(id int64) *CpUserDeleteOne {
|
|
builder := c.Delete().Where(cpuser.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &CpUserDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for CpUser.
|
|
func (c *CpUserClient) Query() *CpUserQuery {
|
|
return &CpUserQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeCpUser},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a CpUser entity by its id.
|
|
func (c *CpUserClient) Get(ctx context.Context, id int64) (*CpUser, error) {
|
|
return c.Query().Where(cpuser.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *CpUserClient) GetX(ctx context.Context, id int64) *CpUser {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryCptasks queries the cptasks edge of a CpUser.
|
|
func (c *CpUserClient) QueryCptasks(_m *CpUser) *CpTaskQuery {
|
|
query := (&CpTaskClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(cpuser.Table, cpuser.FieldID, id),
|
|
sqlgraph.To(cptask.Table, cptask.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, cpuser.CptasksTable, cpuser.CptasksColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QuerySysuser queries the sysuser edge of a CpUser.
|
|
func (c *CpUserClient) QuerySysuser(_m *CpUser) *SysUserQuery {
|
|
query := (&SysUserClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(cpuser.Table, cpuser.FieldID, id),
|
|
sqlgraph.To(sysuser.Table, sysuser.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, cpuser.SysuserTable, cpuser.SysuserColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryCpTaskLogs queries the cp_task_logs edge of a CpUser.
|
|
func (c *CpUserClient) QueryCpTaskLogs(_m *CpUser) *CpTaskLogQuery {
|
|
query := (&CpTaskLogClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(cpuser.Table, cpuser.FieldID, id),
|
|
sqlgraph.To(cptasklog.Table, cptasklog.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, cpuser.CpTaskLogsTable, cpuser.CpTaskLogsColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QuerySchool queries the school edge of a CpUser.
|
|
func (c *CpUserClient) QuerySchool(_m *CpUser) *CpSchoolQuery {
|
|
query := (&CpSchoolClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(cpuser.Table, cpuser.FieldID, id),
|
|
sqlgraph.To(cpschool.Table, cpschool.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, cpuser.SchoolTable, cpuser.SchoolColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *CpUserClient) Hooks() []Hook {
|
|
return c.hooks.CpUser
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *CpUserClient) Interceptors() []Interceptor {
|
|
return c.inters.CpUser
|
|
}
|
|
|
|
func (c *CpUserClient) mutate(ctx context.Context, m *CpUserMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&CpUserCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&CpUserUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&CpUserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&CpUserDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown CpUser mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// SysAgentClient is a client for the SysAgent schema.
|
|
type SysAgentClient struct {
|
|
config
|
|
}
|
|
|
|
// NewSysAgentClient returns a client for the SysAgent from the given config.
|
|
func NewSysAgentClient(c config) *SysAgentClient {
|
|
return &SysAgentClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `sysagent.Hooks(f(g(h())))`.
|
|
func (c *SysAgentClient) Use(hooks ...Hook) {
|
|
c.hooks.SysAgent = append(c.hooks.SysAgent, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `sysagent.Intercept(f(g(h())))`.
|
|
func (c *SysAgentClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.SysAgent = append(c.inters.SysAgent, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a SysAgent entity.
|
|
func (c *SysAgentClient) Create() *SysAgentCreate {
|
|
mutation := newSysAgentMutation(c.config, OpCreate)
|
|
return &SysAgentCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of SysAgent entities.
|
|
func (c *SysAgentClient) CreateBulk(builders ...*SysAgentCreate) *SysAgentCreateBulk {
|
|
return &SysAgentCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
|
// a builder and applies setFunc on it.
|
|
func (c *SysAgentClient) MapCreateBulk(slice any, setFunc func(*SysAgentCreate, int)) *SysAgentCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &SysAgentCreateBulk{err: fmt.Errorf("calling to SysAgentClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*SysAgentCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &SysAgentCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for SysAgent.
|
|
func (c *SysAgentClient) Update() *SysAgentUpdate {
|
|
mutation := newSysAgentMutation(c.config, OpUpdate)
|
|
return &SysAgentUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *SysAgentClient) UpdateOne(_m *SysAgent) *SysAgentUpdateOne {
|
|
mutation := newSysAgentMutation(c.config, OpUpdateOne, withSysAgent(_m))
|
|
return &SysAgentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *SysAgentClient) UpdateOneID(id int64) *SysAgentUpdateOne {
|
|
mutation := newSysAgentMutation(c.config, OpUpdateOne, withSysAgentID(id))
|
|
return &SysAgentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for SysAgent.
|
|
func (c *SysAgentClient) Delete() *SysAgentDelete {
|
|
mutation := newSysAgentMutation(c.config, OpDelete)
|
|
return &SysAgentDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *SysAgentClient) DeleteOne(_m *SysAgent) *SysAgentDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *SysAgentClient) DeleteOneID(id int64) *SysAgentDeleteOne {
|
|
builder := c.Delete().Where(sysagent.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &SysAgentDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for SysAgent.
|
|
func (c *SysAgentClient) Query() *SysAgentQuery {
|
|
return &SysAgentQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeSysAgent},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a SysAgent entity by its id.
|
|
func (c *SysAgentClient) Get(ctx context.Context, id int64) (*SysAgent, error) {
|
|
return c.Query().Where(sysagent.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *SysAgentClient) GetX(ctx context.Context, id int64) *SysAgent {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryUsers queries the users edge of a SysAgent.
|
|
func (c *SysAgentClient) QueryUsers(_m *SysAgent) *SysUserQuery {
|
|
query := (&SysUserClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(sysagent.Table, sysagent.FieldID, id),
|
|
sqlgraph.To(sysuser.Table, sysuser.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2O, true, sysagent.UsersTable, sysagent.UsersColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *SysAgentClient) Hooks() []Hook {
|
|
hooks := c.hooks.SysAgent
|
|
return append(hooks[:len(hooks):len(hooks)], sysagent.Hooks[:]...)
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *SysAgentClient) Interceptors() []Interceptor {
|
|
return c.inters.SysAgent
|
|
}
|
|
|
|
func (c *SysAgentClient) mutate(ctx context.Context, m *SysAgentMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&SysAgentCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&SysAgentUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&SysAgentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&SysAgentDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown SysAgent mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// SysCardClient is a client for the SysCard schema.
|
|
type SysCardClient struct {
|
|
config
|
|
}
|
|
|
|
// NewSysCardClient returns a client for the SysCard from the given config.
|
|
func NewSysCardClient(c config) *SysCardClient {
|
|
return &SysCardClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `syscard.Hooks(f(g(h())))`.
|
|
func (c *SysCardClient) Use(hooks ...Hook) {
|
|
c.hooks.SysCard = append(c.hooks.SysCard, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `syscard.Intercept(f(g(h())))`.
|
|
func (c *SysCardClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.SysCard = append(c.inters.SysCard, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a SysCard entity.
|
|
func (c *SysCardClient) Create() *SysCardCreate {
|
|
mutation := newSysCardMutation(c.config, OpCreate)
|
|
return &SysCardCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of SysCard entities.
|
|
func (c *SysCardClient) CreateBulk(builders ...*SysCardCreate) *SysCardCreateBulk {
|
|
return &SysCardCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
|
// a builder and applies setFunc on it.
|
|
func (c *SysCardClient) MapCreateBulk(slice any, setFunc func(*SysCardCreate, int)) *SysCardCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &SysCardCreateBulk{err: fmt.Errorf("calling to SysCardClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*SysCardCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &SysCardCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for SysCard.
|
|
func (c *SysCardClient) Update() *SysCardUpdate {
|
|
mutation := newSysCardMutation(c.config, OpUpdate)
|
|
return &SysCardUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *SysCardClient) UpdateOne(_m *SysCard) *SysCardUpdateOne {
|
|
mutation := newSysCardMutation(c.config, OpUpdateOne, withSysCard(_m))
|
|
return &SysCardUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *SysCardClient) UpdateOneID(id int64) *SysCardUpdateOne {
|
|
mutation := newSysCardMutation(c.config, OpUpdateOne, withSysCardID(id))
|
|
return &SysCardUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for SysCard.
|
|
func (c *SysCardClient) Delete() *SysCardDelete {
|
|
mutation := newSysCardMutation(c.config, OpDelete)
|
|
return &SysCardDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *SysCardClient) DeleteOne(_m *SysCard) *SysCardDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *SysCardClient) DeleteOneID(id int64) *SysCardDeleteOne {
|
|
builder := c.Delete().Where(syscard.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &SysCardDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for SysCard.
|
|
func (c *SysCardClient) Query() *SysCardQuery {
|
|
return &SysCardQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeSysCard},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a SysCard entity by its id.
|
|
func (c *SysCardClient) Get(ctx context.Context, id int64) (*SysCard, error) {
|
|
return c.Query().Where(syscard.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *SysCardClient) GetX(ctx context.Context, id int64) *SysCard {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryCreator queries the creator edge of a SysCard.
|
|
func (c *SysCardClient) QueryCreator(_m *SysCard) *SysUserQuery {
|
|
query := (&SysUserClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(syscard.Table, syscard.FieldID, id),
|
|
sqlgraph.To(sysuser.Table, sysuser.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, syscard.CreatorTable, syscard.CreatorColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryUser queries the user edge of a SysCard.
|
|
func (c *SysCardClient) QueryUser(_m *SysCard) *SysUserQuery {
|
|
query := (&SysUserClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(syscard.Table, syscard.FieldID, id),
|
|
sqlgraph.To(sysuser.Table, sysuser.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, syscard.UserTable, syscard.UserColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryCashUser queries the cash_user edge of a SysCard.
|
|
func (c *SysCardClient) QueryCashUser(_m *SysCard) *SysUserQuery {
|
|
query := (&SysUserClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(syscard.Table, syscard.FieldID, id),
|
|
sqlgraph.To(sysuser.Table, sysuser.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, syscard.CashUserTable, syscard.CashUserColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *SysCardClient) Hooks() []Hook {
|
|
hooks := c.hooks.SysCard
|
|
return append(hooks[:len(hooks):len(hooks)], syscard.Hooks[:]...)
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *SysCardClient) Interceptors() []Interceptor {
|
|
return c.inters.SysCard
|
|
}
|
|
|
|
func (c *SysCardClient) mutate(ctx context.Context, m *SysCardMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&SysCardCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&SysCardUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&SysCardUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&SysCardDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown SysCard mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// SysMenuClient is a client for the SysMenu schema.
|
|
type SysMenuClient struct {
|
|
config
|
|
}
|
|
|
|
// NewSysMenuClient returns a client for the SysMenu from the given config.
|
|
func NewSysMenuClient(c config) *SysMenuClient {
|
|
return &SysMenuClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `sysmenu.Hooks(f(g(h())))`.
|
|
func (c *SysMenuClient) Use(hooks ...Hook) {
|
|
c.hooks.SysMenu = append(c.hooks.SysMenu, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `sysmenu.Intercept(f(g(h())))`.
|
|
func (c *SysMenuClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.SysMenu = append(c.inters.SysMenu, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a SysMenu entity.
|
|
func (c *SysMenuClient) Create() *SysMenuCreate {
|
|
mutation := newSysMenuMutation(c.config, OpCreate)
|
|
return &SysMenuCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of SysMenu entities.
|
|
func (c *SysMenuClient) CreateBulk(builders ...*SysMenuCreate) *SysMenuCreateBulk {
|
|
return &SysMenuCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
|
// a builder and applies setFunc on it.
|
|
func (c *SysMenuClient) MapCreateBulk(slice any, setFunc func(*SysMenuCreate, int)) *SysMenuCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &SysMenuCreateBulk{err: fmt.Errorf("calling to SysMenuClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*SysMenuCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &SysMenuCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for SysMenu.
|
|
func (c *SysMenuClient) Update() *SysMenuUpdate {
|
|
mutation := newSysMenuMutation(c.config, OpUpdate)
|
|
return &SysMenuUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *SysMenuClient) UpdateOne(_m *SysMenu) *SysMenuUpdateOne {
|
|
mutation := newSysMenuMutation(c.config, OpUpdateOne, withSysMenu(_m))
|
|
return &SysMenuUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *SysMenuClient) UpdateOneID(id int64) *SysMenuUpdateOne {
|
|
mutation := newSysMenuMutation(c.config, OpUpdateOne, withSysMenuID(id))
|
|
return &SysMenuUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for SysMenu.
|
|
func (c *SysMenuClient) Delete() *SysMenuDelete {
|
|
mutation := newSysMenuMutation(c.config, OpDelete)
|
|
return &SysMenuDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *SysMenuClient) DeleteOne(_m *SysMenu) *SysMenuDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *SysMenuClient) DeleteOneID(id int64) *SysMenuDeleteOne {
|
|
builder := c.Delete().Where(sysmenu.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &SysMenuDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for SysMenu.
|
|
func (c *SysMenuClient) Query() *SysMenuQuery {
|
|
return &SysMenuQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeSysMenu},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a SysMenu entity by its id.
|
|
func (c *SysMenuClient) Get(ctx context.Context, id int64) (*SysMenu, error) {
|
|
return c.Query().Where(sysmenu.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *SysMenuClient) GetX(ctx context.Context, id int64) *SysMenu {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryRoles queries the roles edge of a SysMenu.
|
|
func (c *SysMenuClient) QueryRoles(_m *SysMenu) *SysRoleQuery {
|
|
query := (&SysRoleClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(sysmenu.Table, sysmenu.FieldID, id),
|
|
sqlgraph.To(sysrole.Table, sysrole.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2M, true, sysmenu.RolesTable, sysmenu.RolesPrimaryKey...),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryParent queries the parent edge of a SysMenu.
|
|
func (c *SysMenuClient) QueryParent(_m *SysMenu) *SysMenuQuery {
|
|
query := (&SysMenuClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(sysmenu.Table, sysmenu.FieldID, id),
|
|
sqlgraph.To(sysmenu.Table, sysmenu.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, sysmenu.ParentTable, sysmenu.ParentColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryChildren queries the children edge of a SysMenu.
|
|
func (c *SysMenuClient) QueryChildren(_m *SysMenu) *SysMenuQuery {
|
|
query := (&SysMenuClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(sysmenu.Table, sysmenu.FieldID, id),
|
|
sqlgraph.To(sysmenu.Table, sysmenu.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, sysmenu.ChildrenTable, sysmenu.ChildrenColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *SysMenuClient) Hooks() []Hook {
|
|
hooks := c.hooks.SysMenu
|
|
return append(hooks[:len(hooks):len(hooks)], sysmenu.Hooks[:]...)
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *SysMenuClient) Interceptors() []Interceptor {
|
|
return c.inters.SysMenu
|
|
}
|
|
|
|
func (c *SysMenuClient) mutate(ctx context.Context, m *SysMenuMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&SysMenuCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&SysMenuUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&SysMenuUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&SysMenuDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown SysMenu mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// SysRoleClient is a client for the SysRole schema.
|
|
type SysRoleClient struct {
|
|
config
|
|
}
|
|
|
|
// NewSysRoleClient returns a client for the SysRole from the given config.
|
|
func NewSysRoleClient(c config) *SysRoleClient {
|
|
return &SysRoleClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `sysrole.Hooks(f(g(h())))`.
|
|
func (c *SysRoleClient) Use(hooks ...Hook) {
|
|
c.hooks.SysRole = append(c.hooks.SysRole, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `sysrole.Intercept(f(g(h())))`.
|
|
func (c *SysRoleClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.SysRole = append(c.inters.SysRole, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a SysRole entity.
|
|
func (c *SysRoleClient) Create() *SysRoleCreate {
|
|
mutation := newSysRoleMutation(c.config, OpCreate)
|
|
return &SysRoleCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of SysRole entities.
|
|
func (c *SysRoleClient) CreateBulk(builders ...*SysRoleCreate) *SysRoleCreateBulk {
|
|
return &SysRoleCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
|
// a builder and applies setFunc on it.
|
|
func (c *SysRoleClient) MapCreateBulk(slice any, setFunc func(*SysRoleCreate, int)) *SysRoleCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &SysRoleCreateBulk{err: fmt.Errorf("calling to SysRoleClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*SysRoleCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &SysRoleCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for SysRole.
|
|
func (c *SysRoleClient) Update() *SysRoleUpdate {
|
|
mutation := newSysRoleMutation(c.config, OpUpdate)
|
|
return &SysRoleUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *SysRoleClient) UpdateOne(_m *SysRole) *SysRoleUpdateOne {
|
|
mutation := newSysRoleMutation(c.config, OpUpdateOne, withSysRole(_m))
|
|
return &SysRoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *SysRoleClient) UpdateOneID(id int64) *SysRoleUpdateOne {
|
|
mutation := newSysRoleMutation(c.config, OpUpdateOne, withSysRoleID(id))
|
|
return &SysRoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for SysRole.
|
|
func (c *SysRoleClient) Delete() *SysRoleDelete {
|
|
mutation := newSysRoleMutation(c.config, OpDelete)
|
|
return &SysRoleDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *SysRoleClient) DeleteOne(_m *SysRole) *SysRoleDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *SysRoleClient) DeleteOneID(id int64) *SysRoleDeleteOne {
|
|
builder := c.Delete().Where(sysrole.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &SysRoleDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for SysRole.
|
|
func (c *SysRoleClient) Query() *SysRoleQuery {
|
|
return &SysRoleQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeSysRole},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a SysRole entity by its id.
|
|
func (c *SysRoleClient) Get(ctx context.Context, id int64) (*SysRole, error) {
|
|
return c.Query().Where(sysrole.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *SysRoleClient) GetX(ctx context.Context, id int64) *SysRole {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryMenus queries the menus edge of a SysRole.
|
|
func (c *SysRoleClient) QueryMenus(_m *SysRole) *SysMenuQuery {
|
|
query := (&SysMenuClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(sysrole.Table, sysrole.FieldID, id),
|
|
sqlgraph.To(sysmenu.Table, sysmenu.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2M, false, sysrole.MenusTable, sysrole.MenusPrimaryKey...),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryUsers queries the users edge of a SysRole.
|
|
func (c *SysRoleClient) QueryUsers(_m *SysRole) *SysUserQuery {
|
|
query := (&SysUserClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(sysrole.Table, sysrole.FieldID, id),
|
|
sqlgraph.To(sysuser.Table, sysuser.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2M, true, sysrole.UsersTable, sysrole.UsersPrimaryKey...),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *SysRoleClient) Hooks() []Hook {
|
|
hooks := c.hooks.SysRole
|
|
return append(hooks[:len(hooks):len(hooks)], sysrole.Hooks[:]...)
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *SysRoleClient) Interceptors() []Interceptor {
|
|
return c.inters.SysRole
|
|
}
|
|
|
|
func (c *SysRoleClient) mutate(ctx context.Context, m *SysRoleMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&SysRoleCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&SysRoleUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&SysRoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&SysRoleDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown SysRole mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// SysUserClient is a client for the SysUser schema.
|
|
type SysUserClient struct {
|
|
config
|
|
}
|
|
|
|
// NewSysUserClient returns a client for the SysUser from the given config.
|
|
func NewSysUserClient(c config) *SysUserClient {
|
|
return &SysUserClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `sysuser.Hooks(f(g(h())))`.
|
|
func (c *SysUserClient) Use(hooks ...Hook) {
|
|
c.hooks.SysUser = append(c.hooks.SysUser, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `sysuser.Intercept(f(g(h())))`.
|
|
func (c *SysUserClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.SysUser = append(c.inters.SysUser, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a SysUser entity.
|
|
func (c *SysUserClient) Create() *SysUserCreate {
|
|
mutation := newSysUserMutation(c.config, OpCreate)
|
|
return &SysUserCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of SysUser entities.
|
|
func (c *SysUserClient) CreateBulk(builders ...*SysUserCreate) *SysUserCreateBulk {
|
|
return &SysUserCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
|
// a builder and applies setFunc on it.
|
|
func (c *SysUserClient) MapCreateBulk(slice any, setFunc func(*SysUserCreate, int)) *SysUserCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &SysUserCreateBulk{err: fmt.Errorf("calling to SysUserClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*SysUserCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &SysUserCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for SysUser.
|
|
func (c *SysUserClient) Update() *SysUserUpdate {
|
|
mutation := newSysUserMutation(c.config, OpUpdate)
|
|
return &SysUserUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *SysUserClient) UpdateOne(_m *SysUser) *SysUserUpdateOne {
|
|
mutation := newSysUserMutation(c.config, OpUpdateOne, withSysUser(_m))
|
|
return &SysUserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *SysUserClient) UpdateOneID(id int64) *SysUserUpdateOne {
|
|
mutation := newSysUserMutation(c.config, OpUpdateOne, withSysUserID(id))
|
|
return &SysUserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for SysUser.
|
|
func (c *SysUserClient) Delete() *SysUserDelete {
|
|
mutation := newSysUserMutation(c.config, OpDelete)
|
|
return &SysUserDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *SysUserClient) DeleteOne(_m *SysUser) *SysUserDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *SysUserClient) DeleteOneID(id int64) *SysUserDeleteOne {
|
|
builder := c.Delete().Where(sysuser.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &SysUserDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for SysUser.
|
|
func (c *SysUserClient) Query() *SysUserQuery {
|
|
return &SysUserQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeSysUser},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a SysUser entity by its id.
|
|
func (c *SysUserClient) Get(ctx context.Context, id int64) (*SysUser, error) {
|
|
return c.Query().Where(sysuser.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *SysUserClient) GetX(ctx context.Context, id int64) *SysUser {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryParent queries the parent edge of a SysUser.
|
|
func (c *SysUserClient) QueryParent(_m *SysUser) *SysUserQuery {
|
|
query := (&SysUserClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(sysuser.Table, sysuser.FieldID, id),
|
|
sqlgraph.To(sysuser.Table, sysuser.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, sysuser.ParentTable, sysuser.ParentColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryChildren queries the children edge of a SysUser.
|
|
func (c *SysUserClient) QueryChildren(_m *SysUser) *SysUserQuery {
|
|
query := (&SysUserClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(sysuser.Table, sysuser.FieldID, id),
|
|
sqlgraph.To(sysuser.Table, sysuser.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, sysuser.ChildrenTable, sysuser.ChildrenColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryRoles queries the roles edge of a SysUser.
|
|
func (c *SysUserClient) QueryRoles(_m *SysUser) *SysRoleQuery {
|
|
query := (&SysRoleClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(sysuser.Table, sysuser.FieldID, id),
|
|
sqlgraph.To(sysrole.Table, sysrole.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2M, false, sysuser.RolesTable, sysuser.RolesPrimaryKey...),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryAgent queries the agent edge of a SysUser.
|
|
func (c *SysUserClient) QueryAgent(_m *SysUser) *SysAgentQuery {
|
|
query := (&SysAgentClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(sysuser.Table, sysuser.FieldID, id),
|
|
sqlgraph.To(sysagent.Table, sysagent.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2O, false, sysuser.AgentTable, sysuser.AgentColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryImages queries the images edge of a SysUser.
|
|
func (c *SysUserClient) QueryImages(_m *SysUser) *CpImageQuery {
|
|
query := (&CpImageClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(sysuser.Table, sysuser.FieldID, id),
|
|
sqlgraph.To(cpimage.Table, cpimage.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, sysuser.ImagesTable, sysuser.ImagesColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryCpuser queries the cpuser edge of a SysUser.
|
|
func (c *SysUserClient) QueryCpuser(_m *SysUser) *CpUserQuery {
|
|
query := (&CpUserClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(sysuser.Table, sysuser.FieldID, id),
|
|
sqlgraph.To(cpuser.Table, cpuser.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, sysuser.CpuserTable, sysuser.CpuserColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryCpTask queries the cp_task edge of a SysUser.
|
|
func (c *SysUserClient) QueryCpTask(_m *SysUser) *CpTaskQuery {
|
|
query := (&CpTaskClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(sysuser.Table, sysuser.FieldID, id),
|
|
sqlgraph.To(cptask.Table, cptask.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, sysuser.CpTaskTable, sysuser.CpTaskColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryCpTaskLogs queries the cp_task_logs edge of a SysUser.
|
|
func (c *SysUserClient) QueryCpTaskLogs(_m *SysUser) *CpTaskLogQuery {
|
|
query := (&CpTaskLogClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(sysuser.Table, sysuser.FieldID, id),
|
|
sqlgraph.To(cptasklog.Table, cptasklog.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, sysuser.CpTaskLogsTable, sysuser.CpTaskLogsColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryCreatedCards queries the created_cards edge of a SysUser.
|
|
func (c *SysUserClient) QueryCreatedCards(_m *SysUser) *SysCardQuery {
|
|
query := (&SysCardClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(sysuser.Table, sysuser.FieldID, id),
|
|
sqlgraph.To(syscard.Table, syscard.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, sysuser.CreatedCardsTable, sysuser.CreatedCardsColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryUsedCards queries the used_cards edge of a SysUser.
|
|
func (c *SysUserClient) QueryUsedCards(_m *SysUser) *SysCardQuery {
|
|
query := (&SysCardClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(sysuser.Table, sysuser.FieldID, id),
|
|
sqlgraph.To(syscard.Table, syscard.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, sysuser.UsedCardsTable, sysuser.UsedCardsColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryCashbackCards queries the cashback_cards edge of a SysUser.
|
|
func (c *SysUserClient) QueryCashbackCards(_m *SysUser) *SysCardQuery {
|
|
query := (&SysCardClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(sysuser.Table, sysuser.FieldID, id),
|
|
sqlgraph.To(syscard.Table, syscard.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, sysuser.CashbackCardsTable, sysuser.CashbackCardsColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *SysUserClient) Hooks() []Hook {
|
|
hooks := c.hooks.SysUser
|
|
return append(hooks[:len(hooks):len(hooks)], sysuser.Hooks[:]...)
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *SysUserClient) Interceptors() []Interceptor {
|
|
return c.inters.SysUser
|
|
}
|
|
|
|
func (c *SysUserClient) mutate(ctx context.Context, m *SysUserMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&SysUserCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&SysUserUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&SysUserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&SysUserDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown SysUser mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// SysUserLogClient is a client for the SysUserLog schema.
|
|
type SysUserLogClient struct {
|
|
config
|
|
}
|
|
|
|
// NewSysUserLogClient returns a client for the SysUserLog from the given config.
|
|
func NewSysUserLogClient(c config) *SysUserLogClient {
|
|
return &SysUserLogClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `sysuserlog.Hooks(f(g(h())))`.
|
|
func (c *SysUserLogClient) Use(hooks ...Hook) {
|
|
c.hooks.SysUserLog = append(c.hooks.SysUserLog, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `sysuserlog.Intercept(f(g(h())))`.
|
|
func (c *SysUserLogClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.SysUserLog = append(c.inters.SysUserLog, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a SysUserLog entity.
|
|
func (c *SysUserLogClient) Create() *SysUserLogCreate {
|
|
mutation := newSysUserLogMutation(c.config, OpCreate)
|
|
return &SysUserLogCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of SysUserLog entities.
|
|
func (c *SysUserLogClient) CreateBulk(builders ...*SysUserLogCreate) *SysUserLogCreateBulk {
|
|
return &SysUserLogCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
|
// a builder and applies setFunc on it.
|
|
func (c *SysUserLogClient) MapCreateBulk(slice any, setFunc func(*SysUserLogCreate, int)) *SysUserLogCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &SysUserLogCreateBulk{err: fmt.Errorf("calling to SysUserLogClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*SysUserLogCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &SysUserLogCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for SysUserLog.
|
|
func (c *SysUserLogClient) Update() *SysUserLogUpdate {
|
|
mutation := newSysUserLogMutation(c.config, OpUpdate)
|
|
return &SysUserLogUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *SysUserLogClient) UpdateOne(_m *SysUserLog) *SysUserLogUpdateOne {
|
|
mutation := newSysUserLogMutation(c.config, OpUpdateOne, withSysUserLog(_m))
|
|
return &SysUserLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *SysUserLogClient) UpdateOneID(id int64) *SysUserLogUpdateOne {
|
|
mutation := newSysUserLogMutation(c.config, OpUpdateOne, withSysUserLogID(id))
|
|
return &SysUserLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for SysUserLog.
|
|
func (c *SysUserLogClient) Delete() *SysUserLogDelete {
|
|
mutation := newSysUserLogMutation(c.config, OpDelete)
|
|
return &SysUserLogDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *SysUserLogClient) DeleteOne(_m *SysUserLog) *SysUserLogDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *SysUserLogClient) DeleteOneID(id int64) *SysUserLogDeleteOne {
|
|
builder := c.Delete().Where(sysuserlog.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &SysUserLogDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for SysUserLog.
|
|
func (c *SysUserLogClient) Query() *SysUserLogQuery {
|
|
return &SysUserLogQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeSysUserLog},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a SysUserLog entity by its id.
|
|
func (c *SysUserLogClient) Get(ctx context.Context, id int64) (*SysUserLog, error) {
|
|
return c.Query().Where(sysuserlog.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *SysUserLogClient) GetX(ctx context.Context, id int64) *SysUserLog {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *SysUserLogClient) Hooks() []Hook {
|
|
return c.hooks.SysUserLog
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *SysUserLogClient) Interceptors() []Interceptor {
|
|
return c.inters.SysUserLog
|
|
}
|
|
|
|
func (c *SysUserLogClient) mutate(ctx context.Context, m *SysUserLogMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&SysUserLogCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&SysUserLogUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&SysUserLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&SysUserLogDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown SysUserLog mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// hooks and interceptors per client, for fast access.
|
|
type (
|
|
hooks struct {
|
|
CpImage, CpSchool, CpTask, CpTaskLog, CpUser, SysAgent, SysCard, SysMenu,
|
|
SysRole, SysUser, SysUserLog []ent.Hook
|
|
}
|
|
inters struct {
|
|
CpImage, CpSchool, CpTask, CpTaskLog, CpUser, SysAgent, SysCard, SysMenu,
|
|
SysRole, SysUser, SysUserLog []ent.Interceptor
|
|
}
|
|
)
|