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.ProjectDto;
import com.sptg.estate.api.entity.Project;
import com.sptg.estate.api.feigns.ProjectFeign;
import com.sptg.estate.biz.service.ProjectServiceInterface;
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;

import java.util.List;

/**
 * title: ProjectController
 * package: com.sptg.estate.biz.security
 * description: 实施项目 - 控制器
 *
 *               
 *                     
 */
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/implement/project")
public class ProjectController implements ProjectFeign {

    private final ProjectServiceInterface projectServiceInterface;

    @Override
    @PostMapping(value = "/showList")
    public ResultBean<Page<Project>> showList(@RequestBody ProjectDto projectDto) {
        return this.projectServiceInterface.showList(projectDto);
    }

    @Override
    @PostMapping(value = "/showListInstallation")
    public ResultBean<Page<Project>> showListInstallation(@RequestBody ProjectDto projectDto) {
        return this.projectServiceInterface.showListInstallation(projectDto);
    }

    @Override
    @PostMapping(value = "/showListTest")
    public ResultBean<Page<Project>> showListTest(@RequestBody ProjectDto projectDto) {
        return this.projectServiceInterface.showListTest(projectDto);
    }

    @Override
    @PostMapping(value = "/findByResidentialId")
    public ResultBean<Project> findByResidentialId(@RequestBody Long residentialId) {
        return this.projectServiceInterface.findByResidentialId(residentialId);
    }

    @Override
    @PostMapping(value = "/insert")
    public ResultBean<Boolean> insert(@RequestBody Project project) {
        return new ResultBean<>(ResultEnum.SUCCESS,this.projectServiceInterface.insert(project));
    }

    @Override
    @PostMapping(value = "/updateById")
    public ResultBean<Boolean> updateById(@RequestBody Project project) {
        return new ResultBean<>(ResultEnum.SUCCESS,this.projectServiceInterface.updateById(project));
    }

    @Override
    @PostMapping(value = "/countByResidentialId")
    public ResultBean<Boolean> countByResidentialId(@RequestBody Long residentialId) {
        return this.projectServiceInterface.countByResidentialId(residentialId);
    }

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

    @Override
    @PostMapping(value = "/edit")
    public ResultBean<Boolean> edit(@RequestBody Project project) {
        return new ResultBean<>(ResultEnum.SUCCESS,this.projectServiceInterface.updateById(project));
    }

    @Override
    @PostMapping(value = "/findListByPosition")
    public ResultBean<Project> findListByPosition(@RequestBody ProjectDto projectDto) {
        return this.projectServiceInterface.findListByPosition(projectDto);
    }

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

    @Override
    @PostMapping(value = "/insertProjectAndContract")
    public ResultBean<Boolean> insertProjectAndContract(@RequestBody ProjectDto dto) {
        return this.projectServiceInterface.insertProjectAndContract(dto);
    }

    @Override
    @PostMapping(value = "/findListByXqIds")
    public List<Project> findListByXqIds(@RequestBody List<Long> idList) {
        return this.projectServiceInterface.findListByXqIds(idList);
    }
}
