Skip to content

Commit e13e0f0

Browse files
committed
modified some classes
1 parent 12df3b4 commit e13e0f0

File tree

3 files changed

+70
-24
lines changed

3 files changed

+70
-24
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
<properties>
2020
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21-
<maven.compiler.source>17</maven.compiler.source>
22-
<maven.compiler.target>17</maven.compiler.target>
21+
<maven.compiler.source>1.8</maven.compiler.source>
22+
<maven.compiler.target>1.8</maven.compiler.target>
2323
</properties>
2424

2525
<dependencies>

src/main/java/com/iot/lpnu/Main.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55
import org.springframework.context.annotation.ComponentScan;
66

7-
@SpringBootApplication(scanBasePackages = {"com.iot.lpnu.controller","com.iot.lpnu.services"})
7+
@SpringBootApplication /* ( scanBasePackages = {"com.iot.lpnu.controller","com.iot.lpnu.services"} ) */
8+
@ComponentScan("com.iot.lpnu")
89
public class Main {
910

10-
public static void main(String[] args){
11-
SpringApplication.run(Main.class, args);
12-
}
11+
public static void main(String[] args) {
12+
SpringApplication.run(Main.class, args);
13+
}
1314
}

src/main/java/com/iot/lpnu/controller/ToolController.java

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,60 +3,105 @@
33
import java.util.LinkedList;
44
import java.util.List;
55

6+
import javax.ws.rs.PathParam;
7+
import javax.ws.rs.Consumes;
8+
import javax.ws.rs.DELETE;
9+
import javax.ws.rs.GET;
10+
import javax.ws.rs.POST;
11+
import javax.ws.rs.PUT;
12+
import javax.ws.rs.Path;
13+
import javax.ws.rs.Produces;
14+
615
import org.springframework.beans.factory.annotation.Autowired;
7-
import org.springframework.web.bind.annotation.DeleteMapping;
8-
import org.springframework.web.bind.annotation.GetMapping;
9-
import org.springframework.web.bind.annotation.PathVariable;
10-
import org.springframework.web.bind.annotation.PostMapping;
11-
import org.springframework.web.bind.annotation.PutMapping;
16+
//import org.springframework.web.bind.annotation.DeleteMapping;
17+
//import org.springframework.web.bind.annotation.GetMapping;
18+
//import org.springframework.web.bind.annotation.PathVariable;
19+
//import org.springframework.web.bind.annotation.PostMapping;
20+
//import org.springframework.web.bind.annotation.PutMapping;
1221
import org.springframework.web.bind.annotation.RequestBody;
1322
import org.springframework.web.bind.annotation.RestController;
1423

1524
import com.iot.lpnu.services.ToolService;
1625
import com.iot.lpnu.tools.TreeTools;
1726

27+
1828
@RestController
29+
@Path("/tool")
30+
@Consumes("application/json")
31+
@Produces("application/json")
1932
public class ToolController {
2033
@Autowired
2134
private ToolService toolService;
2235

23-
@GetMapping("/tool/")
36+
@GET
37+
@Path("/")
38+
@Consumes("application/json")
39+
@Produces("application/json")
40+
// @GetMapping("/tool/")
2441
public List<TreeTools> getAllTool() {
2542
return toolService.findAll();
2643
}
2744

28-
@GetMapping("/tool/getbyname/{nameString}")
29-
public List<TreeTools> searchByName(@PathVariable String nameString){
45+
@GET
46+
@Path("/getbyname/{nameString}")
47+
@Consumes("application/json")
48+
@Produces("application/json")
49+
// @GetMapping("/tool/getbyname/{nameString}")
50+
public List<TreeTools> searchByName(@PathParam("nameString") String nameString){
3051
return toolService.findByName(nameString);
3152
}
3253

33-
@GetMapping("/tool/getbyid/{id}")
34-
public TreeTools searchById(@PathVariable int id){
54+
@GET
55+
@Path("/getbyid/{id}")
56+
@Consumes("application/json")
57+
@Produces("application/json")
58+
// @GetMapping("/tool/getbyid/{id}")
59+
public TreeTools searchById(@PathParam("id") int id){
3560
return toolService.findById(id);
3661
}
3762

38-
@GetMapping("/tool/getbycost/{costInUaPerOne}")
39-
public List<TreeTools> searchByCost(@PathVariable Float costInUaPerOne){
63+
@GET
64+
@Path("/getbycost/{costInUaPerOne}")
65+
@Consumes("application/json")
66+
@Produces("application/json")
67+
// @GetMapping("/tool/getbycost/{costInUaPerOne}")
68+
public List<TreeTools> searchByCost(@PathParam("costInUaPerOne") Float costInUaPerOne/* @PathVariable Float costInUaPerOne */){
4069
return toolService.findByCostInUaPerOne(costInUaPerOne);
4170
}
4271

43-
@PostMapping("/tool/add")
72+
@POST
73+
@Path("/add")
74+
@Consumes("application/json")
75+
@Produces("application/json")
76+
// @PostMapping("/tool/add")
4477
public TreeTools addTool(@RequestBody TreeTools treeTools){
4578
return toolService.addTool(treeTools);
4679
}
4780

48-
@PostMapping("/tool/addlist")
81+
@POST
82+
@Path("/addlist")
83+
@Consumes("application/json")
84+
@Produces("application/json")
85+
// @PostMapping("/tool/addlist")
4986
public List<TreeTools> addListOfTools(@RequestBody LinkedList<TreeTools> list){
5087
return toolService.addListOfTool(list);
5188
}
5289

53-
@PutMapping("/tool/update/{id}")
54-
public TreeTools addListOfTools(@PathVariable Integer id, @RequestBody TreeTools treeTools){
90+
@PUT
91+
@Path("/update/{id}")
92+
@Consumes("application/json")
93+
@Produces("application/json")
94+
// @PutMapping("/tool/update/{id}")
95+
public TreeTools addListOfTools(@PathParam("id") Integer id, @RequestBody TreeTools treeTools){
5596
return toolService.update(id, treeTools);
5697
}
5798

58-
@DeleteMapping("tool/delete/{id}")
59-
public void delete(@PathVariable int id) {
99+
@DELETE
100+
@Path("/delete/{id}")
101+
@Consumes("application/json")
102+
@Produces("application/json")
103+
// @DeleteMapping("tool/delete/{id}")
104+
public void delete(@PathParam("id") int id) {
60105
toolService.delete(id);
61106
}
62107
}

0 commit comments

Comments
 (0)