yulichang / mybatis-plus-join

支持连表查询的mybatis-plus,mybatis-plus风格的连表操作提供wrapper.leftJoin(),wrapper.rightJoin()等操作
https://yulichang.github.io/mybatis-plus-join-doc/
Apache License 2.0
971 stars 113 forks source link

join一对多查询dto自动包装成一对多属性结构 #126

Open tom055 opened 1 month ago

tom055 commented 1 month ago

DTO

@Getter
@Setter
public class DeviceRuleNotifyDto {
    //规则表
    DeviceRulePo deviceRulePo;
    //通知表
    List<NotifyTemplatePo> notifyTemplatePos;
}

service

MPJLambdaWrapper<DeviceRuleNotifyDto> baseJoin = new MPJLambdaWrapper<DeviceRuleNotifyDto>()
                .selectAssociation("t", DeviceRulePo.class, DeviceRuleNotifyDto::getDeviceRulePo)
                .selectCollection(NotifyTemplatePo.class, DeviceRuleNotifyDto::getNotifyTemplatePos)
                .leftJoin(DeviceRuleNotifyPo.class, DeviceRuleNotifyPo::getRuleId, DeviceRulePo::getId)
                .leftJoin(NotifyTemplatePo.class, NotifyTemplatePo::getId, DeviceRuleNotifyPo::getNotifyTemplateId);
        MPJLambdaWrapper wrapper = wrapper(baseJoin, queryParam);
        return getBaseMapper().selectJoinOne(DeviceRuleNotifyDto.class,wrapper);

你好 大佬 能查询到数据,但dto无法接数据,请问这个要如何解决呢

Umenezumi commented 3 weeks ago

最后你是如何解决的?

tom055 commented 3 weeks ago

@Umenezumi 手动解决