Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
student-personal-details-spring-boot
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
student-details-microservice
student-personal-details-spring-boot
Commits
a51c8c01
Commit
a51c8c01
authored
Apr 05, 2021
by
Darrick Yong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set up connection with local db
parent
f7ac1395
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
7 deletions
+17
-7
DetailsController.java
...va/com/student/details/controllers/DetailsController.java
+11
-2
Student.java
src/main/java/com/student/details/models/Student.java
+1
-1
StudentRepository.java
...a/com/student/details/repositories/StudentRepository.java
+1
-0
create_tables.sql
src/main/resources/create_tables.sql
+3
-3
insert_data.sql
src/main/resources/insert_data.sql
+1
-1
No files found.
src/main/java/com/student/details/controllers/DetailsController.java
View file @
a51c8c01
package
com
.
student
.
details
.
controllers
;
import
com.student.details.models.Student
;
import
com.student.details.services.StudentService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
@CrossOrigin
(
origins
=
"*"
)
@RestController
@RequestMapping
(
"/api"
)
public
class
DetailsController
{
@Autowired
StudentService
studentService
;
@GetMapping
(
"/students"
)
public
void
index
()
{
System
.
out
.
println
(
"This is the students index route."
);
public
List
<
Student
>
getAllStudents
()
{
// System.out.println("This is the students index route.");
return
studentService
.
findAllStudents
();
}
}
src/main/java/com/student/details/models/Student.java
View file @
a51c8c01
...
...
@@ -4,7 +4,7 @@ import javax.persistence.*;
import
java.time.LocalDate
;
@Entity
@Table
(
name
=
"student"
)
@Table
(
name
=
"student
_details
"
)
public
class
Student
{
@Id
...
...
src/main/java/com/student/details/repositories/StudentRepository.java
View file @
a51c8c01
...
...
@@ -6,5 +6,6 @@ import org.springframework.stereotype.Repository;
@Repository
public
interface
StudentRepository
extends
JpaRepository
<
Student
,
Long
>
{
}
src/main/resources/create_tables.sql
View file @
a51c8c01
...
...
@@ -2,9 +2,9 @@ CREATE TABLE student_details
(
id
SERIAL
PRIMARY
KEY
,
email
VARCHAR
(
100
)
UNIQUE
NOT
NULL
,
first
N
ame
VARCHAR
(
100
)
NOT
NULL
,
last
N
ame
VARCHAR
(
100
)
NOT
NULL
,
date
OfBirth
DATE
NOT
NULL
,
first
_n
ame
VARCHAR
(
100
)
NOT
NULL
,
last
_n
ame
VARCHAR
(
100
)
NOT
NULL
,
date
_of_birth
DATE
NOT
NULL
,
course
VARCHAR
(
100
)
NOT
NULL
);
src/main/resources/insert_data.sql
View file @
a51c8c01
INSERT
INTO
student_details
(
email
,
first
Name
,
lastName
,
dateOfB
irth
,
course
)
INSERT
INTO
student_details
(
email
,
first
_name
,
last_name
,
date_of_b
irth
,
course
)
VALUES
(
'dyong@nisum.com'
,
'Darrick'
,
'Yong'
,
DATE
(
'1990-09-08'
),
'Math'
),
(
'apinto@nisum.com'
,
'Alex'
,
'Pinto'
,
DATE
(
'1997-07-04'
),
'English'
),
(
'banderson@nisum.com'
,
'Ben'
,
'Anderson'
,
DATE
(
'1993-09-20'
),
'Chemistry'
),
...
...
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