✨ 刷课表

This commit is contained in:
sugarBecomer
2025-11-26 10:58:22 +08:00
parent f703344485
commit 73b6c01cf9
29 changed files with 6864 additions and 100 deletions
+215 -35
View File
@@ -11,6 +11,7 @@ import (
"likedream-goframe/internal/ent/migrate"
"likedream-goframe/internal/ent/courseentity"
"likedream-goframe/internal/ent/cpimage"
"likedream-goframe/internal/ent/cpschool"
"likedream-goframe/internal/ent/cptask"
@@ -37,6 +38,8 @@ type Client struct {
config
// Schema is the client for creating, migrating and dropping schema.
Schema *migrate.Schema
// CourseEntity is the client for interacting with the CourseEntity builders.
CourseEntity *CourseEntityClient
// CpImage is the client for interacting with the CpImage builders.
CpImage *CpImageClient
// CpSchool is the client for interacting with the CpSchool builders.
@@ -70,6 +73,7 @@ func NewClient(opts ...Option) *Client {
func (c *Client) init() {
c.Schema = migrate.NewSchema(c.driver)
c.CourseEntity = NewCourseEntityClient(c.config)
c.CpImage = NewCpImageClient(c.config)
c.CpSchool = NewCpSchoolClient(c.config)
c.CpTask = NewCpTaskClient(c.config)
@@ -173,19 +177,20 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
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),
ctx: ctx,
config: cfg,
CourseEntity: NewCourseEntityClient(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
}
@@ -203,26 +208,27 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
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),
ctx: ctx,
config: cfg,
CourseEntity: NewCourseEntityClient(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.
// CourseEntity.
// Query().
// Count(ctx)
func (c *Client) Debug() *Client {
@@ -245,8 +251,8 @@ func (c *Client) Close() error {
// 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,
c.CourseEntity, 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...)
}
@@ -256,8 +262,8 @@ func (c *Client) Use(hooks ...Hook) {
// 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,
c.CourseEntity, 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...)
}
@@ -266,6 +272,8 @@ func (c *Client) Intercept(interceptors ...Interceptor) {
// Mutate implements the ent.Mutator interface.
func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
switch m := m.(type) {
case *CourseEntityMutation:
return c.CourseEntity.mutate(ctx, m)
case *CpImageMutation:
return c.CpImage.mutate(ctx, m)
case *CpSchoolMutation:
@@ -293,6 +301,159 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
}
}
// CourseEntityClient is a client for the CourseEntity schema.
type CourseEntityClient struct {
config
}
// NewCourseEntityClient returns a client for the CourseEntity from the given config.
func NewCourseEntityClient(c config) *CourseEntityClient {
return &CourseEntityClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `courseentity.Hooks(f(g(h())))`.
func (c *CourseEntityClient) Use(hooks ...Hook) {
c.hooks.CourseEntity = append(c.hooks.CourseEntity, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `courseentity.Intercept(f(g(h())))`.
func (c *CourseEntityClient) Intercept(interceptors ...Interceptor) {
c.inters.CourseEntity = append(c.inters.CourseEntity, interceptors...)
}
// Create returns a builder for creating a CourseEntity entity.
func (c *CourseEntityClient) Create() *CourseEntityCreate {
mutation := newCourseEntityMutation(c.config, OpCreate)
return &CourseEntityCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of CourseEntity entities.
func (c *CourseEntityClient) CreateBulk(builders ...*CourseEntityCreate) *CourseEntityCreateBulk {
return &CourseEntityCreateBulk{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 *CourseEntityClient) MapCreateBulk(slice any, setFunc func(*CourseEntityCreate, int)) *CourseEntityCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &CourseEntityCreateBulk{err: fmt.Errorf("calling to CourseEntityClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*CourseEntityCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &CourseEntityCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for CourseEntity.
func (c *CourseEntityClient) Update() *CourseEntityUpdate {
mutation := newCourseEntityMutation(c.config, OpUpdate)
return &CourseEntityUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *CourseEntityClient) UpdateOne(_m *CourseEntity) *CourseEntityUpdateOne {
mutation := newCourseEntityMutation(c.config, OpUpdateOne, withCourseEntity(_m))
return &CourseEntityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *CourseEntityClient) UpdateOneID(id int64) *CourseEntityUpdateOne {
mutation := newCourseEntityMutation(c.config, OpUpdateOne, withCourseEntityID(id))
return &CourseEntityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for CourseEntity.
func (c *CourseEntityClient) Delete() *CourseEntityDelete {
mutation := newCourseEntityMutation(c.config, OpDelete)
return &CourseEntityDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *CourseEntityClient) DeleteOne(_m *CourseEntity) *CourseEntityDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *CourseEntityClient) DeleteOneID(id int64) *CourseEntityDeleteOne {
builder := c.Delete().Where(courseentity.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &CourseEntityDeleteOne{builder}
}
// Query returns a query builder for CourseEntity.
func (c *CourseEntityClient) Query() *CourseEntityQuery {
return &CourseEntityQuery{
config: c.config,
ctx: &QueryContext{Type: TypeCourseEntity},
inters: c.Interceptors(),
}
}
// Get returns a CourseEntity entity by its id.
func (c *CourseEntityClient) Get(ctx context.Context, id int64) (*CourseEntity, error) {
return c.Query().Where(courseentity.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *CourseEntityClient) GetX(ctx context.Context, id int64) *CourseEntity {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QuerySysUser queries the sys_user edge of a CourseEntity.
func (c *CourseEntityClient) QuerySysUser(_m *CourseEntity) *SysUserQuery {
query := (&SysUserClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(courseentity.Table, courseentity.FieldID, id),
sqlgraph.To(sysuser.Table, sysuser.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, courseentity.SysUserTable, courseentity.SysUserColumn),
)
schemaConfig := _m.schemaConfig
step.To.Schema = schemaConfig.SysUser
step.Edge.Schema = schemaConfig.CourseEntity
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *CourseEntityClient) Hooks() []Hook {
hooks := c.hooks.CourseEntity
return append(hooks[:len(hooks):len(hooks)], courseentity.Hooks[:]...)
}
// Interceptors returns the client interceptors.
func (c *CourseEntityClient) Interceptors() []Interceptor {
return c.inters.CourseEntity
}
func (c *CourseEntityClient) mutate(ctx context.Context, m *CourseEntityMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&CourseEntityCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&CourseEntityUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&CourseEntityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&CourseEntityDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown CourseEntity mutation op: %q", m.Op())
}
}
// CpImageClient is a client for the CpImage schema.
type CpImageClient struct {
config
@@ -2139,6 +2300,25 @@ func (c *SysUserClient) QueryCpTask(_m *SysUser) *CpTaskQuery {
return query
}
// QueryCourseEntity queries the course_entity edge of a SysUser.
func (c *SysUserClient) QueryCourseEntity(_m *SysUser) *CourseEntityQuery {
query := (&CourseEntityClient{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(courseentity.Table, courseentity.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, sysuser.CourseEntityTable, sysuser.CourseEntityColumn),
)
schemaConfig := _m.schemaConfig
step.To.Schema = schemaConfig.CourseEntity
step.Edge.Schema = schemaConfig.CourseEntity
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()
@@ -2377,12 +2557,12 @@ func (c *SysUserLogClient) mutate(ctx context.Context, m *SysUserLogMutation) (V
// hooks and interceptors per client, for fast access.
type (
hooks struct {
CpImage, CpSchool, CpTask, CpTaskLog, CpUser, SysAgent, SysCard, SysMenu,
SysRole, SysUser, SysUserLog []ent.Hook
CourseEntity, 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
CourseEntity, CpImage, CpSchool, CpTask, CpTaskLog, CpUser, SysAgent, SysCard,
SysMenu, SysRole, SysUser, SysUserLog []ent.Interceptor
}
)
+288
View File
@@ -0,0 +1,288 @@
// ENT数据库文件,请勿编辑。
package ent
import (
"fmt"
"likedream-goframe/internal/ent/courseentity"
"likedream-goframe/internal/ent/sysuser"
"likedream-goframe/internal/framework/ent2"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// CourseEntity is the model entity for the CourseEntity schema.
type CourseEntity struct {
config `json:"-"`
// ID of the ent.
ID int64 `json:"id,omitempty"`
// CreateTime holds the value of the "create_time" field.
CreateTime *ent2.CustomTime `json:"createTime"`
// UpdateTime holds the value of the "update_time" field.
UpdateTime *ent2.CustomTime `json:"updateTime"`
// UserID holds the value of the "user_id" field.
UserID int64 `json:"user_id,omitempty"`
// Username holds the value of the "username" field.
Username string `json:"username,omitempty"`
// Password holds the value of the "password" field.
Password string `json:"-"`
// Type holds the value of the "type" field.
Type courseentity.Type `json:"type,omitempty"`
// CourseName holds the value of the "course_name" field.
CourseName string `json:"course_name,omitempty"`
// CourseID holds the value of the "course_id" field.
CourseID string `json:"course_id,omitempty"`
// Need holds the value of the "need" field.
Need courseentity.Need `json:"need,omitempty"`
// Status holds the value of the "status" field.
Status courseentity.Status `json:"status,omitempty"`
// TaskCount holds the value of the "task_count" field.
TaskCount int `json:"task_count,omitempty"`
// SuccessCount holds the value of the "success_count" field.
SuccessCount int `json:"success_count,omitempty"`
// ExamState holds the value of the "exam_state" field.
ExamState courseentity.ExamState `json:"exam_state,omitempty"`
// Violence holds the value of the "violence" field.
Violence courseentity.Violence `json:"violence,omitempty"`
// Desc holds the value of the "desc" field.
Desc string `json:"desc,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the CourseEntityQuery when eager-loading is set.
Edges CourseEntityEdges `json:"edges"`
selectValues sql.SelectValues
}
// CourseEntityEdges holds the relations/edges for other nodes in the graph.
type CourseEntityEdges struct {
// SysUser holds the value of the sys_user edge.
SysUser *SysUser `json:"sys_user,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [1]bool
}
// SysUserOrErr returns the SysUser value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e CourseEntityEdges) SysUserOrErr() (*SysUser, error) {
if e.SysUser != nil {
return e.SysUser, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: sysuser.Label}
}
return nil, &NotLoadedError{edge: "sys_user"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*CourseEntity) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case courseentity.FieldCreateTime, courseentity.FieldUpdateTime:
values[i] = new(ent2.CustomTime)
case courseentity.FieldID, courseentity.FieldUserID, courseentity.FieldTaskCount, courseentity.FieldSuccessCount:
values[i] = new(sql.NullInt64)
case courseentity.FieldUsername, courseentity.FieldPassword, courseentity.FieldType, courseentity.FieldCourseName, courseentity.FieldCourseID, courseentity.FieldNeed, courseentity.FieldStatus, courseentity.FieldExamState, courseentity.FieldViolence, courseentity.FieldDesc:
values[i] = new(sql.NullString)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the CourseEntity fields.
func (_m *CourseEntity) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case courseentity.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
_m.ID = int64(value.Int64)
case courseentity.FieldCreateTime:
if value, ok := values[i].(*ent2.CustomTime); !ok {
return fmt.Errorf("unexpected type %T for field create_time", values[i])
} else if value != nil {
_m.CreateTime = value
}
case courseentity.FieldUpdateTime:
if value, ok := values[i].(*ent2.CustomTime); !ok {
return fmt.Errorf("unexpected type %T for field update_time", values[i])
} else if value != nil {
_m.UpdateTime = value
}
case courseentity.FieldUserID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field user_id", values[i])
} else if value.Valid {
_m.UserID = value.Int64
}
case courseentity.FieldUsername:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field username", values[i])
} else if value.Valid {
_m.Username = value.String
}
case courseentity.FieldPassword:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field password", values[i])
} else if value.Valid {
_m.Password = value.String
}
case courseentity.FieldType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field type", values[i])
} else if value.Valid {
_m.Type = courseentity.Type(value.String)
}
case courseentity.FieldCourseName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field course_name", values[i])
} else if value.Valid {
_m.CourseName = value.String
}
case courseentity.FieldCourseID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field course_id", values[i])
} else if value.Valid {
_m.CourseID = value.String
}
case courseentity.FieldNeed:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field need", values[i])
} else if value.Valid {
_m.Need = courseentity.Need(value.String)
}
case courseentity.FieldStatus:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field status", values[i])
} else if value.Valid {
_m.Status = courseentity.Status(value.String)
}
case courseentity.FieldTaskCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field task_count", values[i])
} else if value.Valid {
_m.TaskCount = int(value.Int64)
}
case courseentity.FieldSuccessCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field success_count", values[i])
} else if value.Valid {
_m.SuccessCount = int(value.Int64)
}
case courseentity.FieldExamState:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field exam_state", values[i])
} else if value.Valid {
_m.ExamState = courseentity.ExamState(value.String)
}
case courseentity.FieldViolence:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field violence", values[i])
} else if value.Valid {
_m.Violence = courseentity.Violence(value.String)
}
case courseentity.FieldDesc:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field desc", values[i])
} else if value.Valid {
_m.Desc = value.String
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the CourseEntity.
// This includes values selected through modifiers, order, etc.
func (_m *CourseEntity) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QuerySysUser queries the "sys_user" edge of the CourseEntity entity.
func (_m *CourseEntity) QuerySysUser() *SysUserQuery {
return NewCourseEntityClient(_m.config).QuerySysUser(_m)
}
// Update returns a builder for updating this CourseEntity.
// Note that you need to call CourseEntity.Unwrap() before calling this method if this CourseEntity
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *CourseEntity) Update() *CourseEntityUpdateOne {
return NewCourseEntityClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the CourseEntity entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (_m *CourseEntity) Unwrap() *CourseEntity {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: CourseEntity is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *CourseEntity) String() string {
var builder strings.Builder
builder.WriteString("CourseEntity(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("create_time=")
builder.WriteString(fmt.Sprintf("%v", _m.CreateTime))
builder.WriteString(", ")
builder.WriteString("update_time=")
builder.WriteString(fmt.Sprintf("%v", _m.UpdateTime))
builder.WriteString(", ")
builder.WriteString("user_id=")
builder.WriteString(fmt.Sprintf("%v", _m.UserID))
builder.WriteString(", ")
builder.WriteString("username=")
builder.WriteString(_m.Username)
builder.WriteString(", ")
builder.WriteString("password=<sensitive>")
builder.WriteString(", ")
builder.WriteString("type=")
builder.WriteString(fmt.Sprintf("%v", _m.Type))
builder.WriteString(", ")
builder.WriteString("course_name=")
builder.WriteString(_m.CourseName)
builder.WriteString(", ")
builder.WriteString("course_id=")
builder.WriteString(_m.CourseID)
builder.WriteString(", ")
builder.WriteString("need=")
builder.WriteString(fmt.Sprintf("%v", _m.Need))
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(fmt.Sprintf("%v", _m.Status))
builder.WriteString(", ")
builder.WriteString("task_count=")
builder.WriteString(fmt.Sprintf("%v", _m.TaskCount))
builder.WriteString(", ")
builder.WriteString("success_count=")
builder.WriteString(fmt.Sprintf("%v", _m.SuccessCount))
builder.WriteString(", ")
builder.WriteString("exam_state=")
builder.WriteString(fmt.Sprintf("%v", _m.ExamState))
builder.WriteString(", ")
builder.WriteString("violence=")
builder.WriteString(fmt.Sprintf("%v", _m.Violence))
builder.WriteString(", ")
builder.WriteString("desc=")
builder.WriteString(_m.Desc)
builder.WriteByte(')')
return builder.String()
}
// CourseEntities is a parsable slice of CourseEntity.
type CourseEntities []*CourseEntity
+335
View File
@@ -0,0 +1,335 @@
// ENT数据库文件,请勿编辑。
package courseentity
import (
"fmt"
"likedream-goframe/internal/framework/ent2"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the courseentity type in the database.
Label = "course_entity"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreateTime holds the string denoting the create_time field in the database.
FieldCreateTime = "create_time"
// FieldUpdateTime holds the string denoting the update_time field in the database.
FieldUpdateTime = "update_time"
// FieldUserID holds the string denoting the user_id field in the database.
FieldUserID = "user_id"
// FieldUsername holds the string denoting the username field in the database.
FieldUsername = "username"
// FieldPassword holds the string denoting the password field in the database.
FieldPassword = "password"
// FieldType holds the string denoting the type field in the database.
FieldType = "type"
// FieldCourseName holds the string denoting the course_name field in the database.
FieldCourseName = "course_name"
// FieldCourseID holds the string denoting the course_id field in the database.
FieldCourseID = "course_id"
// FieldNeed holds the string denoting the need field in the database.
FieldNeed = "need"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status"
// FieldTaskCount holds the string denoting the task_count field in the database.
FieldTaskCount = "task_count"
// FieldSuccessCount holds the string denoting the success_count field in the database.
FieldSuccessCount = "success_count"
// FieldExamState holds the string denoting the exam_state field in the database.
FieldExamState = "exam_state"
// FieldViolence holds the string denoting the violence field in the database.
FieldViolence = "violence"
// FieldDesc holds the string denoting the desc field in the database.
FieldDesc = "desc"
// EdgeSysUser holds the string denoting the sys_user edge name in mutations.
EdgeSysUser = "sys_user"
// Table holds the table name of the courseentity in the database.
Table = "course_entity"
// SysUserTable is the table that holds the sys_user relation/edge.
SysUserTable = "course_entity"
// SysUserInverseTable is the table name for the SysUser entity.
// It exists in this package in order to avoid circular dependency with the "sysuser" package.
SysUserInverseTable = "sys_user"
// SysUserColumn is the table column denoting the sys_user relation/edge.
SysUserColumn = "user_id"
)
// Columns holds all SQL columns for courseentity fields.
var Columns = []string{
FieldID,
FieldCreateTime,
FieldUpdateTime,
FieldUserID,
FieldUsername,
FieldPassword,
FieldType,
FieldCourseName,
FieldCourseID,
FieldNeed,
FieldStatus,
FieldTaskCount,
FieldSuccessCount,
FieldExamState,
FieldViolence,
FieldDesc,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
// Note that the variables below are initialized by the runtime
// package on the initialization of the application. Therefore,
// it should be imported in the main as follows:
//
// import _ "likedream-goframe/internal/ent/runtime"
var (
Hooks [1]ent.Hook
// DefaultCreateTime holds the default value on creation for the "create_time" field.
DefaultCreateTime func() *ent2.CustomTime
// DefaultUpdateTime holds the default value on creation for the "update_time" field.
DefaultUpdateTime func() *ent2.CustomTime
// DefaultTaskCount holds the default value on creation for the "task_count" field.
DefaultTaskCount int
// DefaultSuccessCount holds the default value on creation for the "success_count" field.
DefaultSuccessCount int
)
// Type defines the type for the "type" enum field.
type Type string
// Type values.
const (
TypeXxt Type = "xxt"
)
func (_type Type) String() string {
return string(_type)
}
// TypeValidator is a validator for the "type" field enum values. It is called by the builders before save.
func TypeValidator(_type Type) error {
switch _type {
case TypeXxt:
return nil
default:
return fmt.Errorf("courseentity: invalid enum value for type field: %q", _type)
}
}
// Need defines the type for the "need" enum field.
type Need string
// Need values.
const (
NeedTask Need = "task"
NeedExam Need = "exam"
NeedAll Need = "all"
)
func (n Need) String() string {
return string(n)
}
// NeedValidator is a validator for the "need" field enum values. It is called by the builders before save.
func NeedValidator(n Need) error {
switch n {
case NeedTask, NeedExam, NeedAll:
return nil
default:
return fmt.Errorf("courseentity: invalid enum value for need field: %q", n)
}
}
// Status defines the type for the "status" enum field.
type Status string
// StatusNotStart is the default value of the Status enum.
const DefaultStatus = StatusNotStart
// Status values.
const (
StatusNotStart Status = "not_start"
StatusWaiting Status = "waiting"
StatusDoing Status = "doing"
StatusDone Status = "done"
StatusFail Status = "fail"
StatusPause Status = "pause"
)
func (s Status) String() string {
return string(s)
}
// StatusValidator is a validator for the "status" field enum values. It is called by the builders before save.
func StatusValidator(s Status) error {
switch s {
case StatusNotStart, StatusWaiting, StatusDoing, StatusDone, StatusFail, StatusPause:
return nil
default:
return fmt.Errorf("courseentity: invalid enum value for status field: %q", s)
}
}
// ExamState defines the type for the "exam_state" enum field.
type ExamState string
// ExamStateNotStart is the default value of the ExamState enum.
const DefaultExamState = ExamStateNotStart
// ExamState values.
const (
ExamStateNotStart ExamState = "not_start"
ExamStateWaiting ExamState = "waiting"
ExamStateDoing ExamState = "doing"
ExamStateDone ExamState = "done"
ExamStateFail ExamState = "fail"
)
func (es ExamState) String() string {
return string(es)
}
// ExamStateValidator is a validator for the "exam_state" field enum values. It is called by the builders before save.
func ExamStateValidator(es ExamState) error {
switch es {
case ExamStateNotStart, ExamStateWaiting, ExamStateDoing, ExamStateDone, ExamStateFail:
return nil
default:
return fmt.Errorf("courseentity: invalid enum value for exam_state field: %q", es)
}
}
// Violence defines the type for the "violence" enum field.
type Violence string
// ViolenceNo is the default value of the Violence enum.
const DefaultViolence = ViolenceNo
// Violence values.
const (
ViolenceNo Violence = "no"
ViolenceYes Violence = "yes"
)
func (v Violence) String() string {
return string(v)
}
// ViolenceValidator is a validator for the "violence" field enum values. It is called by the builders before save.
func ViolenceValidator(v Violence) error {
switch v {
case ViolenceNo, ViolenceYes:
return nil
default:
return fmt.Errorf("courseentity: invalid enum value for violence field: %q", v)
}
}
// OrderOption defines the ordering options for the CourseEntity 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()
}
// ByCreateTime orders the results by the create_time field.
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
}
// ByUpdateTime orders the results by the update_time field.
func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdateTime, opts...).ToFunc()
}
// ByUserID orders the results by the user_id field.
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUserID, opts...).ToFunc()
}
// ByUsername orders the results by the username field.
func ByUsername(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUsername, opts...).ToFunc()
}
// ByPassword orders the results by the password field.
func ByPassword(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPassword, opts...).ToFunc()
}
// ByType orders the results by the type field.
func ByType(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldType, opts...).ToFunc()
}
// ByCourseName orders the results by the course_name field.
func ByCourseName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCourseName, opts...).ToFunc()
}
// ByCourseID orders the results by the course_id field.
func ByCourseID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCourseID, opts...).ToFunc()
}
// ByNeed orders the results by the need field.
func ByNeed(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldNeed, opts...).ToFunc()
}
// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStatus, opts...).ToFunc()
}
// ByTaskCount orders the results by the task_count field.
func ByTaskCount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTaskCount, opts...).ToFunc()
}
// BySuccessCount orders the results by the success_count field.
func BySuccessCount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSuccessCount, opts...).ToFunc()
}
// ByExamState orders the results by the exam_state field.
func ByExamState(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldExamState, opts...).ToFunc()
}
// ByViolence orders the results by the violence field.
func ByViolence(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldViolence, opts...).ToFunc()
}
// ByDesc orders the results by the desc field.
func ByDesc(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDesc, opts...).ToFunc()
}
// BySysUserField orders the results by sys_user field.
func BySysUserField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newSysUserStep(), sql.OrderByField(field, opts...))
}
}
func newSysUserStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(SysUserInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, SysUserTable, SysUserColumn),
)
}
+826
View File
@@ -0,0 +1,826 @@
// ENT数据库文件,请勿编辑。
package courseentity
import (
"likedream-goframe/internal/ent/internal"
"likedream-goframe/internal/ent/predicate"
"likedream-goframe/internal/framework/ent2"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldLTE(FieldID, id))
}
// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ.
func CreateTime(v *ent2.CustomTime) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldCreateTime, v))
}
// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ.
func UpdateTime(v *ent2.CustomTime) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldUpdateTime, v))
}
// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ.
func UserID(v int64) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldUserID, v))
}
// Username applies equality check predicate on the "username" field. It's identical to UsernameEQ.
func Username(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldUsername, v))
}
// Password applies equality check predicate on the "password" field. It's identical to PasswordEQ.
func Password(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldPassword, v))
}
// CourseName applies equality check predicate on the "course_name" field. It's identical to CourseNameEQ.
func CourseName(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldCourseName, v))
}
// CourseID applies equality check predicate on the "course_id" field. It's identical to CourseIDEQ.
func CourseID(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldCourseID, v))
}
// TaskCount applies equality check predicate on the "task_count" field. It's identical to TaskCountEQ.
func TaskCount(v int) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldTaskCount, v))
}
// SuccessCount applies equality check predicate on the "success_count" field. It's identical to SuccessCountEQ.
func SuccessCount(v int) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldSuccessCount, v))
}
// Desc applies equality check predicate on the "desc" field. It's identical to DescEQ.
func Desc(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldDesc, v))
}
// CreateTimeEQ applies the EQ predicate on the "create_time" field.
func CreateTimeEQ(v *ent2.CustomTime) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldCreateTime, v))
}
// CreateTimeNEQ applies the NEQ predicate on the "create_time" field.
func CreateTimeNEQ(v *ent2.CustomTime) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNEQ(FieldCreateTime, v))
}
// CreateTimeIn applies the In predicate on the "create_time" field.
func CreateTimeIn(vs ...*ent2.CustomTime) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldIn(FieldCreateTime, vs...))
}
// CreateTimeNotIn applies the NotIn predicate on the "create_time" field.
func CreateTimeNotIn(vs ...*ent2.CustomTime) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNotIn(FieldCreateTime, vs...))
}
// CreateTimeGT applies the GT predicate on the "create_time" field.
func CreateTimeGT(v *ent2.CustomTime) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldGT(FieldCreateTime, v))
}
// CreateTimeGTE applies the GTE predicate on the "create_time" field.
func CreateTimeGTE(v *ent2.CustomTime) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldGTE(FieldCreateTime, v))
}
// CreateTimeLT applies the LT predicate on the "create_time" field.
func CreateTimeLT(v *ent2.CustomTime) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldLT(FieldCreateTime, v))
}
// CreateTimeLTE applies the LTE predicate on the "create_time" field.
func CreateTimeLTE(v *ent2.CustomTime) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldLTE(FieldCreateTime, v))
}
// CreateTimeContains applies the Contains predicate on the "create_time" field.
func CreateTimeContains(v *ent2.CustomTime) predicate.CourseEntity {
vc := v.String()
return predicate.CourseEntity(sql.FieldContains(FieldCreateTime, vc))
}
// CreateTimeHasPrefix applies the HasPrefix predicate on the "create_time" field.
func CreateTimeHasPrefix(v *ent2.CustomTime) predicate.CourseEntity {
vc := v.String()
return predicate.CourseEntity(sql.FieldHasPrefix(FieldCreateTime, vc))
}
// CreateTimeHasSuffix applies the HasSuffix predicate on the "create_time" field.
func CreateTimeHasSuffix(v *ent2.CustomTime) predicate.CourseEntity {
vc := v.String()
return predicate.CourseEntity(sql.FieldHasSuffix(FieldCreateTime, vc))
}
// CreateTimeEqualFold applies the EqualFold predicate on the "create_time" field.
func CreateTimeEqualFold(v *ent2.CustomTime) predicate.CourseEntity {
vc := v.String()
return predicate.CourseEntity(sql.FieldEqualFold(FieldCreateTime, vc))
}
// CreateTimeContainsFold applies the ContainsFold predicate on the "create_time" field.
func CreateTimeContainsFold(v *ent2.CustomTime) predicate.CourseEntity {
vc := v.String()
return predicate.CourseEntity(sql.FieldContainsFold(FieldCreateTime, vc))
}
// UpdateTimeEQ applies the EQ predicate on the "update_time" field.
func UpdateTimeEQ(v *ent2.CustomTime) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldUpdateTime, v))
}
// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field.
func UpdateTimeNEQ(v *ent2.CustomTime) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNEQ(FieldUpdateTime, v))
}
// UpdateTimeIn applies the In predicate on the "update_time" field.
func UpdateTimeIn(vs ...*ent2.CustomTime) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldIn(FieldUpdateTime, vs...))
}
// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field.
func UpdateTimeNotIn(vs ...*ent2.CustomTime) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNotIn(FieldUpdateTime, vs...))
}
// UpdateTimeGT applies the GT predicate on the "update_time" field.
func UpdateTimeGT(v *ent2.CustomTime) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldGT(FieldUpdateTime, v))
}
// UpdateTimeGTE applies the GTE predicate on the "update_time" field.
func UpdateTimeGTE(v *ent2.CustomTime) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldGTE(FieldUpdateTime, v))
}
// UpdateTimeLT applies the LT predicate on the "update_time" field.
func UpdateTimeLT(v *ent2.CustomTime) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldLT(FieldUpdateTime, v))
}
// UpdateTimeLTE applies the LTE predicate on the "update_time" field.
func UpdateTimeLTE(v *ent2.CustomTime) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldLTE(FieldUpdateTime, v))
}
// UpdateTimeContains applies the Contains predicate on the "update_time" field.
func UpdateTimeContains(v *ent2.CustomTime) predicate.CourseEntity {
vc := v.String()
return predicate.CourseEntity(sql.FieldContains(FieldUpdateTime, vc))
}
// UpdateTimeHasPrefix applies the HasPrefix predicate on the "update_time" field.
func UpdateTimeHasPrefix(v *ent2.CustomTime) predicate.CourseEntity {
vc := v.String()
return predicate.CourseEntity(sql.FieldHasPrefix(FieldUpdateTime, vc))
}
// UpdateTimeHasSuffix applies the HasSuffix predicate on the "update_time" field.
func UpdateTimeHasSuffix(v *ent2.CustomTime) predicate.CourseEntity {
vc := v.String()
return predicate.CourseEntity(sql.FieldHasSuffix(FieldUpdateTime, vc))
}
// UpdateTimeEqualFold applies the EqualFold predicate on the "update_time" field.
func UpdateTimeEqualFold(v *ent2.CustomTime) predicate.CourseEntity {
vc := v.String()
return predicate.CourseEntity(sql.FieldEqualFold(FieldUpdateTime, vc))
}
// UpdateTimeContainsFold applies the ContainsFold predicate on the "update_time" field.
func UpdateTimeContainsFold(v *ent2.CustomTime) predicate.CourseEntity {
vc := v.String()
return predicate.CourseEntity(sql.FieldContainsFold(FieldUpdateTime, vc))
}
// UserIDEQ applies the EQ predicate on the "user_id" field.
func UserIDEQ(v int64) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldUserID, v))
}
// UserIDNEQ applies the NEQ predicate on the "user_id" field.
func UserIDNEQ(v int64) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNEQ(FieldUserID, v))
}
// UserIDIn applies the In predicate on the "user_id" field.
func UserIDIn(vs ...int64) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldIn(FieldUserID, vs...))
}
// UserIDNotIn applies the NotIn predicate on the "user_id" field.
func UserIDNotIn(vs ...int64) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNotIn(FieldUserID, vs...))
}
// UsernameEQ applies the EQ predicate on the "username" field.
func UsernameEQ(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldUsername, v))
}
// UsernameNEQ applies the NEQ predicate on the "username" field.
func UsernameNEQ(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNEQ(FieldUsername, v))
}
// UsernameIn applies the In predicate on the "username" field.
func UsernameIn(vs ...string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldIn(FieldUsername, vs...))
}
// UsernameNotIn applies the NotIn predicate on the "username" field.
func UsernameNotIn(vs ...string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNotIn(FieldUsername, vs...))
}
// UsernameGT applies the GT predicate on the "username" field.
func UsernameGT(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldGT(FieldUsername, v))
}
// UsernameGTE applies the GTE predicate on the "username" field.
func UsernameGTE(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldGTE(FieldUsername, v))
}
// UsernameLT applies the LT predicate on the "username" field.
func UsernameLT(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldLT(FieldUsername, v))
}
// UsernameLTE applies the LTE predicate on the "username" field.
func UsernameLTE(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldLTE(FieldUsername, v))
}
// UsernameContains applies the Contains predicate on the "username" field.
func UsernameContains(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldContains(FieldUsername, v))
}
// UsernameHasPrefix applies the HasPrefix predicate on the "username" field.
func UsernameHasPrefix(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldHasPrefix(FieldUsername, v))
}
// UsernameHasSuffix applies the HasSuffix predicate on the "username" field.
func UsernameHasSuffix(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldHasSuffix(FieldUsername, v))
}
// UsernameEqualFold applies the EqualFold predicate on the "username" field.
func UsernameEqualFold(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEqualFold(FieldUsername, v))
}
// UsernameContainsFold applies the ContainsFold predicate on the "username" field.
func UsernameContainsFold(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldContainsFold(FieldUsername, v))
}
// PasswordEQ applies the EQ predicate on the "password" field.
func PasswordEQ(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldPassword, v))
}
// PasswordNEQ applies the NEQ predicate on the "password" field.
func PasswordNEQ(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNEQ(FieldPassword, v))
}
// PasswordIn applies the In predicate on the "password" field.
func PasswordIn(vs ...string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldIn(FieldPassword, vs...))
}
// PasswordNotIn applies the NotIn predicate on the "password" field.
func PasswordNotIn(vs ...string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNotIn(FieldPassword, vs...))
}
// PasswordGT applies the GT predicate on the "password" field.
func PasswordGT(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldGT(FieldPassword, v))
}
// PasswordGTE applies the GTE predicate on the "password" field.
func PasswordGTE(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldGTE(FieldPassword, v))
}
// PasswordLT applies the LT predicate on the "password" field.
func PasswordLT(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldLT(FieldPassword, v))
}
// PasswordLTE applies the LTE predicate on the "password" field.
func PasswordLTE(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldLTE(FieldPassword, v))
}
// PasswordContains applies the Contains predicate on the "password" field.
func PasswordContains(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldContains(FieldPassword, v))
}
// PasswordHasPrefix applies the HasPrefix predicate on the "password" field.
func PasswordHasPrefix(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldHasPrefix(FieldPassword, v))
}
// PasswordHasSuffix applies the HasSuffix predicate on the "password" field.
func PasswordHasSuffix(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldHasSuffix(FieldPassword, v))
}
// PasswordEqualFold applies the EqualFold predicate on the "password" field.
func PasswordEqualFold(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEqualFold(FieldPassword, v))
}
// PasswordContainsFold applies the ContainsFold predicate on the "password" field.
func PasswordContainsFold(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldContainsFold(FieldPassword, v))
}
// TypeEQ applies the EQ predicate on the "type" field.
func TypeEQ(v Type) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldType, v))
}
// TypeNEQ applies the NEQ predicate on the "type" field.
func TypeNEQ(v Type) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNEQ(FieldType, v))
}
// TypeIn applies the In predicate on the "type" field.
func TypeIn(vs ...Type) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldIn(FieldType, vs...))
}
// TypeNotIn applies the NotIn predicate on the "type" field.
func TypeNotIn(vs ...Type) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNotIn(FieldType, vs...))
}
// CourseNameEQ applies the EQ predicate on the "course_name" field.
func CourseNameEQ(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldCourseName, v))
}
// CourseNameNEQ applies the NEQ predicate on the "course_name" field.
func CourseNameNEQ(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNEQ(FieldCourseName, v))
}
// CourseNameIn applies the In predicate on the "course_name" field.
func CourseNameIn(vs ...string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldIn(FieldCourseName, vs...))
}
// CourseNameNotIn applies the NotIn predicate on the "course_name" field.
func CourseNameNotIn(vs ...string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNotIn(FieldCourseName, vs...))
}
// CourseNameGT applies the GT predicate on the "course_name" field.
func CourseNameGT(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldGT(FieldCourseName, v))
}
// CourseNameGTE applies the GTE predicate on the "course_name" field.
func CourseNameGTE(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldGTE(FieldCourseName, v))
}
// CourseNameLT applies the LT predicate on the "course_name" field.
func CourseNameLT(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldLT(FieldCourseName, v))
}
// CourseNameLTE applies the LTE predicate on the "course_name" field.
func CourseNameLTE(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldLTE(FieldCourseName, v))
}
// CourseNameContains applies the Contains predicate on the "course_name" field.
func CourseNameContains(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldContains(FieldCourseName, v))
}
// CourseNameHasPrefix applies the HasPrefix predicate on the "course_name" field.
func CourseNameHasPrefix(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldHasPrefix(FieldCourseName, v))
}
// CourseNameHasSuffix applies the HasSuffix predicate on the "course_name" field.
func CourseNameHasSuffix(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldHasSuffix(FieldCourseName, v))
}
// CourseNameEqualFold applies the EqualFold predicate on the "course_name" field.
func CourseNameEqualFold(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEqualFold(FieldCourseName, v))
}
// CourseNameContainsFold applies the ContainsFold predicate on the "course_name" field.
func CourseNameContainsFold(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldContainsFold(FieldCourseName, v))
}
// CourseIDEQ applies the EQ predicate on the "course_id" field.
func CourseIDEQ(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldCourseID, v))
}
// CourseIDNEQ applies the NEQ predicate on the "course_id" field.
func CourseIDNEQ(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNEQ(FieldCourseID, v))
}
// CourseIDIn applies the In predicate on the "course_id" field.
func CourseIDIn(vs ...string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldIn(FieldCourseID, vs...))
}
// CourseIDNotIn applies the NotIn predicate on the "course_id" field.
func CourseIDNotIn(vs ...string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNotIn(FieldCourseID, vs...))
}
// CourseIDGT applies the GT predicate on the "course_id" field.
func CourseIDGT(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldGT(FieldCourseID, v))
}
// CourseIDGTE applies the GTE predicate on the "course_id" field.
func CourseIDGTE(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldGTE(FieldCourseID, v))
}
// CourseIDLT applies the LT predicate on the "course_id" field.
func CourseIDLT(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldLT(FieldCourseID, v))
}
// CourseIDLTE applies the LTE predicate on the "course_id" field.
func CourseIDLTE(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldLTE(FieldCourseID, v))
}
// CourseIDContains applies the Contains predicate on the "course_id" field.
func CourseIDContains(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldContains(FieldCourseID, v))
}
// CourseIDHasPrefix applies the HasPrefix predicate on the "course_id" field.
func CourseIDHasPrefix(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldHasPrefix(FieldCourseID, v))
}
// CourseIDHasSuffix applies the HasSuffix predicate on the "course_id" field.
func CourseIDHasSuffix(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldHasSuffix(FieldCourseID, v))
}
// CourseIDEqualFold applies the EqualFold predicate on the "course_id" field.
func CourseIDEqualFold(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEqualFold(FieldCourseID, v))
}
// CourseIDContainsFold applies the ContainsFold predicate on the "course_id" field.
func CourseIDContainsFold(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldContainsFold(FieldCourseID, v))
}
// NeedEQ applies the EQ predicate on the "need" field.
func NeedEQ(v Need) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldNeed, v))
}
// NeedNEQ applies the NEQ predicate on the "need" field.
func NeedNEQ(v Need) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNEQ(FieldNeed, v))
}
// NeedIn applies the In predicate on the "need" field.
func NeedIn(vs ...Need) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldIn(FieldNeed, vs...))
}
// NeedNotIn applies the NotIn predicate on the "need" field.
func NeedNotIn(vs ...Need) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNotIn(FieldNeed, vs...))
}
// StatusEQ applies the EQ predicate on the "status" field.
func StatusEQ(v Status) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldStatus, v))
}
// StatusNEQ applies the NEQ predicate on the "status" field.
func StatusNEQ(v Status) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNEQ(FieldStatus, v))
}
// StatusIn applies the In predicate on the "status" field.
func StatusIn(vs ...Status) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldIn(FieldStatus, vs...))
}
// StatusNotIn applies the NotIn predicate on the "status" field.
func StatusNotIn(vs ...Status) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNotIn(FieldStatus, vs...))
}
// TaskCountEQ applies the EQ predicate on the "task_count" field.
func TaskCountEQ(v int) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldTaskCount, v))
}
// TaskCountNEQ applies the NEQ predicate on the "task_count" field.
func TaskCountNEQ(v int) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNEQ(FieldTaskCount, v))
}
// TaskCountIn applies the In predicate on the "task_count" field.
func TaskCountIn(vs ...int) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldIn(FieldTaskCount, vs...))
}
// TaskCountNotIn applies the NotIn predicate on the "task_count" field.
func TaskCountNotIn(vs ...int) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNotIn(FieldTaskCount, vs...))
}
// TaskCountGT applies the GT predicate on the "task_count" field.
func TaskCountGT(v int) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldGT(FieldTaskCount, v))
}
// TaskCountGTE applies the GTE predicate on the "task_count" field.
func TaskCountGTE(v int) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldGTE(FieldTaskCount, v))
}
// TaskCountLT applies the LT predicate on the "task_count" field.
func TaskCountLT(v int) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldLT(FieldTaskCount, v))
}
// TaskCountLTE applies the LTE predicate on the "task_count" field.
func TaskCountLTE(v int) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldLTE(FieldTaskCount, v))
}
// SuccessCountEQ applies the EQ predicate on the "success_count" field.
func SuccessCountEQ(v int) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldSuccessCount, v))
}
// SuccessCountNEQ applies the NEQ predicate on the "success_count" field.
func SuccessCountNEQ(v int) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNEQ(FieldSuccessCount, v))
}
// SuccessCountIn applies the In predicate on the "success_count" field.
func SuccessCountIn(vs ...int) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldIn(FieldSuccessCount, vs...))
}
// SuccessCountNotIn applies the NotIn predicate on the "success_count" field.
func SuccessCountNotIn(vs ...int) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNotIn(FieldSuccessCount, vs...))
}
// SuccessCountGT applies the GT predicate on the "success_count" field.
func SuccessCountGT(v int) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldGT(FieldSuccessCount, v))
}
// SuccessCountGTE applies the GTE predicate on the "success_count" field.
func SuccessCountGTE(v int) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldGTE(FieldSuccessCount, v))
}
// SuccessCountLT applies the LT predicate on the "success_count" field.
func SuccessCountLT(v int) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldLT(FieldSuccessCount, v))
}
// SuccessCountLTE applies the LTE predicate on the "success_count" field.
func SuccessCountLTE(v int) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldLTE(FieldSuccessCount, v))
}
// ExamStateEQ applies the EQ predicate on the "exam_state" field.
func ExamStateEQ(v ExamState) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldExamState, v))
}
// ExamStateNEQ applies the NEQ predicate on the "exam_state" field.
func ExamStateNEQ(v ExamState) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNEQ(FieldExamState, v))
}
// ExamStateIn applies the In predicate on the "exam_state" field.
func ExamStateIn(vs ...ExamState) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldIn(FieldExamState, vs...))
}
// ExamStateNotIn applies the NotIn predicate on the "exam_state" field.
func ExamStateNotIn(vs ...ExamState) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNotIn(FieldExamState, vs...))
}
// ViolenceEQ applies the EQ predicate on the "violence" field.
func ViolenceEQ(v Violence) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldViolence, v))
}
// ViolenceNEQ applies the NEQ predicate on the "violence" field.
func ViolenceNEQ(v Violence) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNEQ(FieldViolence, v))
}
// ViolenceIn applies the In predicate on the "violence" field.
func ViolenceIn(vs ...Violence) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldIn(FieldViolence, vs...))
}
// ViolenceNotIn applies the NotIn predicate on the "violence" field.
func ViolenceNotIn(vs ...Violence) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNotIn(FieldViolence, vs...))
}
// DescEQ applies the EQ predicate on the "desc" field.
func DescEQ(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEQ(FieldDesc, v))
}
// DescNEQ applies the NEQ predicate on the "desc" field.
func DescNEQ(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNEQ(FieldDesc, v))
}
// DescIn applies the In predicate on the "desc" field.
func DescIn(vs ...string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldIn(FieldDesc, vs...))
}
// DescNotIn applies the NotIn predicate on the "desc" field.
func DescNotIn(vs ...string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNotIn(FieldDesc, vs...))
}
// DescGT applies the GT predicate on the "desc" field.
func DescGT(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldGT(FieldDesc, v))
}
// DescGTE applies the GTE predicate on the "desc" field.
func DescGTE(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldGTE(FieldDesc, v))
}
// DescLT applies the LT predicate on the "desc" field.
func DescLT(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldLT(FieldDesc, v))
}
// DescLTE applies the LTE predicate on the "desc" field.
func DescLTE(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldLTE(FieldDesc, v))
}
// DescContains applies the Contains predicate on the "desc" field.
func DescContains(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldContains(FieldDesc, v))
}
// DescHasPrefix applies the HasPrefix predicate on the "desc" field.
func DescHasPrefix(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldHasPrefix(FieldDesc, v))
}
// DescHasSuffix applies the HasSuffix predicate on the "desc" field.
func DescHasSuffix(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldHasSuffix(FieldDesc, v))
}
// DescIsNil applies the IsNil predicate on the "desc" field.
func DescIsNil() predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldIsNull(FieldDesc))
}
// DescNotNil applies the NotNil predicate on the "desc" field.
func DescNotNil() predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldNotNull(FieldDesc))
}
// DescEqualFold applies the EqualFold predicate on the "desc" field.
func DescEqualFold(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldEqualFold(FieldDesc, v))
}
// DescContainsFold applies the ContainsFold predicate on the "desc" field.
func DescContainsFold(v string) predicate.CourseEntity {
return predicate.CourseEntity(sql.FieldContainsFold(FieldDesc, v))
}
// HasSysUser applies the HasEdge predicate on the "sys_user" edge.
func HasSysUser() predicate.CourseEntity {
return predicate.CourseEntity(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, SysUserTable, SysUserColumn),
)
schemaConfig := internal.SchemaConfigFromContext(s.Context())
step.To.Schema = schemaConfig.SysUser
step.Edge.Schema = schemaConfig.CourseEntity
sqlgraph.HasNeighbors(s, step)
})
}
// HasSysUserWith applies the HasEdge predicate on the "sys_user" edge with a given conditions (other predicates).
func HasSysUserWith(preds ...predicate.SysUser) predicate.CourseEntity {
return predicate.CourseEntity(func(s *sql.Selector) {
step := newSysUserStep()
schemaConfig := internal.SchemaConfigFromContext(s.Context())
step.To.Schema = schemaConfig.SysUser
step.Edge.Schema = schemaConfig.CourseEntity
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.CourseEntity) predicate.CourseEntity {
return predicate.CourseEntity(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.CourseEntity) predicate.CourseEntity {
return predicate.CourseEntity(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.CourseEntity) predicate.CourseEntity {
return predicate.CourseEntity(sql.NotPredicates(p))
}
File diff suppressed because it is too large Load Diff
+91
View File
@@ -0,0 +1,91 @@
// ENT数据库文件,请勿编辑。
package ent
import (
"context"
"likedream-goframe/internal/ent/courseentity"
"likedream-goframe/internal/ent/internal"
"likedream-goframe/internal/ent/predicate"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// CourseEntityDelete is the builder for deleting a CourseEntity entity.
type CourseEntityDelete struct {
config
hooks []Hook
mutation *CourseEntityMutation
}
// Where appends a list predicates to the CourseEntityDelete builder.
func (_d *CourseEntityDelete) Where(ps ...predicate.CourseEntity) *CourseEntityDelete {
_d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (_d *CourseEntityDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *CourseEntityDelete) ExecX(ctx context.Context) int {
n, err := _d.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (_d *CourseEntityDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(courseentity.Table, sqlgraph.NewFieldSpec(courseentity.FieldID, field.TypeInt64))
_spec.Node.Schema = _d.schemaConfig.CourseEntity
ctx = internal.NewSchemaConfigContext(ctx, _d.schemaConfig)
if ps := _d.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
_d.mutation.done = true
return affected, err
}
// CourseEntityDeleteOne is the builder for deleting a single CourseEntity entity.
type CourseEntityDeleteOne struct {
_d *CourseEntityDelete
}
// Where appends a list predicates to the CourseEntityDelete builder.
func (_d *CourseEntityDeleteOne) Where(ps ...predicate.CourseEntity) *CourseEntityDeleteOne {
_d._d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query.
func (_d *CourseEntityDeleteOne) Exec(ctx context.Context) error {
n, err := _d._d.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{courseentity.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *CourseEntityDeleteOne) ExecX(ctx context.Context) {
if err := _d.Exec(ctx); err != nil {
panic(err)
}
}
+667
View File
@@ -0,0 +1,667 @@
// ENT数据库文件,请勿编辑。
package ent
import (
"context"
"fmt"
"likedream-goframe/internal/ent/courseentity"
"likedream-goframe/internal/ent/internal"
"likedream-goframe/internal/ent/predicate"
"likedream-goframe/internal/ent/sysuser"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// CourseEntityQuery is the builder for querying CourseEntity entities.
type CourseEntityQuery struct {
config
ctx *QueryContext
order []courseentity.OrderOption
inters []Interceptor
predicates []predicate.CourseEntity
withSysUser *SysUserQuery
modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the CourseEntityQuery builder.
func (_q *CourseEntityQuery) Where(ps ...predicate.CourseEntity) *CourseEntityQuery {
_q.predicates = append(_q.predicates, ps...)
return _q
}
// Limit the number of records to be returned by this query.
func (_q *CourseEntityQuery) Limit(limit int) *CourseEntityQuery {
_q.ctx.Limit = &limit
return _q
}
// Offset to start from.
func (_q *CourseEntityQuery) Offset(offset int) *CourseEntityQuery {
_q.ctx.Offset = &offset
return _q
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (_q *CourseEntityQuery) Unique(unique bool) *CourseEntityQuery {
_q.ctx.Unique = &unique
return _q
}
// Order specifies how the records should be ordered.
func (_q *CourseEntityQuery) Order(o ...courseentity.OrderOption) *CourseEntityQuery {
_q.order = append(_q.order, o...)
return _q
}
// QuerySysUser chains the current query on the "sys_user" edge.
func (_q *CourseEntityQuery) QuerySysUser() *SysUserQuery {
query := (&SysUserClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(courseentity.Table, courseentity.FieldID, selector),
sqlgraph.To(sysuser.Table, sysuser.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, courseentity.SysUserTable, courseentity.SysUserColumn),
)
schemaConfig := _q.schemaConfig
step.To.Schema = schemaConfig.SysUser
step.Edge.Schema = schemaConfig.CourseEntity
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
}
return query
}
// First returns the first CourseEntity entity from the query.
// Returns a *NotFoundError when no CourseEntity was found.
func (_q *CourseEntityQuery) First(ctx context.Context) (*CourseEntity, error) {
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{courseentity.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (_q *CourseEntityQuery) FirstX(ctx context.Context) *CourseEntity {
node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first CourseEntity ID from the query.
// Returns a *NotFoundError when no CourseEntity ID was found.
func (_q *CourseEntityQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{courseentity.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (_q *CourseEntityQuery) FirstIDX(ctx context.Context) int64 {
id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single CourseEntity entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one CourseEntity entity is found.
// Returns a *NotFoundError when no CourseEntity entities are found.
func (_q *CourseEntityQuery) Only(ctx context.Context) (*CourseEntity, error) {
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{courseentity.Label}
default:
return nil, &NotSingularError{courseentity.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (_q *CourseEntityQuery) OnlyX(ctx context.Context) *CourseEntity {
node, err := _q.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only CourseEntity ID in the query.
// Returns a *NotSingularError when more than one CourseEntity ID is found.
// Returns a *NotFoundError when no entities are found.
func (_q *CourseEntityQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{courseentity.Label}
default:
err = &NotSingularError{courseentity.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (_q *CourseEntityQuery) OnlyIDX(ctx context.Context) int64 {
id, err := _q.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of CourseEntities.
func (_q *CourseEntityQuery) All(ctx context.Context) ([]*CourseEntity, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*CourseEntity, *CourseEntityQuery]()
return withInterceptors[[]*CourseEntity](ctx, _q, qr, _q.inters)
}
// AllX is like All, but panics if an error occurs.
func (_q *CourseEntityQuery) AllX(ctx context.Context) []*CourseEntity {
nodes, err := _q.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of CourseEntity IDs.
func (_q *CourseEntityQuery) IDs(ctx context.Context) (ids []int64, err error) {
if _q.ctx.Unique == nil && _q.path != nil {
_q.Unique(true)
}
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
if err = _q.Select(courseentity.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (_q *CourseEntityQuery) IDsX(ctx context.Context) []int64 {
ids, err := _q.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (_q *CourseEntityQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := _q.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, _q, querierCount[*CourseEntityQuery](), _q.inters)
}
// CountX is like Count, but panics if an error occurs.
func (_q *CourseEntityQuery) CountX(ctx context.Context) int {
count, err := _q.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (_q *CourseEntityQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := _q.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (_q *CourseEntityQuery) ExistX(ctx context.Context) bool {
exist, err := _q.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the CourseEntityQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (_q *CourseEntityQuery) Clone() *CourseEntityQuery {
if _q == nil {
return nil
}
return &CourseEntityQuery{
config: _q.config,
ctx: _q.ctx.Clone(),
order: append([]courseentity.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.CourseEntity{}, _q.predicates...),
withSysUser: _q.withSysUser.Clone(),
// clone intermediate query.
sql: _q.sql.Clone(),
path: _q.path,
modifiers: append([]func(*sql.Selector){}, _q.modifiers...),
}
}
// WithSysUser tells the query-builder to eager-load the nodes that are connected to
// the "sys_user" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *CourseEntityQuery) WithSysUser(opts ...func(*SysUserQuery)) *CourseEntityQuery {
query := (&SysUserClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withSysUser = query
return _q
}
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
// Example:
//
// var v []struct {
// CreateTime *ent2.CustomTime `json:"createTime"`
// Count int `json:"count,omitempty"`
// }
//
// client.CourseEntity.Query().
// GroupBy(courseentity.FieldCreateTime).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (_q *CourseEntityQuery) GroupBy(field string, fields ...string) *CourseEntityGroupBy {
_q.ctx.Fields = append([]string{field}, fields...)
grbuild := &CourseEntityGroupBy{build: _q}
grbuild.flds = &_q.ctx.Fields
grbuild.label = courseentity.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// CreateTime *ent2.CustomTime `json:"createTime"`
// }
//
// client.CourseEntity.Query().
// Select(courseentity.FieldCreateTime).
// Scan(ctx, &v)
func (_q *CourseEntityQuery) Select(fields ...string) *CourseEntitySelect {
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &CourseEntitySelect{CourseEntityQuery: _q}
sbuild.label = courseentity.Label
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a CourseEntitySelect configured with the given aggregations.
func (_q *CourseEntityQuery) Aggregate(fns ...AggregateFunc) *CourseEntitySelect {
return _q.Select().Aggregate(fns...)
}
func (_q *CourseEntityQuery) prepareQuery(ctx context.Context) error {
for _, inter := range _q.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, _q); err != nil {
return err
}
}
}
for _, f := range _q.ctx.Fields {
if !courseentity.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if _q.path != nil {
prev, err := _q.path(ctx)
if err != nil {
return err
}
_q.sql = prev
}
return nil
}
func (_q *CourseEntityQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*CourseEntity, error) {
var (
nodes = []*CourseEntity{}
_spec = _q.querySpec()
loadedTypes = [1]bool{
_q.withSysUser != nil,
}
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*CourseEntity).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &CourseEntity{config: _q.config}
nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
_spec.Node.Schema = _q.schemaConfig.CourseEntity
ctx = internal.NewSchemaConfigContext(ctx, _q.schemaConfig)
if len(_q.modifiers) > 0 {
_spec.Modifiers = _q.modifiers
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := _q.withSysUser; query != nil {
if err := _q.loadSysUser(ctx, query, nodes, nil,
func(n *CourseEntity, e *SysUser) { n.Edges.SysUser = e }); err != nil {
return nil, err
}
}
return nodes, nil
}
func (_q *CourseEntityQuery) loadSysUser(ctx context.Context, query *SysUserQuery, nodes []*CourseEntity, init func(*CourseEntity), assign func(*CourseEntity, *SysUser)) error {
ids := make([]int64, 0, len(nodes))
nodeids := make(map[int64][]*CourseEntity)
for i := range nodes {
fk := nodes[i].UserID
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
if len(ids) == 0 {
return nil
}
query.Where(sysuser.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return fmt.Errorf(`unexpected foreign-key "user_id" returned %v`, n.ID)
}
for i := range nodes {
assign(nodes[i], n)
}
}
return nil
}
func (_q *CourseEntityQuery) sqlCount(ctx context.Context) (int, error) {
_spec := _q.querySpec()
_spec.Node.Schema = _q.schemaConfig.CourseEntity
ctx = internal.NewSchemaConfigContext(ctx, _q.schemaConfig)
if len(_q.modifiers) > 0 {
_spec.Modifiers = _q.modifiers
}
_spec.Node.Columns = _q.ctx.Fields
if len(_q.ctx.Fields) > 0 {
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
}
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
}
func (_q *CourseEntityQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(courseentity.Table, courseentity.Columns, sqlgraph.NewFieldSpec(courseentity.FieldID, field.TypeInt64))
_spec.From = _q.sql
if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if _q.path != nil {
_spec.Unique = true
}
if fields := _q.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, courseentity.FieldID)
for i := range fields {
if fields[i] != courseentity.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
if _q.withSysUser != nil {
_spec.Node.AddColumnOnce(courseentity.FieldUserID)
}
}
if ps := _q.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := _q.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := _q.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := _q.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (_q *CourseEntityQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(courseentity.Table)
columns := _q.ctx.Fields
if len(columns) == 0 {
columns = courseentity.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if _q.sql != nil {
selector = _q.sql
selector.Select(selector.Columns(columns...)...)
}
if _q.ctx.Unique != nil && *_q.ctx.Unique {
selector.Distinct()
}
t1.Schema(_q.schemaConfig.CourseEntity)
ctx = internal.NewSchemaConfigContext(ctx, _q.schemaConfig)
selector.WithContext(ctx)
for _, m := range _q.modifiers {
m(selector)
}
for _, p := range _q.predicates {
p(selector)
}
for _, p := range _q.order {
p(selector)
}
if offset := _q.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := _q.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ForUpdate locks the selected rows against concurrent updates, and prevent them from being
// updated, deleted or "selected ... for update" by other sessions, until the transaction is
// either committed or rolled-back.
func (_q *CourseEntityQuery) ForUpdate(opts ...sql.LockOption) *CourseEntityQuery {
if _q.driver.Dialect() == dialect.Postgres {
_q.Unique(false)
}
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
s.ForUpdate(opts...)
})
return _q
}
// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock
// on any rows that are read. Other sessions can read the rows, but cannot modify them
// until your transaction commits.
func (_q *CourseEntityQuery) ForShare(opts ...sql.LockOption) *CourseEntityQuery {
if _q.driver.Dialect() == dialect.Postgres {
_q.Unique(false)
}
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
s.ForShare(opts...)
})
return _q
}
// Modify adds a query modifier for attaching custom logic to queries.
func (_q *CourseEntityQuery) Modify(modifiers ...func(s *sql.Selector)) *CourseEntitySelect {
_q.modifiers = append(_q.modifiers, modifiers...)
return _q.Select()
}
// CourseEntityGroupBy is the group-by builder for CourseEntity entities.
type CourseEntityGroupBy struct {
selector
build *CourseEntityQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (_g *CourseEntityGroupBy) Aggregate(fns ...AggregateFunc) *CourseEntityGroupBy {
_g.fns = append(_g.fns, fns...)
return _g
}
// Scan applies the selector query and scans the result into the given value.
func (_g *CourseEntityGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := _g.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*CourseEntityQuery, *CourseEntityGroupBy](ctx, _g.build, _g, _g.build.inters, v)
}
func (_g *CourseEntityGroupBy) sqlScan(ctx context.Context, root *CourseEntityQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(_g.fns))
for _, fn := range _g.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
for _, f := range *_g.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*_g.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// CourseEntitySelect is the builder for selecting fields of CourseEntity entities.
type CourseEntitySelect struct {
*CourseEntityQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (_s *CourseEntitySelect) Aggregate(fns ...AggregateFunc) *CourseEntitySelect {
_s.fns = append(_s.fns, fns...)
return _s
}
// Scan applies the selector query and scans the result into the given value.
func (_s *CourseEntitySelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := _s.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*CourseEntityQuery, *CourseEntitySelect](ctx, _s.CourseEntityQuery, _s, _s.inters, v)
}
func (_s *CourseEntitySelect) sqlScan(ctx context.Context, root *CourseEntityQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(_s.fns))
for _, fn := range _s.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*_s.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// Modify adds a query modifier for attaching custom logic to queries.
func (_s *CourseEntitySelect) Modify(modifiers ...func(s *sql.Selector)) *CourseEntitySelect {
_s.modifiers = append(_s.modifiers, modifiers...)
return _s
}
+878
View File
@@ -0,0 +1,878 @@
// ENT数据库文件,请勿编辑。
package ent
import (
"context"
"errors"
"fmt"
"likedream-goframe/internal/ent/courseentity"
"likedream-goframe/internal/ent/internal"
"likedream-goframe/internal/ent/predicate"
"likedream-goframe/internal/ent/sysuser"
"likedream-goframe/internal/framework/ent2"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// CourseEntityUpdate is the builder for updating CourseEntity entities.
type CourseEntityUpdate struct {
config
hooks []Hook
mutation *CourseEntityMutation
modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the CourseEntityUpdate builder.
func (_u *CourseEntityUpdate) Where(ps ...predicate.CourseEntity) *CourseEntityUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetUpdateTime sets the "update_time" field.
func (_u *CourseEntityUpdate) SetUpdateTime(v *ent2.CustomTime) *CourseEntityUpdate {
_u.mutation.SetUpdateTime(v)
return _u
}
// SetUserID sets the "user_id" field.
func (_u *CourseEntityUpdate) SetUserID(v int64) *CourseEntityUpdate {
_u.mutation.SetUserID(v)
return _u
}
// SetNillableUserID sets the "user_id" field if the given value is not nil.
func (_u *CourseEntityUpdate) SetNillableUserID(v *int64) *CourseEntityUpdate {
if v != nil {
_u.SetUserID(*v)
}
return _u
}
// SetUsername sets the "username" field.
func (_u *CourseEntityUpdate) SetUsername(v string) *CourseEntityUpdate {
_u.mutation.SetUsername(v)
return _u
}
// SetNillableUsername sets the "username" field if the given value is not nil.
func (_u *CourseEntityUpdate) SetNillableUsername(v *string) *CourseEntityUpdate {
if v != nil {
_u.SetUsername(*v)
}
return _u
}
// SetPassword sets the "password" field.
func (_u *CourseEntityUpdate) SetPassword(v string) *CourseEntityUpdate {
_u.mutation.SetPassword(v)
return _u
}
// SetNillablePassword sets the "password" field if the given value is not nil.
func (_u *CourseEntityUpdate) SetNillablePassword(v *string) *CourseEntityUpdate {
if v != nil {
_u.SetPassword(*v)
}
return _u
}
// SetType sets the "type" field.
func (_u *CourseEntityUpdate) SetType(v courseentity.Type) *CourseEntityUpdate {
_u.mutation.SetType(v)
return _u
}
// SetNillableType sets the "type" field if the given value is not nil.
func (_u *CourseEntityUpdate) SetNillableType(v *courseentity.Type) *CourseEntityUpdate {
if v != nil {
_u.SetType(*v)
}
return _u
}
// SetCourseName sets the "course_name" field.
func (_u *CourseEntityUpdate) SetCourseName(v string) *CourseEntityUpdate {
_u.mutation.SetCourseName(v)
return _u
}
// SetNillableCourseName sets the "course_name" field if the given value is not nil.
func (_u *CourseEntityUpdate) SetNillableCourseName(v *string) *CourseEntityUpdate {
if v != nil {
_u.SetCourseName(*v)
}
return _u
}
// SetCourseID sets the "course_id" field.
func (_u *CourseEntityUpdate) SetCourseID(v string) *CourseEntityUpdate {
_u.mutation.SetCourseID(v)
return _u
}
// SetNillableCourseID sets the "course_id" field if the given value is not nil.
func (_u *CourseEntityUpdate) SetNillableCourseID(v *string) *CourseEntityUpdate {
if v != nil {
_u.SetCourseID(*v)
}
return _u
}
// SetNeed sets the "need" field.
func (_u *CourseEntityUpdate) SetNeed(v courseentity.Need) *CourseEntityUpdate {
_u.mutation.SetNeed(v)
return _u
}
// SetNillableNeed sets the "need" field if the given value is not nil.
func (_u *CourseEntityUpdate) SetNillableNeed(v *courseentity.Need) *CourseEntityUpdate {
if v != nil {
_u.SetNeed(*v)
}
return _u
}
// SetStatus sets the "status" field.
func (_u *CourseEntityUpdate) SetStatus(v courseentity.Status) *CourseEntityUpdate {
_u.mutation.SetStatus(v)
return _u
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (_u *CourseEntityUpdate) SetNillableStatus(v *courseentity.Status) *CourseEntityUpdate {
if v != nil {
_u.SetStatus(*v)
}
return _u
}
// SetTaskCount sets the "task_count" field.
func (_u *CourseEntityUpdate) SetTaskCount(v int) *CourseEntityUpdate {
_u.mutation.ResetTaskCount()
_u.mutation.SetTaskCount(v)
return _u
}
// SetNillableTaskCount sets the "task_count" field if the given value is not nil.
func (_u *CourseEntityUpdate) SetNillableTaskCount(v *int) *CourseEntityUpdate {
if v != nil {
_u.SetTaskCount(*v)
}
return _u
}
// AddTaskCount adds value to the "task_count" field.
func (_u *CourseEntityUpdate) AddTaskCount(v int) *CourseEntityUpdate {
_u.mutation.AddTaskCount(v)
return _u
}
// SetSuccessCount sets the "success_count" field.
func (_u *CourseEntityUpdate) SetSuccessCount(v int) *CourseEntityUpdate {
_u.mutation.ResetSuccessCount()
_u.mutation.SetSuccessCount(v)
return _u
}
// SetNillableSuccessCount sets the "success_count" field if the given value is not nil.
func (_u *CourseEntityUpdate) SetNillableSuccessCount(v *int) *CourseEntityUpdate {
if v != nil {
_u.SetSuccessCount(*v)
}
return _u
}
// AddSuccessCount adds value to the "success_count" field.
func (_u *CourseEntityUpdate) AddSuccessCount(v int) *CourseEntityUpdate {
_u.mutation.AddSuccessCount(v)
return _u
}
// SetExamState sets the "exam_state" field.
func (_u *CourseEntityUpdate) SetExamState(v courseentity.ExamState) *CourseEntityUpdate {
_u.mutation.SetExamState(v)
return _u
}
// SetNillableExamState sets the "exam_state" field if the given value is not nil.
func (_u *CourseEntityUpdate) SetNillableExamState(v *courseentity.ExamState) *CourseEntityUpdate {
if v != nil {
_u.SetExamState(*v)
}
return _u
}
// SetViolence sets the "violence" field.
func (_u *CourseEntityUpdate) SetViolence(v courseentity.Violence) *CourseEntityUpdate {
_u.mutation.SetViolence(v)
return _u
}
// SetNillableViolence sets the "violence" field if the given value is not nil.
func (_u *CourseEntityUpdate) SetNillableViolence(v *courseentity.Violence) *CourseEntityUpdate {
if v != nil {
_u.SetViolence(*v)
}
return _u
}
// SetDesc sets the "desc" field.
func (_u *CourseEntityUpdate) SetDesc(v string) *CourseEntityUpdate {
_u.mutation.SetDesc(v)
return _u
}
// SetNillableDesc sets the "desc" field if the given value is not nil.
func (_u *CourseEntityUpdate) SetNillableDesc(v *string) *CourseEntityUpdate {
if v != nil {
_u.SetDesc(*v)
}
return _u
}
// ClearDesc clears the value of the "desc" field.
func (_u *CourseEntityUpdate) ClearDesc() *CourseEntityUpdate {
_u.mutation.ClearDesc()
return _u
}
// SetSysUserID sets the "sys_user" edge to the SysUser entity by ID.
func (_u *CourseEntityUpdate) SetSysUserID(id int64) *CourseEntityUpdate {
_u.mutation.SetSysUserID(id)
return _u
}
// SetSysUser sets the "sys_user" edge to the SysUser entity.
func (_u *CourseEntityUpdate) SetSysUser(v *SysUser) *CourseEntityUpdate {
return _u.SetSysUserID(v.ID)
}
// Mutation returns the CourseEntityMutation object of the builder.
func (_u *CourseEntityUpdate) Mutation() *CourseEntityMutation {
return _u.mutation
}
// ClearSysUser clears the "sys_user" edge to the SysUser entity.
func (_u *CourseEntityUpdate) ClearSysUser() *CourseEntityUpdate {
_u.mutation.ClearSysUser()
return _u
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *CourseEntityUpdate) Save(ctx context.Context) (int, error) {
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *CourseEntityUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *CourseEntityUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *CourseEntityUpdate) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *CourseEntityUpdate) check() error {
if v, ok := _u.mutation.GetType(); ok {
if err := courseentity.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "CourseEntity.type": %w`, err)}
}
}
if v, ok := _u.mutation.Need(); ok {
if err := courseentity.NeedValidator(v); err != nil {
return &ValidationError{Name: "need", err: fmt.Errorf(`ent: validator failed for field "CourseEntity.need": %w`, err)}
}
}
if v, ok := _u.mutation.Status(); ok {
if err := courseentity.StatusValidator(v); err != nil {
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "CourseEntity.status": %w`, err)}
}
}
if v, ok := _u.mutation.ExamState(); ok {
if err := courseentity.ExamStateValidator(v); err != nil {
return &ValidationError{Name: "exam_state", err: fmt.Errorf(`ent: validator failed for field "CourseEntity.exam_state": %w`, err)}
}
}
if v, ok := _u.mutation.Violence(); ok {
if err := courseentity.ViolenceValidator(v); err != nil {
return &ValidationError{Name: "violence", err: fmt.Errorf(`ent: validator failed for field "CourseEntity.violence": %w`, err)}
}
}
if _u.mutation.SysUserCleared() && len(_u.mutation.SysUserIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "CourseEntity.sys_user"`)
}
return nil
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (_u *CourseEntityUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CourseEntityUpdate {
_u.modifiers = append(_u.modifiers, modifiers...)
return _u
}
func (_u *CourseEntityUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(courseentity.Table, courseentity.Columns, sqlgraph.NewFieldSpec(courseentity.FieldID, field.TypeInt64))
if ps := _u.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := _u.mutation.UpdateTime(); ok {
_spec.SetField(courseentity.FieldUpdateTime, field.TypeString, value)
}
if value, ok := _u.mutation.Username(); ok {
_spec.SetField(courseentity.FieldUsername, field.TypeString, value)
}
if value, ok := _u.mutation.Password(); ok {
_spec.SetField(courseentity.FieldPassword, field.TypeString, value)
}
if value, ok := _u.mutation.GetType(); ok {
_spec.SetField(courseentity.FieldType, field.TypeEnum, value)
}
if value, ok := _u.mutation.CourseName(); ok {
_spec.SetField(courseentity.FieldCourseName, field.TypeString, value)
}
if value, ok := _u.mutation.CourseID(); ok {
_spec.SetField(courseentity.FieldCourseID, field.TypeString, value)
}
if value, ok := _u.mutation.Need(); ok {
_spec.SetField(courseentity.FieldNeed, field.TypeEnum, value)
}
if value, ok := _u.mutation.Status(); ok {
_spec.SetField(courseentity.FieldStatus, field.TypeEnum, value)
}
if value, ok := _u.mutation.TaskCount(); ok {
_spec.SetField(courseentity.FieldTaskCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedTaskCount(); ok {
_spec.AddField(courseentity.FieldTaskCount, field.TypeInt, value)
}
if value, ok := _u.mutation.SuccessCount(); ok {
_spec.SetField(courseentity.FieldSuccessCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedSuccessCount(); ok {
_spec.AddField(courseentity.FieldSuccessCount, field.TypeInt, value)
}
if value, ok := _u.mutation.ExamState(); ok {
_spec.SetField(courseentity.FieldExamState, field.TypeEnum, value)
}
if value, ok := _u.mutation.Violence(); ok {
_spec.SetField(courseentity.FieldViolence, field.TypeEnum, value)
}
if value, ok := _u.mutation.Desc(); ok {
_spec.SetField(courseentity.FieldDesc, field.TypeString, value)
}
if _u.mutation.DescCleared() {
_spec.ClearField(courseentity.FieldDesc, field.TypeString)
}
if _u.mutation.SysUserCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: courseentity.SysUserTable,
Columns: []string{courseentity.SysUserColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(sysuser.FieldID, field.TypeInt64),
},
}
edge.Schema = _u.schemaConfig.CourseEntity
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.SysUserIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: courseentity.SysUserTable,
Columns: []string{courseentity.SysUserColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(sysuser.FieldID, field.TypeInt64),
},
}
edge.Schema = _u.schemaConfig.CourseEntity
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.Node.Schema = _u.schemaConfig.CourseEntity
ctx = internal.NewSchemaConfigContext(ctx, _u.schemaConfig)
_spec.AddModifiers(_u.modifiers...)
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{courseentity.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// CourseEntityUpdateOne is the builder for updating a single CourseEntity entity.
type CourseEntityUpdateOne struct {
config
fields []string
hooks []Hook
mutation *CourseEntityMutation
modifiers []func(*sql.UpdateBuilder)
}
// SetUpdateTime sets the "update_time" field.
func (_u *CourseEntityUpdateOne) SetUpdateTime(v *ent2.CustomTime) *CourseEntityUpdateOne {
_u.mutation.SetUpdateTime(v)
return _u
}
// SetUserID sets the "user_id" field.
func (_u *CourseEntityUpdateOne) SetUserID(v int64) *CourseEntityUpdateOne {
_u.mutation.SetUserID(v)
return _u
}
// SetNillableUserID sets the "user_id" field if the given value is not nil.
func (_u *CourseEntityUpdateOne) SetNillableUserID(v *int64) *CourseEntityUpdateOne {
if v != nil {
_u.SetUserID(*v)
}
return _u
}
// SetUsername sets the "username" field.
func (_u *CourseEntityUpdateOne) SetUsername(v string) *CourseEntityUpdateOne {
_u.mutation.SetUsername(v)
return _u
}
// SetNillableUsername sets the "username" field if the given value is not nil.
func (_u *CourseEntityUpdateOne) SetNillableUsername(v *string) *CourseEntityUpdateOne {
if v != nil {
_u.SetUsername(*v)
}
return _u
}
// SetPassword sets the "password" field.
func (_u *CourseEntityUpdateOne) SetPassword(v string) *CourseEntityUpdateOne {
_u.mutation.SetPassword(v)
return _u
}
// SetNillablePassword sets the "password" field if the given value is not nil.
func (_u *CourseEntityUpdateOne) SetNillablePassword(v *string) *CourseEntityUpdateOne {
if v != nil {
_u.SetPassword(*v)
}
return _u
}
// SetType sets the "type" field.
func (_u *CourseEntityUpdateOne) SetType(v courseentity.Type) *CourseEntityUpdateOne {
_u.mutation.SetType(v)
return _u
}
// SetNillableType sets the "type" field if the given value is not nil.
func (_u *CourseEntityUpdateOne) SetNillableType(v *courseentity.Type) *CourseEntityUpdateOne {
if v != nil {
_u.SetType(*v)
}
return _u
}
// SetCourseName sets the "course_name" field.
func (_u *CourseEntityUpdateOne) SetCourseName(v string) *CourseEntityUpdateOne {
_u.mutation.SetCourseName(v)
return _u
}
// SetNillableCourseName sets the "course_name" field if the given value is not nil.
func (_u *CourseEntityUpdateOne) SetNillableCourseName(v *string) *CourseEntityUpdateOne {
if v != nil {
_u.SetCourseName(*v)
}
return _u
}
// SetCourseID sets the "course_id" field.
func (_u *CourseEntityUpdateOne) SetCourseID(v string) *CourseEntityUpdateOne {
_u.mutation.SetCourseID(v)
return _u
}
// SetNillableCourseID sets the "course_id" field if the given value is not nil.
func (_u *CourseEntityUpdateOne) SetNillableCourseID(v *string) *CourseEntityUpdateOne {
if v != nil {
_u.SetCourseID(*v)
}
return _u
}
// SetNeed sets the "need" field.
func (_u *CourseEntityUpdateOne) SetNeed(v courseentity.Need) *CourseEntityUpdateOne {
_u.mutation.SetNeed(v)
return _u
}
// SetNillableNeed sets the "need" field if the given value is not nil.
func (_u *CourseEntityUpdateOne) SetNillableNeed(v *courseentity.Need) *CourseEntityUpdateOne {
if v != nil {
_u.SetNeed(*v)
}
return _u
}
// SetStatus sets the "status" field.
func (_u *CourseEntityUpdateOne) SetStatus(v courseentity.Status) *CourseEntityUpdateOne {
_u.mutation.SetStatus(v)
return _u
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (_u *CourseEntityUpdateOne) SetNillableStatus(v *courseentity.Status) *CourseEntityUpdateOne {
if v != nil {
_u.SetStatus(*v)
}
return _u
}
// SetTaskCount sets the "task_count" field.
func (_u *CourseEntityUpdateOne) SetTaskCount(v int) *CourseEntityUpdateOne {
_u.mutation.ResetTaskCount()
_u.mutation.SetTaskCount(v)
return _u
}
// SetNillableTaskCount sets the "task_count" field if the given value is not nil.
func (_u *CourseEntityUpdateOne) SetNillableTaskCount(v *int) *CourseEntityUpdateOne {
if v != nil {
_u.SetTaskCount(*v)
}
return _u
}
// AddTaskCount adds value to the "task_count" field.
func (_u *CourseEntityUpdateOne) AddTaskCount(v int) *CourseEntityUpdateOne {
_u.mutation.AddTaskCount(v)
return _u
}
// SetSuccessCount sets the "success_count" field.
func (_u *CourseEntityUpdateOne) SetSuccessCount(v int) *CourseEntityUpdateOne {
_u.mutation.ResetSuccessCount()
_u.mutation.SetSuccessCount(v)
return _u
}
// SetNillableSuccessCount sets the "success_count" field if the given value is not nil.
func (_u *CourseEntityUpdateOne) SetNillableSuccessCount(v *int) *CourseEntityUpdateOne {
if v != nil {
_u.SetSuccessCount(*v)
}
return _u
}
// AddSuccessCount adds value to the "success_count" field.
func (_u *CourseEntityUpdateOne) AddSuccessCount(v int) *CourseEntityUpdateOne {
_u.mutation.AddSuccessCount(v)
return _u
}
// SetExamState sets the "exam_state" field.
func (_u *CourseEntityUpdateOne) SetExamState(v courseentity.ExamState) *CourseEntityUpdateOne {
_u.mutation.SetExamState(v)
return _u
}
// SetNillableExamState sets the "exam_state" field if the given value is not nil.
func (_u *CourseEntityUpdateOne) SetNillableExamState(v *courseentity.ExamState) *CourseEntityUpdateOne {
if v != nil {
_u.SetExamState(*v)
}
return _u
}
// SetViolence sets the "violence" field.
func (_u *CourseEntityUpdateOne) SetViolence(v courseentity.Violence) *CourseEntityUpdateOne {
_u.mutation.SetViolence(v)
return _u
}
// SetNillableViolence sets the "violence" field if the given value is not nil.
func (_u *CourseEntityUpdateOne) SetNillableViolence(v *courseentity.Violence) *CourseEntityUpdateOne {
if v != nil {
_u.SetViolence(*v)
}
return _u
}
// SetDesc sets the "desc" field.
func (_u *CourseEntityUpdateOne) SetDesc(v string) *CourseEntityUpdateOne {
_u.mutation.SetDesc(v)
return _u
}
// SetNillableDesc sets the "desc" field if the given value is not nil.
func (_u *CourseEntityUpdateOne) SetNillableDesc(v *string) *CourseEntityUpdateOne {
if v != nil {
_u.SetDesc(*v)
}
return _u
}
// ClearDesc clears the value of the "desc" field.
func (_u *CourseEntityUpdateOne) ClearDesc() *CourseEntityUpdateOne {
_u.mutation.ClearDesc()
return _u
}
// SetSysUserID sets the "sys_user" edge to the SysUser entity by ID.
func (_u *CourseEntityUpdateOne) SetSysUserID(id int64) *CourseEntityUpdateOne {
_u.mutation.SetSysUserID(id)
return _u
}
// SetSysUser sets the "sys_user" edge to the SysUser entity.
func (_u *CourseEntityUpdateOne) SetSysUser(v *SysUser) *CourseEntityUpdateOne {
return _u.SetSysUserID(v.ID)
}
// Mutation returns the CourseEntityMutation object of the builder.
func (_u *CourseEntityUpdateOne) Mutation() *CourseEntityMutation {
return _u.mutation
}
// ClearSysUser clears the "sys_user" edge to the SysUser entity.
func (_u *CourseEntityUpdateOne) ClearSysUser() *CourseEntityUpdateOne {
_u.mutation.ClearSysUser()
return _u
}
// Where appends a list predicates to the CourseEntityUpdate builder.
func (_u *CourseEntityUpdateOne) Where(ps ...predicate.CourseEntity) *CourseEntityUpdateOne {
_u.mutation.Where(ps...)
return _u
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (_u *CourseEntityUpdateOne) Select(field string, fields ...string) *CourseEntityUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated CourseEntity entity.
func (_u *CourseEntityUpdateOne) Save(ctx context.Context) (*CourseEntity, error) {
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *CourseEntityUpdateOne) SaveX(ctx context.Context) *CourseEntity {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *CourseEntityUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *CourseEntityUpdateOne) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *CourseEntityUpdateOne) check() error {
if v, ok := _u.mutation.GetType(); ok {
if err := courseentity.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "CourseEntity.type": %w`, err)}
}
}
if v, ok := _u.mutation.Need(); ok {
if err := courseentity.NeedValidator(v); err != nil {
return &ValidationError{Name: "need", err: fmt.Errorf(`ent: validator failed for field "CourseEntity.need": %w`, err)}
}
}
if v, ok := _u.mutation.Status(); ok {
if err := courseentity.StatusValidator(v); err != nil {
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "CourseEntity.status": %w`, err)}
}
}
if v, ok := _u.mutation.ExamState(); ok {
if err := courseentity.ExamStateValidator(v); err != nil {
return &ValidationError{Name: "exam_state", err: fmt.Errorf(`ent: validator failed for field "CourseEntity.exam_state": %w`, err)}
}
}
if v, ok := _u.mutation.Violence(); ok {
if err := courseentity.ViolenceValidator(v); err != nil {
return &ValidationError{Name: "violence", err: fmt.Errorf(`ent: validator failed for field "CourseEntity.violence": %w`, err)}
}
}
if _u.mutation.SysUserCleared() && len(_u.mutation.SysUserIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "CourseEntity.sys_user"`)
}
return nil
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (_u *CourseEntityUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CourseEntityUpdateOne {
_u.modifiers = append(_u.modifiers, modifiers...)
return _u
}
func (_u *CourseEntityUpdateOne) sqlSave(ctx context.Context) (_node *CourseEntity, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(courseentity.Table, courseentity.Columns, sqlgraph.NewFieldSpec(courseentity.FieldID, field.TypeInt64))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "CourseEntity.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := _u.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, courseentity.FieldID)
for _, f := range fields {
if !courseentity.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != courseentity.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := _u.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := _u.mutation.UpdateTime(); ok {
_spec.SetField(courseentity.FieldUpdateTime, field.TypeString, value)
}
if value, ok := _u.mutation.Username(); ok {
_spec.SetField(courseentity.FieldUsername, field.TypeString, value)
}
if value, ok := _u.mutation.Password(); ok {
_spec.SetField(courseentity.FieldPassword, field.TypeString, value)
}
if value, ok := _u.mutation.GetType(); ok {
_spec.SetField(courseentity.FieldType, field.TypeEnum, value)
}
if value, ok := _u.mutation.CourseName(); ok {
_spec.SetField(courseentity.FieldCourseName, field.TypeString, value)
}
if value, ok := _u.mutation.CourseID(); ok {
_spec.SetField(courseentity.FieldCourseID, field.TypeString, value)
}
if value, ok := _u.mutation.Need(); ok {
_spec.SetField(courseentity.FieldNeed, field.TypeEnum, value)
}
if value, ok := _u.mutation.Status(); ok {
_spec.SetField(courseentity.FieldStatus, field.TypeEnum, value)
}
if value, ok := _u.mutation.TaskCount(); ok {
_spec.SetField(courseentity.FieldTaskCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedTaskCount(); ok {
_spec.AddField(courseentity.FieldTaskCount, field.TypeInt, value)
}
if value, ok := _u.mutation.SuccessCount(); ok {
_spec.SetField(courseentity.FieldSuccessCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedSuccessCount(); ok {
_spec.AddField(courseentity.FieldSuccessCount, field.TypeInt, value)
}
if value, ok := _u.mutation.ExamState(); ok {
_spec.SetField(courseentity.FieldExamState, field.TypeEnum, value)
}
if value, ok := _u.mutation.Violence(); ok {
_spec.SetField(courseentity.FieldViolence, field.TypeEnum, value)
}
if value, ok := _u.mutation.Desc(); ok {
_spec.SetField(courseentity.FieldDesc, field.TypeString, value)
}
if _u.mutation.DescCleared() {
_spec.ClearField(courseentity.FieldDesc, field.TypeString)
}
if _u.mutation.SysUserCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: courseentity.SysUserTable,
Columns: []string{courseentity.SysUserColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(sysuser.FieldID, field.TypeInt64),
},
}
edge.Schema = _u.schemaConfig.CourseEntity
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.SysUserIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: courseentity.SysUserTable,
Columns: []string{courseentity.SysUserColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(sysuser.FieldID, field.TypeInt64),
},
}
edge.Schema = _u.schemaConfig.CourseEntity
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.Node.Schema = _u.schemaConfig.CourseEntity
ctx = internal.NewSchemaConfigContext(ctx, _u.schemaConfig)
_spec.AddModifiers(_u.modifiers...)
_node = &CourseEntity{config: _u.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{courseentity.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}
+13 -11
View File
@@ -6,6 +6,7 @@ import (
"context"
"errors"
"fmt"
"likedream-goframe/internal/ent/courseentity"
"likedream-goframe/internal/ent/cpimage"
"likedream-goframe/internal/ent/cpschool"
"likedream-goframe/internal/ent/cptask"
@@ -83,17 +84,18 @@ var (
func checkColumn(t, c string) error {
initCheck.Do(func() {
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
cpimage.Table: cpimage.ValidColumn,
cpschool.Table: cpschool.ValidColumn,
cptask.Table: cptask.ValidColumn,
cptasklog.Table: cptasklog.ValidColumn,
cpuser.Table: cpuser.ValidColumn,
sysagent.Table: sysagent.ValidColumn,
syscard.Table: syscard.ValidColumn,
sysmenu.Table: sysmenu.ValidColumn,
sysrole.Table: sysrole.ValidColumn,
sysuser.Table: sysuser.ValidColumn,
sysuserlog.Table: sysuserlog.ValidColumn,
courseentity.Table: courseentity.ValidColumn,
cpimage.Table: cpimage.ValidColumn,
cpschool.Table: cpschool.ValidColumn,
cptask.Table: cptask.ValidColumn,
cptasklog.Table: cptasklog.ValidColumn,
cpuser.Table: cpuser.ValidColumn,
sysagent.Table: sysagent.ValidColumn,
syscard.Table: syscard.ValidColumn,
sysmenu.Table: sysmenu.ValidColumn,
sysrole.Table: sysrole.ValidColumn,
sysuser.Table: sysuser.ValidColumn,
sysuserlog.Table: sysuserlog.ValidColumn,
})
})
return columnCheck(t, c)
+218 -22
View File
@@ -3,6 +3,7 @@
package ent
import (
"likedream-goframe/internal/ent/courseentity"
"likedream-goframe/internal/ent/cpimage"
"likedream-goframe/internal/ent/cpschool"
"likedream-goframe/internal/ent/cptask"
@@ -24,8 +25,36 @@ import (
// schemaGraph holds a representation of ent/schema at runtime.
var schemaGraph = func() *sqlgraph.Schema {
graph := &sqlgraph.Schema{Nodes: make([]*sqlgraph.Node, 11)}
graph := &sqlgraph.Schema{Nodes: make([]*sqlgraph.Node, 12)}
graph.Nodes[0] = &sqlgraph.Node{
NodeSpec: sqlgraph.NodeSpec{
Table: courseentity.Table,
Columns: courseentity.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt64,
Column: courseentity.FieldID,
},
},
Type: "CourseEntity",
Fields: map[string]*sqlgraph.FieldSpec{
courseentity.FieldCreateTime: {Type: field.TypeString, Column: courseentity.FieldCreateTime},
courseentity.FieldUpdateTime: {Type: field.TypeString, Column: courseentity.FieldUpdateTime},
courseentity.FieldUserID: {Type: field.TypeInt64, Column: courseentity.FieldUserID},
courseentity.FieldUsername: {Type: field.TypeString, Column: courseentity.FieldUsername},
courseentity.FieldPassword: {Type: field.TypeString, Column: courseentity.FieldPassword},
courseentity.FieldType: {Type: field.TypeEnum, Column: courseentity.FieldType},
courseentity.FieldCourseName: {Type: field.TypeString, Column: courseentity.FieldCourseName},
courseentity.FieldCourseID: {Type: field.TypeString, Column: courseentity.FieldCourseID},
courseentity.FieldNeed: {Type: field.TypeEnum, Column: courseentity.FieldNeed},
courseentity.FieldStatus: {Type: field.TypeEnum, Column: courseentity.FieldStatus},
courseentity.FieldTaskCount: {Type: field.TypeInt, Column: courseentity.FieldTaskCount},
courseentity.FieldSuccessCount: {Type: field.TypeInt, Column: courseentity.FieldSuccessCount},
courseentity.FieldExamState: {Type: field.TypeEnum, Column: courseentity.FieldExamState},
courseentity.FieldViolence: {Type: field.TypeEnum, Column: courseentity.FieldViolence},
courseentity.FieldDesc: {Type: field.TypeString, Column: courseentity.FieldDesc},
},
}
graph.Nodes[1] = &sqlgraph.Node{
NodeSpec: sqlgraph.NodeSpec{
Table: cpimage.Table,
Columns: cpimage.Columns,
@@ -45,7 +74,7 @@ var schemaGraph = func() *sqlgraph.Schema {
cpimage.FieldContentLength: {Type: field.TypeInt64, Column: cpimage.FieldContentLength},
},
}
graph.Nodes[1] = &sqlgraph.Node{
graph.Nodes[2] = &sqlgraph.Node{
NodeSpec: sqlgraph.NodeSpec{
Table: cpschool.Table,
Columns: cpschool.Columns,
@@ -63,7 +92,7 @@ var schemaGraph = func() *sqlgraph.Schema {
cpschool.FieldIconImg: {Type: field.TypeString, Column: cpschool.FieldIconImg},
},
}
graph.Nodes[2] = &sqlgraph.Node{
graph.Nodes[3] = &sqlgraph.Node{
NodeSpec: sqlgraph.NodeSpec{
Table: cptask.Table,
Columns: cptask.Columns,
@@ -92,7 +121,7 @@ var schemaGraph = func() *sqlgraph.Schema {
cptask.FieldNextExecuteTime: {Type: field.TypeInt64, Column: cptask.FieldNextExecuteTime},
},
}
graph.Nodes[3] = &sqlgraph.Node{
graph.Nodes[4] = &sqlgraph.Node{
NodeSpec: sqlgraph.NodeSpec{
Table: cptasklog.Table,
Columns: cptasklog.Columns,
@@ -113,7 +142,7 @@ var schemaGraph = func() *sqlgraph.Schema {
cptasklog.FieldRealName: {Type: field.TypeString, Column: cptasklog.FieldRealName},
},
}
graph.Nodes[4] = &sqlgraph.Node{
graph.Nodes[5] = &sqlgraph.Node{
NodeSpec: sqlgraph.NodeSpec{
Table: cpuser.Table,
Columns: cpuser.Columns,
@@ -136,7 +165,7 @@ var schemaGraph = func() *sqlgraph.Schema {
cpuser.FieldMobileType: {Type: field.TypeEnum, Column: cpuser.FieldMobileType},
},
}
graph.Nodes[5] = &sqlgraph.Node{
graph.Nodes[6] = &sqlgraph.Node{
NodeSpec: sqlgraph.NodeSpec{
Table: sysagent.Table,
Columns: sysagent.Columns,
@@ -153,7 +182,7 @@ var schemaGraph = func() *sqlgraph.Schema {
sysagent.FieldRate: {Type: field.TypeString, Column: sysagent.FieldRate},
},
}
graph.Nodes[6] = &sqlgraph.Node{
graph.Nodes[7] = &sqlgraph.Node{
NodeSpec: sqlgraph.NodeSpec{
Table: syscard.Table,
Columns: syscard.Columns,
@@ -175,7 +204,7 @@ var schemaGraph = func() *sqlgraph.Schema {
syscard.FieldCashValue: {Type: field.TypeString, Column: syscard.FieldCashValue},
},
}
graph.Nodes[7] = &sqlgraph.Node{
graph.Nodes[8] = &sqlgraph.Node{
NodeSpec: sqlgraph.NodeSpec{
Table: sysmenu.Table,
Columns: sysmenu.Columns,
@@ -201,7 +230,7 @@ var schemaGraph = func() *sqlgraph.Schema {
sysmenu.FieldOrder: {Type: field.TypeUint, Column: sysmenu.FieldOrder},
},
}
graph.Nodes[8] = &sqlgraph.Node{
graph.Nodes[9] = &sqlgraph.Node{
NodeSpec: sqlgraph.NodeSpec{
Table: sysrole.Table,
Columns: sysrole.Columns,
@@ -220,7 +249,7 @@ var schemaGraph = func() *sqlgraph.Schema {
sysrole.FieldOrder: {Type: field.TypeUint, Column: sysrole.FieldOrder},
},
}
graph.Nodes[9] = &sqlgraph.Node{
graph.Nodes[10] = &sqlgraph.Node{
NodeSpec: sqlgraph.NodeSpec{
Table: sysuser.Table,
Columns: sysuser.Columns,
@@ -243,7 +272,7 @@ var schemaGraph = func() *sqlgraph.Schema {
sysuser.FieldInviteCashback: {Type: field.TypeString, Column: sysuser.FieldInviteCashback},
},
}
graph.Nodes[10] = &sqlgraph.Node{
graph.Nodes[11] = &sqlgraph.Node{
NodeSpec: sqlgraph.NodeSpec{
Table: sysuserlog.Table,
Columns: sysuserlog.Columns,
@@ -255,6 +284,18 @@ var schemaGraph = func() *sqlgraph.Schema {
Type: "SysUserLog",
Fields: map[string]*sqlgraph.FieldSpec{},
}
graph.MustAddE(
"sys_user",
&sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: courseentity.SysUserTable,
Columns: []string{courseentity.SysUserColumn},
Bidi: false,
},
"CourseEntity",
"SysUser",
)
graph.MustAddE(
"user",
&sqlgraph.EdgeSpec{
@@ -591,6 +632,18 @@ var schemaGraph = func() *sqlgraph.Schema {
"SysUser",
"CpTask",
)
graph.MustAddE(
"course_entity",
&sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: sysuser.CourseEntityTable,
Columns: []string{sysuser.CourseEntityColumn},
Bidi: false,
},
"SysUser",
"CourseEntity",
)
graph.MustAddE(
"cp_task_logs",
&sqlgraph.EdgeSpec{
@@ -648,6 +701,135 @@ type predicateAdder interface {
addPredicate(func(s *sql.Selector))
}
// addPredicate implements the predicateAdder interface.
func (_q *CourseEntityQuery) addPredicate(pred func(s *sql.Selector)) {
_q.predicates = append(_q.predicates, pred)
}
// Filter returns a Filter implementation to apply filters on the CourseEntityQuery builder.
func (_q *CourseEntityQuery) Filter() *CourseEntityFilter {
return &CourseEntityFilter{config: _q.config, predicateAdder: _q}
}
// addPredicate implements the predicateAdder interface.
func (m *CourseEntityMutation) addPredicate(pred func(s *sql.Selector)) {
m.predicates = append(m.predicates, pred)
}
// Filter returns an entql.Where implementation to apply filters on the CourseEntityMutation builder.
func (m *CourseEntityMutation) Filter() *CourseEntityFilter {
return &CourseEntityFilter{config: m.config, predicateAdder: m}
}
// CourseEntityFilter provides a generic filtering capability at runtime for CourseEntityQuery.
type CourseEntityFilter struct {
predicateAdder
config
}
// Where applies the entql predicate on the query filter.
func (f *CourseEntityFilter) Where(p entql.P) {
f.addPredicate(func(s *sql.Selector) {
if err := schemaGraph.EvalP(schemaGraph.Nodes[0].Type, p, s); err != nil {
s.AddError(err)
}
})
}
// WhereID applies the entql int64 predicate on the id field.
func (f *CourseEntityFilter) WhereID(p entql.Int64P) {
f.Where(p.Field(courseentity.FieldID))
}
// WhereCreateTime applies the entql string predicate on the create_time field.
func (f *CourseEntityFilter) WhereCreateTime(p entql.StringP) {
f.Where(p.Field(courseentity.FieldCreateTime))
}
// WhereUpdateTime applies the entql string predicate on the update_time field.
func (f *CourseEntityFilter) WhereUpdateTime(p entql.StringP) {
f.Where(p.Field(courseentity.FieldUpdateTime))
}
// WhereUserID applies the entql int64 predicate on the user_id field.
func (f *CourseEntityFilter) WhereUserID(p entql.Int64P) {
f.Where(p.Field(courseentity.FieldUserID))
}
// WhereUsername applies the entql string predicate on the username field.
func (f *CourseEntityFilter) WhereUsername(p entql.StringP) {
f.Where(p.Field(courseentity.FieldUsername))
}
// WherePassword applies the entql string predicate on the password field.
func (f *CourseEntityFilter) WherePassword(p entql.StringP) {
f.Where(p.Field(courseentity.FieldPassword))
}
// WhereType applies the entql string predicate on the type field.
func (f *CourseEntityFilter) WhereType(p entql.StringP) {
f.Where(p.Field(courseentity.FieldType))
}
// WhereCourseName applies the entql string predicate on the course_name field.
func (f *CourseEntityFilter) WhereCourseName(p entql.StringP) {
f.Where(p.Field(courseentity.FieldCourseName))
}
// WhereCourseID applies the entql string predicate on the course_id field.
func (f *CourseEntityFilter) WhereCourseID(p entql.StringP) {
f.Where(p.Field(courseentity.FieldCourseID))
}
// WhereNeed applies the entql string predicate on the need field.
func (f *CourseEntityFilter) WhereNeed(p entql.StringP) {
f.Where(p.Field(courseentity.FieldNeed))
}
// WhereStatus applies the entql string predicate on the status field.
func (f *CourseEntityFilter) WhereStatus(p entql.StringP) {
f.Where(p.Field(courseentity.FieldStatus))
}
// WhereTaskCount applies the entql int predicate on the task_count field.
func (f *CourseEntityFilter) WhereTaskCount(p entql.IntP) {
f.Where(p.Field(courseentity.FieldTaskCount))
}
// WhereSuccessCount applies the entql int predicate on the success_count field.
func (f *CourseEntityFilter) WhereSuccessCount(p entql.IntP) {
f.Where(p.Field(courseentity.FieldSuccessCount))
}
// WhereExamState applies the entql string predicate on the exam_state field.
func (f *CourseEntityFilter) WhereExamState(p entql.StringP) {
f.Where(p.Field(courseentity.FieldExamState))
}
// WhereViolence applies the entql string predicate on the violence field.
func (f *CourseEntityFilter) WhereViolence(p entql.StringP) {
f.Where(p.Field(courseentity.FieldViolence))
}
// WhereDesc applies the entql string predicate on the desc field.
func (f *CourseEntityFilter) WhereDesc(p entql.StringP) {
f.Where(p.Field(courseentity.FieldDesc))
}
// WhereHasSysUser applies a predicate to check if query has an edge sys_user.
func (f *CourseEntityFilter) WhereHasSysUser() {
f.Where(entql.HasEdge("sys_user"))
}
// WhereHasSysUserWith applies a predicate to check if query has an edge sys_user with a given conditions (other predicates).
func (f *CourseEntityFilter) WhereHasSysUserWith(preds ...predicate.SysUser) {
f.Where(entql.HasEdgeWith("sys_user", sqlgraph.WrapFunc(func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})))
}
// addPredicate implements the predicateAdder interface.
func (_q *CpImageQuery) addPredicate(pred func(s *sql.Selector)) {
_q.predicates = append(_q.predicates, pred)
@@ -677,7 +859,7 @@ type CpImageFilter struct {
// Where applies the entql predicate on the query filter.
func (f *CpImageFilter) Where(p entql.P) {
f.addPredicate(func(s *sql.Selector) {
if err := schemaGraph.EvalP(schemaGraph.Nodes[0].Type, p, s); err != nil {
if err := schemaGraph.EvalP(schemaGraph.Nodes[1].Type, p, s); err != nil {
s.AddError(err)
}
})
@@ -766,7 +948,7 @@ type CpSchoolFilter struct {
// Where applies the entql predicate on the query filter.
func (f *CpSchoolFilter) Where(p entql.P) {
f.addPredicate(func(s *sql.Selector) {
if err := schemaGraph.EvalP(schemaGraph.Nodes[1].Type, p, s); err != nil {
if err := schemaGraph.EvalP(schemaGraph.Nodes[2].Type, p, s); err != nil {
s.AddError(err)
}
})
@@ -845,7 +1027,7 @@ type CpTaskFilter struct {
// Where applies the entql predicate on the query filter.
func (f *CpTaskFilter) Where(p entql.P) {
f.addPredicate(func(s *sql.Selector) {
if err := schemaGraph.EvalP(schemaGraph.Nodes[2].Type, p, s); err != nil {
if err := schemaGraph.EvalP(schemaGraph.Nodes[3].Type, p, s); err != nil {
s.AddError(err)
}
})
@@ -1007,7 +1189,7 @@ type CpTaskLogFilter struct {
// Where applies the entql predicate on the query filter.
func (f *CpTaskLogFilter) Where(p entql.P) {
f.addPredicate(func(s *sql.Selector) {
if err := schemaGraph.EvalP(schemaGraph.Nodes[3].Type, p, s); err != nil {
if err := schemaGraph.EvalP(schemaGraph.Nodes[4].Type, p, s); err != nil {
s.AddError(err)
}
})
@@ -1129,7 +1311,7 @@ type CpUserFilter struct {
// Where applies the entql predicate on the query filter.
func (f *CpUserFilter) Where(p entql.P) {
f.addPredicate(func(s *sql.Selector) {
if err := schemaGraph.EvalP(schemaGraph.Nodes[4].Type, p, s); err != nil {
if err := schemaGraph.EvalP(schemaGraph.Nodes[5].Type, p, s); err != nil {
s.AddError(err)
}
})
@@ -1275,7 +1457,7 @@ type SysAgentFilter struct {
// Where applies the entql predicate on the query filter.
func (f *SysAgentFilter) Where(p entql.P) {
f.addPredicate(func(s *sql.Selector) {
if err := schemaGraph.EvalP(schemaGraph.Nodes[5].Type, p, s); err != nil {
if err := schemaGraph.EvalP(schemaGraph.Nodes[6].Type, p, s); err != nil {
s.AddError(err)
}
})
@@ -1349,7 +1531,7 @@ type SysCardFilter struct {
// Where applies the entql predicate on the query filter.
func (f *SysCardFilter) Where(p entql.P) {
f.addPredicate(func(s *sql.Selector) {
if err := schemaGraph.EvalP(schemaGraph.Nodes[6].Type, p, s); err != nil {
if err := schemaGraph.EvalP(schemaGraph.Nodes[7].Type, p, s); err != nil {
s.AddError(err)
}
})
@@ -1476,7 +1658,7 @@ type SysMenuFilter struct {
// Where applies the entql predicate on the query filter.
func (f *SysMenuFilter) Where(p entql.P) {
f.addPredicate(func(s *sql.Selector) {
if err := schemaGraph.EvalP(schemaGraph.Nodes[7].Type, p, s); err != nil {
if err := schemaGraph.EvalP(schemaGraph.Nodes[8].Type, p, s); err != nil {
s.AddError(err)
}
})
@@ -1623,7 +1805,7 @@ type SysRoleFilter struct {
// Where applies the entql predicate on the query filter.
func (f *SysRoleFilter) Where(p entql.P) {
f.addPredicate(func(s *sql.Selector) {
if err := schemaGraph.EvalP(schemaGraph.Nodes[8].Type, p, s); err != nil {
if err := schemaGraph.EvalP(schemaGraph.Nodes[9].Type, p, s); err != nil {
s.AddError(err)
}
})
@@ -1721,7 +1903,7 @@ type SysUserFilter struct {
// Where applies the entql predicate on the query filter.
func (f *SysUserFilter) Where(p entql.P) {
f.addPredicate(func(s *sql.Selector) {
if err := schemaGraph.EvalP(schemaGraph.Nodes[9].Type, p, s); err != nil {
if err := schemaGraph.EvalP(schemaGraph.Nodes[10].Type, p, s); err != nil {
s.AddError(err)
}
})
@@ -1880,6 +2062,20 @@ func (f *SysUserFilter) WhereHasCpTaskWith(preds ...predicate.CpTask) {
})))
}
// WhereHasCourseEntity applies a predicate to check if query has an edge course_entity.
func (f *SysUserFilter) WhereHasCourseEntity() {
f.Where(entql.HasEdge("course_entity"))
}
// WhereHasCourseEntityWith applies a predicate to check if query has an edge course_entity with a given conditions (other predicates).
func (f *SysUserFilter) WhereHasCourseEntityWith(preds ...predicate.CourseEntity) {
f.Where(entql.HasEdgeWith("course_entity", sqlgraph.WrapFunc(func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})))
}
// WhereHasCpTaskLogs applies a predicate to check if query has an edge cp_task_logs.
func (f *SysUserFilter) WhereHasCpTaskLogs() {
f.Where(entql.HasEdge("cp_task_logs"))
@@ -1965,7 +2161,7 @@ type SysUserLogFilter struct {
// Where applies the entql predicate on the query filter.
func (f *SysUserLogFilter) Where(p entql.P) {
f.addPredicate(func(s *sql.Selector) {
if err := schemaGraph.EvalP(schemaGraph.Nodes[10].Type, p, s); err != nil {
if err := schemaGraph.EvalP(schemaGraph.Nodes[11].Type, p, s); err != nil {
s.AddError(err)
}
})
+12
View File
@@ -8,6 +8,18 @@ import (
"likedream-goframe/internal/ent"
)
// The CourseEntityFunc type is an adapter to allow the use of ordinary
// function as CourseEntity mutator.
type CourseEntityFunc func(context.Context, *ent.CourseEntityMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f CourseEntityFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.CourseEntityMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.CourseEntityMutation", m)
}
// The CpImageFunc type is an adapter to allow the use of ordinary
// function as CpImage mutator.
type CpImageFunc func(context.Context, *ent.CpImageMutation) (ent.Value, error)
+30
View File
@@ -7,6 +7,7 @@ import (
"fmt"
"likedream-goframe/internal/ent"
"likedream-goframe/internal/ent/courseentity"
"likedream-goframe/internal/ent/cpimage"
"likedream-goframe/internal/ent/cpschool"
"likedream-goframe/internal/ent/cptask"
@@ -79,6 +80,33 @@ func (f TraverseFunc) Traverse(ctx context.Context, q ent.Query) error {
return f(ctx, query)
}
// The CourseEntityFunc type is an adapter to allow the use of ordinary function as a Querier.
type CourseEntityFunc func(context.Context, *ent.CourseEntityQuery) (ent.Value, error)
// Query calls f(ctx, q).
func (f CourseEntityFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
if q, ok := q.(*ent.CourseEntityQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *ent.CourseEntityQuery", q)
}
// The TraverseCourseEntity type is an adapter to allow the use of ordinary function as Traverser.
type TraverseCourseEntity func(context.Context, *ent.CourseEntityQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseCourseEntity) Intercept(next ent.Querier) ent.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseCourseEntity) Traverse(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.CourseEntityQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *ent.CourseEntityQuery", q)
}
// The CpImageFunc type is an adapter to allow the use of ordinary function as a Querier.
type CpImageFunc func(context.Context, *ent.CpImageQuery) (ent.Value, error)
@@ -379,6 +407,8 @@ func (f TraverseSysUserLog) Traverse(ctx context.Context, q ent.Query) error {
// NewQuery returns the generic Query interface for the given typed query.
func NewQuery(q ent.Query) (Query, error) {
switch q := q.(type) {
case *ent.CourseEntityQuery:
return &query[*ent.CourseEntityQuery, predicate.CourseEntity, courseentity.OrderOption]{typ: ent.TypeCourseEntity, tq: q}, nil
case *ent.CpImageQuery:
return &query[*ent.CpImageQuery, predicate.CpImage, cpimage.OrderOption]{typ: ent.TypeCpImage, tq: q}, nil
case *ent.CpSchoolQuery:
File diff suppressed because one or more lines are too long
+1
View File
@@ -7,6 +7,7 @@ import "context"
// SchemaConfig represents alternative schema names for all tables
// that can be passed at runtime.
type SchemaConfig struct {
CourseEntity string // CourseEntity table.
CpImage string // CpImage table.
CpSchool string // CpSchool table.
CpTask string // CpTask table.
+38
View File
@@ -9,6 +9,39 @@ import (
)
var (
// CourseEntityColumns holds the columns for the "course_entity" table.
CourseEntityColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true},
{Name: "create_time", Type: field.TypeString, SchemaType: map[string]string{"mysql": "datetime", "postgres": "timestamp", "sqlite3": "datetime"}},
{Name: "update_time", Type: field.TypeString, SchemaType: map[string]string{"mysql": "datetime", "postgres": "timestamp", "sqlite3": "datetime"}},
{Name: "username", Type: field.TypeString},
{Name: "password", Type: field.TypeString},
{Name: "type", Type: field.TypeEnum, Enums: []string{"xxt"}},
{Name: "course_name", Type: field.TypeString},
{Name: "course_id", Type: field.TypeString},
{Name: "need", Type: field.TypeEnum, Enums: []string{"task", "exam", "all"}},
{Name: "status", Type: field.TypeEnum, Enums: []string{"not_start", "waiting", "doing", "done", "fail", "pause"}, Default: "not_start"},
{Name: "task_count", Type: field.TypeInt, Default: 0},
{Name: "success_count", Type: field.TypeInt, Default: 0},
{Name: "exam_state", Type: field.TypeEnum, Enums: []string{"not_start", "waiting", "doing", "done", "fail"}, Default: "not_start"},
{Name: "violence", Type: field.TypeEnum, Enums: []string{"no", "yes"}, Default: "no"},
{Name: "desc", Type: field.TypeString, Nullable: true},
{Name: "user_id", Type: field.TypeInt64},
}
// CourseEntityTable holds the schema information for the "course_entity" table.
CourseEntityTable = &schema.Table{
Name: "course_entity",
Columns: CourseEntityColumns,
PrimaryKey: []*schema.Column{CourseEntityColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "course_entity_sys_user_course_entity",
Columns: []*schema.Column{CourseEntityColumns[15]},
RefColumns: []*schema.Column{SysUserColumns[0]},
OnDelete: schema.Cascade,
},
},
}
// CpImageColumns holds the columns for the "cp_image" table.
CpImageColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true},
@@ -362,6 +395,7 @@ var (
}
// Tables holds all the tables in the schema.
Tables = []*schema.Table{
CourseEntityTable,
CpImageTable,
CpSchoolsTable,
CpTasksTable,
@@ -379,6 +413,10 @@ var (
)
func init() {
CourseEntityTable.ForeignKeys[0].RefTable = SysUserTable
CourseEntityTable.Annotation = &entsql.Annotation{
Table: "course_entity",
}
CpImageTable.ForeignKeys[0].RefTable = SysUserTable
CpImageTable.Annotation = &entsql.Annotation{
Table: "cp_image",
+1339 -14
View File
File diff suppressed because it is too large Load Diff
+3
View File
@@ -6,6 +6,9 @@ import (
"entgo.io/ent/dialect/sql"
)
// CourseEntity is the predicate function for courseentity builders.
type CourseEntity func(*sql.Selector)
// CpImage is the predicate function for cpimage builders.
type CpImage func(*sql.Selector)
+28
View File
@@ -111,6 +111,30 @@ func DenyMutationOperationRule(op ent.Op) MutationRule {
return OnMutationOperation(rule, op)
}
// The CourseEntityQueryRuleFunc type is an adapter to allow the use of ordinary
// functions as a query rule.
type CourseEntityQueryRuleFunc func(context.Context, *ent.CourseEntityQuery) error
// EvalQuery return f(ctx, q).
func (f CourseEntityQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.CourseEntityQuery); ok {
return f(ctx, q)
}
return Denyf("ent/privacy: unexpected query type %T, expect *ent.CourseEntityQuery", q)
}
// The CourseEntityMutationRuleFunc type is an adapter to allow the use of ordinary
// functions as a mutation rule.
type CourseEntityMutationRuleFunc func(context.Context, *ent.CourseEntityMutation) error
// EvalMutation calls f(ctx, m).
func (f CourseEntityMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
if m, ok := m.(*ent.CourseEntityMutation); ok {
return f(ctx, m)
}
return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.CourseEntityMutation", m)
}
// The CpImageQueryRuleFunc type is an adapter to allow the use of ordinary
// functions as a query rule.
type CpImageQueryRuleFunc func(context.Context, *ent.CpImageQuery) error
@@ -410,6 +434,8 @@ var _ QueryMutationRule = FilterFunc(nil)
func queryFilter(q ent.Query) (Filter, error) {
switch q := q.(type) {
case *ent.CourseEntityQuery:
return q.Filter(), nil
case *ent.CpImageQuery:
return q.Filter(), nil
case *ent.CpSchoolQuery:
@@ -439,6 +465,8 @@ func queryFilter(q ent.Query) (Filter, error) {
func mutationFilter(m ent.Mutation) (Filter, error) {
switch m := m.(type) {
case *ent.CourseEntityMutation:
return m.Filter(), nil
case *ent.CpImageMutation:
return m.Filter(), nil
case *ent.CpSchoolMutation:
+24
View File
@@ -3,6 +3,7 @@
package runtime
import (
"likedream-goframe/internal/ent/courseentity"
"likedream-goframe/internal/ent/cpimage"
"likedream-goframe/internal/ent/cpschool"
"likedream-goframe/internal/ent/cptask"
@@ -24,6 +25,29 @@ import (
// (default values, validators, hooks and policies) and stitches it
// to their package variables.
func init() {
courseentityMixin := schema.CourseEntity{}.Mixin()
courseentityMixinHooks0 := courseentityMixin[0].Hooks()
courseentity.Hooks[0] = courseentityMixinHooks0[0]
courseentityMixinFields0 := courseentityMixin[0].Fields()
_ = courseentityMixinFields0
courseentityFields := schema.CourseEntity{}.Fields()
_ = courseentityFields
// courseentityDescCreateTime is the schema descriptor for create_time field.
courseentityDescCreateTime := courseentityMixinFields0[0].Descriptor()
// courseentity.DefaultCreateTime holds the default value on creation for the create_time field.
courseentity.DefaultCreateTime = courseentityDescCreateTime.Default.(func() *ent2.CustomTime)
// courseentityDescUpdateTime is the schema descriptor for update_time field.
courseentityDescUpdateTime := courseentityMixinFields0[1].Descriptor()
// courseentity.DefaultUpdateTime holds the default value on creation for the update_time field.
courseentity.DefaultUpdateTime = courseentityDescUpdateTime.Default.(func() *ent2.CustomTime)
// courseentityDescTaskCount is the schema descriptor for task_count field.
courseentityDescTaskCount := courseentityFields[8].Descriptor()
// courseentity.DefaultTaskCount holds the default value on creation for the task_count field.
courseentity.DefaultTaskCount = courseentityDescTaskCount.Default.(int)
// courseentityDescSuccessCount is the schema descriptor for success_count field.
courseentityDescSuccessCount := courseentityFields[9].Descriptor()
// courseentity.DefaultSuccessCount holds the default value on creation for the success_count field.
courseentity.DefaultSuccessCount = courseentityDescSuccessCount.Default.(int)
cpimageMixin := schema.CpImage{}.Mixin()
cpimageMixinHooks0 := cpimageMixin[0].Hooks()
cpimage.Hooks[0] = cpimageMixinHooks0[0]
+2 -2
View File
@@ -37,8 +37,8 @@ func (CpTask) Fields() []ent.Field {
// Edges of the CpTask.
func (CpTask) Edges() []ent.Edge {
return []ent.Edge{
edge.From("cp_user", CpUser.Type).Ref("cptasks").Field("cp_user_id").Unique().Required().Annotations(entsql.OnDelete(entsql.Cascade)),
edge.From("sys_user", SysUser.Type).Ref("cp_task").Field("user_id").Unique().Required().Annotations(entsql.OnDelete(entsql.Cascade)),
edge.From("cp_user", CpUser.Type).Ref("cptasks").Field("cp_user_id").Unique().Required(),
edge.From("sys_user", SysUser.Type).Ref("cp_task").Field("user_id").Unique().Required(),
edge.To("cp_task_logs", CpTaskLog.Type).Annotations(entsql.OnDelete(entsql.Cascade)), // 任务拥有的cp任务日志
}
}
+9 -8
View File
@@ -46,14 +46,15 @@ func (SysUser) Edges() []ent.Edge {
edge.To("children", SysUser.Type).
From("parent").
Unique(),
edge.To("roles", SysRole.Type).Annotations(entsql.OnDelete(entsql.Cascade)), // 用户拥有角色
edge.To("agent", SysAgent.Type).Unique().Annotations(entsql.OnDelete(entsql.Cascade)), // 用户拥有代理
edge.To("images", CpImage.Type).Annotations(entsql.OnDelete(entsql.Cascade)), // 用户拥有的图片
edge.To("cpuser", CpUser.Type).Annotations(entsql.OnDelete(entsql.Cascade)), // 用户拥有的cp用户
edge.To("cp_task", CpTask.Type).Annotations(entsql.OnDelete(entsql.Cascade)),
edge.To("cp_task_logs", CpTaskLog.Type).Annotations(entsql.OnDelete(entsql.Cascade)), // 用户拥有的cp任务日志
edge.To("created_cards", SysCard.Type), // 用户创建的卡
edge.To("used_cards", SysCard.Type), // 用户使用的卡
edge.To("roles", SysRole.Type).Annotations(entsql.OnDelete(entsql.Cascade)), // 用户拥有角色
edge.To("agent", SysAgent.Type).Unique().Annotations(entsql.OnDelete(entsql.Cascade)), // 用户拥有代理
edge.To("images", CpImage.Type).Annotations(entsql.OnDelete(entsql.Cascade)), // 用户拥有的图片
edge.To("cpuser", CpUser.Type).Annotations(entsql.OnDelete(entsql.Cascade)), // 用户拥有的cp用户
edge.To("cp_task", CpTask.Type).Annotations(entsql.OnDelete(entsql.Cascade)), // 用户拥有的cp任务
edge.To("course_entity", CourseEntity.Type).Annotations(entsql.OnDelete(entsql.Cascade)), // 用户拥有的刷课课程
edge.To("cp_task_logs", CpTaskLog.Type).Annotations(entsql.OnDelete(entsql.Cascade)), // 用户拥有的cp任务日志
edge.To("created_cards", SysCard.Type), // 用户创建的卡
edge.To("used_cards", SysCard.Type), // 用户使用的卡
edge.To("cashback_cards", SysCard.Type),
}
}
+53
View File
@@ -0,0 +1,53 @@
package schema
import (
"likedream-goframe/internal/ent/schema/mix"
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
type CourseEntity struct {
ent.Schema
}
// Fields of the SysUser.
func (CourseEntity) Fields() []ent.Field {
return []ent.Field{
field.Int64("user_id"),
field.String("username"), // 账号
field.String("password").Sensitive(), //密码
field.Enum("type").Values("xxt"), // 类型:目前只有学习通
field.String("course_name"), // 课程名称
field.String("course_id"), // 课程ID
field.Enum("need").Values("task", "exam", "all"), // 需要刷的内容:任务点、考试、全部
field.Enum("status").Values("not_start", "waiting", "doing", "done", "fail", "pause").Default("not_start"), // 状态
field.Int("task_count").Default(0), // 任务点数量
field.Int("success_count").Default(0), // 成功数量
field.Enum("exam_state").Values("not_start", "waiting", "doing", "done", "fail").Default("not_start"), // 考试状态
field.Enum("violence").Values("no", "yes").Default("no"), // 是否暴力刷课
field.String("desc").Optional(),
}
}
// Edges of the CpTask.
func (CourseEntity) Edges() []ent.Edge {
return []ent.Edge{
edge.From("sys_user", SysUser.Type).Ref("course_entity").Field("user_id").Unique().Required(),
}
}
func (CourseEntity) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "course_entity"},
}
}
func (CourseEntity) Mixin() []ent.Mixin {
return []ent.Mixin{
mix.MixinTime{},
}
}
+46 -5
View File
@@ -62,6 +62,8 @@ type SysUserEdges struct {
Cpuser []*CpUser `json:"cpuser,omitempty"`
// CpTask holds the value of the cp_task edge.
CpTask []*CpTask `json:"cp_task,omitempty"`
// CourseEntity holds the value of the course_entity edge.
CourseEntity []*CourseEntity `json:"course_entity,omitempty"`
// CpTaskLogs holds the value of the cp_task_logs edge.
CpTaskLogs []*CpTaskLog `json:"cp_task_logs,omitempty"`
// CreatedCards holds the value of the created_cards edge.
@@ -72,12 +74,13 @@ type SysUserEdges struct {
CashbackCards []*SysCard `json:"cashback_cards,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [11]bool
loadedTypes [12]bool
namedChildren map[string][]*SysUser
namedRoles map[string][]*SysRole
namedImages map[string][]*CpImage
namedCpuser map[string][]*CpUser
namedCpTask map[string][]*CpTask
namedCourseEntity map[string][]*CourseEntity
namedCpTaskLogs map[string][]*CpTaskLog
namedCreatedCards map[string][]*SysCard
namedUsedCards map[string][]*SysCard
@@ -151,10 +154,19 @@ func (e SysUserEdges) CpTaskOrErr() ([]*CpTask, error) {
return nil, &NotLoadedError{edge: "cp_task"}
}
// CourseEntityOrErr returns the CourseEntity value or an error if the edge
// was not loaded in eager-loading.
func (e SysUserEdges) CourseEntityOrErr() ([]*CourseEntity, error) {
if e.loadedTypes[7] {
return e.CourseEntity, nil
}
return nil, &NotLoadedError{edge: "course_entity"}
}
// CpTaskLogsOrErr returns the CpTaskLogs value or an error if the edge
// was not loaded in eager-loading.
func (e SysUserEdges) CpTaskLogsOrErr() ([]*CpTaskLog, error) {
if e.loadedTypes[7] {
if e.loadedTypes[8] {
return e.CpTaskLogs, nil
}
return nil, &NotLoadedError{edge: "cp_task_logs"}
@@ -163,7 +175,7 @@ func (e SysUserEdges) CpTaskLogsOrErr() ([]*CpTaskLog, error) {
// CreatedCardsOrErr returns the CreatedCards value or an error if the edge
// was not loaded in eager-loading.
func (e SysUserEdges) CreatedCardsOrErr() ([]*SysCard, error) {
if e.loadedTypes[8] {
if e.loadedTypes[9] {
return e.CreatedCards, nil
}
return nil, &NotLoadedError{edge: "created_cards"}
@@ -172,7 +184,7 @@ func (e SysUserEdges) CreatedCardsOrErr() ([]*SysCard, error) {
// UsedCardsOrErr returns the UsedCards value or an error if the edge
// was not loaded in eager-loading.
func (e SysUserEdges) UsedCardsOrErr() ([]*SysCard, error) {
if e.loadedTypes[9] {
if e.loadedTypes[10] {
return e.UsedCards, nil
}
return nil, &NotLoadedError{edge: "used_cards"}
@@ -181,7 +193,7 @@ func (e SysUserEdges) UsedCardsOrErr() ([]*SysCard, error) {
// CashbackCardsOrErr returns the CashbackCards value or an error if the edge
// was not loaded in eager-loading.
func (e SysUserEdges) CashbackCardsOrErr() ([]*SysCard, error) {
if e.loadedTypes[10] {
if e.loadedTypes[11] {
return e.CashbackCards, nil
}
return nil, &NotLoadedError{edge: "cashback_cards"}
@@ -340,6 +352,11 @@ func (_m *SysUser) QueryCpTask() *CpTaskQuery {
return NewSysUserClient(_m.config).QueryCpTask(_m)
}
// QueryCourseEntity queries the "course_entity" edge of the SysUser entity.
func (_m *SysUser) QueryCourseEntity() *CourseEntityQuery {
return NewSysUserClient(_m.config).QueryCourseEntity(_m)
}
// QueryCpTaskLogs queries the "cp_task_logs" edge of the SysUser entity.
func (_m *SysUser) QueryCpTaskLogs() *CpTaskLogQuery {
return NewSysUserClient(_m.config).QueryCpTaskLogs(_m)
@@ -535,6 +552,30 @@ func (_m *SysUser) appendNamedCpTask(name string, edges ...*CpTask) {
}
}
// NamedCourseEntity returns the CourseEntity named value or an error if the edge was not
// loaded in eager-loading with this name.
func (_m *SysUser) NamedCourseEntity(name string) ([]*CourseEntity, error) {
if _m.Edges.namedCourseEntity == nil {
return nil, &NotLoadedError{edge: name}
}
nodes, ok := _m.Edges.namedCourseEntity[name]
if !ok {
return nil, &NotLoadedError{edge: name}
}
return nodes, nil
}
func (_m *SysUser) appendNamedCourseEntity(name string, edges ...*CourseEntity) {
if _m.Edges.namedCourseEntity == nil {
_m.Edges.namedCourseEntity = make(map[string][]*CourseEntity)
}
if len(edges) == 0 {
_m.Edges.namedCourseEntity[name] = []*CourseEntity{}
} else {
_m.Edges.namedCourseEntity[name] = append(_m.Edges.namedCourseEntity[name], edges...)
}
}
// NamedCpTaskLogs returns the CpTaskLogs named value or an error if the edge was not
// loaded in eager-loading with this name.
func (_m *SysUser) NamedCpTaskLogs(name string) ([]*CpTaskLog, error) {
+30
View File
@@ -50,6 +50,8 @@ const (
EdgeCpuser = "cpuser"
// EdgeCpTask holds the string denoting the cp_task edge name in mutations.
EdgeCpTask = "cp_task"
// EdgeCourseEntity holds the string denoting the course_entity edge name in mutations.
EdgeCourseEntity = "course_entity"
// EdgeCpTaskLogs holds the string denoting the cp_task_logs edge name in mutations.
EdgeCpTaskLogs = "cp_task_logs"
// EdgeCreatedCards holds the string denoting the created_cards edge name in mutations.
@@ -101,6 +103,13 @@ const (
CpTaskInverseTable = "cp_tasks"
// CpTaskColumn is the table column denoting the cp_task relation/edge.
CpTaskColumn = "user_id"
// CourseEntityTable is the table that holds the course_entity relation/edge.
CourseEntityTable = "course_entity"
// CourseEntityInverseTable is the table name for the CourseEntity entity.
// It exists in this package in order to avoid circular dependency with the "courseentity" package.
CourseEntityInverseTable = "course_entity"
// CourseEntityColumn is the table column denoting the course_entity relation/edge.
CourseEntityColumn = "user_id"
// CpTaskLogsTable is the table that holds the cp_task_logs relation/edge.
CpTaskLogsTable = "cp_task_logs"
// CpTaskLogsInverseTable is the table name for the CpTaskLog entity.
@@ -338,6 +347,20 @@ func ByCpTask(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
}
}
// ByCourseEntityCount orders the results by course_entity count.
func ByCourseEntityCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newCourseEntityStep(), opts...)
}
}
// ByCourseEntity orders the results by course_entity terms.
func ByCourseEntity(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newCourseEntityStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByCpTaskLogsCount orders the results by cp_task_logs count.
func ByCpTaskLogsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
@@ -442,6 +465,13 @@ func newCpTaskStep() *sqlgraph.Step {
sqlgraph.Edge(sqlgraph.O2M, false, CpTaskTable, CpTaskColumn),
)
}
func newCourseEntityStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(CourseEntityInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, CourseEntityTable, CourseEntityColumn),
)
}
func newCpTaskLogsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
+29
View File
@@ -880,6 +880,35 @@ func HasCpTaskWith(preds ...predicate.CpTask) predicate.SysUser {
})
}
// HasCourseEntity applies the HasEdge predicate on the "course_entity" edge.
func HasCourseEntity() predicate.SysUser {
return predicate.SysUser(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, CourseEntityTable, CourseEntityColumn),
)
schemaConfig := internal.SchemaConfigFromContext(s.Context())
step.To.Schema = schemaConfig.CourseEntity
step.Edge.Schema = schemaConfig.CourseEntity
sqlgraph.HasNeighbors(s, step)
})
}
// HasCourseEntityWith applies the HasEdge predicate on the "course_entity" edge with a given conditions (other predicates).
func HasCourseEntityWith(preds ...predicate.CourseEntity) predicate.SysUser {
return predicate.SysUser(func(s *sql.Selector) {
step := newCourseEntityStep()
schemaConfig := internal.SchemaConfigFromContext(s.Context())
step.To.Schema = schemaConfig.CourseEntity
step.Edge.Schema = schemaConfig.CourseEntity
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// HasCpTaskLogs applies the HasEdge predicate on the "cp_task_logs" edge.
func HasCpTaskLogs() predicate.SysUser {
return predicate.SysUser(func(s *sql.Selector) {
+33
View File
@@ -6,6 +6,7 @@ import (
"context"
"errors"
"fmt"
"likedream-goframe/internal/ent/courseentity"
"likedream-goframe/internal/ent/cpimage"
"likedream-goframe/internal/ent/cptask"
"likedream-goframe/internal/ent/cptasklog"
@@ -243,6 +244,21 @@ func (_c *SysUserCreate) AddCpTask(v ...*CpTask) *SysUserCreate {
return _c.AddCpTaskIDs(ids...)
}
// AddCourseEntityIDs adds the "course_entity" edge to the CourseEntity entity by IDs.
func (_c *SysUserCreate) AddCourseEntityIDs(ids ...int64) *SysUserCreate {
_c.mutation.AddCourseEntityIDs(ids...)
return _c
}
// AddCourseEntity adds the "course_entity" edges to the CourseEntity entity.
func (_c *SysUserCreate) AddCourseEntity(v ...*CourseEntity) *SysUserCreate {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddCourseEntityIDs(ids...)
}
// AddCpTaskLogIDs adds the "cp_task_logs" edge to the CpTaskLog entity by IDs.
func (_c *SysUserCreate) AddCpTaskLogIDs(ids ...int64) *SysUserCreate {
_c.mutation.AddCpTaskLogIDs(ids...)
@@ -601,6 +617,23 @@ func (_c *SysUserCreate) createSpec() (*SysUser, *sqlgraph.CreateSpec) {
}
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.CourseEntityIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: sysuser.CourseEntityTable,
Columns: []string{sysuser.CourseEntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(courseentity.FieldID, field.TypeInt64),
},
}
edge.Schema = _c.schemaConfig.CourseEntity
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.CpTaskLogsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
+110 -1
View File
@@ -6,6 +6,7 @@ import (
"context"
"database/sql/driver"
"fmt"
"likedream-goframe/internal/ent/courseentity"
"likedream-goframe/internal/ent/cpimage"
"likedream-goframe/internal/ent/cptask"
"likedream-goframe/internal/ent/cptasklog"
@@ -39,6 +40,7 @@ type SysUserQuery struct {
withImages *CpImageQuery
withCpuser *CpUserQuery
withCpTask *CpTaskQuery
withCourseEntity *CourseEntityQuery
withCpTaskLogs *CpTaskLogQuery
withCreatedCards *SysCardQuery
withUsedCards *SysCardQuery
@@ -50,6 +52,7 @@ type SysUserQuery struct {
withNamedImages map[string]*CpImageQuery
withNamedCpuser map[string]*CpUserQuery
withNamedCpTask map[string]*CpTaskQuery
withNamedCourseEntity map[string]*CourseEntityQuery
withNamedCpTaskLogs map[string]*CpTaskLogQuery
withNamedCreatedCards map[string]*SysCardQuery
withNamedUsedCards map[string]*SysCardQuery
@@ -265,6 +268,31 @@ func (_q *SysUserQuery) QueryCpTask() *CpTaskQuery {
return query
}
// QueryCourseEntity chains the current query on the "course_entity" edge.
func (_q *SysUserQuery) QueryCourseEntity() *CourseEntityQuery {
query := (&CourseEntityClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(sysuser.Table, sysuser.FieldID, selector),
sqlgraph.To(courseentity.Table, courseentity.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, sysuser.CourseEntityTable, sysuser.CourseEntityColumn),
)
schemaConfig := _q.schemaConfig
step.To.Schema = schemaConfig.CourseEntity
step.Edge.Schema = schemaConfig.CourseEntity
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
}
return query
}
// QueryCpTaskLogs chains the current query on the "cp_task_logs" edge.
func (_q *SysUserQuery) QueryCpTaskLogs() *CpTaskLogQuery {
query := (&CpTaskLogClient{config: _q.config}).Query()
@@ -564,6 +592,7 @@ func (_q *SysUserQuery) Clone() *SysUserQuery {
withImages: _q.withImages.Clone(),
withCpuser: _q.withCpuser.Clone(),
withCpTask: _q.withCpTask.Clone(),
withCourseEntity: _q.withCourseEntity.Clone(),
withCpTaskLogs: _q.withCpTaskLogs.Clone(),
withCreatedCards: _q.withCreatedCards.Clone(),
withUsedCards: _q.withUsedCards.Clone(),
@@ -652,6 +681,17 @@ func (_q *SysUserQuery) WithCpTask(opts ...func(*CpTaskQuery)) *SysUserQuery {
return _q
}
// WithCourseEntity tells the query-builder to eager-load the nodes that are connected to
// the "course_entity" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *SysUserQuery) WithCourseEntity(opts ...func(*CourseEntityQuery)) *SysUserQuery {
query := (&CourseEntityClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withCourseEntity = query
return _q
}
// WithCpTaskLogs tells the query-builder to eager-load the nodes that are connected to
// the "cp_task_logs" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *SysUserQuery) WithCpTaskLogs(opts ...func(*CpTaskLogQuery)) *SysUserQuery {
@@ -775,7 +815,7 @@ func (_q *SysUserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*SysU
nodes = []*SysUser{}
withFKs = _q.withFKs
_spec = _q.querySpec()
loadedTypes = [11]bool{
loadedTypes = [12]bool{
_q.withParent != nil,
_q.withChildren != nil,
_q.withRoles != nil,
@@ -783,6 +823,7 @@ func (_q *SysUserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*SysU
_q.withImages != nil,
_q.withCpuser != nil,
_q.withCpTask != nil,
_q.withCourseEntity != nil,
_q.withCpTaskLogs != nil,
_q.withCreatedCards != nil,
_q.withUsedCards != nil,
@@ -890,6 +931,18 @@ func (_q *SysUserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*SysU
return nil, err
}
}
if query := _q.withCourseEntity; query != nil {
if err := _q.loadCourseEntity(ctx, query, nodes,
func(n *SysUser) { n.Edges.CourseEntity = []*CourseEntity{} },
func(n *SysUser, e *CourseEntity) {
n.Edges.CourseEntity = append(n.Edges.CourseEntity, e)
if !e.Edges.loadedTypes[0] {
e.Edges.SysUser = n
}
}); err != nil {
return nil, err
}
}
if query := _q.withCpTaskLogs; query != nil {
if err := _q.loadCpTaskLogs(ctx, query, nodes,
func(n *SysUser) { n.Edges.CpTaskLogs = []*CpTaskLog{} },
@@ -993,6 +1046,18 @@ func (_q *SysUserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*SysU
return nil, err
}
}
for name, query := range _q.withNamedCourseEntity {
if err := _q.loadCourseEntity(ctx, query, nodes,
func(n *SysUser) { n.appendNamedCourseEntity(name) },
func(n *SysUser, e *CourseEntity) {
n.appendNamedCourseEntity(name, e)
if !e.Edges.loadedTypes[0] {
e.Edges.SysUser = n
}
}); err != nil {
return nil, err
}
}
for name, query := range _q.withNamedCpTaskLogs {
if err := _q.loadCpTaskLogs(ctx, query, nodes,
func(n *SysUser) { n.appendNamedCpTaskLogs(name) },
@@ -1287,6 +1352,36 @@ func (_q *SysUserQuery) loadCpTask(ctx context.Context, query *CpTaskQuery, node
}
return nil
}
func (_q *SysUserQuery) loadCourseEntity(ctx context.Context, query *CourseEntityQuery, nodes []*SysUser, init func(*SysUser), assign func(*SysUser, *CourseEntity)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[int64]*SysUser)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
if init != nil {
init(nodes[i])
}
}
if len(query.ctx.Fields) > 0 {
query.ctx.AppendFieldOnce(courseentity.FieldUserID)
}
query.Where(predicate.CourseEntity(func(s *sql.Selector) {
s.Where(sql.InValues(s.C(sysuser.CourseEntityColumn), fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
fk := n.UserID
node, ok := nodeids[fk]
if !ok {
return fmt.Errorf(`unexpected referenced foreign-key "user_id" returned %v for node %v`, fk, n.ID)
}
assign(node, n)
}
return nil
}
func (_q *SysUserQuery) loadCpTaskLogs(ctx context.Context, query *CpTaskLogQuery, nodes []*SysUser, init func(*SysUser), assign func(*SysUser, *CpTaskLog)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[int64]*SysUser)
@@ -1602,6 +1697,20 @@ func (_q *SysUserQuery) WithNamedCpTask(name string, opts ...func(*CpTaskQuery))
return _q
}
// WithNamedCourseEntity tells the query-builder to eager-load the nodes that are connected to the "course_entity"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (_q *SysUserQuery) WithNamedCourseEntity(name string, opts ...func(*CourseEntityQuery)) *SysUserQuery {
query := (&CourseEntityClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
if _q.withNamedCourseEntity == nil {
_q.withNamedCourseEntity = make(map[string]*CourseEntityQuery)
}
_q.withNamedCourseEntity[name] = query
return _q
}
// WithNamedCpTaskLogs tells the query-builder to eager-load the nodes that are connected to the "cp_task_logs"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (_q *SysUserQuery) WithNamedCpTaskLogs(name string, opts ...func(*CpTaskLogQuery)) *SysUserQuery {
+169
View File
@@ -6,6 +6,7 @@ import (
"context"
"errors"
"fmt"
"likedream-goframe/internal/ent/courseentity"
"likedream-goframe/internal/ent/cpimage"
"likedream-goframe/internal/ent/cptask"
"likedream-goframe/internal/ent/cptasklog"
@@ -275,6 +276,21 @@ func (_u *SysUserUpdate) AddCpTask(v ...*CpTask) *SysUserUpdate {
return _u.AddCpTaskIDs(ids...)
}
// AddCourseEntityIDs adds the "course_entity" edge to the CourseEntity entity by IDs.
func (_u *SysUserUpdate) AddCourseEntityIDs(ids ...int64) *SysUserUpdate {
_u.mutation.AddCourseEntityIDs(ids...)
return _u
}
// AddCourseEntity adds the "course_entity" edges to the CourseEntity entity.
func (_u *SysUserUpdate) AddCourseEntity(v ...*CourseEntity) *SysUserUpdate {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddCourseEntityIDs(ids...)
}
// AddCpTaskLogIDs adds the "cp_task_logs" edge to the CpTaskLog entity by IDs.
func (_u *SysUserUpdate) AddCpTaskLogIDs(ids ...int64) *SysUserUpdate {
_u.mutation.AddCpTaskLogIDs(ids...)
@@ -457,6 +473,27 @@ func (_u *SysUserUpdate) RemoveCpTask(v ...*CpTask) *SysUserUpdate {
return _u.RemoveCpTaskIDs(ids...)
}
// ClearCourseEntity clears all "course_entity" edges to the CourseEntity entity.
func (_u *SysUserUpdate) ClearCourseEntity() *SysUserUpdate {
_u.mutation.ClearCourseEntity()
return _u
}
// RemoveCourseEntityIDs removes the "course_entity" edge to CourseEntity entities by IDs.
func (_u *SysUserUpdate) RemoveCourseEntityIDs(ids ...int64) *SysUserUpdate {
_u.mutation.RemoveCourseEntityIDs(ids...)
return _u
}
// RemoveCourseEntity removes "course_entity" edges to CourseEntity entities.
func (_u *SysUserUpdate) RemoveCourseEntity(v ...*CourseEntity) *SysUserUpdate {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveCourseEntityIDs(ids...)
}
// ClearCpTaskLogs clears all "cp_task_logs" edges to the CpTaskLog entity.
func (_u *SysUserUpdate) ClearCpTaskLogs() *SysUserUpdate {
_u.mutation.ClearCpTaskLogs()
@@ -928,6 +965,54 @@ func (_u *SysUserUpdate) sqlSave(ctx context.Context) (_node int, err error) {
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.CourseEntityCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: sysuser.CourseEntityTable,
Columns: []string{sysuser.CourseEntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(courseentity.FieldID, field.TypeInt64),
},
}
edge.Schema = _u.schemaConfig.CourseEntity
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedCourseEntityIDs(); len(nodes) > 0 && !_u.mutation.CourseEntityCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: sysuser.CourseEntityTable,
Columns: []string{sysuser.CourseEntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(courseentity.FieldID, field.TypeInt64),
},
}
edge.Schema = _u.schemaConfig.CourseEntity
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.CourseEntityIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: sysuser.CourseEntityTable,
Columns: []string{sysuser.CourseEntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(courseentity.FieldID, field.TypeInt64),
},
}
edge.Schema = _u.schemaConfig.CourseEntity
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.CpTaskLogsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
@@ -1381,6 +1466,21 @@ func (_u *SysUserUpdateOne) AddCpTask(v ...*CpTask) *SysUserUpdateOne {
return _u.AddCpTaskIDs(ids...)
}
// AddCourseEntityIDs adds the "course_entity" edge to the CourseEntity entity by IDs.
func (_u *SysUserUpdateOne) AddCourseEntityIDs(ids ...int64) *SysUserUpdateOne {
_u.mutation.AddCourseEntityIDs(ids...)
return _u
}
// AddCourseEntity adds the "course_entity" edges to the CourseEntity entity.
func (_u *SysUserUpdateOne) AddCourseEntity(v ...*CourseEntity) *SysUserUpdateOne {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddCourseEntityIDs(ids...)
}
// AddCpTaskLogIDs adds the "cp_task_logs" edge to the CpTaskLog entity by IDs.
func (_u *SysUserUpdateOne) AddCpTaskLogIDs(ids ...int64) *SysUserUpdateOne {
_u.mutation.AddCpTaskLogIDs(ids...)
@@ -1563,6 +1663,27 @@ func (_u *SysUserUpdateOne) RemoveCpTask(v ...*CpTask) *SysUserUpdateOne {
return _u.RemoveCpTaskIDs(ids...)
}
// ClearCourseEntity clears all "course_entity" edges to the CourseEntity entity.
func (_u *SysUserUpdateOne) ClearCourseEntity() *SysUserUpdateOne {
_u.mutation.ClearCourseEntity()
return _u
}
// RemoveCourseEntityIDs removes the "course_entity" edge to CourseEntity entities by IDs.
func (_u *SysUserUpdateOne) RemoveCourseEntityIDs(ids ...int64) *SysUserUpdateOne {
_u.mutation.RemoveCourseEntityIDs(ids...)
return _u
}
// RemoveCourseEntity removes "course_entity" edges to CourseEntity entities.
func (_u *SysUserUpdateOne) RemoveCourseEntity(v ...*CourseEntity) *SysUserUpdateOne {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveCourseEntityIDs(ids...)
}
// ClearCpTaskLogs clears all "cp_task_logs" edges to the CpTaskLog entity.
func (_u *SysUserUpdateOne) ClearCpTaskLogs() *SysUserUpdateOne {
_u.mutation.ClearCpTaskLogs()
@@ -2064,6 +2185,54 @@ func (_u *SysUserUpdateOne) sqlSave(ctx context.Context) (_node *SysUser, err er
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.CourseEntityCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: sysuser.CourseEntityTable,
Columns: []string{sysuser.CourseEntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(courseentity.FieldID, field.TypeInt64),
},
}
edge.Schema = _u.schemaConfig.CourseEntity
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedCourseEntityIDs(); len(nodes) > 0 && !_u.mutation.CourseEntityCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: sysuser.CourseEntityTable,
Columns: []string{sysuser.CourseEntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(courseentity.FieldID, field.TypeInt64),
},
}
edge.Schema = _u.schemaConfig.CourseEntity
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.CourseEntityIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: sysuser.CourseEntityTable,
Columns: []string{sysuser.CourseEntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(courseentity.FieldID, field.TypeInt64),
},
}
edge.Schema = _u.schemaConfig.CourseEntity
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.CpTaskLogsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
+4 -1
View File
@@ -14,6 +14,8 @@ import (
// Tx is a transactional client that is created by calling Client.Tx().
type Tx struct {
config
// CourseEntity is the client for interacting with the CourseEntity builders.
CourseEntity *CourseEntityClient
// CpImage is the client for interacting with the CpImage builders.
CpImage *CpImageClient
// CpSchool is the client for interacting with the CpSchool builders.
@@ -167,6 +169,7 @@ func (tx *Tx) Client() *Client {
}
func (tx *Tx) init() {
tx.CourseEntity = NewCourseEntityClient(tx.config)
tx.CpImage = NewCpImageClient(tx.config)
tx.CpSchool = NewCpSchoolClient(tx.config)
tx.CpTask = NewCpTaskClient(tx.config)
@@ -187,7 +190,7 @@ func (tx *Tx) init() {
// of them in order to commit or rollback the transaction.
//
// If a closed transaction is embedded in one of the generated entities, and the entity
// applies a query, for example: CpImage.QueryXXX(), the query will be executed
// applies a query, for example: CourseEntity.QueryXXX(), the query will be executed
// through the driver which created this transaction.
//
// Note that txDriver is not goroutine safe.