Search in sources :

Example 1 with PropertyMapper

use of com.baomidou.mybatisplus.solon.toolkit.PropertyMapper in project solon by noear.

the class MybatisPlusInterceptor method setProperties.

/**
 * 使用内部规则,拿分页插件举个栗子:
 * <p>
 * - key: "@page" ,value: "com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor"
 * - key: "page:limit" ,value: "100"
 * <p>
 * 解读1: key 以 "@" 开头定义了这是一个需要组装的 `InnerInterceptor`, 以 "page" 结尾表示别名
 * value 是 `InnerInterceptor` 的具体的 class 全名
 * 解读2: key 以上面定义的 "别名 + ':'" 开头指这个 `value` 是定义的该 `InnerInterceptor` 属性需要设置的值
 * <p>
 * 如果这个 `InnerInterceptor` 不需要配置属性也要加别名
 */
@Override
public void setProperties(Properties properties) {
    PropertyMapper pm = PropertyMapper.newInstance(properties);
    Map<String, Properties> group = pm.group(StringPool.AT);
    group.forEach((k, v) -> {
        InnerInterceptor innerInterceptor = ClassUtils.newInstance(k);
        innerInterceptor.setProperties(v);
        addInnerInterceptor(innerInterceptor);
    });
}
Also used : PropertyMapper(com.baomidou.mybatisplus.solon.toolkit.PropertyMapper) InnerInterceptor(com.baomidou.mybatisplus.solon.plugins.inner.InnerInterceptor)

Aggregations

InnerInterceptor (com.baomidou.mybatisplus.solon.plugins.inner.InnerInterceptor)1 PropertyMapper (com.baomidou.mybatisplus.solon.toolkit.PropertyMapper)1