本次迭代覆盖MES与WMS核心业务: 1. 新增接驳台托盘传感器读取与AGV对接能力 2. 完善工单排产、备料流程与权限体系拆分 3. 优化看板接口与前端路由、样式 4. 新增操作日志、库存盘点与角色保护逻辑 5. 修复代理地址、BOM保存等已知问题
492 lines
15 KiB
Go
492 lines
15 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_wms/ent/eventlog"
|
|
"bj_power_wms/ent/predicate"
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// EventLogUpdate is the builder for updating EventLog entities.
|
|
type EventLogUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *EventLogMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the EventLogUpdate builder.
|
|
func (_u *EventLogUpdate) Where(ps ...predicate.EventLog) *EventLogUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetEventType sets the "event_type" field.
|
|
func (_u *EventLogUpdate) SetEventType(v string) *EventLogUpdate {
|
|
_u.mutation.SetEventType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEventType sets the "event_type" field if the given value is not nil.
|
|
func (_u *EventLogUpdate) SetNillableEventType(v *string) *EventLogUpdate {
|
|
if v != nil {
|
|
_u.SetEventType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetOperator sets the "operator" field.
|
|
func (_u *EventLogUpdate) SetOperator(v string) *EventLogUpdate {
|
|
_u.mutation.SetOperator(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOperator sets the "operator" field if the given value is not nil.
|
|
func (_u *EventLogUpdate) SetNillableOperator(v *string) *EventLogUpdate {
|
|
if v != nil {
|
|
_u.SetOperator(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetEntityType sets the "entity_type" field.
|
|
func (_u *EventLogUpdate) SetEntityType(v string) *EventLogUpdate {
|
|
_u.mutation.SetEntityType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEntityType sets the "entity_type" field if the given value is not nil.
|
|
func (_u *EventLogUpdate) SetNillableEntityType(v *string) *EventLogUpdate {
|
|
if v != nil {
|
|
_u.SetEntityType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetEntityID sets the "entity_id" field.
|
|
func (_u *EventLogUpdate) SetEntityID(v string) *EventLogUpdate {
|
|
_u.mutation.SetEntityID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEntityID sets the "entity_id" field if the given value is not nil.
|
|
func (_u *EventLogUpdate) SetNillableEntityID(v *string) *EventLogUpdate {
|
|
if v != nil {
|
|
_u.SetEntityID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (_u *EventLogUpdate) SetDescription(v string) *EventLogUpdate {
|
|
_u.mutation.SetDescription(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
func (_u *EventLogUpdate) SetNillableDescription(v *string) *EventLogUpdate {
|
|
if v != nil {
|
|
_u.SetDescription(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetPayload sets the "payload" field.
|
|
func (_u *EventLogUpdate) SetPayload(v map[string]interface{}) *EventLogUpdate {
|
|
_u.mutation.SetPayload(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearPayload clears the value of the "payload" field.
|
|
func (_u *EventLogUpdate) ClearPayload() *EventLogUpdate {
|
|
_u.mutation.ClearPayload()
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *EventLogUpdate) SetCreatedAt(v int64) *EventLogUpdate {
|
|
_u.mutation.ResetCreatedAt()
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *EventLogUpdate) SetNillableCreatedAt(v *int64) *EventLogUpdate {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddCreatedAt adds value to the "created_at" field.
|
|
func (_u *EventLogUpdate) AddCreatedAt(v int64) *EventLogUpdate {
|
|
_u.mutation.AddCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the EventLogMutation object of the builder.
|
|
func (_u *EventLogUpdate) Mutation() *EventLogMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *EventLogUpdate) 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 *EventLogUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *EventLogUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *EventLogUpdate) 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 *EventLogUpdate) check() error {
|
|
if v, ok := _u.mutation.EventType(); ok {
|
|
if err := eventlog.EventTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "event_type", err: fmt.Errorf(`ent: validator failed for field "EventLog.event_type": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Operator(); ok {
|
|
if err := eventlog.OperatorValidator(v); err != nil {
|
|
return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "EventLog.operator": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.EntityType(); ok {
|
|
if err := eventlog.EntityTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "entity_type", err: fmt.Errorf(`ent: validator failed for field "EventLog.entity_type": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.EntityID(); ok {
|
|
if err := eventlog.EntityIDValidator(v); err != nil {
|
|
return &ValidationError{Name: "entity_id", err: fmt.Errorf(`ent: validator failed for field "EventLog.entity_id": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *EventLogUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(eventlog.Table, eventlog.Columns, sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt))
|
|
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.EventType(); ok {
|
|
_spec.SetField(eventlog.FieldEventType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Operator(); ok {
|
|
_spec.SetField(eventlog.FieldOperator, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.EntityType(); ok {
|
|
_spec.SetField(eventlog.FieldEntityType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.EntityID(); ok {
|
|
_spec.SetField(eventlog.FieldEntityID, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Description(); ok {
|
|
_spec.SetField(eventlog.FieldDescription, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Payload(); ok {
|
|
_spec.SetField(eventlog.FieldPayload, field.TypeJSON, value)
|
|
}
|
|
if _u.mutation.PayloadCleared() {
|
|
_spec.ClearField(eventlog.FieldPayload, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(eventlog.FieldCreatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedCreatedAt(); ok {
|
|
_spec.AddField(eventlog.FieldCreatedAt, field.TypeInt64, value)
|
|
}
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{eventlog.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// EventLogUpdateOne is the builder for updating a single EventLog entity.
|
|
type EventLogUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *EventLogMutation
|
|
}
|
|
|
|
// SetEventType sets the "event_type" field.
|
|
func (_u *EventLogUpdateOne) SetEventType(v string) *EventLogUpdateOne {
|
|
_u.mutation.SetEventType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEventType sets the "event_type" field if the given value is not nil.
|
|
func (_u *EventLogUpdateOne) SetNillableEventType(v *string) *EventLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetEventType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetOperator sets the "operator" field.
|
|
func (_u *EventLogUpdateOne) SetOperator(v string) *EventLogUpdateOne {
|
|
_u.mutation.SetOperator(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOperator sets the "operator" field if the given value is not nil.
|
|
func (_u *EventLogUpdateOne) SetNillableOperator(v *string) *EventLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetOperator(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetEntityType sets the "entity_type" field.
|
|
func (_u *EventLogUpdateOne) SetEntityType(v string) *EventLogUpdateOne {
|
|
_u.mutation.SetEntityType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEntityType sets the "entity_type" field if the given value is not nil.
|
|
func (_u *EventLogUpdateOne) SetNillableEntityType(v *string) *EventLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetEntityType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetEntityID sets the "entity_id" field.
|
|
func (_u *EventLogUpdateOne) SetEntityID(v string) *EventLogUpdateOne {
|
|
_u.mutation.SetEntityID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEntityID sets the "entity_id" field if the given value is not nil.
|
|
func (_u *EventLogUpdateOne) SetNillableEntityID(v *string) *EventLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetEntityID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (_u *EventLogUpdateOne) SetDescription(v string) *EventLogUpdateOne {
|
|
_u.mutation.SetDescription(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
func (_u *EventLogUpdateOne) SetNillableDescription(v *string) *EventLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetDescription(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetPayload sets the "payload" field.
|
|
func (_u *EventLogUpdateOne) SetPayload(v map[string]interface{}) *EventLogUpdateOne {
|
|
_u.mutation.SetPayload(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearPayload clears the value of the "payload" field.
|
|
func (_u *EventLogUpdateOne) ClearPayload() *EventLogUpdateOne {
|
|
_u.mutation.ClearPayload()
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *EventLogUpdateOne) SetCreatedAt(v int64) *EventLogUpdateOne {
|
|
_u.mutation.ResetCreatedAt()
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *EventLogUpdateOne) SetNillableCreatedAt(v *int64) *EventLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddCreatedAt adds value to the "created_at" field.
|
|
func (_u *EventLogUpdateOne) AddCreatedAt(v int64) *EventLogUpdateOne {
|
|
_u.mutation.AddCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the EventLogMutation object of the builder.
|
|
func (_u *EventLogUpdateOne) Mutation() *EventLogMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Where appends a list predicates to the EventLogUpdate builder.
|
|
func (_u *EventLogUpdateOne) Where(ps ...predicate.EventLog) *EventLogUpdateOne {
|
|
_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 *EventLogUpdateOne) Select(field string, fields ...string) *EventLogUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated EventLog entity.
|
|
func (_u *EventLogUpdateOne) Save(ctx context.Context) (*EventLog, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *EventLogUpdateOne) SaveX(ctx context.Context) *EventLog {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *EventLogUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *EventLogUpdateOne) 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 *EventLogUpdateOne) check() error {
|
|
if v, ok := _u.mutation.EventType(); ok {
|
|
if err := eventlog.EventTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "event_type", err: fmt.Errorf(`ent: validator failed for field "EventLog.event_type": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Operator(); ok {
|
|
if err := eventlog.OperatorValidator(v); err != nil {
|
|
return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "EventLog.operator": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.EntityType(); ok {
|
|
if err := eventlog.EntityTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "entity_type", err: fmt.Errorf(`ent: validator failed for field "EventLog.entity_type": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.EntityID(); ok {
|
|
if err := eventlog.EntityIDValidator(v); err != nil {
|
|
return &ValidationError{Name: "entity_id", err: fmt.Errorf(`ent: validator failed for field "EventLog.entity_id": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *EventLogUpdateOne) sqlSave(ctx context.Context) (_node *EventLog, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(eventlog.Table, eventlog.Columns, sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "EventLog.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, eventlog.FieldID)
|
|
for _, f := range fields {
|
|
if !eventlog.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != eventlog.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.EventType(); ok {
|
|
_spec.SetField(eventlog.FieldEventType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Operator(); ok {
|
|
_spec.SetField(eventlog.FieldOperator, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.EntityType(); ok {
|
|
_spec.SetField(eventlog.FieldEntityType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.EntityID(); ok {
|
|
_spec.SetField(eventlog.FieldEntityID, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Description(); ok {
|
|
_spec.SetField(eventlog.FieldDescription, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Payload(); ok {
|
|
_spec.SetField(eventlog.FieldPayload, field.TypeJSON, value)
|
|
}
|
|
if _u.mutation.PayloadCleared() {
|
|
_spec.ClearField(eventlog.FieldPayload, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(eventlog.FieldCreatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedCreatedAt(); ok {
|
|
_spec.AddField(eventlog.FieldCreatedAt, field.TypeInt64, value)
|
|
}
|
|
_node = &EventLog{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{eventlog.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|