package com.sptg.gateway.controller;


import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.estate.api.dto.FloorDto;
import com.sptg.estate.api.dto.UserDto;
import com.sptg.estate.api.entity.Floor;
import com.sptg.estate.api.entity.User;
import com.sptg.estate.api.feigns.UserFeign;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/grid/user")
public class UserController {

    private final UserFeign userFeign;

    @GetMapping(value = "/syncUser/{residentialId}")
    public List<User> syncUser(@PathVariable(value="residentialId")Long residentialId){
        Page<User> page = new Page<>();
        page.setCurrent(1);
        page.setSize(999999999);
        UserDto userDto = new UserDto();
        userDto.setResidentialId(residentialId);
        userDto.setPage(page);
        ResultBean<Page<User>> pageResultBean = this.userFeign.showUserList(userDto);
        if(pageResultBean !=null){
            if(pageResultBean.getData()!=null){
                return pageResultBean.getData().getRecords();
            }
        }
        return null;
    }
}
