File tree Expand file tree Collapse file tree 1 file changed +0
-20
lines changed
src/main/java/com/code/food/controller Expand file tree Collapse file tree 1 file changed +0
-20
lines changed Original file line number Diff line number Diff line change 1
1
package com .code .food .controller ;
2
2
3
- import com .code .food .entity .UserEntity ;
4
- import com .code .food .repository .UserRepository ;
5
- import io .swagger .v3 .oas .annotations .parameters .RequestBody ;
6
- import org .springframework .beans .factory .annotation .Autowired ;
7
- import org .springframework .web .bind .annotation .PostMapping ;
8
3
import org .springframework .web .bind .annotation .RequestMapping ;
9
4
import org .springframework .web .bind .annotation .RestController ;
10
5
14
9
@ RequestMapping ("/user" )
15
10
public class UserController {
16
11
17
- //O @Autowired serve para inicializar uma determinada dependencia
18
- @ Autowired
19
- private UserRepository userRepository ;
20
-
21
- //O @PostMapping serve para indicar que a funcionalidade é uma função responsável por inserção
22
- @ PostMapping
23
- public UserEntity createUser (@ RequestBody UserEntity userEntity ) {
24
- if (userEntity .getEmail ().isEmpty ()||userEntity .getName ().isEmpty ()||userEntity .getPassword ().isEmpty ()||userEntity .getPhone ().isEmpty ()){
25
- throw new RuntimeException ("Por favor inserir campos validos" );
26
- }
27
- return userRepository .save (userEntity );
28
- }
29
-
30
- //TODO: @BrunoAligathor deve criar uma funcionalidade que retorne todos os usuários
31
- //TODO: @Ingrid deve validar se ao criar um usuário, todos os campos estão sendo preenchidos corretamente
32
12
}
You can’t perform that action at this time.
0 commit comments