Files
bj_power/bj_power_wms/ent/material.go
T
SunYF e852c7cd37 chore: 批量完成项目多模块迭代优化
1. 废弃半成品库存表并统一库存主表
2. 修复列表排序与搜索大小写不敏感问题
3. 新增用户最近登录时间、工单BOM名称字段
4. 完善角色管理、工位选择器功能
5. 增加拧紧数据补录、成品自动回流WMS能力
6. 统一导出时间范围校验规则
7. 丰富物料/备料单筛选条件
8. 调整菜单与权限命名适配产品型号业务
2026-09-08 11:44:04 +08:00

249 lines
8.4 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"bj_power_wms/ent/material"
"fmt"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// Material is the model entity for the Material schema.
type Material struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// 物料唯一编码
Code string `json:"code,omitempty"`
// 物料真实名称
Name string `json:"name,omitempty"`
// 简称
ShortName string `json:"shortName,omitempty"`
// 规格型号
Spec string `json:"spec,omitempty"`
// 单位
Unit string `json:"unit,omitempty"`
// 描述
Description string `json:"description,omitempty"`
// 品类 1原材料/2半成品/3成品
ItemType int `json:"itemType,omitempty"`
// 管理粒度 1批次/2序列号
ManageMode int `json:"manageMode,omitempty"`
// 是否批次管理
IsBatchManaged bool `json:"isBatchManaged,omitempty"`
// 是否序列号管理
IsSerialManaged bool `json:"isSerialManaged,omitempty"`
// 物料模板编码(物料种类)
TemplateCode string `json:"templateCode,omitempty"`
// 是否启用
IsActive bool `json:"isActive,omitempty"`
// 创建时间
CreatedAt int64 `json:"createdAt,omitempty"`
// 更新时间
UpdatedAt int64 `json:"updatedAt,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Material) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case material.FieldIsBatchManaged, material.FieldIsSerialManaged, material.FieldIsActive:
values[i] = new(sql.NullBool)
case material.FieldID, material.FieldItemType, material.FieldManageMode, material.FieldCreatedAt, material.FieldUpdatedAt:
values[i] = new(sql.NullInt64)
case material.FieldCode, material.FieldName, material.FieldShortName, material.FieldSpec, material.FieldUnit, material.FieldDescription, material.FieldTemplateCode:
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 Material fields.
func (_m *Material) 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 material.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
_m.ID = int(value.Int64)
case material.FieldCode:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field code", values[i])
} else if value.Valid {
_m.Code = value.String
}
case material.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
_m.Name = value.String
}
case material.FieldShortName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field short_name", values[i])
} else if value.Valid {
_m.ShortName = value.String
}
case material.FieldSpec:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field spec", values[i])
} else if value.Valid {
_m.Spec = value.String
}
case material.FieldUnit:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field unit", values[i])
} else if value.Valid {
_m.Unit = value.String
}
case material.FieldDescription:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field description", values[i])
} else if value.Valid {
_m.Description = value.String
}
case material.FieldItemType:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field item_type", values[i])
} else if value.Valid {
_m.ItemType = int(value.Int64)
}
case material.FieldManageMode:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field manage_mode", values[i])
} else if value.Valid {
_m.ManageMode = int(value.Int64)
}
case material.FieldIsBatchManaged:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field is_batch_managed", values[i])
} else if value.Valid {
_m.IsBatchManaged = value.Bool
}
case material.FieldIsSerialManaged:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field is_serial_managed", values[i])
} else if value.Valid {
_m.IsSerialManaged = value.Bool
}
case material.FieldTemplateCode:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field template_code", values[i])
} else if value.Valid {
_m.TemplateCode = value.String
}
case material.FieldIsActive:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field is_active", values[i])
} else if value.Valid {
_m.IsActive = value.Bool
}
case material.FieldCreatedAt:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
_m.CreatedAt = value.Int64
}
case material.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
_m.UpdatedAt = value.Int64
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Material.
// This includes values selected through modifiers, order, etc.
func (_m *Material) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// Update returns a builder for updating this Material.
// Note that you need to call Material.Unwrap() before calling this method if this Material
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *Material) Update() *MaterialUpdateOne {
return NewMaterialClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the Material 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 *Material) Unwrap() *Material {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: Material is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *Material) String() string {
var builder strings.Builder
builder.WriteString("Material(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("code=")
builder.WriteString(_m.Code)
builder.WriteString(", ")
builder.WriteString("name=")
builder.WriteString(_m.Name)
builder.WriteString(", ")
builder.WriteString("short_name=")
builder.WriteString(_m.ShortName)
builder.WriteString(", ")
builder.WriteString("spec=")
builder.WriteString(_m.Spec)
builder.WriteString(", ")
builder.WriteString("unit=")
builder.WriteString(_m.Unit)
builder.WriteString(", ")
builder.WriteString("description=")
builder.WriteString(_m.Description)
builder.WriteString(", ")
builder.WriteString("item_type=")
builder.WriteString(fmt.Sprintf("%v", _m.ItemType))
builder.WriteString(", ")
builder.WriteString("manage_mode=")
builder.WriteString(fmt.Sprintf("%v", _m.ManageMode))
builder.WriteString(", ")
builder.WriteString("is_batch_managed=")
builder.WriteString(fmt.Sprintf("%v", _m.IsBatchManaged))
builder.WriteString(", ")
builder.WriteString("is_serial_managed=")
builder.WriteString(fmt.Sprintf("%v", _m.IsSerialManaged))
builder.WriteString(", ")
builder.WriteString("template_code=")
builder.WriteString(_m.TemplateCode)
builder.WriteString(", ")
builder.WriteString("is_active=")
builder.WriteString(fmt.Sprintf("%v", _m.IsActive))
builder.WriteString(", ")
builder.WriteString("created_at=")
builder.WriteString(fmt.Sprintf("%v", _m.CreatedAt))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(fmt.Sprintf("%v", _m.UpdatedAt))
builder.WriteByte(')')
return builder.String()
}
// Materials is a parsable slice of Material.
type Materials []*Material