package com.sptg.estate.biz.controller;

import com.sptg.common.core.beans.ResultBean;
import com.sptg.estate.api.dto.ThirdUserDto;
import com.sptg.estate.api.entity.ThirdUser;
import com.sptg.estate.api.feigns.ThirdUserFeign;
import com.sptg.estate.biz.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * title: UserController
 * package: com.sptg.estate.biz.controller
 * description:住户 控制器
 *
 *
 *
 */
@RestController
public class ThirdUserController implements ThirdUserFeign {

    private final ThirdUserServiceInterface thirdUserServiceInterface;
    private final ResidentialServiceInterface residentialServiceInterface;
    private final BuildingServiceInterface buildingServiceInterface;
    private final UnitServiceInterface unitServiceInterface;
    private final FloorServiceInterface floorServiceInterface;
    private final RoomServiceInterface roomServiceInterface;

    @Autowired
    public ThirdUserController(ThirdUserServiceInterface thirdUserServiceInterface, ResidentialServiceInterface residentialServiceInterface, BuildingServiceInterface buildingServiceInterface,
                               UnitServiceInterface unitServiceInterface, FloorServiceInterface floorServiceInterface, RoomServiceInterface roomServiceInterface) {
        this.thirdUserServiceInterface = thirdUserServiceInterface;
        this.residentialServiceInterface = residentialServiceInterface;
        this.buildingServiceInterface = buildingServiceInterface;
        this.unitServiceInterface = unitServiceInterface;
        this.floorServiceInterface = floorServiceInterface;
        this.roomServiceInterface = roomServiceInterface;
    }

    @Override
    @PostMapping(value = "/thirdUser/addUser")
    public ResultBean<Boolean> addUser(@RequestBody ThirdUserDto userDto) {
        return this.thirdUserServiceInterface.addUser(userDto);
    }

    @Override
    @GetMapping(value = "/thirdUser/findUserById/{id}")
    public ThirdUser findUserById(@PathVariable(value = "id") Long id) {
        return this.thirdUserServiceInterface.findUserById(id);
    }

    @Override
    @PostMapping(value = "/thirdUser/updateEntity")
    public boolean updateEntity(@RequestBody ThirdUser user) {
        return this.thirdUserServiceInterface.updateEntity(user);
    }

    @Override
    @PostMapping(value = "/thirdUser/getListByCondition")
    public List<ThirdUser> getListByCondition(@RequestBody ThirdUserDto dto) {
        return thirdUserServiceInterface.getListByCondition(dto);
    }

    @Override
    @PostMapping(value = "/thirdUser/updateUser")
    public ResultBean<Boolean> updateUser(@RequestBody ThirdUserDto userDto) {
        return this.thirdUserServiceInterface.updateUser(userDto);
    }

    @Override
    @PostMapping(value = "/thirdUser/deleteUser")
    public ResultBean<Boolean> deleteUser(@RequestBody ThirdUserDto userDto) {
        return this.thirdUserServiceInterface.deleteUser(userDto);
    }


}
