package com.sptg.estate.biz.controller;

import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.estate.api.entity.InstallationReview;
import com.sptg.estate.api.feigns.InstallationReviewFeign;
import com.sptg.estate.biz.service.InstallationReviewServiceInterface;
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/installation/review")
public class InstallationReviewController implements InstallationReviewFeign {

    private final InstallationReviewServiceInterface installationReviewServiceInterface;

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

    @Override
    @PostMapping(value = "/findByPositionRecordId")
    public ResultBean<InstallationReview> findByPositionRecordId(@RequestBody Long positionRecordId) {
        return this.installationReviewServiceInterface.findByPositionRecordId(positionRecordId);
    }

    @Override
    @PostMapping(value = "/insertOrUpdate")
    public ResultBean<Boolean> insertOrUpdate(@RequestBody InstallationReview installationReview) {
        return this.installationReviewServiceInterface.insertOrUpdateEntity(installationReview);
    }

    @Override
    @PostMapping(value = "/findByEnvironmentalReviewId")
    public ResultBean<InstallationReview> findByEnvironmentalReviewId(@RequestBody Long environmentalReviewId) {
        return this.installationReviewServiceInterface.findByEnvironmentalReviewId(environmentalReviewId);
    }

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