diff --git a/backend-services/feed-service/app/controllers/DailyController.scala b/backend-services/feed-service/app/controllers/DailyController.scala index 8e5d1b2ba0764ff8f9e8957d8b1d7028fcd33220..4d640bc89d56f77aca2afdd841d26c2cd1ea607a 100644 --- a/backend-services/feed-service/app/controllers/DailyController.scala +++ b/backend-services/feed-service/app/controllers/DailyController.scala @@ -35,11 +35,11 @@ class DailyController @Inject()(val controllerComponents: ControllerComponents) /** * Create an Action to fetch the user's Dailies in the DB. */ - def getUserDailies() = Action { + def getUserDailies(userId: String) = Action { println("DailyController:getUserDailies") try { - val result: Seq[Daily] = Daily.getUserDailiesAsync(new ObjectId("641128f7e80bcd1ba39d04af")) + val result: Seq[Daily] = Daily.getUserDailiesAsync(new ObjectId(userId)) val jsonResult: JsValue = Daily.toJson(result) Ok(jsonResult) } catch { @@ -51,11 +51,11 @@ class DailyController @Inject()(val controllerComponents: ControllerComponents) /** * Create an Action to fetch the user's Feed. */ - def getUserFeed() = Action { + def getUserFeed(userId: String) = Action { println("DailyController:getUserFeed") try { - val result: Seq[Daily] = Daily.getUserFeedAsync(new ObjectId("641128f7e80bcd1ba39d04ae")) + val result: Seq[Daily] = Daily.getUserFeedAsync(new ObjectId(userId)) val jsonResult: JsValue = Daily.toJson(result) Ok(jsonResult) } catch { @@ -67,12 +67,12 @@ class DailyController @Inject()(val controllerComponents: ControllerComponents) /** * Create an Action to create a Daily. */ - def create() = Action { + def create(userId: String, questionId: String, content: String) = Action { println("DailyController:create") try { // Dummy data - val result: Daily = Daily.createDailyAsync(new ObjectId("641128f7e80bcd1ba39d04ae"), new ObjectId("641128f7e80bcd1ba39d04ae"), "asddas") + val result: Daily = Daily.createDailyAsync(new ObjectId(userId), new ObjectId(questionId), content) val jsonResult: JsValue = Daily.toJson(result) Ok(jsonResult) } catch { @@ -84,12 +84,12 @@ class DailyController @Inject()(val controllerComponents: ControllerComponents) /** * Create an Action to like a Daily. */ - def like() = Action { + def like(dailyId: String, likerId: String) = Action { println("DailyController:like") try { // Dummy data - Daily.likeAsync(new ObjectId("642314b4b9748f6794e9895b"), new ObjectId("641128f7e80bcd1ba39d04ae")) + Daily.likeAsync(new ObjectId(dailyId), new ObjectId(likerId)) Ok("Updated") } catch { case _: TimeoutException => BadRequest("Request timed out") @@ -102,12 +102,12 @@ class DailyController @Inject()(val controllerComponents: ControllerComponents) /** * Create an Action to unlike a Daily. */ - def unlike() = Action { + def unlike(dailyId: String, likerId: String) = Action { println("DailyController:unlike") try { // Dummy data - Daily.unlikeAsync(new ObjectId("642314b4b9748f6794e9895b"), new ObjectId("641128f7e80bcd1ba39d04ae")) + Daily.unlikeAsync(new ObjectId(dailyId), new ObjectId(likerId)) Ok("Updated") } catch { case _: TimeoutException => BadRequest("Request timed out") diff --git a/backend-services/feed-service/conf/routes b/backend-services/feed-service/conf/routes index 90c875672604793a78be188407207bc9f5cff64e..d826e757c1a1fdb726b6ad6c7408f616f7413c5e 100644 --- a/backend-services/feed-service/conf/routes +++ b/backend-services/feed-service/conf/routes @@ -11,12 +11,12 @@ GET /assets/*file controllers.Assets.versioned(path="/public", GET /daily/getAll controllers.DailyController.getAll() -GET /daily/users controllers.DailyController.getUserDailies() +GET /daily/users controllers.DailyController.getUserDailies(userId: String) -GET /feed controllers.DailyController.getUserFeed() +GET /feed controllers.DailyController.getUserFeed(userId: String) -POST /daily/create controllers.DailyController.create() +POST /daily/create controllers.DailyController.create(userId: String, questionId: String, content: String) -PUT /daily/like controllers.DailyController.like() +PUT /daily/like controllers.DailyController.like(dailyId: String, likerId: String) -PUT /daily/unlike controllers.DailyController.unlike() +PUT /daily/unlike controllers.DailyController.unlike(dailyId: String, likerId: String)