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

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

The newest version!
package com.github.yulichang.toolkit;

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

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 MPJBaseMapper, "mapper <%s> not extends MPJBaseMapper ", entityClass.getSimpleName());
        return function.apply((MPJBaseMapper) mapper);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy