-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Created NPO Service #23
Open
Mush222
wants to merge
26
commits into
main
Choose a base branch
from
feature/npos
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 17 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
1b1a823
added npo class
Mush222 75b8656
added name property to NPO model
Dingwer 7471e16
Merge branch 'main' of https://github.com/stevensblueprint/blueprint_…
Mush222 e87f659
started adding the assigned team in NPO
Mush222 1511757
created npo model
Dingwer 2355903
Created Files for NPO Endpoints
butterman0423 117398e
Created NPORepository and templates for service
butterman0423 a750109
Added public access modifier
butterman0423 67e6fcf
commited first 3 methods of NPOServiceImpl
Dingwer 2d2601d
Controller template, fixes in NPO model
butterman0423 57c0f0a
Merge branch 'feature/npos' of github.com:stevensblueprint/blueprint_…
butterman0423 9d73f33
Implemented NPOs Controller, Marked NPO Service as @Service
butterman0423 65baeec
Fixed NPOs model to better fit schema, Resolved init.sql syntax errors
butterman0423 f7f9e55
completed NPOServiceImpl.java
Dingwer 19adc8e
Merge branch 'dev/feature/npos' into feature/npos
butterman0423 fa63ccf
Merge branch 'feature/npos' of github.com:stevensblueprint/blueprint_…
butterman0423 9a83ad4
Added update NPO route for NPO Controller
butterman0423 82dbbaa
Edited SQL init file to allow for testing. Moved NPO FK declaration
butterman0423 fefca49
Resolve PR comment: /api/v1/npos/{id} mapping
butterman0423 93f3588
Commented out setting Date of Recruitment in CRUD
butterman0423 bd55346
Changed field name to align with npos schema
butterman0423 32ea709
Merge branch 'main' into dev/feature/npos
butterman0423 75e8639
Resolved init.sql merge conflict; adjusted NPOS syntax to align with …
butterman0423 ac26f28
Removed duplicate alter statement
butterman0423 4922c43
Run ./gradlew :spotlessApply
butterman0423 724bacb
Merge branch 'main' into feature/npos
butterman0423 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/com/sitblueprint/admin/controller/users/NPOController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.sitblueprint.admin.controller.users; | ||
|
||
import com.sitblueprint.admin.model.npos.NPO; | ||
import com.sitblueprint.admin.service.users.NPOService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/npos/") | ||
public class NPOController { | ||
|
||
@Autowired | ||
NPOService npoService; | ||
|
||
@GetMapping("all") | ||
public List<NPO> getAllNPOs() { return npoService.getAllNPOs(); } | ||
|
||
@GetMapping | ||
public NPO getNPOById(@Param("npoId") String npoId) { return npoService.getNPOById(Long.parseLong(npoId)); } | ||
|
||
@PostMapping | ||
public NPO createNPO(@RequestBody NPO npo) { return npoService.createNPO(npo); } | ||
|
||
@PutMapping | ||
public NPO updateNPO(@RequestBody NPO npo) { return npoService.updateNPO(npo); } | ||
|
||
@DeleteMapping | ||
public void deleteNPO(String npoId) { npoService.deleteNPOById(Long.parseLong(npoId)); } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.sitblueprint.admin.model.npos; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import com.sitblueprint.admin.model.users.Team; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Entity | ||
@Table(name = "npos") | ||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class NPO { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private long id; | ||
|
||
@Column(nullable = false) | ||
private String name; | ||
|
||
@OneToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "team_id") | ||
private Team teamAssigned; | ||
|
||
@Column(nullable = false) | ||
private String url; | ||
|
||
@Column(nullable = false) | ||
private LocalDate dateOfRecruitment; | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/sitblueprint/admin/repository/users/NPORepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.sitblueprint.admin.repository.users; | ||
|
||
import com.sitblueprint.admin.model.npos.NPO; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface NPORepository extends JpaRepository<NPO, Long> { | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/sitblueprint/admin/service/users/NPOService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.sitblueprint.admin.service.users; | ||
|
||
import com.sitblueprint.admin.model.npos.NPO; | ||
import com.sitblueprint.admin.model.users.Team; | ||
|
||
import java.util.List; | ||
|
||
public interface NPOService { | ||
List<NPO> getAllNPOs(); | ||
|
||
NPO getNPOById(Long id); | ||
|
||
NPO createNPO(NPO npo); | ||
|
||
NPO updateNPO(NPO npo); | ||
|
||
void deleteNPOById(Long id); | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/com/sitblueprint/admin/service/users/NPOServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.sitblueprint.admin.service.users; | ||
|
||
import com.sitblueprint.admin.model.npos.NPO; | ||
import com.sitblueprint.admin.repository.users.NPORepository; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@Service | ||
public class NPOServiceImpl implements NPOService { | ||
|
||
NPORepository npoRepository; | ||
|
||
public NPOServiceImpl(NPORepository npoRepository) { | ||
this.npoRepository = npoRepository; | ||
} | ||
|
||
@Override | ||
public List<NPO> getAllNPOs() { | ||
return npoRepository.findAll(); | ||
} | ||
|
||
@Override | ||
public NPO getNPOById(Long id) { | ||
return npoRepository.findById(id).orElse(null); | ||
} | ||
|
||
@Override | ||
public NPO createNPO(NPO npo) { | ||
npo.setDateOfRecruitment(LocalDate.now()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean you want us to remove the function or when it saves the time created? |
||
return npoRepository.save(npo); | ||
} | ||
|
||
@Override | ||
public NPO updateNPO(NPO npo) { | ||
return npoRepository.saveAndFlush(npo); | ||
} | ||
|
||
@Override | ||
public void deleteNPOById(Long id) { | ||
npoRepository.deleteById(id); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GetMapping("/{id}")