Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
Student-Marks-Microservice
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vishal Vaddadhi
Student-Marks-Microservice
Commits
83fc091d
Commit
83fc091d
authored
Apr 02, 2021
by
Shanelle Valencia
Browse files
Options
Browse Files
Download
Plain Diff
Pull from master
parents
1229cb4c
787f79e7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
91 additions
and
23 deletions
+91
-23
.gitignore
.gitignore
+1
-0
StudentMarksController.java
...vices/MarksService/controller/StudentMarksController.java
+17
-19
ErrorDetails.java
.../StudentServices/MarksService/exception/ErrorDetails.java
+40
-0
GlobalExceptionHandler.java
...rvices/MarksService/exception/GlobalExceptionHandler.java
+15
-0
ResourceNotFoundException.java
...ces/MarksService/exception/ResourceNotFoundException.java
+11
-0
StudentService.java
.../StudentServices/MarksService/service/StudentService.java
+7
-4
No files found.
.gitignore
View file @
83fc091d
#HELP.md
#.gradle
build/
.gradle
#!gradle/wrapper/gradle-wrapper.jar
#!**/src/main/**/build/
#!**/src/test/**/build/
...
...
src/main/java/com/StudentServices/MarksService/controller/StudentMarksController.java
View file @
83fc091d
package
com
.
StudentServices
.
MarksService
.
controller
;
import
com.StudentServices.MarksService.exception.ResourceNotFoundException
;
import
com.StudentServices.MarksService.model.StudentMarks
;
import
com.StudentServices.MarksService.service.StudentService
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -22,29 +23,26 @@ public class StudentMarksController {
@Autowired
StudentService
studentService
;
// (GET) findall studentmarks
@GetMapping
@GetMapping
(
"/studentMarks"
)
ResponseEntity
<
List
<
StudentMarks
>>
findAllStudentMarks
(){
return
ResponseEntity
.
ok
(
studentService
.
findAllStudents
());
}
// (POST) create studentmark
@PostMapping
(
"/studentMarks"
)
public
ResponseEntity
<
StudentMarks
>
createMarks
(
@RequestBody
StudentMarks
studentMarks
)
{
StudentMarks
studentMarks1
=
studentService
.
addStudent
(
studentMarks
);
return
ResponseEntity
.
ok
().
body
(
studentMarks1
);
return
ResponseEntity
.
ok
(
studentService
.
addStudent
(
studentMarks
));
}
// (GET) find studentmark by id
@GetMapping
ResponseEntity
<
StudentMarks
>
findStudentMarksById
(
String
id
){
StudentMarks
sm
=
studentService
.
getStudentById
(
id
);
if
(
sm
==
null
){
return
new
ResponseEntity
<>(
HttpStatus
.
NOT_FOUND
);
}
else
{
return
ResponseEntity
.
ok
(
sm
);
}
@GetMapping
(
"/studentMarks/{id}"
)
ResponseEntity
<
StudentMarks
>
findStudentMarksById
(
@PathVariable
String
id
)
throws
ResourceNotFoundException
{
StudentMarks
sm
=
studentService
.
getStudentById
(
id
).
orElseThrow
(
()
->
new
ResourceNotFoundException
(
"Student Marks not found... "
+
id
));
return
ResponseEntity
.
ok
(
sm
);
}
//
// // Get a particular employee
// // GET: http://localhost:8080/api/v1/employees/__num__
...
...
@@ -71,13 +69,13 @@ public class StudentMarksController {
@PutMapping
(
"/studentMarks/update/{emailAddress}"
)
public
ResponseEntity
<
StudentMarks
>
updateStudentMarks
(
@PathVariable
(
value
=
"emailAddress"
)
String
emailAddressId
)
throws
ConfigDataResourceNotFoundException
{
StudentMarks
studentMarks
=
studentService
.
getStudentById
(
emailAddressId
)
final
StudentMarks
updatedStudentMarks
=
studentService
.
editStudentMarks
(
studentMarks
);
return
ResponseEntity
.
ok
(
updatedStudentMarks
);
}
//
@PutMapping("/studentMarks/update/{emailAddress}")
//
public ResponseEntity<StudentMarks> updateStudentMarks(@PathVariable (value= "emailAddress") String emailAddressId) throws ConfigDataResourceNotFoundException {
// StudentMarks studentMarks = studentService.getStudentById(emailAddressId);
//
//
final StudentMarks updatedStudentMarks = studentService.editStudentMarks(studentMarks);
//
return ResponseEntity.ok(updatedStudentMarks);
//
}
...
...
src/main/java/com/StudentServices/MarksService/exception/ErrorDetails.java
0 → 100644
View file @
83fc091d
package
com
.
StudentServices
.
MarksService
.
exception
;
import
java.util.Date
;
public
class
ErrorDetails
{
private
Date
timestamp
;
private
String
message
;
private
String
details
;
public
ErrorDetails
(
Date
timestamp
,
String
message
,
String
details
)
{
this
.
timestamp
=
timestamp
;
this
.
message
=
message
;
this
.
details
=
details
;
}
public
Date
getTimestamp
()
{
return
timestamp
;
}
public
void
setTimestamp
(
Date
timestamp
)
{
this
.
timestamp
=
timestamp
;
}
public
String
getMessage
()
{
return
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
public
String
getDetails
()
{
return
details
;
}
public
void
setDetails
(
String
details
)
{
this
.
details
=
details
;
}
}
src/main/java/com/StudentServices/MarksService/exception/GlobalExceptionHandler.java
0 → 100644
View file @
83fc091d
package
com
.
StudentServices
.
MarksService
.
exception
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.context.request.WebRequest
;
import
org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
;
import
java.util.Date
;
public
class
GlobalExceptionHandler
extends
ResponseEntityExceptionHandler
{
public
ResponseEntity
<?>
resourceNotFoundException
(
ResourceNotFoundException
ex
,
WebRequest
webRequest
)
{
ErrorDetails
errorDetails
=
new
ErrorDetails
(
new
Date
(),
ex
.
getMessage
(),
webRequest
.
getDescription
(
false
));
return
new
ResponseEntity
<>(
errorDetails
,
HttpStatus
.
NOT_FOUND
);
}
}
\ No newline at end of file
src/main/java/com/StudentServices/MarksService/exception/ResourceNotFoundException.java
0 → 100644
View file @
83fc091d
package
com
.
StudentServices
.
MarksService
.
exception
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
@ResponseStatus
(
value
=
HttpStatus
.
NOT_FOUND
)
public
class
ResourceNotFoundException
extends
Exception
{
public
ResourceNotFoundException
(
String
message
)
{
super
(
message
);
}
}
\ No newline at end of file
src/main/java/com/StudentServices/MarksService/service/StudentService.java
View file @
83fc091d
...
...
@@ -20,7 +20,7 @@ public class StudentService {
public
List
<
StudentMarks
>
findAllStudents
()
{
return
null
;
return
studentRepository
.
findAll
()
;
}
public
StudentMarks
addStudent
(
StudentMarks
studentMarks
)
{
...
...
@@ -28,12 +28,15 @@ public class StudentService {
}
public
StudentMarks
getStudentById
(
String
ID
)
{
Optional
<
StudentMarks
>
sm
=
studentRepository
.
findById
(
ID
);
return
s
m
.
orElse
(
null
);
public
Optional
<
StudentMarks
>
getStudentById
(
String
ID
)
{
return
s
tudentRepository
.
findById
(
ID
);
}
public
void
updateStudent
(
StudentMarks
studentMarks
)
{}
public
StudentMarks
editStudentMarks
(
StudentMarks
studentMarks
)
{
studentMarks
.
setMarks
(
studentMarks
.
getMarks
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment