package main import ( "git.sxidc.com/go-tools/argo-api/approve_former" "os" ) const dir = "/Users/duyong/workspace/fangshi/meta-business/argo/example/template-render/" func main() { //simpleTemp() buildSignsTemp() buildAndORTemp() } // simpleTemp 什么也没有的流程 func simpleTemp() { flow := approve_former.NewFlow("simple") templateString, err := flow.Render(nil) if err != nil { panic(err) } _ = writeFile(dir+"simple.yaml", templateString) } func writeFile(fileName string, data string) error { // 将字符串写入文件 err := os.WriteFile(fileName, []byte(data), 0644) if err != nil { return err } return nil } // 只有单签的流程模板 func buildSignsTemp() { flow := approve_former.NewFlow("signs", approve_former.NewSign("A"), approve_former.NewSign("B"), approve_former.NewSign("C")) templateString1, err := flow.Render(nil) if err != nil { panic(err) } _ = writeFile(dir+"signs.yaml", templateString1) } // 会签和或签 func buildAndORTemp() { flow := approve_former.NewFlow("andor", approve_former.NewSign("A"), approve_former.NewAnd( approve_former.NewSign("B"), approve_former.NewSign("C"), ), approve_former.NewOr( approve_former.NewSign("D"), approve_former.NewSign("E"), ), approve_former.NewSign("F"), ) templateString, err := flow.Render(nil) if err != nil { panic(err) } _ = writeFile(dir+"andor.yaml", templateString) }