rbatis_codegen/codegen/syntax_tree_pysql/
choose_node.rs1use crate::codegen::syntax_tree_pysql::{Name, NodeType, ToHtml};
2
3#[derive(Clone, Debug, Eq, PartialEq)]
20pub struct ChooseNode {
21 pub when_nodes: Vec<NodeType>,
22 pub otherwise_node: Option<Box<NodeType>>,
23}
24
25impl Name for ChooseNode {
26 fn name() -> &'static str {
27 "choose"
28 }
29}
30
31impl ToHtml for ChooseNode {
32 fn as_html(&self) -> String {
33 let mut childs = String::new();
34 for x in &self.when_nodes {
35 childs.push_str(&x.as_html());
36 }
37 let mut other_html = String::new();
38 match &self.otherwise_node {
39 None => {}
40 Some(v) => {
41 other_html = v.as_html();
42 }
43 }
44 format!("<choose>{}{}</choose>", childs, other_html)
45 }
46}