mybatis一对多对多

@Data
public class ProjectTreeDto {
    @ApiModelProperty(value = "主键")
    private Integer projectId;
    @ApiModelProperty(value = "项目名称")
    private String projectName;
    @ApiModelProperty(value = "项目编号 项目编号")
    private String projectNum;
    @ApiModelProperty(value = "网关集合")
    private List<GatewayTreeDto> gatewayTreeDto;
}

@Data
public class GatewayTreeDto {
    @ApiModelProperty(value="主键")
    private Integer gatewayId;
    @ApiModelProperty(value="设备标识")
    private String deviceId;
    @ApiModelProperty(value="设备名称")
    private String deviceName;
    @ApiModelProperty(value="客户端名称")
    private String clientName;
    @ApiModelProperty(value = "是否在线:1-是  0-不是")
    private Integer gatewayStatus;
    @ApiModelProperty(value = "线路集合")
    private List<DeviceLineTreeDto> deviceLineTreeDto;
}

@Data
public class DeviceLineTreeDto {
    @ApiModelProperty(value = "主键")
    private Integer deviceLineId;
    @ApiModelProperty(value="线路编号")
    private Integer lineNo;
}

List<ProjectTreeDto> getProjectTreeList(@Param("account") String account);
<resultMap id="projectTree" type="com.zbwd.xj001.srv.common.dto.ProjectTreeDto">
        <id property="projectId" column="project_id"/>
        <result property="projectName" column="project_name"/>
        <result property="projectNum" column="project_num"/>
        <collection property="gatewayTreeDto" ofType="com.zbwd.xj001.srv.common.dto.GatewayTreeDto">
            <id property="gatewayId" column="gateway_id"/>
            <result property="deviceId" column="device_id"/>
            <result property="deviceName" column="device_name"/>
            <result property="clientName" column="client_name"/>
            <collection property="deviceLineTreeDto" ofType="com.zbwd.xj001.srv.common.dto.DeviceLineTreeDto">
                <id property="deviceLineId" column="line_id"/>
                <result property="lineNo" column="line_no"/>
            </collection>
        </collection>
    </resultMap>
    <select id="getProjectTreeList" resultMap="projectTree">
        SELECT
        a.id project_id,
        a.project_name,
        a.project_num,
        t.gateway_id,
        t.device_id,
        t.device_name,
        t.client_name,
        t.line_id,
        t.line_no
        FROM
        project a
        LEFT JOIN (
        SELECT
        b.project_id,
        b.id gateway_id,
        b.device_id,
        b.device_name,
        b.client_name,
        c.id line_id,
        c.line_no
        FROM
        device_gateway b
        LEFT JOIN device_line c ON c.gateway_id = b.id
        ) t ON t.project_id = a.id where 1=1
        <if test="account != null and '' != account">
            and account=#{account}
        </if>
    </select>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值