Interface QueryLabel<Children>

All Known Implementing Classes:
KtLambdaWrapper

public interface QueryLabel<Children>
对一或对多查询
Since:
1.4.6
Author:
yulichang
  • Method Details

    • addLabel

      void addLabel(Label<?> label, boolean isCollection)
    • getChildren

      Children getChildren()
    • selectCollection

      default Children selectCollection(Class<?> child, kotlin.reflect.KProperty<?> dtoField)
      一对多查询 调用此方法发必需要调用对应的 left join / right join ... 连表方法,否则会报错

      举例 UserDO AddressDO 为一对多关系 UserDTO 为结果类

           MPJLambdaWrapper<UserDO> wrapper = new MPJLambdaWrapper<UserDO>();
           wrapper.selectAll(UserDO.class)
                  .selectCollection(AddressDO.class, UserDTO::getAddressListDTO)
                  .leftJoin(AddressDO.class, ...... )
                  .eq(...)
                  ...
       
       会自动将 AddressDO类中相同属性的字段 以mybatis的方式映射到UserDTO.addressListDTO属性中
      Parameters:
      child - 连表数据库实体类
      dtoField - 包装类对应的属性
      Since:
      1.3.0
    • selectCollection

      default Children selectCollection(String prefix, Class<?> child, kotlin.reflect.KProperty<?> dtoField)
    • selectCollection

      default Children selectCollection(Class<?> child, kotlin.reflect.KProperty<?> dtoField, MFunction<MybatisLabel.Builder<?,?>> collection)
      一对多查询 调用此方法发必需要调用对应的 left join / right join ... 连表方法,否则会报错

      举例 UserDO AddressDO 为一对多关系 UserDTO 为结果类

         MPJLambdaWrapper<UserDO> wrapper = new MPJLambdaWrapper();
         wrapper.selectAll(UserDO.class)
            .selectCollection(AddressDO.class, UserDTO::getAddressListDTO, map -> map
                 .id(AddressDO::getId, AddressDTO::getId)                 //如果属性名一致 可以传一个
                 .result(AddressDO::getUserId)                            //如果属性名一致 可以传一个
                 .result(AddressDO::getAddress, AddressDTO::getAddress))) //如果属性名一致 可以传一个
            .leftJoin(AddressDO.class, ...... )
            .eq(...)
            ...
       
      
       会自动将 AddressDO类中指定的字段 以mybatis的方式映射到UserDTO.addressListDTO属性中
      Parameters:
      child - 连表数据库实体类
      dtoField - 包装类对应的属性
      collection - collection标签内容
      Since:
      1.3.0
    • selectCollection

      default Children selectCollection(kotlin.reflect.KProperty<?> dtoField, MFunction<MybatisLabelFree.Builder<?>> collection)
    • selectCollection

      default Children selectCollection(String prefix, Class<?> child, kotlin.reflect.KProperty<?> dtoField, MFunction<MybatisLabel.Builder<?,?>> collection)
    • selectAssociation

      default Children selectAssociation(Class<?> child, kotlin.reflect.KProperty<?> dtoField)
      对一查询 用法参考 selectCollection
      Since:
      1.3.0
    • selectAssociation

      default Children selectAssociation(String prefix, Class<?> child, kotlin.reflect.KProperty<?> dtoField)
    • selectAssociation

      default Children selectAssociation(Class<?> child, kotlin.reflect.KProperty<?> dtoField, MFunction<MybatisLabel.Builder<?,?>> collection)
      对一查询 用法参考 selectCollection
      Since:
      1.3.0
    • selectAssociation

      default Children selectAssociation(kotlin.reflect.KProperty<?> dtoField, MFunction<MybatisLabelFree.Builder<?>> collection)
    • selectAssociation

      default Children selectAssociation(String prefix, Class<?> child, kotlin.reflect.KProperty<?> dtoField, MFunction<MybatisLabel.Builder<?,?>> collection)