package cn.com.ty.lift.business.maintenance.controller;

import cn.com.ty.lift.business.common.CommonRequest;
import cn.com.ty.lift.business.common.CommonResponse;
import cn.com.ty.lift.business.emergency.dto.RepairRequest;
import cn.com.ty.lift.business.emergency.entity.EmergencyRepair;
import cn.com.ty.lift.business.maintenance.dao.entity.model.request.PropertyMaintenanceVO;
import cn.com.ty.lift.business.maintenance.dao.entity.model.request.PropertyVo;
import cn.com.ty.lift.business.maintenance.dao.entity.model.response.DynamicMessageResponse;
import cn.com.ty.lift.business.maintenance.dao.entity.model.response.PropertyMtResponse;
import cn.com.ty.lift.business.maintenance.service.PropertyService;
import cn.com.xwy.boot.web.dto.RestResponse;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@AllArgsConstructor
@RequestMapping("property")
public class PropertyController {
    private final PropertyService propertyService;

    @PostMapping("maintenance")
    public RestResponse<?> maintenance(@RequestBody PropertyMaintenanceVO propertyMaintenanceVO) {
        IPage<PropertyMtResponse> propertyMtResponsePage = new Page<>(propertyMaintenanceVO.getPageNum(), propertyMaintenanceVO.getPageSize());
        return RestResponse.success(propertyService.propertyMtResponsePage(propertyMtResponsePage, propertyMaintenanceVO));
    }

    @PostMapping("maintenance/num/month")
    public RestResponse<?> maintenanceNumForMonth(@RequestBody PropertyMaintenanceVO propertyMaintenanceVO) {
        return propertyService.queryMaintenancePlanMonth(propertyMaintenanceVO);
    }

    @PostMapping("repair/message")
    public RestResponse<?> repairMessage(@RequestBody PropertyMaintenanceVO propertyMaintenanceVO) {
        IPage<DynamicMessageResponse> dynamicMessageResponsePage = new Page<>(propertyMaintenanceVO.getPageNum(), propertyMaintenanceVO.getPageSize());
        return propertyService.queryEmergencyRepairDynamicMessage(dynamicMessageResponsePage, propertyMaintenanceVO);
    }

    @PostMapping("maintenance/message")
    public RestResponse<?> maintenanceMessage(@RequestBody PropertyMaintenanceVO propertyMaintenanceVO) {
        IPage<DynamicMessageResponse> dynamicMessageResponsePage = new Page<>(propertyMaintenanceVO.getPageNum(), propertyMaintenanceVO.getPageSize());
        return propertyService.queryMaintenanceSuccessDynamicMessage(dynamicMessageResponsePage, propertyMaintenanceVO);
    }

    @PostMapping("evaluate")
    public RestResponse<?> evaluate(@RequestBody PropertyVo propertyVo) {
        return propertyService.queryEvaluateAuth(propertyVo);
    }

    @PostMapping("project")
    public RestResponse<?> project(@RequestBody PropertyVo propertyVo) {
        return propertyService.queryJoinProjectList(propertyVo);
    }

    @PostMapping("repair/list")
    public RestResponse<?> repair(@RequestBody PropertyVo propertyVo) {
        return propertyService.queryRepairList(propertyVo);
    }

    @PostMapping("repair/add")
    public RestResponse<?> repairAdd(@RequestBody EmergencyRepair entity) {
        return propertyService.repairAdd(entity);
    }

    @PostMapping("repair/bill")
    public RestResponse<?> repairBill(@RequestBody RepairRequest request) {
        return propertyService.repairBill(request);
    }

    @PostMapping("count")
    public RestResponse<?> count(@RequestBody CommonRequest request) {
        return propertyService.count(request);
    }
}