CompanyController.java 1.1 KB
package cn.dnect.company.controller;

import cn.dnect.company.entity.Company;
import cn.dnect.company.service.CompanyService;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * Date: 2019/2/12
 * Time: 9:31
 *
 * @author: 二条
 * Description:
 */
@RestController
public class CompanyController {
    @Autowired private CompanyService companyService;

    @Value("${server.port}")
    private String port;

    @GetMapping("/")
    public String home() {
        return "Hello world ,port:" + port;
    }

    @GetMapping("/{id}")
    public Company getCompany(@PathVariable("id") Long id) {
        return companyService.getCompany(id);
    }

    @GetMapping("hi")
    public String sayHi(@RequestParam String name) {
        return "你好," + name + "!";
    }

}