added CourseTee access
This commit is contained in:
@@ -2,10 +2,12 @@ package com.poststats.golf.rs.api;
|
||||
|
||||
import com.poststats.golf.rs.api.model.Course;
|
||||
import com.poststats.golf.rs.api.model.CourseNine;
|
||||
import com.poststats.golf.rs.api.model.CourseTee;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Positive;
|
||||
@@ -17,10 +19,12 @@ import jakarta.ws.rs.Produces;
|
||||
/**
|
||||
* @author brian.long@poststats.com
|
||||
*/
|
||||
@Path("/golf/course/{courseId}")
|
||||
@Path("/golf/course/{courseId:[0-9]+}")
|
||||
@Tag(name = "Course API")
|
||||
@ApiResponse(responseCode = "200", description = "Success")
|
||||
@ApiResponses({
|
||||
@ApiResponse(responseCode = "200", description = "Success"),
|
||||
@ApiResponse(responseCode = "404", description = "A golf course with the specified ID could not be found")
|
||||
})
|
||||
public interface CourseApi {
|
||||
|
||||
@GET
|
||||
@@ -29,27 +33,35 @@ public interface CourseApi {
|
||||
summary = "Retrieves meta-data about a course.",
|
||||
description = "Retreives name, location, and other direct meta-data about the specified course."
|
||||
)
|
||||
public abstract Course get(@Parameter(description = "A unique identifier for a golf course")
|
||||
Course get(@Parameter(description = "A unique identifier for a golf course")
|
||||
@NotNull @Positive @PathParam("courseId") int courseId);
|
||||
|
||||
@GET
|
||||
@Path("/nine/byName/{name}")
|
||||
@Produces(Constants.V1_JSON)
|
||||
@Operation(
|
||||
summary = "Retrieves meta-data about a course nine.",
|
||||
description = "Retreives name, location, and other direct meta-data about the specified course."
|
||||
)
|
||||
public abstract CourseNine getNine(@Parameter(description = "A unique identifier for a golf course")
|
||||
@Operation(summary = "Retrieves meta-data about a course nine.")
|
||||
CourseNine getNine(@Parameter(description = "A unique identifier for a golf course")
|
||||
@NotNull @Positive @PathParam("courseId") int courseId, @PathParam("name") String name);
|
||||
|
||||
@GET
|
||||
@Path("/nine/{nineId:[0-9]+}")
|
||||
@Produces(Constants.V1_JSON)
|
||||
@Operation(
|
||||
summary = "Retrieves limited meta-data about a course nine.",
|
||||
description = "Retreives name, location, and other direct meta-data about the specified course."
|
||||
)
|
||||
public abstract CourseNine getNine(@Parameter(description = "A unique identifier for a golf course")
|
||||
@Operation(summary = "Retrieves limited meta-data about a course nine.")
|
||||
CourseNine getNine(@Parameter(description = "A unique identifier for a golf course")
|
||||
@NotNull @Positive @PathParam("courseId") int courseId, @PathParam("nineId") long courseNineId);
|
||||
|
||||
@GET
|
||||
@Path("/nine/byName/{name}")
|
||||
@Produces(Constants.V1_JSON)
|
||||
@Operation(summary = "Retrieves meta-data about a course tee.")
|
||||
CourseTee getTee(@Parameter(description = "A unique identifier for a golf course")
|
||||
@NotNull @Positive @PathParam("courseId") int courseId, @PathParam("name") String name);
|
||||
|
||||
@GET
|
||||
@Path("/nine/{nineId:[0-9]+}")
|
||||
@Produces(Constants.V1_JSON)
|
||||
@Operation(summary = "Retrieves limited meta-data about a course tee.")
|
||||
CourseTee getTee(@Parameter(description = "A unique identifier for a golf course")
|
||||
@NotNull @Positive @PathParam("courseId") int courseId, @PathParam("teeId") long courseTeeId);
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,62 @@
|
||||
package com.poststats.golf.rs.api.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.poststats.rs.api.annotation.MapEntry;
|
||||
import com.poststats.rs.api.model.BaseModel;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public abstract class BaseCourseTee<ConcreteT extends BaseCourseTee<ConcreteT>> extends BaseModel<ConcreteT> {
|
||||
|
||||
@JsonProperty
|
||||
@MapEntry("tee")
|
||||
private String name;
|
||||
|
||||
@JsonProperty
|
||||
@MapEntry("teeColor")
|
||||
private String color;
|
||||
|
||||
@JsonProperty
|
||||
@MapEntry("primaryGender")
|
||||
private char primaryGender;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public char getPrimaryGender() {
|
||||
return primaryGender;
|
||||
}
|
||||
|
||||
public void setPrimaryGender(char gender) {
|
||||
this.primaryGender = gender;
|
||||
}
|
||||
|
||||
public ConcreteT withName(String name) {
|
||||
this.name = name;
|
||||
return this.withThis();
|
||||
}
|
||||
|
||||
public ConcreteT withColor(String color) {
|
||||
this.color = color;
|
||||
return this.withThis();
|
||||
}
|
||||
|
||||
public ConcreteT withPrimaryGender(char gender) {
|
||||
this.primaryGender = gender;
|
||||
return this.withThis();
|
||||
}
|
||||
|
||||
}
|
112
src/main/java/com/poststats/golf/rs/api/model/CourseTee.java
Normal file
112
src/main/java/com/poststats/golf/rs/api/model/CourseTee.java
Normal file
@@ -0,0 +1,112 @@
|
||||
package com.poststats.golf.rs.api.model;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.poststats.golf.rs.api.Constants;
|
||||
import com.poststats.rs.api.annotation.MapCondition;
|
||||
import com.poststats.rs.api.annotation.MapEntry;
|
||||
import com.poststats.rs.api.model.PeriodConstrainable;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class CourseTee extends BaseCourseTee<CourseTee>
|
||||
implements ReferenceableCourseTee, PeriodConstrainable<LocalDate> {
|
||||
|
||||
@JsonProperty(required = true, access = JsonProperty.Access.READ_ONLY)
|
||||
@MapEntry("teeID")
|
||||
private long id;
|
||||
|
||||
@JsonProperty
|
||||
@MapEntry("liveline")
|
||||
@MapCondition(rolesAllowed = {
|
||||
Constants.ADMIN_ROLE, "course"
|
||||
})
|
||||
private LocalDate liveline;
|
||||
|
||||
@JsonProperty
|
||||
@MapEntry("deadline")
|
||||
@MapCondition(rolesAllowed = {
|
||||
Constants.ADMIN_ROLE, "course"
|
||||
})
|
||||
private LocalDate deadline;
|
||||
|
||||
@JsonProperty
|
||||
@MapEntry
|
||||
private Course course;
|
||||
|
||||
@JsonProperty
|
||||
@MapEntry("courseID")
|
||||
private Integer courseId;
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate getLiveline() {
|
||||
return liveline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLiveline(LocalDate liveline) {
|
||||
this.liveline = liveline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate getDeadline() {
|
||||
return deadline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeadline(LocalDate deadline) {
|
||||
this.deadline = deadline;
|
||||
}
|
||||
|
||||
public Course getCourse() {
|
||||
return course;
|
||||
}
|
||||
|
||||
public void setCourse(Course course) {
|
||||
this.course = course;
|
||||
}
|
||||
|
||||
public Integer getCourseId() {
|
||||
return courseId;
|
||||
}
|
||||
|
||||
public void setCourseId(Integer courseId) {
|
||||
this.courseId = courseId;
|
||||
}
|
||||
|
||||
public CourseTee withId(int id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CourseTee withLiveline(LocalDate liveline) {
|
||||
this.liveline = liveline;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CourseTee withDeadline(LocalDate deadline) {
|
||||
this.deadline = deadline;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CourseTee withCourse(Course course) {
|
||||
this.course = course;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CourseTee withCourseId(Integer courseId) {
|
||||
this.courseId = courseId;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package com.poststats.golf.rs.api.model;
|
||||
|
||||
public interface ReferenceableCourseTee {
|
||||
|
||||
long getId();
|
||||
|
||||
}
|
Reference in New Issue
Block a user