diff --git a/commons/src/main/java/io/flowinquiry/modules/collab/web/rest/ActivityLogController.java b/commons/src/main/java/io/flowinquiry/modules/collab/controller/ActivityLogController.java similarity index 96% rename from commons/src/main/java/io/flowinquiry/modules/collab/web/rest/ActivityLogController.java rename to commons/src/main/java/io/flowinquiry/modules/collab/controller/ActivityLogController.java index d897030..b73f88d 100644 --- a/commons/src/main/java/io/flowinquiry/modules/collab/web/rest/ActivityLogController.java +++ b/commons/src/main/java/io/flowinquiry/modules/collab/controller/ActivityLogController.java @@ -1,4 +1,4 @@ -package io.flowinquiry.modules.collab.web.rest; +package io.flowinquiry.modules.collab.controller; import io.flowinquiry.modules.collab.domain.EntityType; import io.flowinquiry.modules.collab.service.ActivityLogService; diff --git a/commons/src/main/java/io/flowinquiry/modules/collab/web/rest/CommentController.java b/commons/src/main/java/io/flowinquiry/modules/collab/controller/CommentController.java similarity index 97% rename from commons/src/main/java/io/flowinquiry/modules/collab/web/rest/CommentController.java rename to commons/src/main/java/io/flowinquiry/modules/collab/controller/CommentController.java index 05e4864..d3594e0 100644 --- a/commons/src/main/java/io/flowinquiry/modules/collab/web/rest/CommentController.java +++ b/commons/src/main/java/io/flowinquiry/modules/collab/controller/CommentController.java @@ -1,4 +1,4 @@ -package io.flowinquiry.modules.collab.web.rest; +package io.flowinquiry.modules.collab.controller; import io.flowinquiry.modules.collab.domain.Comment; import io.flowinquiry.modules.collab.domain.EntityType; diff --git a/commons/src/main/java/io/flowinquiry/modules/collab/web/rest/NotificationController.java b/commons/src/main/java/io/flowinquiry/modules/collab/controller/NotificationController.java similarity index 97% rename from commons/src/main/java/io/flowinquiry/modules/collab/web/rest/NotificationController.java rename to commons/src/main/java/io/flowinquiry/modules/collab/controller/NotificationController.java index d470231..ba384d2 100644 --- a/commons/src/main/java/io/flowinquiry/modules/collab/web/rest/NotificationController.java +++ b/commons/src/main/java/io/flowinquiry/modules/collab/controller/NotificationController.java @@ -1,4 +1,4 @@ -package io.flowinquiry.modules.collab.web.rest; +package io.flowinquiry.modules.collab.controller; import io.flowinquiry.modules.collab.service.NotificationService; import io.flowinquiry.modules.collab.service.dto.NotificationDTO; diff --git a/commons/src/main/java/io/flowinquiry/modules/fss/controller/EntityAttachmentController.java b/commons/src/main/java/io/flowinquiry/modules/fss/controller/EntityAttachmentController.java new file mode 100644 index 0000000..626a48b --- /dev/null +++ b/commons/src/main/java/io/flowinquiry/modules/fss/controller/EntityAttachmentController.java @@ -0,0 +1,75 @@ +package io.flowinquiry.modules.fss.controller; + +import io.flowinquiry.modules.fss.domain.EntityAttachment; +import io.flowinquiry.modules.fss.service.EntityAttachmentService; +import io.flowinquiry.modules.fss.service.dto.EntityAttachmentDTO; +import java.util.List; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +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.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +@RestController +@RequestMapping("/api/entity-attachments") +public class EntityAttachmentController { + + private final EntityAttachmentService attachmentService; + + public EntityAttachmentController(EntityAttachmentService attachmentService) { + this.attachmentService = attachmentService; + } + + /** + * Upload multiple attachments and associate them with a specific entity. + * + * @param entityType The type of entity (e.g., "team_request", "comment"). + * @param entityId The ID of the entity. + * @param files The list of files to upload. + * @return A list of saved attachment entities. + */ + @PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public ResponseEntity> uploadAttachments( + @RequestParam("entityType") String entityType, + @RequestParam("entityId") Long entityId, + @RequestPart("files") MultipartFile[] files) + throws Exception { + List attachments = + attachmentService.uploadAttachments(entityType, entityId, files); + return ResponseEntity.ok(attachments); + } + + /** + * Retrieve all attachments for a specific entity. + * + * @param entityType The type of entity (e.g., "team_request", "comment"). + * @param entityId The ID of the entity. + * @return A list of attachments for the specified entity. + */ + @GetMapping + public ResponseEntity> getAttachments( + @RequestParam("entityType") String entityType, + @RequestParam("entityId") Long entityId) { + List attachments = + attachmentService.getAttachments(entityType, entityId); + return ResponseEntity.ok(attachments); + } + + /** + * Deletes an attachment by its ID. + * + * @param attachmentId The ID of the attachment to delete. + * @return A ResponseEntity indicating the result of the deletion. + */ + @DeleteMapping("/{attachmentId}") + public ResponseEntity deleteAttachment(@PathVariable("attachmentId") Long attachmentId) { + attachmentService.deleteAttachment(attachmentId); + return ResponseEntity.noContent().build(); + } +} diff --git a/commons/src/main/java/io/flowinquiry/modules/fss/web/rest/FileDownloadController.java b/commons/src/main/java/io/flowinquiry/modules/fss/controller/FileDownloadController.java similarity index 97% rename from commons/src/main/java/io/flowinquiry/modules/fss/web/rest/FileDownloadController.java rename to commons/src/main/java/io/flowinquiry/modules/fss/controller/FileDownloadController.java index 932985c..5f59c7f 100644 --- a/commons/src/main/java/io/flowinquiry/modules/fss/web/rest/FileDownloadController.java +++ b/commons/src/main/java/io/flowinquiry/modules/fss/controller/FileDownloadController.java @@ -1,4 +1,4 @@ -package io.flowinquiry.modules.fss.web.rest; +package io.flowinquiry.modules.fss.controller; import io.flowinquiry.modules.fss.service.StorageService; import jakarta.servlet.http.HttpServletRequest; diff --git a/commons/src/main/java/io/flowinquiry/modules/fss/web/rest/FileUploadController.java b/commons/src/main/java/io/flowinquiry/modules/fss/controller/FileUploadController.java similarity index 80% rename from commons/src/main/java/io/flowinquiry/modules/fss/web/rest/FileUploadController.java rename to commons/src/main/java/io/flowinquiry/modules/fss/controller/FileUploadController.java index 62bde67..e3a96a8 100644 --- a/commons/src/main/java/io/flowinquiry/modules/fss/web/rest/FileUploadController.java +++ b/commons/src/main/java/io/flowinquiry/modules/fss/controller/FileUploadController.java @@ -1,11 +1,9 @@ -package io.flowinquiry.modules.fss.web.rest; +package io.flowinquiry.modules.fss.controller; import io.flowinquiry.modules.fss.service.StorageService; import io.flowinquiry.modules.usermanagement.service.dto.UserKey; import io.flowinquiry.security.SecurityUtils; import jakarta.json.Json; -import java.util.HashMap; -import java.util.Map; import java.util.Optional; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -22,15 +20,6 @@ public class FileUploadController { private static final Logger LOG = LoggerFactory.getLogger(FileUploadController.class); - private static final String AVATAR_TYPE = "avatar"; - - private final Map typeRelativePaths = - new HashMap<>() { - { - put(AVATAR_TYPE, AVATAR_TYPE); - } - }; - private final StorageService storageService; public FileUploadController(StorageService storageService) { @@ -49,10 +38,10 @@ public ResponseEntity submit( currentUser, file.getOriginalFilename(), type); - - if (!typeRelativePaths.containsKey(type)) + String prefixPath = storageService.getRelativePathByType(type); + if (prefixPath == null) { return ResponseEntity.badRequest().body("Not support upload with type " + type); - String prefixPath = typeRelativePaths.get(type); + } String path = storageService.uploadFile( diff --git a/commons/src/main/java/io/flowinquiry/modules/fss/domain/EntityAttachment.java b/commons/src/main/java/io/flowinquiry/modules/fss/domain/EntityAttachment.java new file mode 100644 index 0000000..3540379 --- /dev/null +++ b/commons/src/main/java/io/flowinquiry/modules/fss/domain/EntityAttachment.java @@ -0,0 +1,66 @@ +package io.flowinquiry.modules.fss.domain; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.PrePersist; +import jakarta.persistence.Table; +import jakarta.persistence.UniqueConstraint; +import java.time.LocalDateTime; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Entity +@Table( + name = "fw_entity_attachment", + uniqueConstraints = + @UniqueConstraint(columnNames = {"entity_type", "entity_id", "file_url"})) +@Getter +@Setter +@Builder +@EqualsAndHashCode(onlyExplicitlyIncluded = true) +@NoArgsConstructor +@AllArgsConstructor +public class EntityAttachment { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @EqualsAndHashCode.Include + @Column(name = "entity_type", nullable = false, length = 50) + private String entityType; + + @EqualsAndHashCode.Include + @Column(name = "entity_id", nullable = false) + private Long entityId; + + @Column(name = "file_name", nullable = false, length = 255) + private String fileName; + + @Column(name = "file_type", length = 100) + private String fileType; + + @Column(name = "file_size") + private Long fileSize; + + @EqualsAndHashCode.Include + @Column(name = "file_url", nullable = false, columnDefinition = "TEXT") + private String fileUrl; + + @Column(name = "uploaded_at", nullable = false, updatable = false) + private LocalDateTime uploadedAt; + + @PrePersist + public void prePersist() { + if (this.uploadedAt == null) { + this.uploadedAt = LocalDateTime.now(); + } + } +} diff --git a/commons/src/main/java/io/flowinquiry/modules/fss/repository/EntityAttachmentRepository.java b/commons/src/main/java/io/flowinquiry/modules/fss/repository/EntityAttachmentRepository.java new file mode 100644 index 0000000..6cb1dc6 --- /dev/null +++ b/commons/src/main/java/io/flowinquiry/modules/fss/repository/EntityAttachmentRepository.java @@ -0,0 +1,27 @@ +package io.flowinquiry.modules.fss.repository; + +import io.flowinquiry.modules.fss.domain.EntityAttachment; +import java.util.List; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface EntityAttachmentRepository extends JpaRepository { + + /** + * Finds all attachments for a specific entity type and entity ID. + * + * @param entityType The type of entity (e.g., "team_request", "comment"). + * @param entityId The ID of the entity. + * @return A list of attachments for the specified entity. + */ + List findByEntityTypeAndEntityId(String entityType, Long entityId); + + /** + * Deletes all attachments for a specific entity type and entity ID. + * + * @param entityType The type of entity (e.g., "team_request", "comment"). + * @param entityId The ID of the entity. + */ + void deleteByEntityTypeAndEntityId(String entityType, Long entityId); +} diff --git a/commons/src/main/java/io/flowinquiry/modules/fss/service/EntityAttachmentService.java b/commons/src/main/java/io/flowinquiry/modules/fss/service/EntityAttachmentService.java new file mode 100644 index 0000000..be9c862 --- /dev/null +++ b/commons/src/main/java/io/flowinquiry/modules/fss/service/EntityAttachmentService.java @@ -0,0 +1,149 @@ +package io.flowinquiry.modules.fss.service; + +import io.flowinquiry.modules.fss.domain.EntityAttachment; +import io.flowinquiry.modules.fss.repository.EntityAttachmentRepository; +import io.flowinquiry.modules.fss.service.dto.EntityAttachmentDTO; +import io.flowinquiry.modules.fss.service.mapper.EntityAttachmentMapper; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +@Service +public class EntityAttachmentService { + + private static final Logger LOG = LoggerFactory.getLogger(EntityAttachmentService.class); + + private final EntityAttachmentRepository entityAttachmentRepository; + private final EntityAttachmentMapper entityAttachmentMapper; + private final StorageService storageService; + + public EntityAttachmentService( + EntityAttachmentRepository entityAttachmentRepository, + EntityAttachmentMapper entityAttachmentMapper, + StorageService storageService) { + this.entityAttachmentRepository = entityAttachmentRepository; + this.entityAttachmentMapper = entityAttachmentMapper; + this.storageService = storageService; + } + + /** + * Uploads a single attachment and returns an unsaved EntityAttachment object. + * + * @param entityType The type of entity (e.g., "team_request", "comment"). + * @param entityId The ID of the entity. + * @param file The file to upload. + * @return An unsaved EntityAttachment object. + * @throws Exception If file storage fails or the file is empty. + */ + private EntityAttachment createAttachment(String entityType, Long entityId, MultipartFile file) + throws Exception { + if (file.isEmpty()) { + throw new IllegalArgumentException("File cannot be empty."); + } + + // Store the file and get its URL + String fileUrl = + storageService.uploadFile( + StorageService.ATTACHMENTS, + file.getOriginalFilename(), + file.getInputStream()); + + // Create the attachment entity + EntityAttachment attachment = new EntityAttachment(); + attachment.setEntityType(entityType); + attachment.setEntityId(entityId); + attachment.setFileName(file.getOriginalFilename()); + attachment.setFileType(file.getContentType()); + attachment.setFileSize(file.getSize()); + attachment.setFileUrl(fileUrl); + attachment.setUploadedAt(LocalDateTime.now()); + + return attachment; + } + + /** + * Uploads multiple attachments and associates them with a specific entity using batch insert. + * + * @param entityType The type of entity (e.g., "team_request", "comment"). + * @param entityId The ID of the entity. + * @param files The list of files to upload. + * @return A list of saved EntityAttachment objects. + * @throws Exception If any file storage operation fails. + */ + @Transactional + public List uploadAttachments( + String entityType, Long entityId, MultipartFile[] files) throws Exception { + if (files == null || files.length == 0) { + throw new IllegalArgumentException("File list cannot be empty."); + } + + List attachments = new ArrayList<>(); + for (MultipartFile file : files) { + attachments.add(createAttachment(entityType, entityId, file)); + } + + // Perform batch insert for all attachments + return entityAttachmentRepository.saveAll(attachments); + } + + /** + * Retrieves all attachments associated with a specific entity. + * + * @param entityType The type of entity (e.g., "team_request", "comment"). + * @param entityId The ID of the entity. + * @return A list of attachments for the entity. + */ + public List getAttachments(String entityType, Long entityId) { + return entityAttachmentMapper.toDtoList( + entityAttachmentRepository.findByEntityTypeAndEntityId(entityType, entityId)); + } + + /** + * Deletes all attachments associated with a specific entity. + * + * @param entityType The type of entity (e.g., "team_request", "comment"). + * @param entityId The ID of the entity. + */ + public void deleteAttachments(String entityType, Long entityId) throws Exception { + List attachments = + entityAttachmentRepository.findByEntityTypeAndEntityId(entityType, entityId); + + for (EntityAttachment attachment : attachments) { + if (attachment.getFileUrl() != null) { + storageService.deleteFile(attachment.getFileUrl()); + } + } + + // Delete the attachment records from the database + entityAttachmentRepository.deleteAll(attachments); + } + + /** + * Deletes an attachment by its ID. If the attachment does not exist, it silently ignores the + * operation. + * + * @param attachmentId The ID of the attachment to delete. + */ + @Transactional + public void deleteAttachment(Long attachmentId) { + entityAttachmentRepository + .findById(attachmentId) + .ifPresent( + attachment -> { + if (attachment.getFileUrl() != null) { + try { + storageService.deleteFile(attachment.getFileUrl()); + } catch (Exception e) { + LOG.error("Can not delete file {}", attachment.getFileUrl(), e); + } + } + + entityAttachmentRepository.deleteById(attachmentId); + }); + } +} diff --git a/commons/src/main/java/io/flowinquiry/modules/fss/service/StorageService.java b/commons/src/main/java/io/flowinquiry/modules/fss/service/StorageService.java index 5ca1f8f..39235c9 100644 --- a/commons/src/main/java/io/flowinquiry/modules/fss/service/StorageService.java +++ b/commons/src/main/java/io/flowinquiry/modules/fss/service/StorageService.java @@ -2,9 +2,26 @@ import java.io.InputStream; import java.io.OutputStream; +import java.util.HashMap; +import java.util.Map; public interface StorageService { + String AVATAR_TYPE = "avatar"; + + String ATTACHMENTS = "attachments"; + + Map typeRelativePaths = + new HashMap<>() { + { + put(AVATAR_TYPE, AVATAR_TYPE); + } + }; + + default String getRelativePathByType(String type) { + return typeRelativePaths.get(type); + } + String uploadFile(String containerName, String blobName, InputStream inputStream) throws Exception; diff --git a/commons/src/main/java/io/flowinquiry/modules/fss/service/dto/EntityAttachmentDTO.java b/commons/src/main/java/io/flowinquiry/modules/fss/service/dto/EntityAttachmentDTO.java new file mode 100644 index 0000000..ff267ae --- /dev/null +++ b/commons/src/main/java/io/flowinquiry/modules/fss/service/dto/EntityAttachmentDTO.java @@ -0,0 +1,16 @@ +package io.flowinquiry.modules.fss.service.dto; + +import java.time.LocalDateTime; +import lombok.Data; + +@Data +public class EntityAttachmentDTO { + private Long id; + private String entityType; + private Long entityId; + private String fileName; + private String fileType; + private Long fileSize; + private String fileUrl; + private LocalDateTime uploadedAt; +} diff --git a/commons/src/main/java/io/flowinquiry/modules/fss/service/mapper/EntityAttachmentMapper.java b/commons/src/main/java/io/flowinquiry/modules/fss/service/mapper/EntityAttachmentMapper.java new file mode 100644 index 0000000..f3d7bf0 --- /dev/null +++ b/commons/src/main/java/io/flowinquiry/modules/fss/service/mapper/EntityAttachmentMapper.java @@ -0,0 +1,14 @@ +package io.flowinquiry.modules.fss.service.mapper; + +import io.flowinquiry.modules.fss.domain.EntityAttachment; +import io.flowinquiry.modules.fss.service.dto.EntityAttachmentDTO; +import java.util.List; +import org.mapstruct.Mapper; + +@Mapper(componentModel = "spring") +public interface EntityAttachmentMapper { + + EntityAttachmentDTO toDto(EntityAttachment entity); + + List toDtoList(List entities); +} diff --git a/commons/src/main/java/io/flowinquiry/modules/teams/web/rest/OrganizationController.java b/commons/src/main/java/io/flowinquiry/modules/teams/controller/OrganizationController.java similarity index 98% rename from commons/src/main/java/io/flowinquiry/modules/teams/web/rest/OrganizationController.java rename to commons/src/main/java/io/flowinquiry/modules/teams/controller/OrganizationController.java index 13756cf..7c4ebb0 100644 --- a/commons/src/main/java/io/flowinquiry/modules/teams/web/rest/OrganizationController.java +++ b/commons/src/main/java/io/flowinquiry/modules/teams/controller/OrganizationController.java @@ -1,4 +1,4 @@ -package io.flowinquiry.modules.teams.web.rest; +package io.flowinquiry.modules.teams.controller; import io.flowinquiry.modules.teams.domain.Organization; import io.flowinquiry.modules.teams.service.OrganizationService; diff --git a/commons/src/main/java/io/flowinquiry/modules/teams/web/rest/TeamController.java b/commons/src/main/java/io/flowinquiry/modules/teams/controller/TeamController.java similarity index 99% rename from commons/src/main/java/io/flowinquiry/modules/teams/web/rest/TeamController.java rename to commons/src/main/java/io/flowinquiry/modules/teams/controller/TeamController.java index e80e139..aee0f23 100644 --- a/commons/src/main/java/io/flowinquiry/modules/teams/web/rest/TeamController.java +++ b/commons/src/main/java/io/flowinquiry/modules/teams/controller/TeamController.java @@ -1,4 +1,4 @@ -package io.flowinquiry.modules.teams.web.rest; +package io.flowinquiry.modules.teams.controller; import io.flowinquiry.modules.fss.ResourceRemoveEvent; import io.flowinquiry.modules.fss.service.StorageService; diff --git a/commons/src/main/java/io/flowinquiry/modules/teams/web/rest/TeamRequestController.java b/commons/src/main/java/io/flowinquiry/modules/teams/controller/TeamRequestController.java similarity index 99% rename from commons/src/main/java/io/flowinquiry/modules/teams/web/rest/TeamRequestController.java rename to commons/src/main/java/io/flowinquiry/modules/teams/controller/TeamRequestController.java index 1745567..ec3f048 100644 --- a/commons/src/main/java/io/flowinquiry/modules/teams/web/rest/TeamRequestController.java +++ b/commons/src/main/java/io/flowinquiry/modules/teams/controller/TeamRequestController.java @@ -1,4 +1,4 @@ -package io.flowinquiry.modules.teams.web.rest; +package io.flowinquiry.modules.teams.controller; import io.flowinquiry.modules.teams.service.TeamRequestService; import io.flowinquiry.modules.teams.service.WorkflowTransitionHistoryService; diff --git a/commons/src/main/java/io/flowinquiry/modules/teams/web/rest/WorkflowController.java b/commons/src/main/java/io/flowinquiry/modules/teams/controller/WorkflowController.java similarity index 99% rename from commons/src/main/java/io/flowinquiry/modules/teams/web/rest/WorkflowController.java rename to commons/src/main/java/io/flowinquiry/modules/teams/controller/WorkflowController.java index 5873bcc..ee9ec4b 100644 --- a/commons/src/main/java/io/flowinquiry/modules/teams/web/rest/WorkflowController.java +++ b/commons/src/main/java/io/flowinquiry/modules/teams/controller/WorkflowController.java @@ -1,4 +1,4 @@ -package io.flowinquiry.modules.teams.web.rest; +package io.flowinquiry.modules.teams.controller; import io.flowinquiry.modules.teams.domain.Workflow; import io.flowinquiry.modules.teams.service.WorkflowService; diff --git a/commons/src/main/java/io/flowinquiry/modules/teams/domain/TeamRequest.java b/commons/src/main/java/io/flowinquiry/modules/teams/domain/TeamRequest.java index bef4137..7d444d5 100644 --- a/commons/src/main/java/io/flowinquiry/modules/teams/domain/TeamRequest.java +++ b/commons/src/main/java/io/flowinquiry/modules/teams/domain/TeamRequest.java @@ -22,6 +22,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import org.hibernate.annotations.Formula; @EqualsAndHashCode(callSuper = false) @Entity @@ -93,4 +94,8 @@ public class TeamRequest extends AbstractAuditingEntity { joinColumns = @JoinColumn(name = "team_request_id"), inverseJoinColumns = @JoinColumn(name = "user_id")) private Set watchers; + + @Formula( + "(SELECT COUNT(a.id) FROM fw_entity_attachment a WHERE a.entity_type = 'Team_Request' AND a.entity_id = id)") + private int numberAttachments; } diff --git a/commons/src/main/java/io/flowinquiry/modules/teams/service/dto/TeamRequestDTO.java b/commons/src/main/java/io/flowinquiry/modules/teams/service/dto/TeamRequestDTO.java index bf2bd02..a830a45 100644 --- a/commons/src/main/java/io/flowinquiry/modules/teams/service/dto/TeamRequestDTO.java +++ b/commons/src/main/java/io/flowinquiry/modules/teams/service/dto/TeamRequestDTO.java @@ -39,4 +39,5 @@ public class TeamRequestDTO { private Instant createdAt; private Instant modifiedAt; private Set watchers; + private int numberAttachments; } diff --git a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/AuthenticateController.java b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/AuthenticateController.java similarity index 98% rename from commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/AuthenticateController.java rename to commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/AuthenticateController.java index 95f778f..93f864c 100644 --- a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/AuthenticateController.java +++ b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/AuthenticateController.java @@ -1,4 +1,4 @@ -package io.flowinquiry.modules.usermanagement.web.rest; +package io.flowinquiry.modules.usermanagement.controller; import static io.flowinquiry.security.SecurityUtils.AUTHORITIES_KEY; import static io.flowinquiry.security.SecurityUtils.JWT_ALGORITHM; diff --git a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/AuthorityController.java b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/AuthorityController.java similarity index 99% rename from commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/AuthorityController.java rename to commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/AuthorityController.java index 8d46f7d..f7f68ad 100644 --- a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/AuthorityController.java +++ b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/AuthorityController.java @@ -1,4 +1,4 @@ -package io.flowinquiry.modules.usermanagement.web.rest; +package io.flowinquiry.modules.usermanagement.controller; import io.flowinquiry.modules.usermanagement.domain.Authority; import io.flowinquiry.modules.usermanagement.service.AuthorityService; diff --git a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/AuthorityResourcePermissionController.java b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/AuthorityResourcePermissionController.java similarity index 96% rename from commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/AuthorityResourcePermissionController.java rename to commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/AuthorityResourcePermissionController.java index 39eb30c..4884291 100644 --- a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/AuthorityResourcePermissionController.java +++ b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/AuthorityResourcePermissionController.java @@ -1,4 +1,4 @@ -package io.flowinquiry.modules.usermanagement.web.rest; +package io.flowinquiry.modules.usermanagement.controller; import io.flowinquiry.modules.usermanagement.service.AuthorityResourcePermissionService; import io.flowinquiry.modules.usermanagement.service.dto.AuthorityResourcePermissionDTO; diff --git a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/KeyAndPasswordVM.java b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/KeyAndPasswordVM.java similarity index 76% rename from commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/KeyAndPasswordVM.java rename to commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/KeyAndPasswordVM.java index 370d36f..842f3b9 100644 --- a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/KeyAndPasswordVM.java +++ b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/KeyAndPasswordVM.java @@ -1,4 +1,4 @@ -package io.flowinquiry.modules.usermanagement.web.rest; +package io.flowinquiry.modules.usermanagement.controller; import lombok.Data; diff --git a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/LoginController.java b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/LoginController.java similarity index 98% rename from commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/LoginController.java rename to commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/LoginController.java index 088908f..1f5f7eb 100644 --- a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/LoginController.java +++ b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/LoginController.java @@ -1,4 +1,4 @@ -package io.flowinquiry.modules.usermanagement.web.rest; +package io.flowinquiry.modules.usermanagement.controller; import static io.flowinquiry.security.SecurityUtils.AUTHORITIES_KEY; import static io.flowinquiry.security.SecurityUtils.JWT_ALGORITHM; diff --git a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/LoginVM.java b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/LoginVM.java similarity index 94% rename from commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/LoginVM.java rename to commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/LoginVM.java index dcea0f0..b9fa4d3 100644 --- a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/LoginVM.java +++ b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/LoginVM.java @@ -1,4 +1,4 @@ -package io.flowinquiry.modules.usermanagement.web.rest; +package io.flowinquiry.modules.usermanagement.controller; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; diff --git a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/ManagedUserVM.java b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/ManagedUserVM.java similarity index 93% rename from commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/ManagedUserVM.java rename to commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/ManagedUserVM.java index 714bb95..df19d25 100644 --- a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/ManagedUserVM.java +++ b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/ManagedUserVM.java @@ -1,4 +1,4 @@ -package io.flowinquiry.modules.usermanagement.web.rest; +package io.flowinquiry.modules.usermanagement.controller; import io.flowinquiry.modules.usermanagement.service.dto.UserDTO; import jakarta.validation.constraints.Size; diff --git a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/PublicUserController.java b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/PublicUserController.java similarity index 99% rename from commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/PublicUserController.java rename to commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/PublicUserController.java index d29e58e..5b55575 100644 --- a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/PublicUserController.java +++ b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/PublicUserController.java @@ -1,4 +1,4 @@ -package io.flowinquiry.modules.usermanagement.web.rest; +package io.flowinquiry.modules.usermanagement.controller; import io.flowinquiry.modules.fss.service.StorageService; import io.flowinquiry.modules.usermanagement.AuthoritiesConstants; diff --git a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/ResourceController.java b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/ResourceController.java similarity index 95% rename from commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/ResourceController.java rename to commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/ResourceController.java index 6698d38..e3bf13f 100644 --- a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/ResourceController.java +++ b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/ResourceController.java @@ -1,4 +1,4 @@ -package io.flowinquiry.modules.usermanagement.web.rest; +package io.flowinquiry.modules.usermanagement.controller; import io.flowinquiry.modules.usermanagement.repository.ResourceRepository; import io.flowinquiry.modules.usermanagement.service.dto.ResourceDTO; diff --git a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/UserAccountController.java b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/UserAccountController.java similarity index 99% rename from commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/UserAccountController.java rename to commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/UserAccountController.java index 1712ed3..7d564a8 100644 --- a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/UserAccountController.java +++ b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/UserAccountController.java @@ -1,4 +1,4 @@ -package io.flowinquiry.modules.usermanagement.web.rest; +package io.flowinquiry.modules.usermanagement.controller; import io.flowinquiry.modules.collab.service.MailService; import io.flowinquiry.modules.usermanagement.EmailAlreadyUsedException; diff --git a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/errors/ErrorResponse.java b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/errors/ErrorResponse.java similarity index 79% rename from commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/errors/ErrorResponse.java rename to commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/errors/ErrorResponse.java index ba4937a..8467328 100644 --- a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/errors/ErrorResponse.java +++ b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/errors/ErrorResponse.java @@ -1,4 +1,4 @@ -package io.flowinquiry.modules.usermanagement.web.rest.errors; +package io.flowinquiry.modules.usermanagement.controller.errors; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/errors/ExceptionStatusMapper.java b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/errors/ExceptionStatusMapper.java similarity index 97% rename from commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/errors/ExceptionStatusMapper.java rename to commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/errors/ExceptionStatusMapper.java index a6b2494..c1165fc 100644 --- a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/errors/ExceptionStatusMapper.java +++ b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/errors/ExceptionStatusMapper.java @@ -1,4 +1,4 @@ -package io.flowinquiry.modules.usermanagement.web.rest.errors; +package io.flowinquiry.modules.usermanagement.controller.errors; import io.flowinquiry.exceptions.ResourceConstraintException; import io.flowinquiry.exceptions.ResourceNotFoundException; diff --git a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/errors/ExceptionTranslator.java b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/errors/ExceptionTranslator.java similarity index 97% rename from commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/errors/ExceptionTranslator.java rename to commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/errors/ExceptionTranslator.java index 81392c8..fd6c13e 100644 --- a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/errors/ExceptionTranslator.java +++ b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/errors/ExceptionTranslator.java @@ -1,4 +1,4 @@ -package io.flowinquiry.modules.usermanagement.web.rest.errors; +package io.flowinquiry.modules.usermanagement.controller.errors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/errors/package-info.java b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/errors/package-info.java new file mode 100644 index 0000000..3e7c931 --- /dev/null +++ b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/errors/package-info.java @@ -0,0 +1,2 @@ +/** Rest layer error handling. */ +package io.flowinquiry.modules.usermanagement.controller.errors; diff --git a/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/package-info.java b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/package-info.java new file mode 100644 index 0000000..285d0fc --- /dev/null +++ b/commons/src/main/java/io/flowinquiry/modules/usermanagement/controller/package-info.java @@ -0,0 +1,2 @@ +/** Rest layer. */ +package io.flowinquiry.modules.usermanagement.controller; diff --git a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/errors/package-info.java b/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/errors/package-info.java deleted file mode 100644 index c9894c0..0000000 --- a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/errors/package-info.java +++ /dev/null @@ -1,2 +0,0 @@ -/** Rest layer error handling. */ -package io.flowinquiry.modules.usermanagement.web.rest.errors; diff --git a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/package-info.java b/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/package-info.java deleted file mode 100644 index b32a9b0..0000000 --- a/commons/src/main/java/io/flowinquiry/modules/usermanagement/web/rest/package-info.java +++ /dev/null @@ -1,2 +0,0 @@ -/** Rest layer. */ -package io.flowinquiry.modules.usermanagement.web.rest; diff --git a/server/src/test/java/io/flowinquiry/web/rest/AuthenticateControllerIT.java b/server/src/test/java/io/flowinquiry/web/rest/AuthenticateControllerIT.java index ca6921b..eb5ec09 100644 --- a/server/src/test/java/io/flowinquiry/web/rest/AuthenticateControllerIT.java +++ b/server/src/test/java/io/flowinquiry/web/rest/AuthenticateControllerIT.java @@ -12,13 +12,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.flowinquiry.IntegrationTest; +import io.flowinquiry.modules.usermanagement.controller.AuthenticateController; +import io.flowinquiry.modules.usermanagement.controller.LoginVM; import io.flowinquiry.modules.usermanagement.domain.User; import io.flowinquiry.modules.usermanagement.domain.UserAuth; import io.flowinquiry.modules.usermanagement.domain.UserStatus; import io.flowinquiry.modules.usermanagement.repository.UserAuthRepository; import io.flowinquiry.modules.usermanagement.repository.UserRepository; -import io.flowinquiry.modules.usermanagement.web.rest.AuthenticateController; -import io.flowinquiry.modules.usermanagement.web.rest.LoginVM; import java.util.Set; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; diff --git a/server/src/test/java/io/flowinquiry/web/rest/AuthorityControllerIT.java b/server/src/test/java/io/flowinquiry/web/rest/AuthorityControllerIT.java index cb23e3e..c6e2ae8 100644 --- a/server/src/test/java/io/flowinquiry/web/rest/AuthorityControllerIT.java +++ b/server/src/test/java/io/flowinquiry/web/rest/AuthorityControllerIT.java @@ -14,9 +14,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.flowinquiry.IntegrationTest; +import io.flowinquiry.modules.usermanagement.controller.AuthorityController; import io.flowinquiry.modules.usermanagement.domain.Authority; import io.flowinquiry.modules.usermanagement.repository.AuthorityRepository; -import io.flowinquiry.modules.usermanagement.web.rest.AuthorityController; import jakarta.persistence.EntityManager; import java.util.UUID; import org.junit.jupiter.api.AfterEach; diff --git a/server/src/test/java/io/flowinquiry/web/rest/PublicUserControllerIT.java b/server/src/test/java/io/flowinquiry/web/rest/PublicUserControllerIT.java index d48bd0c..2a0e04a 100644 --- a/server/src/test/java/io/flowinquiry/web/rest/PublicUserControllerIT.java +++ b/server/src/test/java/io/flowinquiry/web/rest/PublicUserControllerIT.java @@ -9,10 +9,10 @@ import io.flowinquiry.IntegrationTest; import io.flowinquiry.modules.usermanagement.AuthoritiesConstants; +import io.flowinquiry.modules.usermanagement.controller.PublicUserController; import io.flowinquiry.modules.usermanagement.domain.User; import io.flowinquiry.modules.usermanagement.repository.UserRepository; import io.flowinquiry.modules.usermanagement.service.UserService; -import io.flowinquiry.modules.usermanagement.web.rest.PublicUserController; import jakarta.persistence.EntityManager; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; diff --git a/server/src/test/java/io/flowinquiry/web/rest/UserAccountControllerIT.java b/server/src/test/java/io/flowinquiry/web/rest/UserAccountControllerIT.java index cc2149a..5cbf195 100644 --- a/server/src/test/java/io/flowinquiry/web/rest/UserAccountControllerIT.java +++ b/server/src/test/java/io/flowinquiry/web/rest/UserAccountControllerIT.java @@ -11,6 +11,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.flowinquiry.IntegrationTest; import io.flowinquiry.modules.usermanagement.AuthoritiesConstants; +import io.flowinquiry.modules.usermanagement.controller.KeyAndPasswordVM; +import io.flowinquiry.modules.usermanagement.controller.ManagedUserVM; +import io.flowinquiry.modules.usermanagement.controller.UserAccountController; import io.flowinquiry.modules.usermanagement.domain.User; import io.flowinquiry.modules.usermanagement.domain.UserAuth; import io.flowinquiry.modules.usermanagement.domain.UserStatus; @@ -20,9 +23,6 @@ import io.flowinquiry.modules.usermanagement.service.dto.PasswordChangeDTO; import io.flowinquiry.modules.usermanagement.service.dto.UserDTO; import io.flowinquiry.modules.usermanagement.service.mapper.UserMapper; -import io.flowinquiry.modules.usermanagement.web.rest.KeyAndPasswordVM; -import io.flowinquiry.modules.usermanagement.web.rest.ManagedUserVM; -import io.flowinquiry.modules.usermanagement.web.rest.UserAccountController; import io.flowinquiry.security.Constants; import java.time.Instant; import java.util.HashSet; diff --git a/tools/liquibase/src/main/resources/config/liquibase/tenant/changelog/001_request_workflow_tables.xml b/tools/liquibase/src/main/resources/config/liquibase/tenant/changelog/001_request_workflow_tables.xml index 6365ffb..acacde8 100644 --- a/tools/liquibase/src/main/resources/config/liquibase/tenant/changelog/001_request_workflow_tables.xml +++ b/tools/liquibase/src/main/resources/config/liquibase/tenant/changelog/001_request_workflow_tables.xml @@ -380,6 +380,44 @@ baseColumnNames="escalated_to_user_id" constraintName="fw_escalation_tracking_user" referencedTableName="fw_user" referencedColumnNames="id" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +