package cn.com.ty.demo.controller;

import cn.com.ty.demo.feign.api.PortalFeignApi;
import cn.com.ty.demo.feign.dto.RoleListDto;
import cn.com.ty.demo.feign.vo.RoleVo;
import cn.com.xwy.boot.page.dto.BasePageResult;
import cn.com.xwy.boot.web.dto.RestResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: TODO
 * @Author xwy
 * @create 2019/11/14
 */
@RestController
@RequestMapping("/test/rest")
public class TestRestController {
    @Autowired
    private Environment env;

    @Autowired
    private PortalFeignApi portalFeignApi;

    @GetMapping("/getinfo")
    public RestResponse<String> getTest(){
        // Test config server
        System.out.println(env.getProperty("test.config.name"));
        RoleListDto dto = new RoleListDto();
        dto.setRoleCode("ROLE_ADMIN");
        RestResponse<BasePageResult<RoleVo>> roleVoRestResponse = portalFeignApi.queryMenuByRole(dto);
        List<RoleVo> dataList = roleVoRestResponse.getData().getRows();
        System.out.println(dataList);
        return RestResponse.success(env.getProperty("test.config.name"));
    }
}
