Files
bj_power/bj_power_mes/ent/station_update.go
T
SunYF 4ec6784629 feat: 完成MES工位终端系统全量功能迭代
本次提交包含以下核心变更:
1. 新增按钮级权限控制框架与前端权限校验
2. 新增工位管理、工艺流程、巡检终端等核心业务模块
3. 完善用户体系,支持工位终端专属登录权限
4. 新增文件上传下载、报表查询等配套功能
5. 修复多系统兼容性与交互体验问题
6. 完成所有文档与配置项的规范化更新
2026-08-31 08:06:55 +08:00

422 lines
12 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"bj_power_mes/ent/predicate"
"bj_power_mes/ent/station"
"context"
"errors"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// StationUpdate is the builder for updating Station entities.
type StationUpdate struct {
config
hooks []Hook
mutation *StationMutation
modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the StationUpdate builder.
func (_u *StationUpdate) Where(ps ...predicate.Station) *StationUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetStationNo sets the "stationNo" field.
func (_u *StationUpdate) SetStationNo(v int) *StationUpdate {
_u.mutation.ResetStationNo()
_u.mutation.SetStationNo(v)
return _u
}
// SetNillableStationNo sets the "stationNo" field if the given value is not nil.
func (_u *StationUpdate) SetNillableStationNo(v *int) *StationUpdate {
if v != nil {
_u.SetStationNo(*v)
}
return _u
}
// AddStationNo adds value to the "stationNo" field.
func (_u *StationUpdate) AddStationNo(v int) *StationUpdate {
_u.mutation.AddStationNo(v)
return _u
}
// SetName sets the "name" field.
func (_u *StationUpdate) SetName(v string) *StationUpdate {
_u.mutation.SetName(v)
return _u
}
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *StationUpdate) SetNillableName(v *string) *StationUpdate {
if v != nil {
_u.SetName(*v)
}
return _u
}
// SetFlowId sets the "flowId" field.
func (_u *StationUpdate) SetFlowId(v int) *StationUpdate {
_u.mutation.ResetFlowId()
_u.mutation.SetFlowId(v)
return _u
}
// SetNillableFlowId sets the "flowId" field if the given value is not nil.
func (_u *StationUpdate) SetNillableFlowId(v *int) *StationUpdate {
if v != nil {
_u.SetFlowId(*v)
}
return _u
}
// AddFlowId adds value to the "flowId" field.
func (_u *StationUpdate) AddFlowId(v int) *StationUpdate {
_u.mutation.AddFlowId(v)
return _u
}
// ClearFlowId clears the value of the "flowId" field.
func (_u *StationUpdate) ClearFlowId() *StationUpdate {
_u.mutation.ClearFlowId()
return _u
}
// SetStatus sets the "status" field.
func (_u *StationUpdate) SetStatus(v string) *StationUpdate {
_u.mutation.SetStatus(v)
return _u
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (_u *StationUpdate) SetNillableStatus(v *string) *StationUpdate {
if v != nil {
_u.SetStatus(*v)
}
return _u
}
// Mutation returns the StationMutation object of the builder.
func (_u *StationUpdate) Mutation() *StationMutation {
return _u.mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *StationUpdate) 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 *StationUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *StationUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *StationUpdate) 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 *StationUpdate) check() error {
if v, ok := _u.mutation.Name(); ok {
if err := station.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Station.name": %w`, err)}
}
}
if v, ok := _u.mutation.Status(); ok {
if err := station.StatusValidator(v); err != nil {
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Station.status": %w`, err)}
}
}
return nil
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (_u *StationUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *StationUpdate {
_u.modifiers = append(_u.modifiers, modifiers...)
return _u
}
func (_u *StationUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(station.Table, station.Columns, sqlgraph.NewFieldSpec(station.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.StationNo(); ok {
_spec.SetField(station.FieldStationNo, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedStationNo(); ok {
_spec.AddField(station.FieldStationNo, field.TypeInt, value)
}
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(station.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.FlowId(); ok {
_spec.SetField(station.FieldFlowId, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedFlowId(); ok {
_spec.AddField(station.FieldFlowId, field.TypeInt, value)
}
if _u.mutation.FlowIdCleared() {
_spec.ClearField(station.FieldFlowId, field.TypeInt)
}
if value, ok := _u.mutation.Status(); ok {
_spec.SetField(station.FieldStatus, field.TypeString, value)
}
_spec.AddModifiers(_u.modifiers...)
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{station.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// StationUpdateOne is the builder for updating a single Station entity.
type StationUpdateOne struct {
config
fields []string
hooks []Hook
mutation *StationMutation
modifiers []func(*sql.UpdateBuilder)
}
// SetStationNo sets the "stationNo" field.
func (_u *StationUpdateOne) SetStationNo(v int) *StationUpdateOne {
_u.mutation.ResetStationNo()
_u.mutation.SetStationNo(v)
return _u
}
// SetNillableStationNo sets the "stationNo" field if the given value is not nil.
func (_u *StationUpdateOne) SetNillableStationNo(v *int) *StationUpdateOne {
if v != nil {
_u.SetStationNo(*v)
}
return _u
}
// AddStationNo adds value to the "stationNo" field.
func (_u *StationUpdateOne) AddStationNo(v int) *StationUpdateOne {
_u.mutation.AddStationNo(v)
return _u
}
// SetName sets the "name" field.
func (_u *StationUpdateOne) SetName(v string) *StationUpdateOne {
_u.mutation.SetName(v)
return _u
}
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *StationUpdateOne) SetNillableName(v *string) *StationUpdateOne {
if v != nil {
_u.SetName(*v)
}
return _u
}
// SetFlowId sets the "flowId" field.
func (_u *StationUpdateOne) SetFlowId(v int) *StationUpdateOne {
_u.mutation.ResetFlowId()
_u.mutation.SetFlowId(v)
return _u
}
// SetNillableFlowId sets the "flowId" field if the given value is not nil.
func (_u *StationUpdateOne) SetNillableFlowId(v *int) *StationUpdateOne {
if v != nil {
_u.SetFlowId(*v)
}
return _u
}
// AddFlowId adds value to the "flowId" field.
func (_u *StationUpdateOne) AddFlowId(v int) *StationUpdateOne {
_u.mutation.AddFlowId(v)
return _u
}
// ClearFlowId clears the value of the "flowId" field.
func (_u *StationUpdateOne) ClearFlowId() *StationUpdateOne {
_u.mutation.ClearFlowId()
return _u
}
// SetStatus sets the "status" field.
func (_u *StationUpdateOne) SetStatus(v string) *StationUpdateOne {
_u.mutation.SetStatus(v)
return _u
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (_u *StationUpdateOne) SetNillableStatus(v *string) *StationUpdateOne {
if v != nil {
_u.SetStatus(*v)
}
return _u
}
// Mutation returns the StationMutation object of the builder.
func (_u *StationUpdateOne) Mutation() *StationMutation {
return _u.mutation
}
// Where appends a list predicates to the StationUpdate builder.
func (_u *StationUpdateOne) Where(ps ...predicate.Station) *StationUpdateOne {
_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 *StationUpdateOne) Select(field string, fields ...string) *StationUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated Station entity.
func (_u *StationUpdateOne) Save(ctx context.Context) (*Station, error) {
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *StationUpdateOne) SaveX(ctx context.Context) *Station {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *StationUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *StationUpdateOne) 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 *StationUpdateOne) check() error {
if v, ok := _u.mutation.Name(); ok {
if err := station.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Station.name": %w`, err)}
}
}
if v, ok := _u.mutation.Status(); ok {
if err := station.StatusValidator(v); err != nil {
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Station.status": %w`, err)}
}
}
return nil
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (_u *StationUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *StationUpdateOne {
_u.modifiers = append(_u.modifiers, modifiers...)
return _u
}
func (_u *StationUpdateOne) sqlSave(ctx context.Context) (_node *Station, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(station.Table, station.Columns, sqlgraph.NewFieldSpec(station.FieldID, field.TypeInt))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Station.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, station.FieldID)
for _, f := range fields {
if !station.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != station.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.StationNo(); ok {
_spec.SetField(station.FieldStationNo, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedStationNo(); ok {
_spec.AddField(station.FieldStationNo, field.TypeInt, value)
}
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(station.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.FlowId(); ok {
_spec.SetField(station.FieldFlowId, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedFlowId(); ok {
_spec.AddField(station.FieldFlowId, field.TypeInt, value)
}
if _u.mutation.FlowIdCleared() {
_spec.ClearField(station.FieldFlowId, field.TypeInt)
}
if value, ok := _u.mutation.Status(); ok {
_spec.SetField(station.FieldStatus, field.TypeString, value)
}
_spec.AddModifiers(_u.modifiers...)
_node = &Station{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{station.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}