Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homework Oct.21 2017 #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM openjdk:8-jdk-alpine

VOLUME /tmp
ADD target/spring-boot-microservice-1.0-SNAPSHOT.jar app.jar
ENV JAVA_OPTS=""
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
1 change: 1 addition & 0 deletions evan
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
er
23 changes: 23 additions & 0 deletions src/main/java/spaceshuttle/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import spaceshuttle.model.User;
import spaceshuttle.repository.UserRepository;

import java.util.List;

@RestController
@RequestMapping(path = "/users") // This means URL's start with /user (after Application path)

Expand Down Expand Up @@ -46,4 +48,25 @@ User addUser(@RequestBody User newUser) {
// @RequestParam means it is a parameter from the GET or POST request
return userRepository.save(newUser);
}

@GetMapping("user")
public @ResponseBody
Iterable<User> getUserByID(@RequestParam String username){
return userRepository.findByUsername(username);
}

@PutMapping("save")
public @ResponseBody
String updateUser(@RequestBody User user) {
user = userRepository.save(user);
return "update successfully";
}

@DeleteMapping("delete")
public @ResponseBody
String deleteUser(@RequestParam String username){
Iterable<User> user = userRepository.findByUsername(username);
userRepository.delete(user);
return "delete successfully";
}
}
5 changes: 2 additions & 3 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#spring.jpa.hibernate.ddl-auto=create
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/spaceshuttle
spring.datasource.username=spaceshuttle
spring.datasource.password=spaceshuttle
thisisgood=true
spring.datasource.username=root
spring.datasource.password=