All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.yulichang.toolkit.SqlHelper Maven / Gradle / Ivy

There is a newer version: 1.5.2
Show newest version
package com.github.yulichang.toolkit;

import com.baomidou.mybatisplus.core.toolkit.Assert;
import com.github.yulichang.base.JoinMapper;

import java.util.function.Function;

/**
 * @author yulichang
 * @see com.baomidou.mybatisplus.extension.toolkit.SqlHelper
 * @since 1.4.4
 */
@SuppressWarnings("unchecked")
public final class SqlHelper {

    public static  R exec(Class entityClass, Function, R> function) {
        Assert.notNull(entityClass, "请使用 new MPJLambdaWrapper(主表.class) 或 JoinWrappers.lambda(主表.class) 构造方法");
        Object mapper = SpringContentUtils.getMapper(entityClass);
        Assert.notNull(mapper, "mapper not init <%s>", entityClass.getSimpleName());
        Assert.isTrue(mapper instanceof JoinMapper, "mapper <%s> not extends MPJBaseMapper ", entityClass.getSimpleName());
        return function.apply((JoinMapper) mapper);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy