com.github.yulichang.extension.mapping.base.MPJRelationService Maven / Gradle / Ivy
Show all versions of mybatis-plus-join-extension Show documentation
package com.github.yulichang.extension.mapping.base;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.github.yulichang.annotation.EntityMapping;
import com.github.yulichang.annotation.FieldMapping;
import com.github.yulichang.extension.mapping.config.DeepConfig;
import com.github.yulichang.extension.mapping.relation.Relation;
import java.util.function.Function;
/**
* 深度查询
*
* 对配置了映射注解的字段进行查询
* 目前查询深度只支持2级(只解析当前实体类的映射注解,不会对查询结果再次解析注解)
* 多级查询可能存在循环引用的问题,也可能会导致全量查询
* 用于替换deep
*
* @author yulichang
* @see EntityMapping
* @see FieldMapping
* @since 1.4.4
*/
@SuppressWarnings({"unchecked", "unused"})
public interface MPJRelationService extends IService {
/**
* 通过注解实现单表多次查询
*
* @param function BaseMapper调用方法
* @see com.github.yulichang.annotation.EntityMapping
* @see com.github.yulichang.annotation.FieldMapping
*/
default > R getRelation(Function function) {
return Relation.mpjGetRelation(function.apply((M) getBaseMapper()), DeepConfig.defaultConfig());
}
/**
* 通过注解实现单表多次查询
*
* @param function BaseMapper调用方法
* @see com.github.yulichang.annotation.EntityMapping
* @see com.github.yulichang.annotation.FieldMapping
*/
default > R getRelation(Function function, DeepConfig config) {
return Relation.mpjGetRelation(function.apply((M) getBaseMapper()), config);
}
/**
* 通过注解实现单表多次查询
*
* @param function BaseMapper调用方法
* @param config 映射配置
* @see com.github.yulichang.annotation.EntityMapping
* @see com.github.yulichang.annotation.FieldMapping
*/
default > R getRelation(Function function, Function, DeepConfig.Builder> config) {
return Relation.mpjGetRelation(function.apply((M) getBaseMapper()), config.apply(DeepConfig.builder()).build());
}
}