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.EnvironmentalReviewDto;
import com.sptg.estate.api.entity.EnvironmentalReview;
import com.sptg.estate.api.feigns.EnvironmentalReviewFeign;
import com.sptg.estate.biz.service.EnvironmentalReviewServiceInterface;
import lombok.RequiredArgsConstructor;
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;

/**
 * title: DeviceInstallationController
 * package: com.sptg.estate.biz.service
 * description: 环境评审 - 控制器
 *
 *               
 *                      
 */
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/implement/environmental/review")
public class EnvironmentalReviewController implements EnvironmentalReviewFeign {

    private final EnvironmentalReviewServiceInterface environmentalReviewServiceInterface;

    @Override
    @PostMapping(value = "/countByPositionId")
    public ResultBean<Boolean> countByPositionId(@RequestBody Long positionId) {
        return this.environmentalReviewServiceInterface.countByPositionId(positionId);
    }

    @Override
    @PostMapping(value = "/findByPositionId")
    public ResultBean<EnvironmentalReview> findByPositionId(@RequestBody Long positionId) {
        return this.environmentalReviewServiceInterface.findByPositionId(positionId);
    }
    @Override
    @PostMapping(value = "/insertOrUpdate")
    public ResultBean<Boolean> insertOrUpdate(@RequestBody EnvironmentalReview environmentalReview) {
        return this.environmentalReviewServiceInterface.insertOrUpdateEntity(environmentalReview);
    }

    @Override
    @PostMapping(value = "/showList")
    public ResultBean<Page<EnvironmentalReview>> showList(@RequestBody EnvironmentalReviewDto dto) {
        return this.environmentalReviewServiceInterface.showList(dto);
    }

    @Override
    @PostMapping(value = "/countByOrgPosition")
    public ResultBean<Integer> countByOrgPosition(@RequestBody String orgPosition) {
        return this.environmentalReviewServiceInterface.countByOrgPosition(orgPosition);
    }

    @Override
    @PostMapping(value = "/checkState")
    public ResultBean<Boolean> checkState(@RequestBody EnvironmentalReviewDto dto) {
        return this.environmentalReviewServiceInterface.checkState(dto);
    }

    @Override
    @PostMapping(value = "/findById")
    public ResultBean<EnvironmentalReview> findById(@RequestBody Long id) {
        return new ResultBean<>(ResultEnum.SUCCESS,this.environmentalReviewServiceInterface.selectById(id));
    }
}
