e07ee318a7
Release package / release (push) Successful in 9m5s
Co-authored-by: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com> Reviewed-on: #26
31 lines
823 B
Java
31 lines
823 B
Java
package com.drinkool.services;
|
|
|
|
import com.drinkool.InternalValue;
|
|
import com.drinkool.Url;
|
|
import com.drinkool.models.UserModel;
|
|
import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase;
|
|
import jakarta.transaction.Transactional;
|
|
import jakarta.ws.rs.*;
|
|
import jakarta.ws.rs.core.Response;
|
|
import java.util.UUID;
|
|
|
|
public abstract class BaseService<T extends UserModel> {
|
|
|
|
private final PanacheRepositoryBase<T, UUID> repository;
|
|
|
|
protected BaseService(Class<T> entityClass) {
|
|
this.repository = new PanacheRepositoryBase<T, UUID>() {};
|
|
}
|
|
|
|
@GET
|
|
@Path(Url.Me)
|
|
@Transactional
|
|
public Response me(@HeaderParam(InternalValue.userId) UUID id) {
|
|
if (id == null) return Response.status(Response.Status.BAD_REQUEST)
|
|
.entity("InvalidUserId")
|
|
.build();
|
|
|
|
return Response.ok(repository.findById(id)).build();
|
|
}
|
|
}
|