ruwebframe 0.1.5

a simple webframe for rust actix-web, based on rudi and rbatis.
Documentation
use ruwebframe::rubase:: BaseEntity ;
use ruwebframe::rudomain::rudb::dbentity::dbexample::Person;
use ruwebframe::rulog;
use std::any::Any;
use std::collections::HashMap;
use ruwebframe::rubase::get_self::GetSelf;
use ruwebframe::rudomain::rudb::dbentity::dbexample;
use ruwebframe::ruweb::webrouter::{  with_container_mut};

struct Container {
    items: HashMap<String, Box<dyn Any>>,
}

impl Container {
    fn new() -> Self {
        Self {
            items: HashMap::new(),
        }
    }

    fn insert<T: 'static>(&mut self, key: &str, value: T) {
        self.items.insert(key.to_string(), Box::new(value));
    }

    fn get<T: 'static>(&self, key: &str) -> Option<&T> {
        self.items.get(key)?.downcast_ref::<T>()
    }
}

// 示例:定义一个带 new 的类型
struct MyStruct {
    value: i32,
}

impl MyStruct {
    fn new() -> Self {
        Self { value: 42 }
    }
}

#[test]
fn test001() {
    let mut container = Container::new();

    // 1. 存函数指针(无参数版本)
    container.insert("new_fn", MyStruct::new as fn() -> MyStruct);

    // 2. 存闭包(更灵活)
    container.insert(
        "new_closure",
        Box::new(|| MyStruct { value: 100 }) as Box<dyn Fn() -> MyStruct>,
    );

    // 取出函数指针并调用
    if let Some(f) = container.get::<fn() -> MyStruct>("new_fn") {
        let obj = f();
        println!("from fn pointer: {}", obj.value); // 42
    }

    // 取出闭包并调用
    if let Some(f) = container.get::<Box<dyn Fn() -> MyStruct>>("new_closure") {
        let obj = f();
        println!("from closure: {}", obj.value); // 100
    }
}
fn ppp(p: &Person) {
    rulog::info2("pp=", p.to_json().as_str())
}

fn pp(p: &mut Person) {
    p.age = 33;
}
#[test]
fn test002() {
    let mut p = Person::new();
    p.age = 11;
    println!("{}", p.age);

    pp(&mut p);
    println!("{}", p.age);
    ppp(&p)
}
#[test]
fn test003_json() {

    let mut person = dbexample::find_bean_person().unwrap().get_self();
    person.name = "leijmdas".to_string();
    person.id = 11;
    rulog::info2("person:", person.to_json().as_str());

    let p = person.from_json(person.to_json());
    rulog::info2("p:", p.to_json().as_str());
}

#[test]
fn test004() {
  with_container_mut(|container| container.list_routes( )); 
  
}