package com.huiju.estateagents.property.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huiju.estateagents.base.BaseController;
import com.huiju.estateagents.base.ResponseBean;
import com.huiju.estateagents.property.model.TpRoomNo;
import com.huiju.estateagents.property.service.BuildingTreeServiceI;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;


@Api(tags = "楼栋房源信息表 ")
@RestController
@RequestMapping("/api/{client}/buildingInfo/building-room")
public class TpRoomNoController extends BaseController {

    @Autowired
    BuildingTreeServiceI buildingTreeService;

    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
    @GetMapping("/list")
    public ResponseBean getList(@ApiParam(value = "客户端", allowableValues = "admin") @PathVariable String client,
                                @ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
                                @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
                                @ApiParam("期数ID") @RequestParam(value ="phaseId", required = false) Integer phaseId,
                                @ApiParam("楼栋ID") @RequestParam(value ="buildingId", required = false) Integer buildingId,
                                @ApiParam("单元ID") @RequestParam(value ="unitId", required = false) Integer unitId,
                                @ApiParam("楼层ID") @RequestParam(value ="levelId", required = false) Integer levelId,
                                @ApiParam("户号ID") @RequestParam(value ="roomNoId", required = false) Integer roomNoId,
                                HttpServletRequest request) {
        Integer orgId = getOrgId(request);
        IPage<TpRoomNo> page = new Page<>(pageNum, pageSize);

        IPage<TpRoomNo> result = buildingTreeService.getRoomList(page, orgId, phaseId, buildingId, unitId, levelId, roomNoId);

        return ResponseBean.success(result);
    }

}
