Skip to content

Commit ae6ae77

Browse files
committed
roles controller also works
1 parent c8f511c commit ae6ae77

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

src/main/java/ru/techdemo/controllers/api/RolesController.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,29 @@
55
*/
66
package ru.techdemo.controllers.api;
77

8-
/**
9-
*
10-
* @author michael
11-
*/
8+
import java.util.List;
9+
import org.springframework.beans.factory.annotation.Autowired;
10+
import org.springframework.web.bind.annotation.GetMapping;
11+
import org.springframework.web.bind.annotation.PathVariable;
12+
import org.springframework.web.bind.annotation.RestController;
13+
import ru.techdemo.dal.IApplicationDataContext;
14+
import ru.techdemo.dal.entity.RoleEntity;
15+
16+
@RestController
1217
public class RolesController {
1318

19+
@GetMapping("/api/roles")
20+
public List<RoleEntity> get(){
21+
List<RoleEntity> roles = dataContext.getRolesRepository().getAll();
22+
return roles;
23+
}
24+
25+
@GetMapping("/api/roles/{id}")
26+
public RoleEntity get(@PathVariable(required = true)Long id){
27+
RoleEntity role = dataContext.getRolesRepository().getById(id);
28+
return role;
29+
}
30+
31+
@Autowired
32+
IApplicationDataContext dataContext;
1433
}

0 commit comments

Comments
 (0)