-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4bc5cfd
commit 91c7ef2
Showing
5 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/com/asrez/wheremoney/api/controller/TypeController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.asrez.wheremoney.api.controller; | ||
|
||
import com.asrez.wheremoney.api.entity.Type; | ||
import com.asrez.wheremoney.api.service.TypeService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import javax.validation.Valid; | ||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/type") | ||
public class TypeController { | ||
|
||
private final TypeService typeService; | ||
|
||
@Autowired | ||
public TypeController(TypeService typeService) { | ||
this.typeService = typeService; | ||
} | ||
|
||
@PostMapping | ||
public ResponseEntity<Type> addType(@RequestBody @Valid Type type) { | ||
return ResponseEntity.ok(typeService.addType(type)); | ||
} | ||
|
||
@GetMapping | ||
public List<Type> getAllTypes() { | ||
return typeService.getAllTypes(); | ||
} | ||
|
||
@DeleteMapping("{id}") | ||
public ResponseEntity<Object> deleteType(@PathVariable("id") Long id) { | ||
return ResponseEntity.ok(typeService.deleteType(id)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters