Skip to content

Commit

Permalink
Merge pull request #195 from FEBFES/feature/191/task-deadline
Browse files Browse the repository at this point in the history
191 - task deadline
  • Loading branch information
IvanShish authored Jun 6, 2024
2 parents 4577312 + 404583f commit ded3646
Show file tree
Hide file tree
Showing 22 changed files with 95 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import lombok.*;
import lombok.experimental.SuperBuilder;

import java.util.Date;
import java.time.LocalDateTime;

@Entity
@Table(name = "refresh_token")
Expand All @@ -29,6 +29,6 @@ public class RefreshTokenEntity extends BaseEntity {
private String token;

@Column(name = "expiry_date", nullable = false)
private Date expiryDate;
private LocalDateTime expiryDate;

}
7 changes: 5 additions & 2 deletions src/main/java/com/febfes/fftmback/domain/dao/TaskEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.hibernate.annotations.Type;
import org.hibernate.annotations.UpdateTimestamp;

import java.util.Date;
import java.time.LocalDateTime;


@Entity
Expand Down Expand Up @@ -55,7 +55,10 @@ public class TaskEntity extends OrderedEntity {

@Column(name = "update_date")
@UpdateTimestamp
private Date updateDate;
private LocalDateTime updateDate;

@Column(name = "deadline_date")
private LocalDateTime deadlineDate;

@Override
public String getColumnToFindOrder() {
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/febfes/fftmback/domain/dao/TaskView.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import lombok.*;
import lombok.experimental.SuperBuilder;

import java.util.Date;
import java.time.LocalDateTime;

@Entity
@Table(name = "v_task")
Expand Down Expand Up @@ -51,5 +51,8 @@ public class TaskView extends OrderedView {
private Long filesCounter;

@Column(name = "\"updateDate\"")
private Date updateDate;
private LocalDateTime updateDate;

@Column(name = "\"deadlineDate\"")
private LocalDateTime deadlineDate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.CreationTimestamp;

import java.util.Date;
import java.time.LocalDateTime;

@MappedSuperclass
@SuperBuilder
Expand All @@ -22,5 +22,5 @@ public abstract class BaseEntity {

@Column(name = "create_date", updatable = false)
@CreationTimestamp
private Date createDate;
private LocalDateTime createDate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.CreationTimestamp;

import java.util.Date;
import java.time.LocalDateTime;

@MappedSuperclass
@SuperBuilder
Expand All @@ -23,5 +23,5 @@ public abstract class BaseView {

@Column(name = "\"createDate\"", updatable = false)
@CreationTimestamp
private Date createDate;
private LocalDateTime createDate;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.febfes.fftmback.domain.projection;

import java.util.Date;
import java.time.LocalDateTime;

public interface ProjectForUserProjection {

Expand All @@ -10,7 +10,7 @@ public interface ProjectForUserProjection {

String getDescription();

Date getCreateDate();
LocalDateTime getCreateDate();

Long getOwnerId();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.febfes.fftmback.domain.projection;

import java.util.Date;
import java.time.LocalDateTime;

public interface ProjectProjection {

Expand All @@ -10,7 +10,7 @@ public interface ProjectProjection {

String getDescription();

Date getCreateDate();
LocalDateTime getCreateDate();

Long getOwnerId();

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/febfes/fftmback/dto/ColumnDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import jakarta.validation.constraints.NotBlank;
import lombok.Builder;

import java.util.Date;
import java.time.LocalDateTime;

@Builder
public record ColumnDto(
Expand All @@ -15,7 +15,7 @@ public record ColumnDto(
String name,

@Schema(accessMode = Schema.AccessMode.READ_ONLY)
Date createDate,
LocalDateTime createDate,

@Schema(description = "Column order on the board. Starts at 1")
Integer order,
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/com/febfes/fftmback/dto/EditTaskDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@
import com.febfes.fftmback.domain.common.TaskPriority;
import jakarta.validation.constraints.NotBlank;

import java.time.LocalDateTime;

public record EditTaskDto(

@NotBlank(message = "Invalid Name: Empty name")
String name,

String description,

Long assigneeId,

TaskPriority priority,

String type,

Integer order
Integer order,
LocalDateTime deadlineDate
) {
}
4 changes: 2 additions & 2 deletions src/main/java/com/febfes/fftmback/dto/OneProjectDto.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.febfes.fftmback.dto;

import java.util.Date;
import java.time.LocalDateTime;
import java.util.List;

public record OneProjectDto(
Long id,
String name,
String description,
Date createDate,
LocalDateTime createDate,
Boolean isFavourite,
List<MemberDto> members,
RoleDto userRoleOnProject
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/febfes/fftmback/dto/ProjectDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import jakarta.validation.constraints.NotBlank;
import lombok.Builder;

import java.util.Date;
import java.time.LocalDateTime;

@Builder
public record ProjectDto(
Expand All @@ -18,7 +18,7 @@ public record ProjectDto(
String description,

@Schema(accessMode = Schema.AccessMode.READ_ONLY)
Date createDate,
LocalDateTime createDate,

@Schema(accessMode = Schema.AccessMode.READ_ONLY)
Long ownerId,
Expand Down
30 changes: 15 additions & 15 deletions src/main/java/com/febfes/fftmback/dto/TaskDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
import com.febfes.fftmback.domain.common.TaskPriority;
import lombok.Builder;

import java.util.Date;
import java.time.LocalDateTime;
import java.util.List;

@Builder
public record TaskDto(

Long id,
String name,
String description,
Date createDate,
Long projectId,
Long columnId,
TaskPriority priority,
String type,
Long filesCounter,
List<TaskFileDto> files,
UserDto owner,
UserDto assignee,

Date updateDate
Long id
, String name
, String description
, LocalDateTime createDate
, Long projectId
, Long columnId
, TaskPriority priority
, String type
, Long filesCounter
, List<TaskFileDto> files
, UserDto owner
, UserDto assignee
, LocalDateTime updateDate
, LocalDateTime deadlineDate
) {

}
4 changes: 2 additions & 2 deletions src/main/java/com/febfes/fftmback/dto/TaskFileDto.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.febfes.fftmback.dto;

import java.util.Date;
import java.time.LocalDateTime;

public record TaskFileDto(

Long id,

Date createDate,
LocalDateTime createDate,

Long userId,

Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/febfes/fftmback/dto/TaskShortDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@

import com.febfes.fftmback.domain.common.TaskPriority;

import java.util.Date;
import java.time.LocalDateTime;

public record TaskShortDto(
Long id,
String name,
String description,
Long columnId,
Long projectId,
Date createDate,
LocalDateTime createDate,
TaskPriority priority,
String type,
Long filesCounter,
UserDto owner,
UserDto assignee,
Date updateDate,
Integer order
LocalDateTime updateDate,
Integer order,
LocalDateTime deadlineDate
) {
}
4 changes: 2 additions & 2 deletions src/main/java/com/febfes/fftmback/dto/error/ErrorDto.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.febfes.fftmback.dto.error;

import java.util.Date;
import java.time.LocalDateTime;
import java.util.Map;

public record ErrorDto(

Integer statusCode,
StatusError status,
ErrorType errorType,
Date timestamp,
LocalDateTime timestamp,
String message,
Map<String, ?> error
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.febfes.fftmback.dto.error.ErrorDto;
import com.febfes.fftmback.dto.error.ErrorType;
import com.febfes.fftmback.dto.error.StatusError;
import com.febfes.fftmback.util.DateUtils;
import io.jsonwebtoken.ExpiredJwtException;
import io.swagger.v3.oas.annotations.Hidden;
import lombok.RequiredArgsConstructor;
Expand All @@ -20,6 +19,7 @@
import java.util.Map;

import static com.febfes.fftmback.dto.error.AuthError.createBaseError;
import static com.febfes.fftmback.util.DateUtils.getCurrentLocalDateTime;
import static java.util.Objects.isNull;

@RestControllerAdvice
Expand Down Expand Up @@ -62,7 +62,7 @@ public ErrorDto handleConstraintViolationException(
.orElse(Collections.emptyMap());
log.error(LOG_MSG.formatted(ex.getClass().getSimpleName()), ex);
return new ErrorDto(HttpStatus.UNPROCESSABLE_ENTITY.value(), StatusError.ARGUMENT_NOT_VALID,
errorType, DateUtils.getCurrentDate(), ex.getMessage(), errorMap);
errorType, getCurrentLocalDateTime(), ex.getMessage(), errorMap);
}

@ExceptionHandler({ExpiredJwtException.class, TokenExpiredException.class})
Expand Down Expand Up @@ -94,7 +94,7 @@ public ErrorDto handleBadCredentialsException(
ErrorType errorType = ErrorType.AUTH;
log.error(LOG_MSG.formatted(ex.getClass().getSimpleName()), ex);
return new ErrorDto(HttpStatus.UNPROCESSABLE_ENTITY.value(), StatusError.BAD_CREDENTIALS,
errorType, DateUtils.getCurrentDate(), ex.getMessage(),
errorType, getCurrentLocalDateTime(), ex.getMessage(),
createBaseError(UserEntity.ENTITY_NAME, "password", null, errorType));
}

Expand Down Expand Up @@ -126,7 +126,7 @@ private ErrorDto createExceptionResponseBody(
status.value(),
ex.getStatusError(),
ex.getErrorType(),
DateUtils.getCurrentDate(),
getCurrentLocalDateTime(),
ex.getMessage(),
ex.getBaseError()
);
Expand All @@ -140,7 +140,7 @@ private ErrorDto createExceptionResponseBody(
status.value(),
StatusError.UNDEFINED,
ErrorType.UNDEFINED,
DateUtils.getCurrentDate(),
getCurrentLocalDateTime(),
ex.getMessage(),
null
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import java.util.UUID;

import static com.febfes.fftmback.util.DateUtils.getCurrentLocalDateTimePlusSeconds;

@Service
@Slf4j
@RequiredArgsConstructor
Expand Down Expand Up @@ -49,7 +51,7 @@ public RefreshTokenEntity getByUserId(Long userId) {
@Override
public RefreshTokenEntity updateRefreshToken(RefreshTokenEntity refreshToken) {
refreshToken.setToken(UUID.randomUUID().toString());
refreshToken.setExpiryDate(DateUtils.getCurrentDatePlusSeconds(jwtRefreshExpirationDateInSeconds));
refreshToken.setExpiryDate(getCurrentLocalDateTimePlusSeconds(jwtRefreshExpirationDateInSeconds));
RefreshTokenEntity updatedRefreshToken = refreshTokenRepository.save(refreshToken);
log.info("Updated refresh token entity: {}", updatedRefreshToken);
return updatedRefreshToken;
Expand All @@ -60,7 +62,7 @@ public RefreshTokenEntity createRefreshToken(Long userId) {
RefreshTokenEntity refreshToken = refreshTokenRepository.save(
RefreshTokenEntity.builder()
.userEntity(userService.getUserById(userId))
.expiryDate(DateUtils.getCurrentDatePlusSeconds(jwtRefreshExpirationDateInSeconds))
.expiryDate(getCurrentLocalDateTimePlusSeconds(jwtRefreshExpirationDateInSeconds))
.token(UUID.randomUUID().toString())
.build()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public void updateTask(TaskEntity editTask) {
task.setProjectId(editTask.getProjectId());
task.setPriority(editTask.getPriority());
task.setAssigneeId(editTask.getAssigneeId());
task.setDeadlineDate(editTask.getDeadlineDate());
fillTaskType(task, editTask.getTaskType().getName(), editTask.getProjectId());
taskRepository.save(task);
orderService.editOrder(task, editTask.getEntityOrder());
Expand Down
Loading

0 comments on commit ded3646

Please sign in to comment.