提交
This commit is contained in:
@@ -43,7 +43,7 @@ func (w *Writer) Write(ctx context.Context, eventType, workOrderNo, operator, en
|
||||
// from/to 传时间戳毫秒(0 表示不限)。
|
||||
// operators:操作人候选列表(任一命中即算),历史数据里 operator 中文名/用户名混杂,调用方应同时传两者;
|
||||
// admin 精确筛选单人时传单元素即可,传空切片=不过滤。
|
||||
func (w *Writer) Query(ctx context.Context, eventType, workOrderNo string, operators []string, fromMs, toMs int64, page, pageSize int) ([]*ent.EventLog, int, error) {
|
||||
func (w *Writer) Query(ctx context.Context, eventType, workOrderNo string, operators []string, entityType string, fromMs, toMs int64, page, pageSize int) ([]*ent.EventLog, int, error) {
|
||||
q := w.client.EventLog.Query()
|
||||
// 操作日志只收录业务操作,登录/退出(auth.*)不属于操作日志范畴,一律不展示。
|
||||
q = q.Where(eventlog.Not(eventlog.EventTypeHasPrefix("auth.")))
|
||||
@@ -57,6 +57,10 @@ func (w *Writer) Query(ctx context.Context, eventType, workOrderNo string, opera
|
||||
if len(operators) > 0 {
|
||||
q = q.Where(eventlog.OperatorIn(operators...))
|
||||
}
|
||||
if entityType != "" {
|
||||
// B3.4 对象类型筛选(如 workpiece / material / alert_rule)
|
||||
q = q.Where(eventlog.EntityTypeEQ(entityType))
|
||||
}
|
||||
if fromMs > 0 {
|
||||
q = q.Where(eventlog.CreatedAtGTE(time.UnixMilli(fromMs)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user