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("技术总监"), approve_former.NewSign("研发总监"), approve_former.NewSign("人事总监")) templateString, err := flow.Render(nil) if err != nil { panic(err) } _ = writeFile(dir+"signs.yaml", templateString) flow1 := approve_former.NewFlow("signs", approve_former.NewSign("A"), approve_former.NewSign("B"), approve_former.NewSign("C")) templateString1, err := flow1.Render(nil) if err != nil { panic(err) } _ = writeFile(dir+"signs1.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) }