generated from ministryofjustice/hmpps-template-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adding enums and entity class app, users * updating entity data model class * updating entity classes * updating entity model class and adding test data generator * revertinng ddl auto alue to none * adding spring boo test annotations * refactoring, code clean up and tests
- Loading branch information
1 parent
6a9bb2b
commit 10a3de4
Showing
28 changed files
with
659 additions
and
15 deletions.
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
2 changes: 2 additions & 0 deletions
2
...in/kotlin/uk/gov/justice/digital/hmpps/managingprisonerappsapi/ManagingPrisonerAppsApi.kt
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
38 changes: 38 additions & 0 deletions
38
src/main/kotlin/uk/gov/justice/digital/hmpps/managingprisonerappsapi/model/App.kt
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,38 @@ | ||
package uk.gov.justice.digital.hmpps.managingprisonerappsapi.model | ||
|
||
import jakarta.persistence.ElementCollection | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import java.time.LocalDateTime | ||
import java.util.UUID | ||
|
||
@Entity | ||
data class App( | ||
@Id | ||
val id: UUID, | ||
val reference: String, | ||
val assignedGroup: UUID, | ||
val appType: AppType, | ||
val createdDate: LocalDateTime, | ||
val lastModifiedDateTime: LocalDateTime, | ||
val lastModifiedBy: UUID, | ||
@ElementCollection | ||
val comments: List<UUID>, | ||
// @ElementCollection | ||
// val requests: List<Map<String, JvmType.Object>>, | ||
val requestedDateTime: LocalDateTime, | ||
val requestedBy: UUID, | ||
) { | ||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as App | ||
|
||
return id == other.id | ||
} | ||
|
||
override fun hashCode(): Int { | ||
return id.hashCode() | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/kotlin/uk/gov/justice/digital/hmpps/managingprisonerappsapi/model/AppType.kt
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 uk.gov.justice.digital.hmpps.managingprisonerappsapi.model | ||
|
||
enum class AppType { | ||
PIN_PHONE_CREDIT_TOP_UP, | ||
PIN_PHONE_EMERGENCY_CREDIT_TOP_UP, | ||
PIN_PHONE_ADD_NEW_CONTACT, | ||
PIN_PHONE_REMOVE_CONTACT, | ||
PIN_PHONE_CREDIT_SWAP_VISITING_ORDERS, | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/kotlin/uk/gov/justice/digital/hmpps/managingprisonerappsapi/model/Comment.kt
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,39 @@ | ||
package uk.gov.justice.digital.hmpps.managingprisonerappsapi.model | ||
|
||
import jakarta.persistence.Column | ||
import jakarta.persistence.ElementCollection | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import jakarta.persistence.Table | ||
import java.time.LocalDateTime | ||
import java.util.* | ||
|
||
@Entity | ||
@Table(name = "comment") | ||
data class Comment( | ||
@Id | ||
val id: UUID, | ||
@Column(name = "message") | ||
val message: String, | ||
@Column(name = "created_date") | ||
val createdDate: LocalDateTime, | ||
@Column(name = "created_by") | ||
val createdBy: UUID, | ||
@ElementCollection | ||
val users: Set<UUID>, | ||
@Column(name = "app") | ||
val app: UUID, | ||
) { | ||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as Comment | ||
|
||
return id == other.id | ||
} | ||
|
||
override fun hashCode(): Int { | ||
return id.hashCode() | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/kotlin/uk/gov/justice/digital/hmpps/managingprisonerappsapi/model/Decision.kt
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,6 @@ | ||
package uk.gov.justice.digital.hmpps.managingprisonerappsapi.model | ||
|
||
enum class Decision { | ||
APPROVED, | ||
DECLINED, | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/kotlin/uk/gov/justice/digital/hmpps/managingprisonerappsapi/model/Establishment.kt
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,27 @@ | ||
package uk.gov.justice.digital.hmpps.managingprisonerappsapi.model | ||
|
||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import jakarta.persistence.Table | ||
import java.util.UUID | ||
|
||
@Entity | ||
@Table(name = "establishment") | ||
data class Establishment( | ||
@Id | ||
val id: UUID, | ||
val name: String, | ||
) { | ||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as Establishment | ||
|
||
return id == other.id | ||
} | ||
|
||
override fun hashCode(): Int { | ||
return id.hashCode() | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...in/kotlin/uk/gov/justice/digital/hmpps/managingprisonerappsapi/model/EstablishmentRole.kt
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,26 @@ | ||
package uk.gov.justice.digital.hmpps.managingprisonerappsapi.model | ||
|
||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import java.util.* | ||
|
||
@Entity | ||
data class EstablishmentRole( | ||
@Id | ||
val id: UUID, | ||
val establishment: UUID, | ||
val role: Role, | ||
) { | ||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as EstablishmentRole | ||
|
||
return id == other.id | ||
} | ||
|
||
override fun hashCode(): Int { | ||
return id.hashCode() | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/kotlin/uk/gov/justice/digital/hmpps/managingprisonerappsapi/model/GroupType.kt
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,6 @@ | ||
package uk.gov.justice.digital.hmpps.managingprisonerappsapi.model | ||
|
||
enum class GroupType { | ||
WING, | ||
DEPARTMENT, | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/kotlin/uk/gov/justice/digital/hmpps/managingprisonerappsapi/model/Groups.kt
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,34 @@ | ||
package uk.gov.justice.digital.hmpps.managingprisonerappsapi.model | ||
|
||
import jakarta.persistence.ElementCollection | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import jakarta.persistence.Table | ||
import java.util.UUID | ||
|
||
@Entity | ||
@Table(name = "groups") | ||
data class Groups( | ||
@Id | ||
val id: UUID, | ||
val name: String, | ||
val establishment: UUID, | ||
@ElementCollection | ||
val staffs: Set<UUID>, | ||
@ElementCollection | ||
val initialsApps: List<AppType>, | ||
val type: GroupType, | ||
) { | ||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as Groups | ||
|
||
return id == other.id | ||
} | ||
|
||
override fun hashCode(): Int { | ||
return id.hashCode() | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/kotlin/uk/gov/justice/digital/hmpps/managingprisonerappsapi/model/Prisoner.kt
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,28 @@ | ||
package uk.gov.justice.digital.hmpps.managingprisonerappsapi.model | ||
|
||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import java.util.UUID | ||
|
||
@Entity | ||
data class Prisoner( | ||
@Id | ||
val id: UUID, | ||
val firstName: String, | ||
val lastName: String, | ||
val category: UserCategory, | ||
val location: String, | ||
) { | ||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as Prisoner | ||
|
||
return id == other.id | ||
} | ||
|
||
override fun hashCode(): Int { | ||
return id.hashCode() | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/kotlin/uk/gov/justice/digital/hmpps/managingprisonerappsapi/model/Response.kt
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,31 @@ | ||
package uk.gov.justice.digital.hmpps.managingprisonerappsapi.model | ||
|
||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import jakarta.persistence.Table | ||
import java.time.LocalDateTime | ||
import java.util.UUID | ||
|
||
@Entity | ||
@Table(name = "response") | ||
data class Response( | ||
@Id | ||
val id: UUID, | ||
val reason: String, | ||
val decision: Decision, | ||
val createdDate: LocalDateTime, | ||
val createdBy: UUID, | ||
) { | ||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as Response | ||
|
||
return id == other.id | ||
} | ||
|
||
override fun hashCode(): Int { | ||
return id.hashCode() | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/kotlin/uk/gov/justice/digital/hmpps/managingprisonerappsapi/model/Role.kt
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,6 @@ | ||
package uk.gov.justice.digital.hmpps.managingprisonerappsapi.model | ||
|
||
enum class Role { | ||
ADMIN, | ||
USER, | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/kotlin/uk/gov/justice/digital/hmpps/managingprisonerappsapi/model/Staff.kt
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,31 @@ | ||
package uk.gov.justice.digital.hmpps.managingprisonerappsapi.model | ||
|
||
import jakarta.persistence.ElementCollection | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import java.util.* | ||
|
||
@Entity | ||
data class Staff( | ||
@Id | ||
val id: UUID, | ||
val firstName: String, | ||
val lastName: String, | ||
val category: UserCategory, | ||
@ElementCollection | ||
val roles: Set<UUID>, | ||
val jobTitle: String, | ||
) { | ||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as Staff | ||
|
||
return id == other.id | ||
} | ||
|
||
override fun hashCode(): Int { | ||
return id.hashCode() | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/kotlin/uk/gov/justice/digital/hmpps/managingprisonerappsapi/model/UserCategory.kt
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,6 @@ | ||
package uk.gov.justice.digital.hmpps.managingprisonerappsapi.model | ||
|
||
enum class UserCategory() { | ||
STAFF, | ||
PRISONER, | ||
} |
9 changes: 9 additions & 0 deletions
9
...n/kotlin/uk/gov/justice/digital/hmpps/managingprisonerappsapi/repository/AppRepository.kt
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 uk.gov.justice.digital.hmpps.managingprisonerappsapi.repository | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository | ||
import org.springframework.stereotype.Repository | ||
import uk.gov.justice.digital.hmpps.managingprisonerappsapi.model.App | ||
import java.util.UUID | ||
|
||
@Repository | ||
interface AppRepository : JpaRepository<App, UUID> |
9 changes: 9 additions & 0 deletions
9
...tlin/uk/gov/justice/digital/hmpps/managingprisonerappsapi/repository/CommentRepository.kt
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 uk.gov.justice.digital.hmpps.managingprisonerappsapi.repository | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository | ||
import org.springframework.stereotype.Repository | ||
import uk.gov.justice.digital.hmpps.managingprisonerappsapi.model.Comment | ||
import java.util.UUID | ||
|
||
@Repository | ||
interface CommentRepository : JpaRepository<Comment, UUID> |
9 changes: 9 additions & 0 deletions
9
...kotlin/uk/gov/justice/digital/hmpps/managingprisonerappsapi/repository/GroupRepository.kt
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 uk.gov.justice.digital.hmpps.managingprisonerappsapi.repository | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository | ||
import org.springframework.stereotype.Repository | ||
import uk.gov.justice.digital.hmpps.managingprisonerappsapi.model.Groups | ||
import java.util.UUID | ||
|
||
@Repository | ||
interface GroupRepository : JpaRepository<Groups, UUID> |
9 changes: 9 additions & 0 deletions
9
...lin/uk/gov/justice/digital/hmpps/managingprisonerappsapi/repository/ResponseRepository.kt
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 uk.gov.justice.digital.hmpps.managingprisonerappsapi.repository | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository | ||
import org.springframework.stereotype.Repository | ||
import uk.gov.justice.digital.hmpps.managingprisonerappsapi.model.Response | ||
import java.util.UUID | ||
|
||
@Repository | ||
interface ResponseRepository : JpaRepository<Response, UUID> |
Oops, something went wrong.