Skip to content

Commit 589a72d

Browse files
committed
updated to fix method signature and request
request object and method signature fix
1 parent 605efae commit 589a72d

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

src/main/java/org/couchbase/quickstart/controllers/ProfileController.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import io.swagger.annotations.ApiResponses;
1111
import static org.couchbase.quickstart.configs.CollectionNames.PROFILE;
1212
import org.couchbase.quickstart.models.Profile;
13+
import org.couchbase.quickstart.models.ProfileRequest;
1314
import org.couchbase.quickstart.models.ProfileResult;
1415
import org.springframework.http.HttpStatus;
1516
import org.springframework.http.MediaType;
@@ -42,11 +43,11 @@ public ProfileController(Cluster cluster, Bucket bucket) {
4243
@ApiResponse(code = 201, message = "Created", response = Profile.class),
4344
@ApiResponse(code = 500, message = "Internal Server Error", response = Error.class)
4445
})
45-
public ResponseEntity<Profile> save(@RequestBody final Profile userProfile) {
46+
public ResponseEntity<Profile> save(@RequestBody final ProfileRequest userProfile) {
4647
//generates an id and save the user
47-
userProfile.setPid(UUID.randomUUID().toString());
48-
profileCol.insert(userProfile.getPid(), userProfile);
49-
return ResponseEntity.status(HttpStatus.CREATED).body(userProfile);
48+
Profile profile = userProfile.getProfile();
49+
profileCol.insert(profile.getPid(), profile);
50+
return ResponseEntity.status(HttpStatus.CREATED).body(profile);
5051
}
5152

5253

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package org.couchbase.quickstart.models;
2+
3+
import java.util.UUID;
4+
5+
public class ProfileRequest {
6+
7+
private String firstName, lastName, email, password;
8+
9+
public String getFirstName() { return firstName; }
10+
public void setFirstName(String firstName) { this.firstName = firstName; }
11+
12+
public String getLastName() { return lastName; }
13+
public void setLastName(String lastName) { this.lastName = lastName; }
14+
15+
public String getEmail() { return email; }
16+
public void setEmail(String email) { this.email = email; }
17+
18+
public String getPassword() { return password; }
19+
public void setPassword(String password) {
20+
this.password = password;
21+
}
22+
23+
public ProfileRequest() { }
24+
25+
public ProfileRequest(String firstName, String lastName, String email, String password){
26+
27+
this.firstName = firstName;
28+
this.lastName = lastName;
29+
this.email = email;
30+
this.password = password;
31+
}
32+
33+
public Profile getProfile() {
34+
return new Profile(UUID.randomUUID().toString(), firstName, lastName, email, password);
35+
}
36+
}

0 commit comments

Comments
 (0)