From a6654c96a2f2c29b3a4bf7f0d946e5f293a2e0e4 Mon Sep 17 00:00:00 2001 From: snehal-gothe Date: Fri, 3 Jul 2026 13:12:20 +0530 Subject: [PATCH 1/4] learner path apis added --- .../learnerPath/LearnerPathRepository.java | 14 ++ .../learnerPath/UserPassbookRepository.java | 14 ++ .../controller/LearnerPathController.java | 59 +++++++ .../learnerPath/model/LearnerPath.java | 145 ++++++++++++++++++ .../learnerPath/model/UserPassbook.java | 133 ++++++++++++++++ .../service/LearnerPathService.java | 54 +++++++ .../service/UserPassbookService.java | 113 ++++++++++++++ 7 files changed, 532 insertions(+) create mode 100644 src/main/java/org/sunbird/learnerPath/LearnerPathRepository.java create mode 100644 src/main/java/org/sunbird/learnerPath/UserPassbookRepository.java create mode 100644 src/main/java/org/sunbird/learnerPath/controller/LearnerPathController.java create mode 100644 src/main/java/org/sunbird/learnerPath/model/LearnerPath.java create mode 100644 src/main/java/org/sunbird/learnerPath/model/UserPassbook.java create mode 100644 src/main/java/org/sunbird/learnerPath/service/LearnerPathService.java create mode 100644 src/main/java/org/sunbird/learnerPath/service/UserPassbookService.java diff --git a/src/main/java/org/sunbird/learnerPath/LearnerPathRepository.java b/src/main/java/org/sunbird/learnerPath/LearnerPathRepository.java new file mode 100644 index 000000000..f6ec8f74f --- /dev/null +++ b/src/main/java/org/sunbird/learnerPath/LearnerPathRepository.java @@ -0,0 +1,14 @@ +package org.sunbird.learnerPath; + +import java.util.List; + +import org.springframework.data.cassandra.repository.CassandraRepository; +import org.springframework.stereotype.Repository; +import org.sunbird.learnerPath.model.LearnerPath; + + +@Repository +public interface LearnerPathRepository extends CassandraRepository { + List findByUserid(String userid); + List findByUseridAndCourseid(String userId, String courseId); +} diff --git a/src/main/java/org/sunbird/learnerPath/UserPassbookRepository.java b/src/main/java/org/sunbird/learnerPath/UserPassbookRepository.java new file mode 100644 index 000000000..9e9a3521e --- /dev/null +++ b/src/main/java/org/sunbird/learnerPath/UserPassbookRepository.java @@ -0,0 +1,14 @@ +package org.sunbird.learnerPath; + +import org.springframework.data.cassandra.repository.CassandraRepository; +import org.springframework.stereotype.Repository; +import org.sunbird.learnerPath.model.UserPassbook; + +import java.util.List; + +@Repository +public interface UserPassbookRepository extends CassandraRepository { + + List findByUserid(String userid); + +} diff --git a/src/main/java/org/sunbird/learnerPath/controller/LearnerPathController.java b/src/main/java/org/sunbird/learnerPath/controller/LearnerPathController.java new file mode 100644 index 000000000..982b96b13 --- /dev/null +++ b/src/main/java/org/sunbird/learnerPath/controller/LearnerPathController.java @@ -0,0 +1,59 @@ +package org.sunbird.learnerPath.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.sunbird.learnerPath.model.LearnerPath; +import org.sunbird.learnerPath.service.LearnerPathService; +import org.sunbird.learnerPath.service.UserPassbookService; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class LearnerPathController { + + @Autowired + private LearnerPathService learnerpathservice; + @Autowired + private UserPassbookService userPassbookService; + + @PostMapping(value = "/learnerpath") + public ResponseEntity createOrUpdateLearnerPath(@RequestBody LearnerPath learnerPath) { + return ResponseEntity.ok(learnerpathservice.insertOrUpdate(learnerPath)); + } + + + @GetMapping("/learnerpath") + public ResponseEntity> getLearnerPath(@RequestParam(value = "userId", required = true) String userId, + @RequestParam(value = "courseId", required = false) String courseId) { + + List learnerPaths; + List userPassbooks; + if (courseId != null) { + + userPassbooks= userPassbookService.getUserPassbookByUseridAndCourseId(userId, courseId); + learnerPaths = learnerpathservice.findByUserIdAndCourseId(userId, courseId); + + } else { + userPassbooks = userPassbookService.getUserPassbookByUserid(userId); + learnerPaths = learnerpathservice.findByUserId(userId); + } +// Set learnerPathSet = new HashSet<>(learnerPaths); // Convert to set to eliminate duplicates +// learnerPathSet.removeAll(userPassbooks); // Remove userPassbooks from learnerPaths set + Set mergedSet = new HashSet<>(learnerPaths); + mergedSet.addAll(userPassbooks); + + List mergedList = new ArrayList<>(mergedSet); + + if (mergedList.isEmpty()) { + return ResponseEntity.notFound().build(); + } + + return ResponseEntity.ok(mergedList); + } +} diff --git a/src/main/java/org/sunbird/learnerPath/model/LearnerPath.java b/src/main/java/org/sunbird/learnerPath/model/LearnerPath.java new file mode 100644 index 000000000..5e66ec20b --- /dev/null +++ b/src/main/java/org/sunbird/learnerPath/model/LearnerPath.java @@ -0,0 +1,145 @@ +package org.sunbird.learnerPath.model; + +import java.time.LocalDateTime; + +import org.springframework.data.cassandra.core.mapping.PrimaryKey; +import org.springframework.data.cassandra.core.mapping.Table; + +@Table(value = "asha_learnerpath") +public class LearnerPath { + @PrimaryKey("userid") + private String userid; // Unique user identifier + private String courseid; // Identifier for the course + private String batchid; // Identifier for the batch + private String contentid; // Identifier for the content + private String competencyid; + private int competencylevel; // competency level + private double completionpercentage; // Percentage of completion + private LocalDateTime datetime; // Date and time of enrollment + private LocalDateTime last_access_time; // Last access time of the learner + private LocalDateTime last_completed_time; // Last completion time of the learner + private String content_type; // Progress status (e.g., "In Progress", "Completed") + private String pass_fail_status = "Fail"; // Default value set to "Fail" + private int attemptcount = 0; // Default value set to 0 + + + // Getters and Setters + + public String getUserid() { + return userid; + } + + public void setUserid(String userid) { + this.userid = userid; + } + + public String getCourseid() { + return courseid; + } + + public void setCourseid(String courseid) { + this.courseid = courseid; + } + + public String getBatchid() { + return batchid; + } + + public void setBatchid(String batchid) { + this.batchid = batchid; + } + + public String getContentid() { + return contentid; + } + + public void setContentid(String contentid) { + this.contentid = contentid; + } + + public String getCompetencyid() { + return competencyid; + } + + public void setCompetencyid(String competencyid) { + this.competencyid = competencyid; + } + + public int getcompetencylevel() { + return competencylevel; + } + + public void setcompetencylevel(int competencylevel) { + this.competencylevel = competencylevel; + } + + public double getCompletionpercentage() { + return completionpercentage; + } + + public void setCompletionpercentage(double completionpercentage) { + this.completionpercentage = completionpercentage; + // Update passFailStatus if completionpercentage is 100 + if (completionpercentage == 100) { + this.pass_fail_status = "Pass"; + updateLastCompletedTime(); + } + } + + public LocalDateTime getDatetime() { + return datetime; + } + + // Only set this once when the user enrolls + public void setDatetime(LocalDateTime datetime) { + if (this.datetime == null) { + this.datetime = datetime; + } + } + + public LocalDateTime getLastAccessTime() { + return last_access_time; + } + + public void setLastAccessTime(LocalDateTime lastAccessTime) { + this.last_access_time = lastAccessTime; + } + + public LocalDateTime getLastCompletedTime() { + return last_completed_time; + } + + private void updateLastCompletedTime() { + this.last_completed_time = LocalDateTime.now(); // Update to current time + } + + public String getContentType() { + return content_type; + } + + public void setContentType(String content_type) { + this.content_type = content_type; + } + + + public String getPassFailStatus() { + return pass_fail_status; + } + + public void setPassFailStatus(String passFailStatus) { + this.pass_fail_status = passFailStatus; + } + + public int getAttemptcount() { + return attemptcount; + } + + // Method to increment attempt count + public void incrementAttemptCount() { + this.attemptcount++; + } + + public void setAttemptcount(int attemptcount) { + this.attemptcount = attemptcount; + } +} diff --git a/src/main/java/org/sunbird/learnerPath/model/UserPassbook.java b/src/main/java/org/sunbird/learnerPath/model/UserPassbook.java new file mode 100644 index 000000000..b45f4a502 --- /dev/null +++ b/src/main/java/org/sunbird/learnerPath/model/UserPassbook.java @@ -0,0 +1,133 @@ +package org.sunbird.learnerPath.model; + +import org.springframework.data.cassandra.core.mapping.Column; +import org.springframework.data.cassandra.core.mapping.PrimaryKey; +import org.springframework.data.cassandra.core.mapping.Table; +import java.time.Instant; +import java.util.Map; + +@Table(value="user_passbook_v2") // table name in Cassandra +public class UserPassbook { + + @PrimaryKey("userid") + @Column("userid") + private String userid; + + @Column("typename") + private String typename; + + @Column("acquiredchannel") + private String acquiredChannel; + + @Column("typeid") + private String typeId; + + @Column("contextid") + private String contextId; + + @Column("effectivedate") + private Instant effectiveDate; + + @Column("acquireddetails") + private Map acquiredDetails; + + @Column("additionalparams") + private Map additionalParams; + + // Top-level fields for final response + private String resourceId; + private String courseId; + private String competencyName; + + // Getters and setters for all fields + + public String getUserid() { + return userid; + } + + public void setUserid(String userid) { + this.userid = userid; + } + + public String getTypename() { + return typename; + } + + public void setTypename(String typename) { + this.typename = typename; + } + + public String getAcquiredChannel() { + return acquiredChannel; + } + + public void setAcquiredChannel(String acquiredChannel) { + this.acquiredChannel = acquiredChannel; + } + + public String getTypeId() { + return typeId; + } + + public void setTypeId(String typeId) { + this.typeId = typeId; + } + + public String getContextId() { + return contextId; + } + + public void setContextId(String contextId) { + this.contextId = contextId; + } + + public Instant getEffectiveDate() { + return effectiveDate; + } + + public void setEffectiveDate(Instant effectiveDate) { + this.effectiveDate = effectiveDate; + } + + public Map getAcquiredDetails() { + return acquiredDetails; + } + + public void setAcquiredDetails(Map acquiredDetails) { + this.acquiredDetails = acquiredDetails; + } + + public Map getAdditionalParams() { + return additionalParams; + } + + public void setAdditionalParams(Map additionalParams) { + this.additionalParams = additionalParams; + } + + // Getters and setters for new top-level fields + public String getResourceId() { + return resourceId; + } + + public void setResourceId(String resourceId) { + this.resourceId = resourceId; + } + + public String getCourseId() { + return courseId; + } + + public void setCourseId(String courseId) { + this.courseId = courseId; + } + + public String getCompetencyName() { + return competencyName; + } + + public void setCompetencyName(String competencyName) { + this.competencyName = competencyName; + } +} + diff --git a/src/main/java/org/sunbird/learnerPath/service/LearnerPathService.java b/src/main/java/org/sunbird/learnerPath/service/LearnerPathService.java new file mode 100644 index 000000000..93a107787 --- /dev/null +++ b/src/main/java/org/sunbird/learnerPath/service/LearnerPathService.java @@ -0,0 +1,54 @@ +package org.sunbird.learnerPath.service; + + +import com.course.recommendation.repository.LearnerPathRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.sunbird.learnerPath.model.LearnerPath; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; + +@Service +public class LearnerPathService { + + private final LearnerPathRepository repository; + + @Autowired + public LearnerPathService(LearnerPathRepository repository) { + this.repository = repository; + } + + public LearnerPath insertOrUpdate(LearnerPath learnerPath) { + // If it's a new enrollment, set the enrollment datetime + if (learnerPath.getDatetime() == null) { + learnerPath.setDatetime(LocalDateTime.now()); + } + + // Update last access time every time the user accesses the course + learnerPath.setLastAccessTime(LocalDateTime.now()); + + // Increment attempt count for each update + learnerPath.incrementAttemptCount(); + + // Save the learnerPath object to the repository + return repository.save(learnerPath); + } + + // public Optional findById(String userId) { +// return repository.findById(userId); +// } + public List findByUserId(String userId) { + return repository.findByUserid(userId); + } + + public List findByUserIdAndCourseId(String userId, String courseId) { + return repository.findByUseridAndCourseid(userId, courseId); + } + + public void deleteById(String userId) { + repository.deleteById(userId); + } +} + diff --git a/src/main/java/org/sunbird/learnerPath/service/UserPassbookService.java b/src/main/java/org/sunbird/learnerPath/service/UserPassbookService.java new file mode 100644 index 000000000..07be43aaf --- /dev/null +++ b/src/main/java/org/sunbird/learnerPath/service/UserPassbookService.java @@ -0,0 +1,113 @@ +package org.sunbird.learnerPath.service; + +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.sunbird.learnerPath.UserPassbookRepository; +import org.sunbird.learnerPath.model.LearnerPath; +import org.sunbird.learnerPath.model.UserPassbook; + +@Service +public class UserPassbookService { + + @Autowired + private UserPassbookRepository userPassbookRepository; + @Autowired + public UserPassbookService(UserPassbookRepository repository) { + this.userPassbookRepository = repository; + } + + + public List getUserPassbookByUserid(String userid) { + // Fetch all UserPassbook records for the given userId + List userPassbooks = userPassbookRepository.findByUserid(userid); + + // Process each UserPassbook in the list + return userPassbooks.stream().map(passbook -> { + // Get the acquiredDetails map + Map acquiredDetails = passbook.getAcquiredDetails(); + LearnerPath learnerPath = new LearnerPath(); + learnerPath.setUserid(passbook.getUserid()); + learnerPath.setContentType(passbook.getAcquiredChannel()); + learnerPath.setCompetencyid(passbook.getTypeId()); + int contextId = Integer.parseInt(passbook.getContextId()); + learnerPath.setcompetencylevel(contextId); + learnerPath.setCompletionpercentage(100); + learnerPath.setPassFailStatus("Pass"); + + if (acquiredDetails != null) { + // Extract the ResourceId, courseId, and competencyName + String resourceId = acquiredDetails.getOrDefault("ResourseId",""); + String courseId = acquiredDetails.get("courseId"); + String competencyName = acquiredDetails.get("competencyName"); + + // Set these values as top-level fields in the UserPassbook object +// passbook.setResourceId(resourceId); +// passbook.setCourseId(courseId); +// passbook.setCompetencyName(competencyName); + learnerPath.setCourseid(courseId); + learnerPath.setContentid(resourceId); + + // Optionally, remove acquiredDetails if you don't want to include it in the final response + passbook.setAcquiredDetails(null); // Nullify or reset the map + } + + return learnerPath; + }).collect(Collectors.toList()); // Collect the modified list of UserPassbook objects + } + + public List getUserPassbookByUseridAndCourseId(String userid, String courseId) { + // Fetch all UserPassbook records for the given userId + List userPassbooks = userPassbookRepository.findByUserid(userid); + + // Process each UserPassbook in the list + return userPassbooks.stream() + // Apply filter for the desired courseId + .filter(passbook -> { + // Check if acquiredDetails is not null and contains the courseId key + Map acquiredDetails = passbook.getAcquiredDetails(); + return acquiredDetails != null && acquiredDetails.containsKey("courseId") && + acquiredDetails.get("courseId").equals(courseId); // courseId is the value you are filtering by + }) + .map(passbook -> { + // Get the acquiredDetails map + Map acquiredDetails = passbook.getAcquiredDetails(); + LearnerPath learnerPath = new LearnerPath(); + learnerPath.setUserid(passbook.getUserid()); + learnerPath.setContentType(passbook.getAcquiredChannel()); + learnerPath.setCompetencyid(passbook.getTypeId()); + int contextId = Integer.parseInt(passbook.getContextId()); + learnerPath.setcompetencylevel(contextId); + learnerPath.setCompletionpercentage(100); + learnerPath.setPassFailStatus("Pass"); + // learnerPath.setDatetime(passbook.getEffectiveDate()); + + if (acquiredDetails != null) { + // Extract the ResourceId, courseId, and competencyName + String resourceId = acquiredDetails.getOrDefault("ResourseId", ""); + String courseIdFromDetails = acquiredDetails.get("courseId"); + String competencyName = acquiredDetails.get("competencyName"); + + learnerPath.setCourseid(courseIdFromDetails); + learnerPath.setContentid(resourceId); + + // Set these values as top-level fields in the UserPassbook object +// passbook.setResourceId(resourceId); +// passbook.setCourseId(courseIdFromDetails); // you may need to use the actual `courseIdFromDetails` +// passbook.setCompetencyName(competencyName); + + // Optionally, remove acquiredDetails if you don't want to include it in the final response + passbook.setAcquiredDetails(null); // Nullify or reset the map + } + + return learnerPath; + }) + .collect(Collectors.toList()); + + } +} + From 9ff452694c69bfdaaa68df62b354eecd72d92b14 Mon Sep 17 00:00:00 2001 From: snehal-gothe Date: Mon, 6 Jul 2026 11:04:42 +0530 Subject: [PATCH 2/4] updating file structure --- .../{ => repository}/LearnerPathRepository.java | 4 ++-- .../{ => repository}/UserPassbookRepository.java | 4 ++-- .../controller/LearnerPathController.java | 8 ++++---- .../learnerPath/{ => repository}/model/LearnerPath.java | 2 +- .../learnerPath/{ => repository}/model/UserPassbook.java | 2 +- .../{ => repository}/service/LearnerPathService.java | 7 +++---- .../{ => repository}/service/UserPassbookService.java | 9 ++++----- 7 files changed, 17 insertions(+), 19 deletions(-) rename src/main/java/org/sunbird/learnerPath/{ => repository}/LearnerPathRepository.java (78%) rename src/main/java/org/sunbird/learnerPath/{ => repository}/UserPassbookRepository.java (74%) rename src/main/java/org/sunbird/learnerPath/{ => repository}/controller/LearnerPathController.java (89%) rename src/main/java/org/sunbird/learnerPath/{ => repository}/model/LearnerPath.java (98%) rename src/main/java/org/sunbird/learnerPath/{ => repository}/model/UserPassbook.java (98%) rename src/main/java/org/sunbird/learnerPath/{ => repository}/service/LearnerPathService.java (88%) rename src/main/java/org/sunbird/learnerPath/{ => repository}/service/UserPassbookService.java (95%) diff --git a/src/main/java/org/sunbird/learnerPath/LearnerPathRepository.java b/src/main/java/org/sunbird/learnerPath/repository/LearnerPathRepository.java similarity index 78% rename from src/main/java/org/sunbird/learnerPath/LearnerPathRepository.java rename to src/main/java/org/sunbird/learnerPath/repository/LearnerPathRepository.java index f6ec8f74f..cb3d78544 100644 --- a/src/main/java/org/sunbird/learnerPath/LearnerPathRepository.java +++ b/src/main/java/org/sunbird/learnerPath/repository/LearnerPathRepository.java @@ -1,10 +1,10 @@ -package org.sunbird.learnerPath; +package org.sunbird.learnerPath.repository; import java.util.List; import org.springframework.data.cassandra.repository.CassandraRepository; import org.springframework.stereotype.Repository; -import org.sunbird.learnerPath.model.LearnerPath; +import org.sunbird.learnerPath.repository.model.LearnerPath; @Repository diff --git a/src/main/java/org/sunbird/learnerPath/UserPassbookRepository.java b/src/main/java/org/sunbird/learnerPath/repository/UserPassbookRepository.java similarity index 74% rename from src/main/java/org/sunbird/learnerPath/UserPassbookRepository.java rename to src/main/java/org/sunbird/learnerPath/repository/UserPassbookRepository.java index 9e9a3521e..5db469345 100644 --- a/src/main/java/org/sunbird/learnerPath/UserPassbookRepository.java +++ b/src/main/java/org/sunbird/learnerPath/repository/UserPassbookRepository.java @@ -1,8 +1,8 @@ -package org.sunbird.learnerPath; +package org.sunbird.learnerPath.repository; import org.springframework.data.cassandra.repository.CassandraRepository; import org.springframework.stereotype.Repository; -import org.sunbird.learnerPath.model.UserPassbook; +import org.sunbird.learnerPath.repository.model.UserPassbook; import java.util.List; diff --git a/src/main/java/org/sunbird/learnerPath/controller/LearnerPathController.java b/src/main/java/org/sunbird/learnerPath/repository/controller/LearnerPathController.java similarity index 89% rename from src/main/java/org/sunbird/learnerPath/controller/LearnerPathController.java rename to src/main/java/org/sunbird/learnerPath/repository/controller/LearnerPathController.java index 982b96b13..caf7d26b6 100644 --- a/src/main/java/org/sunbird/learnerPath/controller/LearnerPathController.java +++ b/src/main/java/org/sunbird/learnerPath/repository/controller/LearnerPathController.java @@ -1,4 +1,4 @@ -package org.sunbird.learnerPath.controller; +package org.sunbird.learnerPath.repository.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -6,9 +6,9 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; -import org.sunbird.learnerPath.model.LearnerPath; -import org.sunbird.learnerPath.service.LearnerPathService; -import org.sunbird.learnerPath.service.UserPassbookService; +import org.sunbird.learnerPath.repository.model.LearnerPath; +import org.sunbird.learnerPath.repository.service.LearnerPathService; +import org.sunbird.learnerPath.repository.service.UserPassbookService; import java.util.ArrayList; import java.util.HashSet; diff --git a/src/main/java/org/sunbird/learnerPath/model/LearnerPath.java b/src/main/java/org/sunbird/learnerPath/repository/model/LearnerPath.java similarity index 98% rename from src/main/java/org/sunbird/learnerPath/model/LearnerPath.java rename to src/main/java/org/sunbird/learnerPath/repository/model/LearnerPath.java index 5e66ec20b..e2606426f 100644 --- a/src/main/java/org/sunbird/learnerPath/model/LearnerPath.java +++ b/src/main/java/org/sunbird/learnerPath/repository/model/LearnerPath.java @@ -1,4 +1,4 @@ -package org.sunbird.learnerPath.model; +package org.sunbird.learnerPath.repository.model; import java.time.LocalDateTime; diff --git a/src/main/java/org/sunbird/learnerPath/model/UserPassbook.java b/src/main/java/org/sunbird/learnerPath/repository/model/UserPassbook.java similarity index 98% rename from src/main/java/org/sunbird/learnerPath/model/UserPassbook.java rename to src/main/java/org/sunbird/learnerPath/repository/model/UserPassbook.java index b45f4a502..9a8d21061 100644 --- a/src/main/java/org/sunbird/learnerPath/model/UserPassbook.java +++ b/src/main/java/org/sunbird/learnerPath/repository/model/UserPassbook.java @@ -1,4 +1,4 @@ -package org.sunbird.learnerPath.model; +package org.sunbird.learnerPath.repository.model; import org.springframework.data.cassandra.core.mapping.Column; import org.springframework.data.cassandra.core.mapping.PrimaryKey; diff --git a/src/main/java/org/sunbird/learnerPath/service/LearnerPathService.java b/src/main/java/org/sunbird/learnerPath/repository/service/LearnerPathService.java similarity index 88% rename from src/main/java/org/sunbird/learnerPath/service/LearnerPathService.java rename to src/main/java/org/sunbird/learnerPath/repository/service/LearnerPathService.java index 93a107787..fcef03ee7 100644 --- a/src/main/java/org/sunbird/learnerPath/service/LearnerPathService.java +++ b/src/main/java/org/sunbird/learnerPath/repository/service/LearnerPathService.java @@ -1,14 +1,13 @@ -package org.sunbird.learnerPath.service; +package org.sunbird.learnerPath.repository.service; -import com.course.recommendation.repository.LearnerPathRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.sunbird.learnerPath.model.LearnerPath; +import org.sunbird.learnerPath.repository.LearnerPathRepository; +import org.sunbird.learnerPath.repository.model.LearnerPath; import java.time.LocalDateTime; import java.util.List; -import java.util.Optional; @Service public class LearnerPathService { diff --git a/src/main/java/org/sunbird/learnerPath/service/UserPassbookService.java b/src/main/java/org/sunbird/learnerPath/repository/service/UserPassbookService.java similarity index 95% rename from src/main/java/org/sunbird/learnerPath/service/UserPassbookService.java rename to src/main/java/org/sunbird/learnerPath/repository/service/UserPassbookService.java index 07be43aaf..4eaa06385 100644 --- a/src/main/java/org/sunbird/learnerPath/service/UserPassbookService.java +++ b/src/main/java/org/sunbird/learnerPath/repository/service/UserPassbookService.java @@ -1,15 +1,14 @@ -package org.sunbird.learnerPath.service; +package org.sunbird.learnerPath.repository.service; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.sunbird.learnerPath.UserPassbookRepository; -import org.sunbird.learnerPath.model.LearnerPath; -import org.sunbird.learnerPath.model.UserPassbook; +import org.sunbird.learnerPath.repository.UserPassbookRepository; +import org.sunbird.learnerPath.repository.model.LearnerPath; +import org.sunbird.learnerPath.repository.model.UserPassbook; @Service public class UserPassbookService { From adfcdfb1d2427d9953c361acc6b409f5caeed28e Mon Sep 17 00:00:00 2001 From: Likhith Thammegowda Date: Mon, 6 Jul 2026 16:27:21 +0530 Subject: [PATCH 3/4] Enable Cassandra repository scanning for learnerPath package UserPassbookService failed to start because the UserPassbookRepository bean was never created. @EnableCassandraRepositories only scanned org.sunbird.assessment.repo, so the learnerPath repositories were not picked up. Added org.sunbird.learnerPath.repository to basePackages. --- src/main/java/org/sunbird/core/config/SunbirdConfig.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/sunbird/core/config/SunbirdConfig.java b/src/main/java/org/sunbird/core/config/SunbirdConfig.java index c2878102e..d03d3861f 100644 --- a/src/main/java/org/sunbird/core/config/SunbirdConfig.java +++ b/src/main/java/org/sunbird/core/config/SunbirdConfig.java @@ -17,7 +17,8 @@ @Configuration @ConfigurationProperties("spring.data.cassandra.sb") -@EnableCassandraRepositories(basePackages = { "org.sunbird.assessment.repo" }, cassandraTemplateRef = "sunbirdTemplate") +@EnableCassandraRepositories(basePackages = { "org.sunbird.assessment.repo", + "org.sunbird.learnerPath.repository" }, cassandraTemplateRef = "sunbirdTemplate") public class SunbirdConfig extends CassandraConfig { private Logger logger = LoggerFactory.getLogger(SunbirdConfig.class); From b73dad0e9090e638f80d1ba9dedeee4d3042a29f Mon Sep 17 00:00:00 2001 From: snehal-gothe Date: Mon, 6 Jul 2026 22:28:45 +0530 Subject: [PATCH 4/4] minor fixes --- .../repository/controller/LearnerPathController.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/sunbird/learnerPath/repository/controller/LearnerPathController.java b/src/main/java/org/sunbird/learnerPath/repository/controller/LearnerPathController.java index caf7d26b6..99d085e83 100644 --- a/src/main/java/org/sunbird/learnerPath/repository/controller/LearnerPathController.java +++ b/src/main/java/org/sunbird/learnerPath/repository/controller/LearnerPathController.java @@ -2,10 +2,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.*; import org.sunbird.learnerPath.repository.model.LearnerPath; import org.sunbird.learnerPath.repository.service.LearnerPathService; import org.sunbird.learnerPath.repository.service.UserPassbookService; @@ -15,6 +12,7 @@ import java.util.List; import java.util.Set; +@RestController public class LearnerPathController { @Autowired