-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.idea | ||
*.iml | ||
target | ||
**/*.xml | ||
**/*.iml |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package de.htwg.konstanz.cloud.service; | ||
|
||
import com.seitenbau.microservices.core.user.UserRepository; | ||
import com.seitenbau.microservices.core.user.model.User; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/users") | ||
public class TestService { | ||
|
||
@Autowired | ||
private UserRepository repository; | ||
|
||
@RequestMapping(method = RequestMethod.GET) | ||
public List<User> getAll() { | ||
return repository.findAll(); | ||
} | ||
|
||
@RequestMapping(method = RequestMethod.POST, consumes = "application/json") | ||
public User create(@RequestBody User user) { | ||
return repository.save(user); | ||
} | ||
|
||
@RequestMapping(value = "{userId}", method = RequestMethod.GET) | ||
public User getUser(@PathVariable String userId) { | ||
return repository.findOne(userId); | ||
} | ||
|
||
@RequestMapping(value = "{userId}", method = RequestMethod.PUT, consumes = "application/json") | ||
public User update(@PathVariable String userId, @RequestBody User user) { | ||
User update = repository.findOne(userId); | ||
update.setFirstName(user.getFirstName()); | ||
update.setLastName(user.getLastName()); | ||
return repository.save(update); | ||
} | ||
|
||
@RequestMapping(value="{userId}", method = RequestMethod.DELETE ) | ||
public void delete(@PathVariable String userId) { | ||
repository.delete(userId); | ||
} | ||
} |