diff --git a/src/main/java/org/sunbird/common/util/Constants.java b/src/main/java/org/sunbird/common/util/Constants.java index c1e79e25c..851311842 100644 --- a/src/main/java/org/sunbird/common/util/Constants.java +++ b/src/main/java/org/sunbird/common/util/Constants.java @@ -936,6 +936,8 @@ public class Constants { public static final String TABLE_KARMA_POINTS_LOOK_UP ="user_karma_points_credit_lookup"; public static final String TABLE_KARMA_POINTS ="user_karma_points"; + public static final String TABLE_USER_KARMA_POINTS_SUMMARY ="user_karma_points_summary"; + private Constants() { throw new IllegalStateException("Utility class"); } diff --git a/src/main/java/org/sunbird/karmapoints/controller/KarmaPointsController.java b/src/main/java/org/sunbird/karmapoints/controller/KarmaPointsController.java index a65bd1f2d..e1336dc7e 100644 --- a/src/main/java/org/sunbird/karmapoints/controller/KarmaPointsController.java +++ b/src/main/java/org/sunbird/karmapoints/controller/KarmaPointsController.java @@ -38,4 +38,10 @@ public ResponseEntity> claimACBPKarmaPoints(@RequestBody Cla karmaPointsService.claimKarmaPoints(request); return new ResponseEntity<>(HttpStatus.OK); } + + @PostMapping("/v1/user/totalkarmapoints") + public ResponseEntity> totalKarmaPoints(@RequestHeader("x-authenticated-userid") String userId){ + Map karmaPointsDataMap = karmaPointsService.userTotalKarmaPoints(userId); + return new ResponseEntity<>(karmaPointsDataMap, HttpStatus.OK); + } } \ No newline at end of file diff --git a/src/main/java/org/sunbird/karmapoints/service/KarmaPointsService.java b/src/main/java/org/sunbird/karmapoints/service/KarmaPointsService.java index b0e762b6c..313ec1cf3 100644 --- a/src/main/java/org/sunbird/karmapoints/service/KarmaPointsService.java +++ b/src/main/java/org/sunbird/karmapoints/service/KarmaPointsService.java @@ -9,5 +9,6 @@ public interface KarmaPointsService { public Map fetchKarmaPointsData(String userId, KarmaPointsRequest request) ; public Map fetchKarmaPointsUserCourse(String userId, Map requestBody) ; public void claimKarmaPoints(ClaimKarmaPointsRequest request); + public Map userTotalKarmaPoints(String userId); } diff --git a/src/main/java/org/sunbird/karmapoints/service/KarmaPointsServiceImpl.java b/src/main/java/org/sunbird/karmapoints/service/KarmaPointsServiceImpl.java index f2c4b6ce5..bcd17ca9f 100644 --- a/src/main/java/org/sunbird/karmapoints/service/KarmaPointsServiceImpl.java +++ b/src/main/java/org/sunbird/karmapoints/service/KarmaPointsServiceImpl.java @@ -100,7 +100,16 @@ public void claimKarmaPoints(ClaimKarmaPointsRequest request) { logger.info("UserID and CourseId successfully Published to : " + serverProperties.getClaimKarmaPointsTopic()); } - public void fetchKarmaPoints(){ - + public Map userTotalKarmaPoints(String userId){ + Map whereMap = new HashMap<>(); + whereMap.put(Constants.KARMA_POINTS_USER_ID, userId); + List> userKpList = cassandraOperation.getRecordsByProperties(Constants.KEYSPACE_SUNBIRD, + Constants.TABLE_USER_KARMA_POINTS_SUMMARY, whereMap, null); + Map resultMap = new HashMap<>(); + Map result = new HashMap<>(); + if(userKpList !=null && !userKpList.isEmpty()) + result = userKpList.get(0); + resultMap.put(Constants.KARMA_POINTS_LIST, result); + return resultMap; } } \ No newline at end of file