Files
SunYF 5c3b747a20 feat: 新增预警与附件模块,优化工位派工功能
1. 新增预警规则、预警消息、业务附件数据库表与CRUD逻辑
2. 为拧紧记录添加审核人、审核时间字段及审核留痕功能
3. 优化产线点位类型与编号描述,更新工位组合下发菜单名称为工艺路线派工
4. 新增上传文件获取原文件名与大小的工具方法
5. 在系统管理菜单新增预警中心与附件中心入口
2026-09-14 16:31:08 +08:00

195 lines
6.0 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"bj_power_mes/ent/alert"
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// Alert is the model entity for the Alert schema.
type Alert struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// 关联规则ID0=手动触发
RuleId int `json:"ruleId,omitempty"`
// 预警类型
Type string `json:"type,omitempty"`
// 标题
Title string `json:"title,omitempty"`
// 内容
Content string `json:"content,omitempty"`
// 关联业务类型
RefType string `json:"refType,omitempty"`
// 关联业务ID
RefId string `json:"refId,omitempty"`
// UNREAD/READ
Status string `json:"status,omitempty"`
// 接收人
Receiver string `json:"receiver,omitempty"`
// CreatedAt holds the value of the "createdAt" field.
CreatedAt time.Time `json:"createdAt,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Alert) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case alert.FieldID, alert.FieldRuleId:
values[i] = new(sql.NullInt64)
case alert.FieldType, alert.FieldTitle, alert.FieldContent, alert.FieldRefType, alert.FieldRefId, alert.FieldStatus, alert.FieldReceiver:
values[i] = new(sql.NullString)
case alert.FieldCreatedAt:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Alert fields.
func (_m *Alert) 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 alert.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 alert.FieldRuleId:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field ruleId", values[i])
} else if value.Valid {
_m.RuleId = int(value.Int64)
}
case alert.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 = value.String
}
case alert.FieldTitle:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field title", values[i])
} else if value.Valid {
_m.Title = value.String
}
case alert.FieldContent:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field content", values[i])
} else if value.Valid {
_m.Content = value.String
}
case alert.FieldRefType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field refType", values[i])
} else if value.Valid {
_m.RefType = value.String
}
case alert.FieldRefId:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field refId", values[i])
} else if value.Valid {
_m.RefId = value.String
}
case alert.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 = value.String
}
case alert.FieldReceiver:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field receiver", values[i])
} else if value.Valid {
_m.Receiver = value.String
}
case alert.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field createdAt", values[i])
} else if value.Valid {
_m.CreatedAt = value.Time
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Alert.
// This includes values selected through modifiers, order, etc.
func (_m *Alert) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// Update returns a builder for updating this Alert.
// Note that you need to call Alert.Unwrap() before calling this method if this Alert
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *Alert) Update() *AlertUpdateOne {
return NewAlertClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the Alert 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 *Alert) Unwrap() *Alert {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: Alert is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *Alert) String() string {
var builder strings.Builder
builder.WriteString("Alert(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("ruleId=")
builder.WriteString(fmt.Sprintf("%v", _m.RuleId))
builder.WriteString(", ")
builder.WriteString("type=")
builder.WriteString(_m.Type)
builder.WriteString(", ")
builder.WriteString("title=")
builder.WriteString(_m.Title)
builder.WriteString(", ")
builder.WriteString("content=")
builder.WriteString(_m.Content)
builder.WriteString(", ")
builder.WriteString("refType=")
builder.WriteString(_m.RefType)
builder.WriteString(", ")
builder.WriteString("refId=")
builder.WriteString(_m.RefId)
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(_m.Status)
builder.WriteString(", ")
builder.WriteString("receiver=")
builder.WriteString(_m.Receiver)
builder.WriteString(", ")
builder.WriteString("createdAt=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
builder.WriteByte(')')
return builder.String()
}
// Alerts is a parsable slice of Alert.
type Alerts []*Alert