package com.example.demo.controller;

import com.community.commom.redis.RedisTemplate;
import com.example.demo.microController.MicroTestController;
import com.example.demo.model.ScUser;
import com.example.demo.service.ScUserServiceI;
import com.netflix.discovery.DiscoveryClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author FXF
 * @date 2018-09-11
 */
@RestController
@RefreshScope
@RequestMapping("/client1")
@Api("eureka-client1的测试controller的API")
public class TestController {
    
    @Value("${abc}")
    private String abc;
    
    @Autowired
    private ScUserServiceI scUserService;
    
    @Autowired
    private MicroTestController microTestController;
    
    @Autowired
    private RedisTemplate redisTemplate;
    
    @ApiOperation(value = "测试无参", notes = "无参")
    @RequestMapping(value = "/hello",method = RequestMethod.GET)
    @ResponseBody
    public String index(){
        redisTemplate.set("1","1");
        return abc;
    }
    
    /**
     * 获取所有的用户信息
     * @return
     */
    @ApiOperation(value = "测试restful接口", notes = "测试接口")
    @RequestMapping(value = "/user",method = RequestMethod.GET)
    @ResponseBody
    public List<ScUser> getUser(){
        return scUserService.getUser();
    }
    
    @RequestMapping(value = "/feignUser",method = RequestMethod.GET)
    @ResponseBody
    public List<ScUser> getMicroUser(){
        return microTestController.getUser();
    }
}
