1. 新增预警规则、预警消息、业务附件数据库表与CRUD逻辑 2. 为拧紧记录添加审核人、审核时间字段及审核留痕功能 3. 优化产线点位类型与编号描述,更新工位组合下发菜单名称为工艺路线派工 4. 新增上传文件获取原文件名与大小的工具方法 5. 在系统管理菜单新增预警中心与附件中心入口
450 lines
13 KiB
Go
450 lines
13 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
|
|
}
|
|
|
|
// 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
|
|
}
|
|
|
|
// SetStationType sets the "stationType" field.
|
|
func (_u *StationUpdate) SetStationType(v string) *StationUpdate {
|
|
_u.mutation.SetStationType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStationType sets the "stationType" field if the given value is not nil.
|
|
func (_u *StationUpdate) SetNillableStationType(v *string) *StationUpdate {
|
|
if v != nil {
|
|
_u.SetStationType(*v)
|
|
}
|
|
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.StationType(); ok {
|
|
if err := station.StationTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "stationType", err: fmt.Errorf(`ent: validator failed for field "Station.stationType": %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
|
|
}
|
|
|
|
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.StationType(); ok {
|
|
_spec.SetField(station.FieldStationType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Status(); ok {
|
|
_spec.SetField(station.FieldStatus, field.TypeString, value)
|
|
}
|
|
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
|
|
}
|
|
|
|
// 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
|
|
}
|
|
|
|
// SetStationType sets the "stationType" field.
|
|
func (_u *StationUpdateOne) SetStationType(v string) *StationUpdateOne {
|
|
_u.mutation.SetStationType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStationType sets the "stationType" field if the given value is not nil.
|
|
func (_u *StationUpdateOne) SetNillableStationType(v *string) *StationUpdateOne {
|
|
if v != nil {
|
|
_u.SetStationType(*v)
|
|
}
|
|
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.StationType(); ok {
|
|
if err := station.StationTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "stationType", err: fmt.Errorf(`ent: validator failed for field "Station.stationType": %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
|
|
}
|
|
|
|
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.StationType(); ok {
|
|
_spec.SetField(station.FieldStationType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Status(); ok {
|
|
_spec.SetField(station.FieldStatus, field.TypeString, value)
|
|
}
|
|
_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
|
|
}
|