Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
e-learning platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2020-027
e-learning platform
Commits
6ef5898d
Commit
6ef5898d
authored
Apr 17, 2020
by
Shaini Thenuwara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create getAllPost function (backend)
parent
993bbc41
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
136 additions
and
0 deletions
+136
-0
Back-end/elearning/src/main/java/com/cdap_2020_027/elearning/controller/PostController.java
...om/cdap_2020_027/elearning/controller/PostController.java
+37
-0
Back-end/elearning/src/main/java/com/cdap_2020_027/elearning/model/Post.java
...src/main/java/com/cdap_2020_027/elearning/model/Post.java
+64
-0
Back-end/elearning/src/main/java/com/cdap_2020_027/elearning/repository/PostRepository.java
...om/cdap_2020_027/elearning/repository/PostRepository.java
+12
-0
Back-end/elearning/src/main/java/com/cdap_2020_027/elearning/service/PostServiceImpl.java
.../com/cdap_2020_027/elearning/service/PostServiceImpl.java
+23
-0
No files found.
Back-end/elearning/src/main/java/com/cdap_2020_027/elearning/controller/PostController.java
0 → 100644
View file @
6ef5898d
package
com.cdap_2020_027.elearning.controller
;
import
com.cdap_2020_027.elearning.model.Post
;
import
com.cdap_2020_027.elearning.service.PostServiceImpl
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
/**
*
* @author IT17120012 - Shaini
*/
@RestController
@CrossOrigin
public
class
PostController
{
@Autowired
PostServiceImpl
postServiceImpl
;
/* get Post Details */
@RequestMapping
(
value
=
"/post"
,
method
=
RequestMethod
.
GET
)
public
ResponseEntity
<
List
<
Post
>>
getAllPost
()
{
try
{
List
<
Post
>
postList
=
postServiceImpl
.
getAllPost
();
return
new
ResponseEntity
<>(
postList
,
HttpStatus
.
OK
);
}
catch
(
Exception
ex
)
{
System
.
out
.
println
(
ex
);
return
new
ResponseEntity
<>(
null
,
HttpStatus
.
INTERNAL_SERVER_ERROR
);
}
}
}
Back-end/elearning/src/main/java/com/cdap_2020_027/elearning/model/Post.java
0 → 100644
View file @
6ef5898d
package
com.cdap_2020_027.elearning.model
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
/**
*
* @author IT17120012 - Shaini
*/
@Entity
@Table
(
name
=
"post"
)
public
class
Post
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Column
(
name
=
"ID"
)
private
Integer
id
;
@Column
(
name
=
"TITLE"
)
private
String
title
;
@Column
(
name
=
"CONTENT"
)
private
String
content
;
@Column
(
name
=
"IMAGE"
)
private
String
image
;
public
Integer
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
String
getContent
()
{
return
content
;
}
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
}
public
String
getImage
()
{
return
image
;
}
public
void
setImage
(
String
image
)
{
this
.
image
=
image
;
}
}
Back-end/elearning/src/main/java/com/cdap_2020_027/elearning/repository/PostRepository.java
0 → 100644
View file @
6ef5898d
package
com.cdap_2020_027.elearning.repository
;
import
com.cdap_2020_027.elearning.model.Post
;
import
org.springframework.data.jpa.repository.JpaRepository
;
/**
*
* @author IT17120012 - Shaini
*/
public
interface
PostRepository
extends
JpaRepository
<
Post
,
Integer
>{
}
Back-end/elearning/src/main/java/com/cdap_2020_027/elearning/service/PostServiceImpl.java
0 → 100644
View file @
6ef5898d
package
com.cdap_2020_027.elearning.service
;
import
com.cdap_2020_027.elearning.model.Post
;
import
com.cdap_2020_027.elearning.repository.PostRepository
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
*
* @author IT17120012 - Shaini
*/
@Service
public
class
PostServiceImpl
{
@Autowired
PostRepository
postRepository
;
public
List
<
Post
>
getAllPost
()
{
return
postRepository
.
findAll
();
}
}
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