Skip to content
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

CCMSPUI-453: Implement Get Notifications Endpoint #122

Merged
merged 15 commits into from
Dec 19, 2024
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Added CaseReferenceController and NewCaseReferenceRepository
Signed-off-by: Jamie Briggs <jamie.briggs@digital.justice.gov.uk>
JamieBriggs-MoJ committed Dec 10, 2024
commit af29e97b9f4d828947a6062a8b14d3ff4dda74cf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package uk.gov.laa.ccms.data.controller;

import lombok.AllArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
import uk.gov.laa.ccms.data.api.CaseReferenceApi;
import uk.gov.laa.ccms.data.model.CaseReferenceSummary;
import uk.gov.laa.ccms.data.repository.NewCaseReferenceRepository;

@RestController
@AllArgsConstructor
public class CaseReferenceController implements CaseReferenceApi {

private final NewCaseReferenceRepository newCaseReferenceRepository;

@Override
public ResponseEntity<CaseReferenceSummary> postCaseReference() {
// TODO: Need to use a proper mapper still, just testing if this repository works with view
String nextCaseReference = newCaseReferenceRepository.getNextCaseReference();
return new ResponseEntity<>(new CaseReferenceSummary().caseReferenceNumber(nextCaseReference), HttpStatus.CREATED);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package uk.gov.laa.ccms.data.entity;

import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.io.Serializable;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Immutable;

@Getter
@EqualsAndHashCode
@Entity
@NoArgsConstructor
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
@Table(name = "XXCCMS_GENERATE_V")
@Immutable
public class CaseReference implements Serializable {

@Id
@Column(name = "NEW_CASE_REFERENCE")
private String caseReference;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package uk.gov.laa.ccms.data.repository;

import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import uk.gov.laa.ccms.data.entity.CaseReference;

/**
* <p>This interface defines a repository for managing CaseReference entities in a read-only manner.
* It extends {@link ReadOnlyRepository} with {@link CaseReference} as the entity type
* and String as the primary key type.</p>
*
* <p>The NewCaseReferenceRepository provides a custom query method to retrieve the next case reference.</p>
*
* @author Jamie Briggs
* @see CaseReference
*/
@Repository
public interface NewCaseReferenceRepository
extends ReadOnlyRepository<CaseReference, String> {

/**
* Retrieves the next case reference from the {@link CaseReference} entity.
*
* @return the next case reference as a {@link String}
*/
@Query("SELECT nextRef.caseReference FROM CaseReference nextRef")
String getNextCaseReference();
}