feat: nullable projectId, new ticket categories, improved create form
This commit is contained in:
@@ -2,11 +2,12 @@ package com.srsystem.dto;
|
||||
|
||||
import com.srsystem.entity.enums.TicketCategory;
|
||||
import com.srsystem.entity.enums.TicketPriority;
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
public record CreateTicketRequest(
|
||||
@NotNull Long projectId,
|
||||
@Nullable Long projectId,
|
||||
@NotNull TicketCategory category,
|
||||
@NotNull TicketPriority priority,
|
||||
@NotBlank String title,
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Ticket extends BaseEntity {
|
||||
private Long ticketId;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "project_id", nullable = false)
|
||||
@JoinColumn(name = "project_id")
|
||||
private Project project;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
|
||||
@@ -4,5 +4,9 @@ public enum TicketCategory {
|
||||
BUG,
|
||||
FEATURE,
|
||||
SUPPORT,
|
||||
QA
|
||||
QA,
|
||||
VACATION,
|
||||
EXPENSE,
|
||||
EQUIPMENT_REQUEST,
|
||||
GENERAL
|
||||
}
|
||||
|
||||
@@ -59,21 +59,22 @@ public class TicketService {
|
||||
Employee requester = employeeRepository.findById(requesterId)
|
||||
.orElseThrow(() -> new BusinessException(ErrorCode.EMPLOYEE_NOT_FOUND));
|
||||
|
||||
Project project = projectRepository.findById(request.projectId())
|
||||
.orElseThrow(() -> new BusinessException(ErrorCode.PROJECT_NOT_FOUND));
|
||||
|
||||
Ticket ticket = Ticket.builder()
|
||||
.project(project)
|
||||
Ticket.TicketBuilder builder = Ticket.builder()
|
||||
.requester(requester)
|
||||
.category(request.category())
|
||||
.priority(request.priority())
|
||||
.title(request.title())
|
||||
.description(request.description())
|
||||
.status(TicketStatus.OPEN)
|
||||
.slaWarnFlag('N')
|
||||
.build();
|
||||
.slaWarnFlag('N');
|
||||
|
||||
Ticket saved = ticketRepository.save(ticket);
|
||||
if (request.projectId() != null) {
|
||||
Project project = projectRepository.findById(request.projectId())
|
||||
.orElseThrow(() -> new BusinessException(ErrorCode.PROJECT_NOT_FOUND));
|
||||
builder.project(project);
|
||||
}
|
||||
|
||||
Ticket saved = ticketRepository.save(builder.build());
|
||||
return toIssueTicket(saved);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
ALTER TABLE tb_ticket ALTER COLUMN project_id DROP NOT NULL;
|
||||
|
||||
INSERT INTO tb_common_code (id, group_code, code_value, code_name, sort_order, is_active, created_at, updated_at)
|
||||
SELECT nextval('sq_common_codes'), 'TICKET_CATEGORY', 'FEATURE', '기능 요청', 2, 'Y', NOW(), NOW()
|
||||
WHERE NOT EXISTS (SELECT 1 FROM tb_common_code WHERE group_code = 'TICKET_CATEGORY' AND code_value = 'FEATURE');
|
||||
|
||||
INSERT INTO tb_common_code (id, group_code, code_value, code_name, sort_order, is_active, created_at, updated_at)
|
||||
SELECT nextval('sq_common_codes'), 'TICKET_CATEGORY', 'VACATION', '휴가 신청', 5, 'Y', NOW(), NOW()
|
||||
WHERE NOT EXISTS (SELECT 1 FROM tb_common_code WHERE group_code = 'TICKET_CATEGORY' AND code_value = 'VACATION');
|
||||
|
||||
INSERT INTO tb_common_code (id, group_code, code_value, code_name, sort_order, is_active, created_at, updated_at)
|
||||
SELECT nextval('sq_common_codes'), 'TICKET_CATEGORY', 'EXPENSE', '비용 청구', 6, 'Y', NOW(), NOW()
|
||||
WHERE NOT EXISTS (SELECT 1 FROM tb_common_code WHERE group_code = 'TICKET_CATEGORY' AND code_value = 'EXPENSE');
|
||||
|
||||
INSERT INTO tb_common_code (id, group_code, code_value, code_name, sort_order, is_active, created_at, updated_at)
|
||||
SELECT nextval('sq_common_codes'), 'TICKET_CATEGORY', 'EQUIPMENT_REQUEST', '장비 요청', 7, 'Y', NOW(), NOW()
|
||||
WHERE NOT EXISTS (SELECT 1 FROM tb_common_code WHERE group_code = 'TICKET_CATEGORY' AND code_value = 'EQUIPMENT_REQUEST');
|
||||
|
||||
INSERT INTO tb_common_code (id, group_code, code_value, code_name, sort_order, is_active, created_at, updated_at)
|
||||
SELECT nextval('sq_common_codes'), 'TICKET_CATEGORY', 'GENERAL', '일반 문의', 8, 'Y', NOW(), NOW()
|
||||
WHERE NOT EXISTS (SELECT 1 FROM tb_common_code WHERE group_code = 'TICKET_CATEGORY' AND code_value = 'GENERAL');
|
||||
Reference in New Issue
Block a user