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.AcceptanceDto;
import com.sptg.estate.api.entity.Acceptance;
import com.sptg.estate.api.feigns.AcceptanceFeign;
import com.sptg.estate.biz.service.AcceptanceServiceInterface;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
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/acceptance")
//@Api(value = "AcceptanceController",description = "竣工验收")
public class AcceptanceController implements AcceptanceFeign {

    private final AcceptanceServiceInterface acceptanceServiceInterface;

    @Override
    @PostMapping("/countByProjectId")
    public ResultBean<Boolean> countByProjectId(@RequestBody Long projectId) {
        return this.acceptanceServiceInterface.countByProjectId(projectId);
    }

    @Override
    @PostMapping("/insert")
//    @ApiOperation(value = "insert",notes="新增")
    public ResultBean<Boolean> insert(@RequestBody AcceptanceDto dto) {
        return this.acceptanceServiceInterface.insertEntity(dto);
    }

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

    @Override
    @PostMapping("/showList")
    public ResultBean<Page<Acceptance>> showList(@RequestBody AcceptanceDto acceptanceDto) {
        Page<Acceptance> page = this.acceptanceServiceInterface.showList(acceptanceDto);
        return new ResultBean<>(ResultEnum.SUCCESS,page);
    }

    @Override
    @PostMapping("/edit")
    public ResultBean<Boolean> edit(@RequestBody Acceptance acceptance) {
        return new ResultBean<>(ResultEnum.SUCCESS,this.acceptanceServiceInterface.updateById(acceptance));
    }

    @Override
    @PostMapping("/checkState")
    public ResultBean<Boolean> checkState(@RequestBody AcceptanceDto dto) {
        return this.acceptanceServiceInterface.checkState(dto);
    }

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