Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SponsorController.java
package com.iamvickyav.springboot.SpringBootRestWithH2;

import com.iamvickyav.springboot.SpringBootRestWithH2.model.Sponsor;
import com.iamvickyav.springboot.SpringBootRestWithH2.service.SponsorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class SponsorController {
@Autowired
private SponsorService sponsorService;

@PostMapping("/sponsors")
public Sponsor createSponsor(@RequestBody Sponsor sponsor) {
return sponsorService.save(sponsor);
}

// other CRUD operations as per requirement
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Sponsor.java
package com.iamvickyav.springboot.SpringBootRestWithH2.model;

import javax.persistence.*;

@Entity
@Table(name = "sponsors")
public class Sponsor {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;

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

// getters and setters
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SponsorService.java
package com.iamvickyav.springboot.SpringBootRestWithH2.service;

import com.iamvickyav.springboot.SpringBootRestWithH2.model.Sponsor;
import org.springframework.data.jpa.repository.JpaRepository;

public interface SponsorService extends JpaRepository<Sponsor, Integer> {
}