backend/restservice/src/main/java/com/plannaplan/responses/models/CommisionResponse.java

65 lines
1.7 KiB
Java
Raw Normal View History

2020-10-15 17:29:40 +02:00
package com.plannaplan.responses.models;
import com.plannaplan.entities.Commision;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
2021-01-15 17:45:29 +01:00
/**
* Commision api response
*/
@ApiModel(description = "Response shows information about commision.", value = "CommisionResponse")
2020-10-15 17:29:40 +02:00
public class CommisionResponse {
@ApiModelProperty(value = "ID created by database")
2020-10-15 17:29:40 +02:00
private Long id;
@ApiModelProperty(value = "ID of user that commision belongs to")
private UserResponse owner;
@ApiModelProperty(value = "ID of user that created commision")
private UserResponse commiter;
@ApiModelProperty(value = "Timestamp where the user commit the commision")
2020-12-10 15:17:13 +01:00
private String commisionDate;
2020-10-15 17:29:40 +02:00
2021-01-15 17:45:29 +01:00
/**
* @param commision commision to map to api response
*/
2020-10-15 17:29:40 +02:00
public CommisionResponse(Commision commision) {
this.id = commision.getId();
2020-12-10 15:17:13 +01:00
this.commisionDate = commision.getCommisionDate().toString();
this.owner = commision.getCommisionOwner() != null ? new UserResponse(commision.getCommisionOwner()) : null;
this.commiter = commision.getCommisionCommiter() != null ? new UserResponse(commision.getCommisionCommiter())
: null;
}
2021-01-15 17:45:29 +01:00
/**
* @return get Commiter user as api response
*/
public UserResponse getCommiter() {
return commiter;
}
2021-01-15 17:45:29 +01:00
/**
* @return get Owner user as api response
*/
public UserResponse getOwner() {
return owner;
2020-10-15 17:29:40 +02:00
}
2021-01-15 17:45:29 +01:00
/**
* @return when commision was created string formated
*/
2020-12-10 15:17:13 +01:00
public String getCommisionDate() {
2020-10-15 17:29:40 +02:00
return commisionDate;
}
2021-01-15 17:45:29 +01:00
/**
* @return db id
*/
2020-10-15 17:29:40 +02:00
public Long getId() {
return id;
}
}