mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-04 00:10:25 +08:00
feat: sql解析器替换、工单统一由‘我的流程’发起、流程定义支持自定义条件触发审批、资源隐藏编号、model支持物理删除等
This commit is contained in:
75
server/internal/db/dbm/sqlparser/sqlstmt/stmt.go
Normal file
75
server/internal/db/dbm/sqlparser/sqlstmt/stmt.go
Normal file
@@ -0,0 +1,75 @@
|
||||
package sqlstmt
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/antlr4-go/antlr/v4"
|
||||
)
|
||||
|
||||
type INode interface {
|
||||
GetText() string
|
||||
|
||||
// GetStartIndex() int
|
||||
// GetStopIndex() int
|
||||
}
|
||||
|
||||
type Node struct {
|
||||
// startIndex int
|
||||
// stopIndex int
|
||||
|
||||
parser antlr.Parser
|
||||
ruleContext antlr.RuleContext
|
||||
}
|
||||
|
||||
func (n *Node) GetText() string {
|
||||
if n == nil || n.ruleContext == nil || n.parser == nil {
|
||||
return ""
|
||||
}
|
||||
return n.parser.GetTokenStream().GetTextFromRuleContext(n.ruleContext)
|
||||
}
|
||||
|
||||
// func (n *Node) GetStartIndex() int {
|
||||
// return n.startIndex
|
||||
// }
|
||||
|
||||
// func (n *Node) GetStopIndex() int {
|
||||
// return n.stopIndex
|
||||
// }
|
||||
|
||||
func NewNode(parser antlr.Parser, ruleContext antlr.RuleContext) *Node {
|
||||
return &Node{
|
||||
parser: parser,
|
||||
ruleContext: ruleContext,
|
||||
}
|
||||
}
|
||||
|
||||
// func NewNode(startIndex, stopIndex int) *Node {
|
||||
// return &Node{
|
||||
// startIndex: startIndex,
|
||||
// stopIndex: stopIndex,
|
||||
// }
|
||||
// }
|
||||
|
||||
// func GetText(sqlstmts string, node INode) string {
|
||||
// return sqlstmts[node.GetStartIndex() : node.GetStopIndex()+1]
|
||||
// }
|
||||
|
||||
type Stmt interface {
|
||||
INode
|
||||
}
|
||||
|
||||
type SqlStmt struct {
|
||||
*Node
|
||||
}
|
||||
|
||||
type DmlStmt struct {
|
||||
SqlStmt
|
||||
}
|
||||
|
||||
type OtherReadStmt struct {
|
||||
*Node
|
||||
}
|
||||
|
||||
func IsSelectStmt(stmt Stmt) bool {
|
||||
return reflect.TypeOf(stmt).AssignableTo(reflect.TypeOf(&SelectStmt{}))
|
||||
}
|
||||
Reference in New Issue
Block a user