diff --git a/server/src/main/java/io/flexwork/modules/crm/service/AccountService.java b/server/src/main/java/io/flexwork/modules/crm/service/AccountService.java index 686befa0..e494dfe8 100644 --- a/server/src/main/java/io/flexwork/modules/crm/service/AccountService.java +++ b/server/src/main/java/io/flexwork/modules/crm/service/AccountService.java @@ -38,7 +38,6 @@ public AccountService( this.accountMapper = accountMapper; } - // Find an account by its ID public Optional findAccountById(Long accountId) { return accountRepository.findById(accountId).map(accountMapper::accountToAccountDTO); } @@ -72,7 +71,6 @@ public AccountDTO updateAccount(Long accountId, AccountDTO accountDetails) { new EntityNotFoundException( "Account not found with id: " + accountId)); - // Step 2: Update the fields of the existing account with the new details existingAccount.setName(accountEntityDetails.getName()); existingAccount.setType(accountEntityDetails.getType()); existingAccount.setIndustry(accountEntityDetails.getIndustry()); diff --git a/server/src/main/java/io/flexwork/modules/crm/service/ContactService.java b/server/src/main/java/io/flexwork/modules/crm/service/ContactService.java index 5a9ea6c1..418164b1 100644 --- a/server/src/main/java/io/flexwork/modules/crm/service/ContactService.java +++ b/server/src/main/java/io/flexwork/modules/crm/service/ContactService.java @@ -27,23 +27,30 @@ public ContactService(ContactRepository contactRepository, ContactMapper contact this.contactMapper = contactMapper; } - public Page findByAccountId(Long accountId, Pageable pageable) { - return contactRepository.findByAccountId(accountId, pageable); + public Page findByAccountId(Long accountId, Pageable pageable) { + return contactRepository + .findByAccountId(accountId, pageable) + .map(contactMapper::contactToContactDTO); } - public Optional getContactById(Long id) { - return contactRepository.findById(id); + public Optional getContactById(Long id) { + return contactRepository.findById(id).map(contactMapper::contactToContactDTO); } - public Contact createContact(Contact contact) { - return contactRepository.save(contact); + public ContactDTO createContact(ContactDTO contact) { + return contactMapper.contactToContactDTO( + contactRepository.save(contactMapper.contactDTOToContact(contact))); } - public Contact updateContact(Long id, Contact contactDetails) { + public ContactDTO updateContact(ContactDTO contactDetails) { Contact contact = contactRepository - .findById(id) - .orElseThrow(() -> new RuntimeException("Contact not found with id " + id)); + .findById(contactDetails.getId()) + .orElseThrow( + () -> + new RuntimeException( + "Contact not found with id " + + contactDetails.getId())); contact.setFirstName(contactDetails.getFirstName()); contact.setLastName(contactDetails.getLastName()); @@ -52,7 +59,7 @@ public Contact updateContact(Long id, Contact contactDetails) { contact.setPosition(contactDetails.getPosition()); contact.setNotes(contactDetails.getNotes()); - return contactRepository.save(contact); + return contactMapper.contactToContactDTO(contactRepository.save(contact)); } public void deleteContact(Long id) { diff --git a/server/src/main/java/io/flexwork/modules/crm/service/dto/AccountDTO.java b/server/src/main/java/io/flexwork/modules/crm/service/dto/AccountDTO.java index 19d4f0eb..83576723 100644 --- a/server/src/main/java/io/flexwork/modules/crm/service/dto/AccountDTO.java +++ b/server/src/main/java/io/flexwork/modules/crm/service/dto/AccountDTO.java @@ -8,43 +8,43 @@ @Builder public class AccountDTO { - private Long id; // Unique identifier for the account + private Long id; - private String name; // Name of the account + private String name; - private String type; // Type of the account (e.g., customer, vendor) + private String type; - private String industry; // Industry in which the account operates + private String industry; - private String website; // Website URL for the account + private String website; - private String phoneNumber; // Contact phone number + private String phoneNumber; - private String email; // Email address + private String email; - private String addressLine1; // First line of address + private String addressLine1; - private String addressLine2; // Second line of address (optional) + private String addressLine2; - private String city; // City where the account is located + private String city; - private String state; // State or region of the account + private String state; - private String postalCode; // Postal code + private String postalCode; - private String country; // Country of the account + private String country; - private String annualRevenue; // Annual revenue of the account (if applicable) + private String annualRevenue; - private Long parentAccountId; // ID of the parent account (if any) + private Long parentAccountId; - private LocalDateTime createdAt; // Creation timestamp + private LocalDateTime createdAt; - private LocalDateTime updatedAt; // Last update timestamp + private LocalDateTime updatedAt; - private String status; // Current status of the account + private String status; - private Long assignedToUserId; // ID of the user the account is assigned to + private Long assignedToUserId; - private String notes; // Additional notes or details about the account + private String notes; } diff --git a/server/src/main/java/io/flexwork/modules/crm/service/dto/ContactDTO.java b/server/src/main/java/io/flexwork/modules/crm/service/dto/ContactDTO.java index 7966b048..debf222e 100644 --- a/server/src/main/java/io/flexwork/modules/crm/service/dto/ContactDTO.java +++ b/server/src/main/java/io/flexwork/modules/crm/service/dto/ContactDTO.java @@ -10,7 +10,7 @@ public class ContactDTO { private Long id; - private Long accountId; // Assuming that you want to reference the Account by its ID in the DTO + private Long accountId; private String accountName; diff --git a/server/src/main/java/io/flexwork/modules/crm/web/rest/ContactController.java b/server/src/main/java/io/flexwork/modules/crm/web/rest/ContactController.java index 6226fe6d..cae0320c 100644 --- a/server/src/main/java/io/flexwork/modules/crm/web/rest/ContactController.java +++ b/server/src/main/java/io/flexwork/modules/crm/web/rest/ContactController.java @@ -1,9 +1,7 @@ package io.flexwork.modules.crm.web.rest; -import io.flexwork.modules.crm.domain.Contact; import io.flexwork.modules.crm.service.ContactService; import io.flexwork.modules.crm.service.dto.ContactDTO; -import io.flexwork.modules.crm.service.mapper.ContactMapper; import io.flexwork.query.QueryDTO; import jakarta.validation.Valid; import java.util.List; @@ -18,13 +16,10 @@ @RequestMapping("/api/crm/contacts") public class ContactController { - private ContactMapper contactMapper; - private ContactService contactService; - public ContactController(ContactService contactService, ContactMapper contactMapper) { + public ContactController(ContactService contactService) { this.contactService = contactService; - this.contactMapper = contactMapper; } @PostMapping("/search") @@ -36,30 +31,25 @@ public ResponseEntity> findContacts( @GetMapping("/account/{accountId}") public Page getContacts(@PathVariable Long accountId, Pageable pageable) { - return contactService - .findByAccountId(accountId, pageable) - .map(value -> contactMapper.contactToContactDTO(value)); + return contactService.findByAccountId(accountId, pageable); } @GetMapping("/{id}") public ResponseEntity getContactById(@PathVariable Long id) { - Optional contact = contactService.getContactById(id); - return contact.map(value -> ResponseEntity.ok(contactMapper.contactToContactDTO(value))) + Optional contact = contactService.getContactById(id); + return contact.map(value -> ResponseEntity.ok(value)) .orElseGet(() -> ResponseEntity.notFound().build()); } @PostMapping public ContactDTO createContact(@RequestBody ContactDTO contactDTO) { - return contactMapper.contactToContactDTO( - contactService.createContact(contactMapper.contactDTOToContact(contactDTO))); + return contactService.createContact(contactDTO); } - @PutMapping("/{id}") - public ResponseEntity updateContact( - @PathVariable Long id, @RequestBody ContactDTO contactDTO) { - Contact updatedContact = - contactService.updateContact(id, contactMapper.contactDTOToContact(contactDTO)); - return ResponseEntity.ok(contactMapper.contactToContactDTO(updatedContact)); + @PutMapping() + public ResponseEntity updateContact(@RequestBody ContactDTO contactDTO) { + ContactDTO updatedContact = contactService.updateContact(contactDTO); + return ResponseEntity.ok(updatedContact); } @DeleteMapping("/{id}") diff --git a/server/src/main/java/io/flexwork/modules/teams/domain/TeamRequest.java b/server/src/main/java/io/flexwork/modules/teams/domain/TeamRequest.java index e5e6dcc7..b3d9a3d7 100644 --- a/server/src/main/java/io/flexwork/modules/teams/domain/TeamRequest.java +++ b/server/src/main/java/io/flexwork/modules/teams/domain/TeamRequest.java @@ -1,5 +1,6 @@ package io.flexwork.modules.teams.domain; +import io.flexwork.modules.usermanagement.domain.Team; import io.flexwork.modules.usermanagement.domain.User; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; @@ -15,7 +16,7 @@ import lombok.NoArgsConstructor; @Entity -@Table(name = "fw_requests") +@Table(name = "fw_team_request") @Data @Builder @NoArgsConstructor @@ -27,22 +28,23 @@ public class TeamRequest { private Long id; @ManyToOne - @JoinColumn(name = "workflow_id", nullable = false) - private Workflow workflow; + @JoinColumn(name = "team_id", nullable = false) + private Team team; @ManyToOne - @JoinColumn(name = "current_status_id", nullable = false) - private WorkflowStatus currentStatus; + @JoinColumn(name = "workflow_id", nullable = false) + private Workflow workflow; @ManyToOne - @JoinColumn(name = "created_by", nullable = false) - private User createdBy; - - private LocalDateTime createdAt; + @JoinColumn(name = "request_user_id", nullable = false) + private User requestUser; @ManyToOne - @JoinColumn(name = "updated_by") - private User updatedBy; + @JoinColumn(name = "assign_user_id") + private User assignUser; - private LocalDateTime updatedAt; + private String requestTitle; + private String requestDescription; + private LocalDateTime createdDate; + private String currentState; } diff --git a/server/src/main/java/io/flexwork/modules/teams/domain/TeamRequestStatus.java b/server/src/main/java/io/flexwork/modules/teams/domain/TeamRequestStatus.java deleted file mode 100644 index 8eeffb75..00000000 --- a/server/src/main/java/io/flexwork/modules/teams/domain/TeamRequestStatus.java +++ /dev/null @@ -1,44 +0,0 @@ -package io.flexwork.modules.teams.domain; - -import io.flexwork.modules.usermanagement.domain.User; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.Table; -import java.time.LocalDateTime; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Entity -@Table(name = "fw_team_request_status") -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class TeamRequestStatus { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @ManyToOne - @JoinColumn(name = "request_id", nullable = false) - private TeamRequest request; - - @ManyToOne - @JoinColumn(name = "status_id", nullable = false) - private WorkflowStatus status; - - private LocalDateTime updatedAt; - - @ManyToOne - @JoinColumn(name = "updated_by", nullable = false) - private User updatedBy; - - private String comments; -} diff --git a/server/src/main/java/io/flexwork/modules/teams/domain/Workflow.java b/server/src/main/java/io/flexwork/modules/teams/domain/Workflow.java index 5cb571e0..1031655b 100644 --- a/server/src/main/java/io/flexwork/modules/teams/domain/Workflow.java +++ b/server/src/main/java/io/flexwork/modules/teams/domain/Workflow.java @@ -1,25 +1,15 @@ package io.flexwork.modules.teams.domain; -import io.flexwork.modules.usermanagement.domain.User; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; import jakarta.persistence.Table; -import java.time.LocalDateTime; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; +import java.util.List; @Entity @Table(name = "fw_workflow") -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor public class Workflow { @Id @@ -27,20 +17,8 @@ public class Workflow { private Long id; private String name; - private String description; - @ManyToOne - @JoinColumn(name = "created_by", nullable = false) - private User createdBy; - - private LocalDateTime createdAt; - - @ManyToOne - @JoinColumn(name = "updated_by") - private User updatedBy; - - private LocalDateTime updatedAt; - - // Getters and Setters + @OneToMany(mappedBy = "workflow") + private List states; } diff --git a/server/src/main/java/io/flexwork/modules/teams/domain/WorkflowAction.java b/server/src/main/java/io/flexwork/modules/teams/domain/WorkflowAction.java new file mode 100644 index 00000000..51d38a5e --- /dev/null +++ b/server/src/main/java/io/flexwork/modules/teams/domain/WorkflowAction.java @@ -0,0 +1,28 @@ +package io.flexwork.modules.teams.domain; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; + +@Entity +@Table(name = "fw_workflow_actions") +public class WorkflowAction { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne + @JoinColumn(name = "transition_id", nullable = false) + private WorkflowTransition transition; + + private String actionType; + + @Column(columnDefinition = "json") + private String actionData; // Store JSON data for flexibility +} diff --git a/server/src/main/java/io/flexwork/modules/teams/domain/WorkflowState.java b/server/src/main/java/io/flexwork/modules/teams/domain/WorkflowState.java new file mode 100644 index 00000000..aa0c9084 --- /dev/null +++ b/server/src/main/java/io/flexwork/modules/teams/domain/WorkflowState.java @@ -0,0 +1,26 @@ +package io.flexwork.modules.teams.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; + +@Entity +@Table(name = "fw_workflow_states") +public class WorkflowState { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne + @JoinColumn(name = "workflow_id", nullable = false) + private Workflow workflow; + + private String stateName; + private Boolean isInitial; + private Boolean isFinal; +} diff --git a/server/src/main/java/io/flexwork/modules/teams/domain/WorkflowStatus.java b/server/src/main/java/io/flexwork/modules/teams/domain/WorkflowStatus.java deleted file mode 100644 index 83783431..00000000 --- a/server/src/main/java/io/flexwork/modules/teams/domain/WorkflowStatus.java +++ /dev/null @@ -1,66 +0,0 @@ -package io.flexwork.modules.teams.domain; - -import io.flexwork.modules.usermanagement.domain.User; -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.EnumType; -import jakarta.persistence.Enumerated; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.Table; -import java.time.LocalDateTime; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Entity -@Table(name = "fw_workflow_status") -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class WorkflowStatus { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - private String name; - - private String description; - - @ManyToOne - @JoinColumn(name = "workflow_id", nullable = false) - private Workflow workflow; - - @Column(name = "order_in_workflow") - private Integer orderInWorkflow; - - @Enumerated(EnumType.STRING) - @Column(name = "status_phase", nullable = false) - private StatusPhase statusPhase; - - @ManyToOne - @JoinColumn(name = "created_by", nullable = false) - private User createdBy; - - private LocalDateTime createdAt; - - @ManyToOne - @JoinColumn(name = "updated_by") - private User updatedBy; - - private LocalDateTime updatedAt; - - public enum StatusPhase { - START, - MIDDLE, - TERMINAL - } - - // Getters and Setters -} diff --git a/server/src/main/java/io/flexwork/modules/teams/domain/WorkflowTransition.java b/server/src/main/java/io/flexwork/modules/teams/domain/WorkflowTransition.java index 1cafcddf..776a9d39 100644 --- a/server/src/main/java/io/flexwork/modules/teams/domain/WorkflowTransition.java +++ b/server/src/main/java/io/flexwork/modules/teams/domain/WorkflowTransition.java @@ -1,7 +1,5 @@ package io.flexwork.modules.teams.domain; -import io.flexwork.modules.usermanagement.domain.User; -import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; @@ -9,10 +7,9 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; -import java.time.LocalDateTime; @Entity -@Table(name = "fw_workflow_transition") +@Table(name = "fw_workflow_transitions") public class WorkflowTransition { @Id @@ -23,25 +20,8 @@ public class WorkflowTransition { @JoinColumn(name = "workflow_id", nullable = false) private Workflow workflow; - @ManyToOne - @JoinColumn(name = "from_status_id", nullable = false) - private WorkflowStatus fromStatus; - - @ManyToOne - @JoinColumn(name = "to_status_id", nullable = false) - private WorkflowStatus toStatus; - - @ManyToOne - @JoinColumn(name = "created_by", nullable = false) - private User createdBy; - - @Column(name = "created_at", nullable = false) - private LocalDateTime createdAt; - - @ManyToOne - @JoinColumn(name = "updated_by") - private User updatedBy; - - @Column(name = "updated_at") - private LocalDateTime updatedAt; + private String sourceState; + private String targetState; + private String eventName; + private Long slaDuration; } diff --git a/server/src/main/java/io/flexwork/modules/teams/domain/WorkflowTransitionHistory.java b/server/src/main/java/io/flexwork/modules/teams/domain/WorkflowTransitionHistory.java new file mode 100644 index 00000000..5149fb4c --- /dev/null +++ b/server/src/main/java/io/flexwork/modules/teams/domain/WorkflowTransitionHistory.java @@ -0,0 +1,30 @@ +package io.flexwork.modules.teams.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import java.time.LocalDateTime; + +@Entity +@Table(name = "fw_workflow_transition_history") +public class WorkflowTransitionHistory { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne + @JoinColumn(name = "team_request_id", nullable = false) + private TeamRequest teamRequest; + + private String fromState; + private String toState; + private String eventName; + private LocalDateTime transitionDate; + private LocalDateTime slaDueDate; + private String status; +} diff --git a/server/src/main/java/io/flexwork/modules/teams/repository/TeamRequestRepository.java b/server/src/main/java/io/flexwork/modules/teams/repository/TeamRequestRepository.java index f48d9443..a3efd6f5 100644 --- a/server/src/main/java/io/flexwork/modules/teams/repository/TeamRequestRepository.java +++ b/server/src/main/java/io/flexwork/modules/teams/repository/TeamRequestRepository.java @@ -2,7 +2,5 @@ import io.flexwork.modules.teams.domain.TeamRequest; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; -@Repository public interface TeamRequestRepository extends JpaRepository {} diff --git a/server/src/main/java/io/flexwork/modules/teams/repository/TeamRequestStatusRepository.java b/server/src/main/java/io/flexwork/modules/teams/repository/TeamRequestStatusRepository.java deleted file mode 100644 index 68f6e8fb..00000000 --- a/server/src/main/java/io/flexwork/modules/teams/repository/TeamRequestStatusRepository.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.flexwork.modules.teams.repository; - -import io.flexwork.modules.teams.domain.TeamRequestStatus; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface TeamRequestStatusRepository extends JpaRepository {} diff --git a/server/src/main/java/io/flexwork/modules/teams/repository/WorkflowActionRepository.java b/server/src/main/java/io/flexwork/modules/teams/repository/WorkflowActionRepository.java new file mode 100644 index 00000000..63f7f112 --- /dev/null +++ b/server/src/main/java/io/flexwork/modules/teams/repository/WorkflowActionRepository.java @@ -0,0 +1,6 @@ +package io.flexwork.modules.teams.repository; + +import io.flexwork.modules.teams.domain.WorkflowAction; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface WorkflowActionRepository extends JpaRepository {} diff --git a/server/src/main/java/io/flexwork/modules/teams/repository/WorkflowRepository.java b/server/src/main/java/io/flexwork/modules/teams/repository/WorkflowRepository.java index e7289a98..acc804c4 100644 --- a/server/src/main/java/io/flexwork/modules/teams/repository/WorkflowRepository.java +++ b/server/src/main/java/io/flexwork/modules/teams/repository/WorkflowRepository.java @@ -2,7 +2,5 @@ import io.flexwork.modules.teams.domain.Workflow; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; -@Repository public interface WorkflowRepository extends JpaRepository {} diff --git a/server/src/main/java/io/flexwork/modules/teams/repository/WorkflowStateRepository.java b/server/src/main/java/io/flexwork/modules/teams/repository/WorkflowStateRepository.java new file mode 100644 index 00000000..7b52f0fa --- /dev/null +++ b/server/src/main/java/io/flexwork/modules/teams/repository/WorkflowStateRepository.java @@ -0,0 +1,6 @@ +package io.flexwork.modules.teams.repository; + +import io.flexwork.modules.teams.domain.WorkflowState; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface WorkflowStateRepository extends JpaRepository {} diff --git a/server/src/main/java/io/flexwork/modules/teams/repository/WorkflowStatusRepository.java b/server/src/main/java/io/flexwork/modules/teams/repository/WorkflowStatusRepository.java deleted file mode 100644 index 7a3c85b6..00000000 --- a/server/src/main/java/io/flexwork/modules/teams/repository/WorkflowStatusRepository.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.flexwork.modules.teams.repository; - -import io.flexwork.modules.teams.domain.WorkflowStatus; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface WorkflowStatusRepository extends JpaRepository {} diff --git a/server/src/main/java/io/flexwork/modules/teams/repository/WorkflowTransitionHistoryRepository.java b/server/src/main/java/io/flexwork/modules/teams/repository/WorkflowTransitionHistoryRepository.java new file mode 100644 index 00000000..7b006b95 --- /dev/null +++ b/server/src/main/java/io/flexwork/modules/teams/repository/WorkflowTransitionHistoryRepository.java @@ -0,0 +1,7 @@ +package io.flexwork.modules.teams.repository; + +import io.flexwork.modules.teams.domain.WorkflowTransitionHistory; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface WorkflowTransitionHistoryRepository + extends JpaRepository {} diff --git a/server/src/main/java/io/flexwork/modules/teams/repository/WorkflowTransitionRepository.java b/server/src/main/java/io/flexwork/modules/teams/repository/WorkflowTransitionRepository.java index 1f95bd4d..039954d4 100644 --- a/server/src/main/java/io/flexwork/modules/teams/repository/WorkflowTransitionRepository.java +++ b/server/src/main/java/io/flexwork/modules/teams/repository/WorkflowTransitionRepository.java @@ -2,7 +2,5 @@ import io.flexwork.modules.teams.domain.WorkflowTransition; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; -@Repository public interface WorkflowTransitionRepository extends JpaRepository {} diff --git a/server/src/main/java/io/flexwork/modules/teams/service/TeamRequestService.java b/server/src/main/java/io/flexwork/modules/teams/service/TeamRequestService.java deleted file mode 100644 index d88dcb69..00000000 --- a/server/src/main/java/io/flexwork/modules/teams/service/TeamRequestService.java +++ /dev/null @@ -1,40 +0,0 @@ -package io.flexwork.modules.teams.service; - -import io.flexwork.modules.teams.domain.TeamRequest; -import io.flexwork.modules.teams.repository.TeamRequestRepository; -import java.util.List; -import org.springframework.stereotype.Service; - -@Service -public class TeamRequestService { - - private final TeamRequestRepository teamRequestRepository; - - public TeamRequestService(TeamRequestRepository teamRequestRepository) { - this.teamRequestRepository = teamRequestRepository; - } - - public List getAllTeamRequests() { - return teamRequestRepository.findAll(); - } - - public TeamRequest getTeamRequestById(Long id) { - return teamRequestRepository - .findById(id) - .orElseThrow(() -> new RuntimeException("Team request not found")); - } - - public TeamRequest createTeamRequest(TeamRequest teamRequest) { - return teamRequestRepository.save(teamRequest); - } - - public TeamRequest updateTeamRequest(Long id, TeamRequest updatedRequest) { - TeamRequest request = getTeamRequestById(id); - request.setCurrentStatus(updatedRequest.getCurrentStatus()); - return teamRequestRepository.save(request); - } - - public void deleteTeamRequest(Long id) { - teamRequestRepository.deleteById(id); - } -} diff --git a/server/src/main/java/io/flexwork/modules/teams/service/TeamRequestStatusService.java b/server/src/main/java/io/flexwork/modules/teams/service/TeamRequestStatusService.java deleted file mode 100644 index 80836d8a..00000000 --- a/server/src/main/java/io/flexwork/modules/teams/service/TeamRequestStatusService.java +++ /dev/null @@ -1,40 +0,0 @@ -package io.flexwork.modules.teams.service; - -import io.flexwork.modules.teams.domain.TeamRequestStatus; -import io.flexwork.modules.teams.repository.TeamRequestStatusRepository; -import java.util.List; -import org.springframework.stereotype.Service; - -@Service -public class TeamRequestStatusService { - - private final TeamRequestStatusRepository teamRequestStatusRepository; - - public TeamRequestStatusService(TeamRequestStatusRepository teamRequestStatusRepository) { - this.teamRequestStatusRepository = teamRequestStatusRepository; - } - - public List getAllTeamRequestStatuses() { - return teamRequestStatusRepository.findAll(); - } - - public TeamRequestStatus getTeamRequestStatusById(Long id) { - return teamRequestStatusRepository - .findById(id) - .orElseThrow(() -> new RuntimeException("Team request status not found")); - } - - public TeamRequestStatus createTeamRequestStatus(TeamRequestStatus teamRequestStatus) { - return teamRequestStatusRepository.save(teamRequestStatus); - } - - public TeamRequestStatus updateTeamRequestStatus(Long id, TeamRequestStatus updatedStatus) { - TeamRequestStatus status = getTeamRequestStatusById(id); - status.setComments(updatedStatus.getComments()); - return teamRequestStatusRepository.save(status); - } - - public void deleteTeamRequestStatus(Long id) { - teamRequestStatusRepository.deleteById(id); - } -} diff --git a/server/src/main/java/io/flexwork/modules/teams/service/WorkflowService.java b/server/src/main/java/io/flexwork/modules/teams/service/WorkflowService.java deleted file mode 100644 index bdf6f3bc..00000000 --- a/server/src/main/java/io/flexwork/modules/teams/service/WorkflowService.java +++ /dev/null @@ -1,42 +0,0 @@ -package io.flexwork.modules.teams.service; - -import io.flexwork.modules.teams.domain.Workflow; -import io.flexwork.modules.teams.repository.WorkflowRepository; -import java.util.List; -import org.springframework.stereotype.Service; - -@Service -public class WorkflowService { - - private final WorkflowRepository workflowRepository; - - public WorkflowService(WorkflowRepository workflowRepository) { - this.workflowRepository = workflowRepository; - } - - public List getAllWorkflows() { - return workflowRepository.findAll(); - } - - public Workflow getWorkflowById(Long id) { - return workflowRepository - .findById(id) - .orElseThrow(() -> new RuntimeException("Workflow not found")); - } - - public Workflow createWorkflow(Workflow workflow) { - return workflowRepository.save(workflow); - } - - public Workflow updateWorkflow(Long id, Workflow updatedWorkflow) { - Workflow workflow = getWorkflowById(id); - workflow.setName(updatedWorkflow.getName()); - workflow.setDescription(updatedWorkflow.getDescription()); - workflow.setUpdatedAt(updatedWorkflow.getUpdatedAt()); - return workflowRepository.save(workflow); - } - - public void deleteWorkflow(Long id) { - workflowRepository.deleteById(id); - } -} diff --git a/server/src/main/java/io/flexwork/modules/teams/service/WorkflowStatusService.java b/server/src/main/java/io/flexwork/modules/teams/service/WorkflowStatusService.java deleted file mode 100644 index 694c6eb7..00000000 --- a/server/src/main/java/io/flexwork/modules/teams/service/WorkflowStatusService.java +++ /dev/null @@ -1,43 +0,0 @@ -package io.flexwork.modules.teams.service; - -import io.flexwork.modules.teams.domain.WorkflowStatus; -import io.flexwork.modules.teams.repository.WorkflowStatusRepository; -import java.util.List; -import org.springframework.stereotype.Service; - -@Service -public class WorkflowStatusService { - - private final WorkflowStatusRepository workflowStatusRepository; - - public WorkflowStatusService(WorkflowStatusRepository workflowStatusRepository) { - this.workflowStatusRepository = workflowStatusRepository; - } - - public List getAllWorkflowStatuses() { - return workflowStatusRepository.findAll(); - } - - public WorkflowStatus getWorkflowStatusById(Long id) { - return workflowStatusRepository - .findById(id) - .orElseThrow(() -> new RuntimeException("Workflow status not found")); - } - - public WorkflowStatus createWorkflowStatus(WorkflowStatus workflowStatus) { - return workflowStatusRepository.save(workflowStatus); - } - - public WorkflowStatus updateWorkflowStatus(Long id, WorkflowStatus updatedStatus) { - WorkflowStatus status = getWorkflowStatusById(id); - status.setName(updatedStatus.getName()); - status.setDescription(updatedStatus.getDescription()); - status.setOrderInWorkflow(updatedStatus.getOrderInWorkflow()); - status.setStatusPhase(updatedStatus.getStatusPhase()); - return workflowStatusRepository.save(status); - } - - public void deleteWorkflowStatus(Long id) { - workflowStatusRepository.deleteById(id); - } -} diff --git a/server/src/main/java/io/flexwork/modules/teams/service/dto/TeamRequestDTO.java b/server/src/main/java/io/flexwork/modules/teams/service/dto/TeamRequestDTO.java deleted file mode 100644 index 9a00e5a1..00000000 --- a/server/src/main/java/io/flexwork/modules/teams/service/dto/TeamRequestDTO.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.flexwork.modules.teams.service.dto; - -import java.time.LocalDateTime; -import lombok.Builder; -import lombok.Data; - -@Data -@Builder -public class TeamRequestDTO { - - private Long id; - private Long workflowId; - private Long currentStatusId; - private Long createdById; - private LocalDateTime createdAt; - private Long updatedById; - private LocalDateTime updatedAt; -} diff --git a/server/src/main/java/io/flexwork/modules/teams/service/dto/TeamRequestStatusDTO.java b/server/src/main/java/io/flexwork/modules/teams/service/dto/TeamRequestStatusDTO.java deleted file mode 100644 index fdb7f2b7..00000000 --- a/server/src/main/java/io/flexwork/modules/teams/service/dto/TeamRequestStatusDTO.java +++ /dev/null @@ -1,16 +0,0 @@ -package io.flexwork.modules.teams.service.dto; - -import java.time.LocalDateTime; -import lombok.Builder; -import lombok.Data; - -@Data -@Builder -public class TeamRequestStatusDTO { - private Long id; - private Long teamRequestId; - private Long statusId; - private Long updatedById; - private LocalDateTime updatedAt; - private String comments; -} diff --git a/server/src/main/java/io/flexwork/modules/teams/service/dto/WorkflowDTO.java b/server/src/main/java/io/flexwork/modules/teams/service/dto/WorkflowDTO.java deleted file mode 100644 index 6555f8fd..00000000 --- a/server/src/main/java/io/flexwork/modules/teams/service/dto/WorkflowDTO.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.flexwork.modules.teams.service.dto; - -import java.time.LocalDateTime; -import lombok.Builder; -import lombok.Data; - -@Data -@Builder -public class WorkflowDTO { - - private Long id; - private String name; - private String description; - private Long createdById; - private LocalDateTime createdAt; - private Long updatedById; - private LocalDateTime updatedAt; -} diff --git a/server/src/main/java/io/flexwork/modules/teams/service/dto/WorkflowStatusDTO.java b/server/src/main/java/io/flexwork/modules/teams/service/dto/WorkflowStatusDTO.java deleted file mode 100644 index 1b61e67e..00000000 --- a/server/src/main/java/io/flexwork/modules/teams/service/dto/WorkflowStatusDTO.java +++ /dev/null @@ -1,21 +0,0 @@ -package io.flexwork.modules.teams.service.dto; - -import java.time.LocalDateTime; -import lombok.Builder; -import lombok.Data; - -@Data -@Builder -public class WorkflowStatusDTO { - - private Long id; - private String name; - private String description; - private Long workflowId; - private Integer orderInWorkflow; - private String statusPhase; - private Long createdById; - private LocalDateTime createdAt; - private Long updatedById; - private LocalDateTime updatedAt; -} diff --git a/server/src/main/java/io/flexwork/modules/teams/web/rest/TeamRequestController.java b/server/src/main/java/io/flexwork/modules/teams/web/rest/TeamRequestController.java deleted file mode 100644 index faf04a0e..00000000 --- a/server/src/main/java/io/flexwork/modules/teams/web/rest/TeamRequestController.java +++ /dev/null @@ -1,50 +0,0 @@ -package io.flexwork.modules.teams.web.rest; - -import io.flexwork.modules.teams.domain.TeamRequest; -import io.flexwork.modules.teams.service.TeamRequestService; -import java.util.List; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/api/teams/requests") -public class TeamRequestController { - - private final TeamRequestService teamRequestService; - - public TeamRequestController(TeamRequestService teamRequestService) { - this.teamRequestService = teamRequestService; - } - - @GetMapping - public List getAllTeamRequests() { - return teamRequestService.getAllTeamRequests(); - } - - @GetMapping("/{id}") - public TeamRequest getTeamRequestById(@PathVariable Long id) { - return teamRequestService.getTeamRequestById(id); - } - - @PostMapping - public TeamRequest createTeamRequest(@RequestBody TeamRequest teamRequest) { - return teamRequestService.createTeamRequest(teamRequest); - } - - @PutMapping("/{id}") - public TeamRequest updateTeamRequest( - @PathVariable Long id, @RequestBody TeamRequest updatedRequest) { - return teamRequestService.updateTeamRequest(id, updatedRequest); - } - - @DeleteMapping("/{id}") - public void deleteTeamRequest(@PathVariable Long id) { - teamRequestService.deleteTeamRequest(id); - } -} diff --git a/server/src/main/java/io/flexwork/modules/teams/web/rest/TeamRequestStatusController.java b/server/src/main/java/io/flexwork/modules/teams/web/rest/TeamRequestStatusController.java deleted file mode 100644 index df68243d..00000000 --- a/server/src/main/java/io/flexwork/modules/teams/web/rest/TeamRequestStatusController.java +++ /dev/null @@ -1,51 +0,0 @@ -package io.flexwork.modules.teams.web.rest; - -import io.flexwork.modules.teams.domain.TeamRequestStatus; -import io.flexwork.modules.teams.service.TeamRequestStatusService; -import java.util.List; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/api/teams/request-statuses") -public class TeamRequestStatusController { - - private final TeamRequestStatusService teamRequestStatusService; - - public TeamRequestStatusController(TeamRequestStatusService teamRequestStatusService) { - this.teamRequestStatusService = teamRequestStatusService; - } - - @GetMapping - public List getAllTeamRequestStatuses() { - return teamRequestStatusService.getAllTeamRequestStatuses(); - } - - @GetMapping("/{id}") - public TeamRequestStatus getTeamRequestStatusById(@PathVariable Long id) { - return teamRequestStatusService.getTeamRequestStatusById(id); - } - - @PostMapping - public TeamRequestStatus createTeamRequestStatus( - @RequestBody TeamRequestStatus teamRequestStatus) { - return teamRequestStatusService.createTeamRequestStatus(teamRequestStatus); - } - - @PutMapping("/{id}") - public TeamRequestStatus updateTeamRequestStatus( - @PathVariable Long id, @RequestBody TeamRequestStatus updatedStatus) { - return teamRequestStatusService.updateTeamRequestStatus(id, updatedStatus); - } - - @DeleteMapping("/{id}") - public void deleteTeamRequestStatus(@PathVariable Long id) { - teamRequestStatusService.deleteTeamRequestStatus(id); - } -} diff --git a/server/src/main/java/io/flexwork/modules/teams/web/rest/WorkflowController.java b/server/src/main/java/io/flexwork/modules/teams/web/rest/WorkflowController.java deleted file mode 100644 index 4847c1ec..00000000 --- a/server/src/main/java/io/flexwork/modules/teams/web/rest/WorkflowController.java +++ /dev/null @@ -1,49 +0,0 @@ -package io.flexwork.modules.teams.web.rest; - -import io.flexwork.modules.teams.domain.Workflow; -import io.flexwork.modules.teams.service.WorkflowService; -import java.util.List; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/api/teams/workflows") -public class WorkflowController { - - private final WorkflowService workflowService; - - public WorkflowController(WorkflowService workflowService) { - this.workflowService = workflowService; - } - - @GetMapping - public List getAllWorkflows() { - return workflowService.getAllWorkflows(); - } - - @GetMapping("/{id}") - public Workflow getWorkflowById(@PathVariable Long id) { - return workflowService.getWorkflowById(id); - } - - @PostMapping - public Workflow createWorkflow(@RequestBody Workflow workflow) { - return workflowService.createWorkflow(workflow); - } - - @PutMapping("/{id}") - public Workflow updateWorkflow(@PathVariable Long id, @RequestBody Workflow updatedWorkflow) { - return workflowService.updateWorkflow(id, updatedWorkflow); - } - - @DeleteMapping("/{id}") - public void deleteWorkflow(@PathVariable Long id) { - workflowService.deleteWorkflow(id); - } -} diff --git a/server/src/main/java/io/flexwork/modules/teams/web/rest/WorkflowStatusController.java b/server/src/main/java/io/flexwork/modules/teams/web/rest/WorkflowStatusController.java deleted file mode 100644 index 5c5f4ea4..00000000 --- a/server/src/main/java/io/flexwork/modules/teams/web/rest/WorkflowStatusController.java +++ /dev/null @@ -1,50 +0,0 @@ -package io.flexwork.modules.teams.web.rest; - -import io.flexwork.modules.teams.domain.WorkflowStatus; -import io.flexwork.modules.teams.service.WorkflowStatusService; -import java.util.List; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/api/teams/workflow-statuses") -public class WorkflowStatusController { - - private final WorkflowStatusService workflowStatusService; - - public WorkflowStatusController(WorkflowStatusService workflowStatusService) { - this.workflowStatusService = workflowStatusService; - } - - @GetMapping - public List getAllWorkflowStatuses() { - return workflowStatusService.getAllWorkflowStatuses(); - } - - @GetMapping("/{id}") - public WorkflowStatus getWorkflowStatusById(@PathVariable Long id) { - return workflowStatusService.getWorkflowStatusById(id); - } - - @PostMapping - public WorkflowStatus createWorkflowStatus(@RequestBody WorkflowStatus workflowStatus) { - return workflowStatusService.createWorkflowStatus(workflowStatus); - } - - @PutMapping("/{id}") - public WorkflowStatus updateWorkflowStatus( - @PathVariable Long id, @RequestBody WorkflowStatus updatedStatus) { - return workflowStatusService.updateWorkflowStatus(id, updatedStatus); - } - - @DeleteMapping("/{id}") - public void deleteWorkflowStatus(@PathVariable Long id) { - workflowStatusService.deleteWorkflowStatus(id); - } -} diff --git a/server/src/main/java/io/flexwork/modules/usermanagement/web/rest/AuthorityController.java b/server/src/main/java/io/flexwork/modules/usermanagement/web/rest/AuthorityController.java index df1af5fc..b95057ed 100644 --- a/server/src/main/java/io/flexwork/modules/usermanagement/web/rest/AuthorityController.java +++ b/server/src/main/java/io/flexwork/modules/usermanagement/web/rest/AuthorityController.java @@ -2,7 +2,6 @@ import io.flexwork.modules.usermanagement.domain.Authority; import io.flexwork.modules.usermanagement.repository.AuthorityRepository; -import io.flexwork.modules.usermanagement.web.rest.errors.BadRequestAlertException; import jakarta.validation.Valid; import java.net.URI; import java.net.URISyntaxException; @@ -50,9 +49,7 @@ public AuthorityController(AuthorityRepository authorityRepository) { public ResponseEntity createAuthority(@Valid @RequestBody Authority authority) throws URISyntaxException { LOG.debug("REST request to save Authority : {}", authority); - if (authorityRepository.existsById(authority.getName())) { - throw new BadRequestAlertException("authority already exists", ENTITY_NAME, "idexists"); - } + authority = authorityRepository.save(authority); return ResponseEntity.created(new URI("/api/authorities/" + authority.getName())) .headers( diff --git a/tools/liquibase/src/main/resources/config/liquibase/tenant/changelog/00000000000004_request_workflow_tables.xml b/tools/liquibase/src/main/resources/config/liquibase/tenant/changelog/00000000000004_request_workflow_tables.xml index 337adfd8..6a0adad0 100644 --- a/tools/liquibase/src/main/resources/config/liquibase/tenant/changelog/00000000000004_request_workflow_tables.xml +++ b/tools/liquibase/src/main/resources/config/liquibase/tenant/changelog/00000000000004_request_workflow_tables.xml @@ -6,154 +6,160 @@ http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd"> + + - + - - - - - - - - - - - - + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + + + + - + + - - - - - - - - - - - - + + + + + + - - + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + - + + + + + + + + + + + + + + - - + + + - - + + + + + - - + + - - - + + + + + - + + + - \ No newline at end of file