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
31
32impl ToHtml for ChooseNode {
33 fn as_html(&self) -> String {
34 let mut childs = String::new();
35 for x in &self.when_nodes {
36 childs.push_str(&x.as_html());
37 }
38 let mut other_html = String::new();
39 match &self.otherwise_node {
40 None => {}
41 Some(v) => {
42 other_html = v.as_html();
43 }
44 }
45 format!("<choose>{}{}</choose>", childs, other_html)
46 }
47}