-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathHeroController.java
More file actions
60 lines (53 loc) · 2 KB
/
HeroController.java
File metadata and controls
60 lines (53 loc) · 2 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package com.example.GroupOfHero.Controller;
import com.example.GroupOfHero.Entity.Hero;
import com.example.GroupOfHero.Service.SelectHeroService;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/heroes")
public class HeroController {
private final SelectHeroService selectHeroService;
public HeroController(SelectHeroService selectHeroService) {
this.selectHeroService = selectHeroService;
}
@GetMapping("/name/{name}")
public List<Hero> getHeroesByName(@PathVariable String name) {
return selectHeroService.findByName(name);
}
@GetMapping("/classtype/{classtype}")
public List<Hero> getHeroesByClasstype(@PathVariable String classtype) {
return selectHeroService.findByClasstype(classtype);
}
@GetMapping("/level/greater/{level}")
public List<Hero> getHeroesByLevelGreaterThan(@PathVariable int level) {
return selectHeroService.findByLevelGreaterThan(level);
}
@GetMapping("/level/less/{level}")
public List<Hero> getHeroesByLevelLessThan(@PathVariable int level) {
return selectHeroService.findByLevelLessThan(level);
}
@GetMapping("/weapon/{weapon}")
public List<Hero> getHeroesByWeapon(@PathVariable String weapon) {
return selectHeroService.findByWeapon(weapon);
}
@PostMapping("/ids")
public List<Hero> getHeroesByIds(@RequestBody List<Long> ids) {
return selectHeroService.findByIdIn(ids);
}
@GetMapping("/alias/{alias}")
public Hero getHeroByAlias(@PathVariable String alias) {
return selectHeroService.findByAlias(alias);
}
@GetMapping("/all")
public List<Hero> findAll() {
return selectHeroService.findAll();
}
@PostMapping("/add")
public List<Hero> addHero(@RequestBody Hero hero) {
return selectHeroService.addHero(hero);
}
@DeleteMapping("/delete/{id}")
public List<Hero> deleteHero(@PathVariable Long id) {
return selectHeroService.deleteHero(id);
}
}