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