25 lines
		
	
	
		
			518 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			518 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package engine
 | 
						|
 | 
						|
import (
 | 
						|
	"git.fsdpf.net/go/condition"
 | 
						|
	"git.fsdpf.net/go/db"
 | 
						|
	"git.fsdpf.net/go/req"
 | 
						|
)
 | 
						|
 | 
						|
type EngineCase[T any] struct {
 | 
						|
	predicate *condition.Condition
 | 
						|
	cb        func(data T, g req.GlobalParams) error
 | 
						|
}
 | 
						|
 | 
						|
func (this EngineCase[T]) ToSql(param condition.TokenValue) db.Expression {
 | 
						|
	if this.predicate == nil || this.predicate.IsEmpty() {
 | 
						|
		return db.Raw("NULL")
 | 
						|
	}
 | 
						|
 | 
						|
	return this.predicate.ToSql(param)
 | 
						|
}
 | 
						|
 | 
						|
func (this EngineCase[T]) Execute(data T, g req.GlobalParams) error {
 | 
						|
	return this.cb(data, g)
 | 
						|
}
 |