Skip to content

Reduce 80% code & create automated CRUD operation of Rest API with atomic-spring-boot-rest-api

Notifications You must be signed in to change notification settings

alex31n/atomic-spring-boot-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Atomic Spring Boot REST API

A collection of boilerplate code and libraries for developing REST API with String Boot

The aim of creating this project to reduce boilerplate code. It can help you to faster way developing CURD-based Rest API and reduce more than 80% of code.

How to use

Just create 4 class and extend their base class. Just it.

Model

@Entity(name = "post")
public class Post  extends IdEntity {

    @NotBlank
    @Column(name = "title")
    private String title;

    @NotBlank
    @Column(name = "content")
    private String content;

    // ----------------------
}

Repository

@Repository
public interface PostRepository extends BaseRepository<Post> {
}

Service

@Service
@Transactional
public class PostService extends BaseService<Post, PostRepository> {
    public PostService(PostRepository repository) {
        super(repository, "Post");  // "Post" is the model name
    }
}

Controller

@RestController
@RequestMapping("post")
@Tag(name = "Posts")
public class PostController extends BaseController<Post, PostService> {
    public PostController(PostService service) {
        super(service);
    }
}

You are done. It will create CRUD API and documentation for you. For example

API ENDPOINT
[GET] /post (purpose for filtering/searching, pagination and sorting, detail below) 
[POST] /post
[GET] /post/{postId}
[PUT] /post/{postId}
[DELETE] /post/{postId}
API Documentation
{HOST}/docs
API Filter/Search

[GET] /user?search="name==*Alex*"&page=0&size=10&sort=name

Syntax Reference: RSQL / FIQL parser

Used technologies

Contribution

Your contribution is most welcome

About

Reduce 80% code & create automated CRUD operation of Rest API with atomic-spring-boot-rest-api

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages