Skip to content

NestedResultEntity 注解 VO映射 - 内嵌类映射

说明

@NestedResultEntity 注解是VO类映射 VO内的内嵌类的,内嵌类还可以再套内嵌类

属性说明

属性是否可空默认值说明
target对应的实体类,不写时,自动选择类上面@ResultEntity里的实体类
storey1存储层级,联表自己join自己时使用,一般不用管

如何用?

java
@Data
@ResultEntity(SysUser.class)
public class SysUserVo {

    private Integer id;
    
    private String userName;

    // 此处字段类型可以实体类 可VO
    @NestedResultEntity(target = SysRole.class)
    private NestedSysRoleVo role;
}
java
@Data
public class NestedSysRoleVo {

    private Integer id;
    
    private String roleName;
}
java
@Service
public class Test{

    @Autowired
    private SysUserMapper sysUserMapper;

    public void demo() {
        Pager<SysUserVo> pager = QueryChain.of(sysUserMapper)
                .select(SysUserVo.class)
                .eq(SysUser::getId,1)
                .like(SysUser::getUserName,"xxx")
                .returnType(SysUserVo.class)
                .paging(Pager.of(1,10));
    }
}