package com.house365.wechat.rest;

import com.house365.beans.vo.Company;
import com.house365.common.searchBeans.CommonSearchResponse;
import com.house365.common.searchBeans.QueryParams;
import com.house365.service.ICompanyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Date: 2017/1/5</p>
 *
 * @author XN
 * @version 1.0
 */
@RestController
@RequestMapping("company")
public class CompanyRestController {
    private final Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private DiscoveryClient client;

    @Autowired
    private ICompanyService companyService;

    @RequestMapping(value = "/list")
    public CommonSearchResponse<Company> list(@RequestBody QueryParams queryParams) {
        //        ServiceInstance instance = client.getLocalServiceInstance();
        CommonSearchResponse<Company> list = companyService.queryByPage(queryParams);
        return list;
    }

    @RequestMapping(method = RequestMethod.GET, value = "/get/{id}")
    Company selectByPrimaryKey(@PathVariable("id") Integer id) {
        return companyService.selectByPrimaryKey(id);
    }

}
