Added info about commiter to comision entity
This commit is contained in:
parent
c62674b9d8
commit
dfae6d7c78
@ -24,6 +24,9 @@ public class Commision {
|
|||||||
@OneToOne
|
@OneToOne
|
||||||
@JoinColumn(name = "owner_id")
|
@JoinColumn(name = "owner_id")
|
||||||
private User commisionOwner;
|
private User commisionOwner;
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "commiter_id")
|
||||||
|
private User commisionCommiter;
|
||||||
private Timestamp commisionDate;
|
private Timestamp commisionDate;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "commision", fetch = FetchType.EAGER)
|
@OneToMany(mappedBy = "commision", fetch = FetchType.EAGER)
|
||||||
@ -37,6 +40,17 @@ public class Commision {
|
|||||||
public Commision(User user) {
|
public Commision(User user) {
|
||||||
this.commisionDate = new Timestamp(System.currentTimeMillis());
|
this.commisionDate = new Timestamp(System.currentTimeMillis());
|
||||||
this.commisionOwner = user;
|
this.commisionOwner = user;
|
||||||
|
this.commisionCommiter = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param user user whose shedule is being commited
|
||||||
|
* @param commiter user that commited new schedule
|
||||||
|
*/
|
||||||
|
public Commision(User user, User commiter) {
|
||||||
|
this(user);
|
||||||
|
this.commisionCommiter = commiter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Commision() {
|
public Commision() {
|
||||||
@ -44,6 +58,7 @@ public class Commision {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Id getter
|
* Id getter
|
||||||
|
*
|
||||||
* @return id id of commision
|
* @return id id of commision
|
||||||
*/
|
*/
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
@ -52,6 +67,7 @@ public class Commision {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* CommisionDate getter
|
* CommisionDate getter
|
||||||
|
*
|
||||||
* @return commisionDate
|
* @return commisionDate
|
||||||
*/
|
*/
|
||||||
public Timestamp getCommisionDate() {
|
public Timestamp getCommisionDate() {
|
||||||
@ -60,14 +76,26 @@ public class Commision {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* User of given commision getter
|
* User of given commision getter
|
||||||
|
*
|
||||||
* @return User commisionOwner
|
* @return User commisionOwner
|
||||||
*/
|
*/
|
||||||
public User getCommisionOwner() {
|
public User getCommisionOwner() {
|
||||||
return commisionOwner;
|
return commisionOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return User entity that created commision (can be owner or deanery user)
|
||||||
|
*/
|
||||||
|
public User getCommisionCommiter() {
|
||||||
|
if (commisionCommiter == null) {
|
||||||
|
return commisionOwner;
|
||||||
|
}
|
||||||
|
return commisionCommiter;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assigments getter
|
* Assigments getter
|
||||||
|
*
|
||||||
* @return List of assignments
|
* @return List of assignments
|
||||||
*/
|
*/
|
||||||
public List<Assignment> getAssignments() {
|
public List<Assignment> getAssignments() {
|
||||||
|
@ -82,7 +82,7 @@ public class CommisionController extends TokenBasedController {
|
|||||||
Assert.isTrue(!notExistingGroup.isPresent(), "Group "
|
Assert.isTrue(!notExistingGroup.isPresent(), "Group "
|
||||||
+ notExistingGroup.orElse(Long.MIN_VALUE).toString() + "doesn't exist");
|
+ notExistingGroup.orElse(Long.MIN_VALUE).toString() + "doesn't exist");
|
||||||
|
|
||||||
final Commision com = new Commision(user);
|
final Commision com = new Commision(user, asker);
|
||||||
this.commisionService.save(com);
|
this.commisionService.save(com);
|
||||||
|
|
||||||
groups.stream().forEach((groupId) -> {
|
groups.stream().forEach((groupId) -> {
|
||||||
|
@ -10,12 +10,29 @@ public class CommisionResponse {
|
|||||||
@ApiModelProperty(value = "ID created by database")
|
@ApiModelProperty(value = "ID created by database")
|
||||||
private Long id;
|
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")
|
@ApiModelProperty(value = "Timestamp where the user commit the commision")
|
||||||
private String commisionDate;
|
private String commisionDate;
|
||||||
|
|
||||||
public CommisionResponse(Commision commision) {
|
public CommisionResponse(Commision commision) {
|
||||||
this.id = commision.getId();
|
this.id = commision.getId();
|
||||||
this.commisionDate = commision.getCommisionDate().toString();
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserResponse getCommiter() {
|
||||||
|
return commiter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserResponse getOwner() {
|
||||||
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCommisionDate() {
|
public String getCommisionDate() {
|
||||||
|
Loading…
Reference in New Issue
Block a user