-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from sunbird-cb/cbrelease-3.0.2-rating-review-…
…features Cbrelease 3.0.2 rating review features
- Loading branch information
Showing
10 changed files
with
878 additions
and
213 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
src/main/java/org/sunbird/ratings/controller/RatingsController.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,47 @@ | ||
package org.sunbird.ratings.controller; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
import org.sunbird.common.model.SBApiResponse; | ||
import org.sunbird.ratings.model.RequestRating; | ||
import org.sunbird.ratings.service.RatingService; | ||
|
||
import javax.validation.Valid; | ||
|
||
@RestController | ||
public class RatingsController { | ||
|
||
@Autowired | ||
RatingService ratingService; | ||
|
||
// ----------------- Public APIs -------------------- | ||
|
||
@PostMapping("/ratings/v1/upsert") | ||
public ResponseEntity<?> upsertRating(@Valid @RequestBody RequestRating requestRatingBody) { | ||
SBApiResponse response = ratingService.upsertRating(requestRatingBody); | ||
return new ResponseEntity<>(response, response.getResponseCode()); | ||
|
||
} | ||
|
||
@GetMapping("/ratings/v1/read/{activity_Type}/{activity_Id}/{userId}") | ||
public ResponseEntity<?> getRating(@PathVariable("activity_Id") String activity_Id, | ||
@PathVariable("activity_Type") String activity_Type, | ||
@PathVariable("userId") String userId) { | ||
SBApiResponse response = ratingService.getRatings(activity_Id, activity_Type, userId); | ||
return new ResponseEntity<>(response, response.getResponseCode()); | ||
|
||
} | ||
// @GetMapping("/ratings/v1/search") | ||
// public ResponseEntity<List<String>> getUsersList() { | ||
// return new ResponseEntity<>(ratingService.getUsers(activity_Id, activity_Type, userId), HttpStatus.OK); | ||
// } | ||
|
||
|
||
// @PostMapping("/ratings/v1/summary") | ||
// public ResponseEntity<?> getRatingSummary( | ||
// @RequestParam( String activity_Id) throws Exception { | ||
// return new ResponseEntity<>(response, response.getResponseCode()); | ||
// } | ||
} | ||
|
68 changes: 68 additions & 0 deletions
68
src/main/java/org/sunbird/ratings/exception/ValidationException.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,68 @@ | ||
package org.sunbird.ratings.exception; | ||
|
||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
||
import java.util.List; | ||
|
||
@ResponseStatus(value = HttpStatus.BAD_REQUEST) | ||
@ResponseBody | ||
public class ValidationException extends RuntimeException { | ||
private static final long serialVersionUID = 1L; | ||
|
||
private String codeMessage = "Validation Exception occurred with these details :"; | ||
/** | ||
* message String ResponseCode. | ||
*/ | ||
private List<String> message; | ||
/** | ||
* responseCode int ResponseCode. | ||
*/ | ||
private int responseCode; | ||
|
||
public void setMessage(List<String> message) { | ||
this.message = message; | ||
} | ||
|
||
public String getCode() { | ||
return codeMessage; | ||
} | ||
|
||
public void setCode(String code) { | ||
this.codeMessage = code; | ||
} | ||
|
||
public int getResponseCode() { | ||
return responseCode; | ||
} | ||
|
||
public void setResponseCode(int responseCode) { | ||
this.responseCode = responseCode; | ||
} | ||
|
||
public String getMessage() { | ||
return message.toString(); | ||
} | ||
|
||
|
||
public ValidationException(List<String> message) { | ||
this.message = message; | ||
} | ||
|
||
public ValidationException(List<String> message, int responseCode) { | ||
super(); | ||
this.message = message; | ||
this.responseCode = responseCode; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ValidationException{" + | ||
"code='" + codeMessage + '\'' + | ||
", message='" + message + '\'' + | ||
", responseCode=" + responseCode + | ||
'}'; | ||
} | ||
} |
112 changes: 112 additions & 0 deletions
112
src/main/java/org/sunbird/ratings/model/RatingMessage.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,112 @@ | ||
package org.sunbird.ratings.model; | ||
|
||
public class RatingMessage { | ||
public Integer version = 1; | ||
private String action = "ratingUpdate"; | ||
private String activity_id; | ||
private String activity_Type; | ||
private String user_id; | ||
private String created_Date; | ||
private UpdatedValues prevValues; | ||
private UpdatedValues updatedValues; | ||
|
||
|
||
public RatingMessage( String action, String activity_id, String activity_Type, String user_id, String created_Date) { | ||
this.action = action; | ||
this.activity_id = activity_id; | ||
this.activity_Type = activity_Type; | ||
this.user_id = user_id; | ||
this.created_Date = created_Date; | ||
} | ||
|
||
|
||
public String getActivity_id() { | ||
return activity_id; | ||
} | ||
|
||
public void setActivity_id(String activity_id) { | ||
this.activity_id = activity_id; | ||
} | ||
|
||
public String getAction() { | ||
return action; | ||
} | ||
|
||
public void setAction(String action) { | ||
this.action = action; | ||
} | ||
|
||
public String getActivity_Type() { | ||
return activity_Type; | ||
} | ||
|
||
public void setActivity_Type(String activity_Type) { | ||
this.activity_Type = activity_Type; | ||
} | ||
|
||
public String getUser_id() { | ||
return user_id; | ||
} | ||
|
||
public void setUser_id(String user_id) { | ||
this.user_id = user_id; | ||
} | ||
|
||
public String getCreated_Date() { | ||
return created_Date; | ||
} | ||
|
||
public void setCreated_Date(String created_Date) { | ||
this.created_Date = created_Date; | ||
} | ||
|
||
public UpdatedValues getPrevValues() { | ||
return prevValues; | ||
} | ||
|
||
public void setPrevValues(UpdatedValues prevValues) { | ||
this.prevValues = prevValues; | ||
} | ||
|
||
public UpdatedValues getUpdatedValues() { | ||
return updatedValues; | ||
} | ||
|
||
public void setUpdatedValues(UpdatedValues updatedValues) { | ||
this.updatedValues = updatedValues; | ||
} | ||
|
||
public static class UpdatedValues { | ||
public String updatedOn; | ||
public Float rating; | ||
public String review; | ||
|
||
public String getUpdatedOn() { | ||
return updatedOn; | ||
} | ||
|
||
public void setUpdatedOn(String updatedOn) { | ||
this.updatedOn = updatedOn; | ||
} | ||
|
||
public Float getRating() { | ||
return rating; | ||
} | ||
|
||
public void setRating(Float rating) { | ||
this.rating = rating; | ||
} | ||
|
||
public String getReview() { | ||
return review; | ||
} | ||
|
||
public void setReview(String review) { | ||
this.review = review; | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
|
52 changes: 52 additions & 0 deletions
52
src/main/java/org/sunbird/ratings/model/RequestRating.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,52 @@ | ||
package org.sunbird.ratings.model; | ||
|
||
public class RequestRating { | ||
String activity_Id; | ||
String userId; | ||
String activity_type; | ||
Float rating; | ||
String review ; | ||
|
||
public String getActivity_Id() { | ||
return activity_Id; | ||
} | ||
|
||
public void setActivity_Id(String activity_Id) { | ||
this.activity_Id = activity_Id; | ||
} | ||
|
||
public String getUserId() { | ||
return userId; | ||
} | ||
|
||
public void setUserId(String userId) { | ||
this.userId = userId; | ||
} | ||
|
||
public String getActivity_type() { | ||
return activity_type; | ||
} | ||
|
||
public void setActivity_type(String activity_type) { | ||
this.activity_type = activity_type; | ||
} | ||
|
||
public Float getRating() { | ||
return rating; | ||
} | ||
|
||
public void setRating(Float rating) { | ||
this.rating = rating; | ||
} | ||
|
||
public String getReview() { | ||
return review; | ||
} | ||
|
||
public void setReview(String review) { | ||
this.review = review; | ||
} | ||
|
||
|
||
|
||
} |
Oops, something went wrong.