-
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.
Merge pull request #482 from Shikkanime/dev
Dev
- Loading branch information
Showing
45 changed files
with
1,121 additions
and
141 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
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
66 changes: 66 additions & 0 deletions
66
src/main/kotlin/fr/shikkanime/controllers/api/MemberActionController.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,66 @@ | ||
package fr.shikkanime.controllers.api | ||
|
||
import com.google.inject.Inject | ||
import fr.shikkanime.dtos.MessageDto | ||
import fr.shikkanime.services.MemberActionService | ||
import fr.shikkanime.utils.routes.Controller | ||
import fr.shikkanime.utils.routes.JWTAuthenticated | ||
import fr.shikkanime.utils.routes.Path | ||
import fr.shikkanime.utils.routes.Response | ||
import fr.shikkanime.utils.routes.method.Post | ||
import fr.shikkanime.utils.routes.openapi.OpenAPI | ||
import fr.shikkanime.utils.routes.openapi.OpenAPIResponse | ||
import fr.shikkanime.utils.routes.param.BodyParam | ||
import fr.shikkanime.utils.routes.param.QueryParam | ||
import java.util.* | ||
|
||
@Controller("/api/v1/member-actions") | ||
class MemberActionController { | ||
@Inject | ||
private lateinit var memberActionService: MemberActionService | ||
|
||
@Path("/validate") | ||
@Post | ||
@JWTAuthenticated | ||
@OpenAPI( | ||
"Validate an action", | ||
[ | ||
OpenAPIResponse( | ||
200, | ||
"Action validated", | ||
Response::class | ||
), | ||
OpenAPIResponse( | ||
400, | ||
"UUID is required OR Action is required", | ||
MessageDto::class | ||
), | ||
], | ||
security = true | ||
) | ||
fun validateAction( | ||
@QueryParam("uuid", required = true) uuid: UUID?, | ||
@BodyParam action: String? | ||
): Response { | ||
if (uuid == null) { | ||
return Response.badRequest( | ||
MessageDto( | ||
MessageDto.Type.ERROR, | ||
"UUID is required" | ||
) | ||
) | ||
} | ||
|
||
if (action.isNullOrEmpty()) { | ||
return Response.badRequest( | ||
MessageDto( | ||
MessageDto.Type.ERROR, | ||
"Action is required" | ||
) | ||
) | ||
} | ||
|
||
memberActionService.validateAction(uuid, action) | ||
return Response.ok() | ||
} | ||
} |
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
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
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
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
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
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 fr.shikkanime.entities | ||
|
||
import fr.shikkanime.entities.enums.Action | ||
import jakarta.persistence.* | ||
import org.hibernate.annotations.Cache | ||
import org.hibernate.annotations.CacheConcurrencyStrategy | ||
import java.time.ZonedDateTime | ||
import java.util.* | ||
|
||
@Entity | ||
@Table(name = "member_action") | ||
@Cacheable | ||
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) | ||
class MemberAction( | ||
uuid: UUID? = null, | ||
@ManyToOne(optional = false, fetch = FetchType.LAZY) | ||
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) | ||
var member: Member? = null, | ||
@Column(nullable = false, name = "creation_date_time") | ||
var creationDateTime: ZonedDateTime = ZonedDateTime.now(), | ||
@Column(nullable = false, name = "update_date_time") | ||
var updateDateTime: ZonedDateTime = creationDateTime, | ||
@Column(nullable = false) | ||
var email: String? = null, | ||
@Column(nullable = false) | ||
@Enumerated(EnumType.STRING) | ||
var action: Action? = null, | ||
@Column(nullable = false) | ||
var validated: Boolean = false, | ||
@Column(nullable = false) | ||
var code: String? = null, | ||
) : ShikkEntity(uuid) |
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,5 @@ | ||
package fr.shikkanime.entities.enums | ||
|
||
enum class Action { | ||
VALIDATE_EMAIL, | ||
} |
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
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
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
Oops, something went wrong.