CompanyController.java
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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 + "!";
}
}