package com.sptg.estate.biz.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.estate.api.dto.EstateRepairDto;
import com.sptg.estate.api.entity.EstateRepair;
import com.sptg.estate.api.feigns.EstateRepairFeign;
import com.sptg.estate.biz.service.EstateRepairServiceInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * title: EstateRepairController
 * package: com.sptg.estate.biz.controller
 * description: 物业报修-控制器
 *
 *                
 *                
 */
@RestController
public class EstateRepairController implements EstateRepairFeign {
    private final EstateRepairServiceInterface estateRepairServiceInterface;


    @Autowired
    public EstateRepairController(EstateRepairServiceInterface estateRepairServiceInterface) {
        this.estateRepairServiceInterface = estateRepairServiceInterface;
    }
    @Override
    @PostMapping(value = "/estateRepair/showEstateRepairList")
    public ResultBean<Page<EstateRepair>> showEstateRepairList(@RequestBody EstateRepairDto estateRepairDto) {
        Page<EstateRepair> page=estateRepairServiceInterface.showEstateRepairList(estateRepairDto);
        return new ResultBean<>(ResultEnum.SUCCESS,page);
    }
    @Override
    @PostMapping(value = "/estateRepair/getList")
    public ResultBean<List<EstateRepair>> getList(@RequestBody EstateRepairDto estateRepairDto) {
        List<EstateRepair> list=estateRepairServiceInterface.getList(estateRepairDto);
        return new ResultBean<List<EstateRepair>>(ResultEnum.SUCCESS,list);
    }
    @Override
    @PostMapping(value = "/estateRepair/addOrEditEstateRepair")
    public ResultBean<EstateRepair> addOrEditEstateRepair(@RequestBody EstateRepair estateRepair){
        EstateRepair result = estateRepairServiceInterface.addOrEditEstateRepair(estateRepair);
        return new ResultBean<>(ResultEnum.SUCCESS,result);
    }
    @Override
    @PostMapping(value = "/estateRepair/findEstateRepairById")
    public ResultBean<EstateRepair> findEstateRepairById(@RequestParam(value = "id") long id){
        EstateRepair estateRepair =  estateRepairServiceInterface.findEstateRepairById(id);
        return new ResultBean<>(ResultEnum.SUCCESS,estateRepair);
    }
    @Override
    @PostMapping(value = "/estateRepair/deleteEstateRepairById")
    public ResultBean<Boolean> deleteEstateRepairById(@RequestParam(value = "id") long id){
        boolean result  =  estateRepairServiceInterface.deleteEstateRepairById(id);
        return new ResultBean<>(ResultEnum.SUCCESS,result);
    }
    @Override
    @PostMapping(value = "/estateRepair/deleteEstateRepairList")
    public ResultBean<Boolean> deleteEstateRepairList(@RequestBody EstateRepairDto estateRepairDto){
        return  this.estateRepairServiceInterface.deleteEstateRepairList(estateRepairDto);
    }
}
