Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
Daily Thought App
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
COM3014-Coursework
Daily Thought App
Commits
86283739
Commit
86283739
authored
2 years ago
by
Felipe D'Abrantes
Browse files
Options
Downloads
Patches
Plain Diff
Add parameters to endpoints
parent
8f83f56c
No related branches found
Branches containing commit
No related tags found
1 merge request
!14
Add endpoints to manage Dailies
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
backend-services/feed-service/app/controllers/DailyController.scala
+10
-10
10 additions, 10 deletions
...rvices/feed-service/app/controllers/DailyController.scala
backend-services/feed-service/conf/routes
+5
-5
5 additions, 5 deletions
backend-services/feed-service/conf/routes
with
15 additions
and
15 deletions
backend-services/feed-service/app/controllers/DailyController.scala
+
10
−
10
View file @
86283739
...
@@ -35,11 +35,11 @@ class DailyController @Inject()(val controllerComponents: ControllerComponents)
...
@@ -35,11 +35,11 @@ class DailyController @Inject()(val controllerComponents: ControllerComponents)
/**
/**
* Create an Action to fetch the user's Dailies in the DB.
* Create an Action to fetch the user's Dailies in the DB.
*/
*/
def
getUserDailies
()
=
Action
{
def
getUserDailies
(
userId
:
String
)
=
Action
{
println
(
"DailyController:getUserDailies"
)
println
(
"DailyController:getUserDailies"
)
try
{
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
)
val
jsonResult
:
JsValue
=
Daily
.
toJson
(
result
)
Ok
(
jsonResult
)
Ok
(
jsonResult
)
}
catch
{
}
catch
{
...
@@ -51,11 +51,11 @@ class DailyController @Inject()(val controllerComponents: ControllerComponents)
...
@@ -51,11 +51,11 @@ class DailyController @Inject()(val controllerComponents: ControllerComponents)
/**
/**
* Create an Action to fetch the user's Feed.
* Create an Action to fetch the user's Feed.
*/
*/
def
getUserFeed
()
=
Action
{
def
getUserFeed
(
userId
:
String
)
=
Action
{
println
(
"DailyController:getUserFeed"
)
println
(
"DailyController:getUserFeed"
)
try
{
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
)
val
jsonResult
:
JsValue
=
Daily
.
toJson
(
result
)
Ok
(
jsonResult
)
Ok
(
jsonResult
)
}
catch
{
}
catch
{
...
@@ -67,12 +67,12 @@ class DailyController @Inject()(val controllerComponents: ControllerComponents)
...
@@ -67,12 +67,12 @@ class DailyController @Inject()(val controllerComponents: ControllerComponents)
/**
/**
* Create an Action to create a Daily.
* Create an Action to create a Daily.
*/
*/
def
create
()
=
Action
{
def
create
(
userId
:
String
,
questionId
:
String
,
content
:
String
)
=
Action
{
println
(
"DailyController:create"
)
println
(
"DailyController:create"
)
try
{
try
{
// Dummy data
// 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
)
val
jsonResult
:
JsValue
=
Daily
.
toJson
(
result
)
Ok
(
jsonResult
)
Ok
(
jsonResult
)
}
catch
{
}
catch
{
...
@@ -84,12 +84,12 @@ class DailyController @Inject()(val controllerComponents: ControllerComponents)
...
@@ -84,12 +84,12 @@ class DailyController @Inject()(val controllerComponents: ControllerComponents)
/**
/**
* Create an Action to like a Daily.
* Create an Action to like a Daily.
*/
*/
def
like
()
=
Action
{
def
like
(
dailyId
:
String
,
likerId
:
String
)
=
Action
{
println
(
"DailyController:like"
)
println
(
"DailyController:like"
)
try
{
try
{
// Dummy data
// Dummy data
Daily
.
likeAsync
(
new
ObjectId
(
"642314b4b9748f6794e9895b"
),
new
ObjectId
(
"641128f7e80bcd1ba39d04ae"
))
Daily
.
likeAsync
(
new
ObjectId
(
dailyId
),
new
ObjectId
(
likerId
))
Ok
(
"Updated"
)
Ok
(
"Updated"
)
}
catch
{
}
catch
{
case
_:
TimeoutException
=>
BadRequest
(
"Request timed out"
)
case
_:
TimeoutException
=>
BadRequest
(
"Request timed out"
)
...
@@ -102,12 +102,12 @@ class DailyController @Inject()(val controllerComponents: ControllerComponents)
...
@@ -102,12 +102,12 @@ class DailyController @Inject()(val controllerComponents: ControllerComponents)
/**
/**
* Create an Action to unlike a Daily.
* Create an Action to unlike a Daily.
*/
*/
def
unlike
()
=
Action
{
def
unlike
(
dailyId
:
String
,
likerId
:
String
)
=
Action
{
println
(
"DailyController:unlike"
)
println
(
"DailyController:unlike"
)
try
{
try
{
// Dummy data
// Dummy data
Daily
.
unlikeAsync
(
new
ObjectId
(
"642314b4b9748f6794e9895b"
),
new
ObjectId
(
"641128f7e80bcd1ba39d04ae"
))
Daily
.
unlikeAsync
(
new
ObjectId
(
dailyId
),
new
ObjectId
(
likerId
))
Ok
(
"Updated"
)
Ok
(
"Updated"
)
}
catch
{
}
catch
{
case
_:
TimeoutException
=>
BadRequest
(
"Request timed out"
)
case
_:
TimeoutException
=>
BadRequest
(
"Request timed out"
)
...
...
This diff is collapsed.
Click to expand it.
backend-services/feed-service/conf/routes
+
5
−
5
View file @
86283739
...
@@ -11,12 +11,12 @@ GET /assets/*file controllers.Assets.versioned(path="/public",
...
@@ -11,12 +11,12 @@ GET /assets/*file controllers.Assets.versioned(path="/public",
GET /daily/getAll controllers.DailyController.getAll()
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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment