Files
iotlcm/admin-svr/server/internal/logic/common/batch_visibility.go

35 lines
1.1 KiB
Go

package common
import (
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/consts"
"github.com/gogf/gf/v2/database/gdb"
)
// visibleBatchTypeModel always excludes internal prepare batches before applying
// an optional caller-provided batch type filter.
func visibleBatchTypeModel(mod *gdb.Model, column string, requested *int) *gdb.Model {
mod = mod.Where(column+" <> ?", consts.BatchTypePrepare)
if requested != nil {
mod = mod.Where(column, *requested)
}
return mod
}
func visibleBatchTypeMatches(actual int, requested *int) bool {
if actual == consts.BatchTypePrepare {
return false
}
return requested == nil || actual == *requested
}
// successListBatchTypeModel keeps export execution logs out of business batch selectors.
func successListBatchTypeModel(mod *gdb.Model, column string, requested *int) *gdb.Model {
mod = visibleBatchTypeModel(mod, column, requested)
return mod.Where(column+" <> ?", consts.BatchTypeExport)
}
func successListBatchTypeMatches(actual int, requested *int) bool {
return actual != consts.BatchTypeExport && visibleBatchTypeMatches(actual, requested)
}