Attribute Macro rbatis::html_sql

source ·
#[html_sql]
Expand description

html sql create macro,this macro use RB.py_query and RB.py_exec for example:

use rbatis::executor::Executor;
use rbatis::html_sql;
#[derive(serde::Serialize,serde::Deserialize)]
pub struct MockTable{}

#[html_sql(r#"
<select id="select_by_condition">
        `select * from activity`
        <where>
            <if test="name != ''">
                ` and name like #{name}`
            </if>
            <if test="dt >= '2023-11-03T21:13:09.9357266+08:00'">
                ` and create_time < #{dt}`
            </if>
            <choose>
                <when test="true">
                    ` and id != '-1'`
                </when>
                <otherwise>and id != -2</otherwise>
            </choose>
            ` and `
            <trim prefixOverrides=" and">
                ` and name != '' `
            </trim>
        </where>
  </select>"#)]
pub async fn select_by_name(rbatis: &dyn Executor, name: &str) -> Option<MockTable> {}

or from file

#[html_sql("xxxx.html")]
pub async fn select_by_name(rbatis: &dyn Executor, name: &str) -> Option<MockTable> {}