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.DeviceInstallationDto;
import com.sptg.estate.api.entity.DeviceInstallation;
import com.sptg.estate.api.feigns.DeviceInstallationFeign;
import com.sptg.estate.biz.service.DeviceInstallationServiceInterface;
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/device/installation")
public class DeviceInstallationController implements DeviceInstallationFeign {

    private final DeviceInstallationServiceInterface deviceInstallationServiceInterface;

    @Override
    @PostMapping("/showList")
    public ResultBean<Page<DeviceInstallation>> showList(@RequestBody DeviceInstallationDto dto){
        Page<DeviceInstallation> deviceInstallationPage = this.deviceInstallationServiceInterface.showList(dto);
        return new ResultBean<>(ResultEnum.SUCCESS,deviceInstallationPage);
    }

    @Override
    @PostMapping("/findById")
    public ResultBean<DeviceInstallation> findById(@RequestBody Long id) {
        DeviceInstallation deviceInstallation =null;
        if(id!=null&&id>0){
            deviceInstallation = this.deviceInstallationServiceInterface.findById(id);
        }
        return new ResultBean<>(ResultEnum.SUCCESS,deviceInstallation);
    }

    @Override
    @PostMapping("/checkState")
    public ResultBean<Boolean> checkState(@RequestBody DeviceInstallationDto dto) {
        boolean result = this.deviceInstallationServiceInterface.checkState(dto);
        return new ResultBean<>(ResultEnum.SUCCESS,result);
    }

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

    @Override
    @PostMapping("/findListByPosition")
    public ResultBean<DeviceInstallation> findListByPosition(@RequestBody DeviceInstallationDto dto) {
        return this.deviceInstallationServiceInterface.findListByPosition(dto);
    }

    @Override
    @PostMapping("/countBySerialNumber")
    public ResultBean<Boolean> countBySerialNumber(@RequestBody String serialNumber) {
        return this.deviceInstallationServiceInterface.countBySerialNumber(serialNumber);
    }

    @Override
    @PostMapping("/insertEntity")
    public ResultBean<Boolean> insertEntity(@RequestBody DeviceInstallation deviceInstallation) {
        return new ResultBean<>(ResultEnum.SUCCESS,this.deviceInstallationServiceInterface.insert(deviceInstallation));
    }

    @Override
    @PostMapping("/findBySerialNumber")
    public ResultBean<DeviceInstallation> findBySerialNumber(@RequestBody String serialNumber) {
        return this.deviceInstallationServiceInterface.findBySerialNumber(serialNumber);
    }

    @Override
    @PostMapping("/findEntityById")
    public ResultBean<DeviceInstallation> findEntityById(@RequestBody Long id) {
        return new ResultBean<>(ResultEnum.SUCCESS,this.deviceInstallationServiceInterface.selectById(id));
    }

    @Override
    @PostMapping("/edit")
    public ResultBean<Boolean> edit(@RequestBody DeviceInstallation deviceInstallation) {
        return this.deviceInstallationServiceInterface.edit(deviceInstallation);
    }

    @Override
    @PostMapping("/countByInstallationReviewId")
    public ResultBean<Boolean> countByInstallationReviewId(@RequestBody Long installationReviewId) {
        return this.deviceInstallationServiceInterface.countByInstallationReviewId(installationReviewId);
    }

    @Override
    @PostMapping("/findByCondition")
    public ResultBean<DeviceInstallation> findByCondition(@RequestBody DeviceInstallation deviceInstallation) {
        return this.deviceInstallationServiceInterface.findByCondition(deviceInstallation);
    }

    @Override
    @PostMapping("/delete")
    public ResultBean<Boolean> delete(@RequestBody Long id){
        return this.deviceInstallationServiceInterface.deleteEntity(id);
    }
}
