chore: update
This commit is contained in:
@@ -1,14 +1,15 @@
|
|||||||
package com.drinkool.dtos;
|
package com.drinkool.dtos;
|
||||||
|
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.eclipse.microprofile.graphql.NonNull;
|
import org.eclipse.microprofile.graphql.NonNull;
|
||||||
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class CreateShift {
|
public class CreateShift {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public String name;
|
public Date date;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public LocalTime startTime;
|
public LocalTime startTime;
|
||||||
@@ -17,4 +18,7 @@ public class CreateShift {
|
|||||||
public LocalTime endTime;
|
public LocalTime endTime;
|
||||||
|
|
||||||
public Integer maxStaff;
|
public Integer maxStaff;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public Integer wage;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
package com.drinkool.entities;
|
package com.drinkool.entities;
|
||||||
|
|
||||||
import com.drinkool.lib.entities.BaseEntity;
|
import com.drinkool.lib.entities.BaseEntity;
|
||||||
|
import jakarta.persistence.CascadeType;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.JoinColumn;
|
import jakarta.persistence.JoinColumn;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.OneToMany;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.util.UUID;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table
|
@Table
|
||||||
@@ -19,7 +23,7 @@ public class ShiftEntity extends BaseEntity {
|
|||||||
public EateryEntity eatery;
|
public EateryEntity eatery;
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
public String name;
|
public Date date;
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
public LocalTime startTime;
|
public LocalTime startTime;
|
||||||
@@ -29,4 +33,14 @@ public class ShiftEntity extends BaseEntity {
|
|||||||
|
|
||||||
@Column(nullable = true)
|
@Column(nullable = true)
|
||||||
public Integer maxStaff;
|
public Integer maxStaff;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
public Integer wage;
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
mappedBy = "shift",
|
||||||
|
cascade = CascadeType.ALL,
|
||||||
|
orphanRemoval = true
|
||||||
|
)
|
||||||
|
public List<ShiftRegistrationEntity> registeredStaff = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.drinkool.entities;
|
|||||||
import com.drinkool.lib.entities.BaseEntity;
|
import com.drinkool.lib.entities.BaseEntity;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -15,7 +17,8 @@ public class ShiftRegistrationEntity extends BaseEntity {
|
|||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
public UUID staffId;
|
public UUID staffId;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
@JoinColumn(name = "shiftId")
|
||||||
public ShiftEntity shift;
|
public ShiftEntity shift;
|
||||||
|
|
||||||
public static long countByShift(UUID shiftId) {
|
public static long countByShift(UUID shiftId) {
|
||||||
|
|||||||
@@ -116,10 +116,11 @@ public class ShiftService {
|
|||||||
|
|
||||||
ShiftEntity shift = new ShiftEntity();
|
ShiftEntity shift = new ShiftEntity();
|
||||||
shift.eatery = eatery;
|
shift.eatery = eatery;
|
||||||
shift.name = input.name;
|
shift.date = input.date;
|
||||||
shift.startTime = input.startTime;
|
shift.startTime = input.startTime;
|
||||||
shift.endTime = input.endTime;
|
shift.endTime = input.endTime;
|
||||||
shift.maxStaff = input.maxStaff;
|
shift.maxStaff = input.maxStaff;
|
||||||
|
shift.wage = input.wage;
|
||||||
|
|
||||||
if (shift.endTime.isBefore(shift.startTime)) {
|
if (shift.endTime.isBefore(shift.startTime)) {
|
||||||
throw new GraphQLException("InvalidEndTime");
|
throw new GraphQLException("InvalidEndTime");
|
||||||
@@ -145,7 +146,6 @@ public class ShiftService {
|
|||||||
!shift.eatery.ownerId.toString().equals(ownerId)
|
!shift.eatery.ownerId.toString().equals(ownerId)
|
||||||
) throw new GraphQLException("InvalidShiftId");
|
) throw new GraphQLException("InvalidShiftId");
|
||||||
|
|
||||||
shift.name = input.name;
|
|
||||||
shift.startTime = input.startTime;
|
shift.startTime = input.startTime;
|
||||||
shift.endTime = input.endTime;
|
shift.endTime = input.endTime;
|
||||||
shift.maxStaff = input.maxStaff;
|
shift.maxStaff = input.maxStaff;
|
||||||
|
|||||||
@@ -196,7 +196,6 @@ public class ShiftServiceTest {
|
|||||||
) {
|
) {
|
||||||
ShiftEntity shift = new ShiftEntity();
|
ShiftEntity shift = new ShiftEntity();
|
||||||
shift.eatery = eatery;
|
shift.eatery = eatery;
|
||||||
shift.name = name;
|
|
||||||
shift.startTime = LocalTime.parse(start);
|
shift.startTime = LocalTime.parse(start);
|
||||||
shift.endTime = LocalTime.parse(end);
|
shift.endTime = LocalTime.parse(end);
|
||||||
shift.maxStaff = 5;
|
shift.maxStaff = 5;
|
||||||
|
|||||||
Reference in New Issue
Block a user