Skip to content

Commit

Permalink
Modular (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
haiphucnguyen authored Dec 28, 2024
1 parent ee46b9e commit 1a046fc
Show file tree
Hide file tree
Showing 254 changed files with 601 additions and 399 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,4 @@ Desktop.ini
/tools/liquibase/build
docker/volumes
storage
commons/build
38 changes: 32 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,48 @@ plugins {
id "com.github.ben-manes.versions" version "0.51.0"
}

description = "The flexible configurable crm service"
description = "The flexible configurable ticket management"

assert System.properties["java.specification.version"] == "21" || "22" || "23"

allprojects {
group = 'io.flowinquiry'
version = project.findProperty('version')
repositories {
mavenCentral()
}

subprojects {
afterEvaluate {
if (it.plugins.hasPlugin('java') || it.plugins.hasPlugin('java-library')) {
java {
sourceCompatibility=21
targetCompatibility=21
afterEvaluate { project ->
if (project.plugins.hasPlugin('java') || project.plugins.hasPlugin('java-library')) {
project.java {
sourceCompatibility = 21
targetCompatibility = 21
}
}

if (project.plugins.hasPlugin('java-library')) {
project.apply(plugin: 'maven-publish')

project.publishing {
publications {
// Check if the publication already exists
if (!project.publishing.publications.names.contains("${project.name}MavenJava")) {
create("${project.name}MavenJava", MavenPublication) {
from project.components.java
}
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/flowinquiry/flowinquiry-server")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.token") ?: System.getenv("GITHUB_TOKEN")
}
}
}
}
}
}
Expand Down
8 changes: 0 additions & 8 deletions buildSrc/gradle/libs.versions.toml

This file was deleted.

7 changes: 7 additions & 0 deletions buildSrc/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dependencyResolutionManagement {
versionCatalogs {
create('libs', { from(files("../gradle/libs.versions.toml")) })
}
}

rootProject.name = 'buildSrc'
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jib {
}
to {
image = "flowinquiry/flowinquiry-server"
tags = ['latest', findProperty('projectVersion')]
tags = ['latest', findProperty('version')]
}
container {
entrypoint = ["bash", "-c", "/entrypoint.sh"]
Expand Down
80 changes: 80 additions & 0 deletions commons/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
plugins {
id 'java-library'
id 'maven-publish'
alias(libs.plugins.spring.dependency.management)
}

group = 'io.flowinquiry'

repositories {
mavenCentral()
}

dependencyManagement {
imports {
mavenBom "org.springframework.boot:spring-boot-dependencies:3.4.1"
}
}

dependencies {
compileOnly(libs.lombok)
api(libs.bundles.json)
api(libs.bundles.shedlock)
api(libs.dot.env)
api(libs.j2html)
api(libs.jclouds) {
exclude group: "com.sun.xml.bind"
}
api(libs.jhipster.framework)
api project(":tools:liquibase")


api("com.fasterxml.jackson.module:jackson-module-jaxb-annotations")
api("com.fasterxml.jackson.datatype:jackson-datatype-hppc")
api("com.fasterxml.jackson.datatype:jackson-datatype-hibernate6")
api("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
api("com.zaxxer:HikariCP")
api("jakarta.annotation:jakarta.annotation-api")
api("org.apache.commons:commons-lang3")
api("org.hibernate.orm:hibernate-core")
api("org.hibernate.validator:hibernate-validator")

api("org.springframework.boot:spring-boot-starter-actuator")
api("org.springframework.boot:spring-boot-starter-aop")
api("org.springframework.boot:spring-boot-starter-data-jpa")
api("org.springframework.boot:spring-boot-loader-tools")
api("org.springframework.boot:spring-boot-starter-logging")
api("org.springframework.boot:spring-boot-starter-mail")
api("org.springframework.boot:spring-boot-starter-oauth2-resource-server")
api("org.springframework.boot:spring-boot-starter-security")
api("org.springframework.boot:spring-boot-starter-thymeleaf")
api("org.springframework.boot:spring-boot-starter-undertow")
modules {
module("org.springframework.boot:spring-boot-starter-tomcat") {
replacedBy("org.springframework.boot:spring-boot-starter-undertow", "Use Undertow instead of Tomcat")
}
}
api("org.springframework.boot:spring-boot-starter-validation")
api("org.springframework.boot:spring-boot-starter-web")
api("org.springframework.security:spring-security-data")


testImplementation platform('org.junit:junit-bom:5.10.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation(libs.assertJ)

testCompileOnly(libs.lombok)
testAnnotationProcessor(libs.lombok)

annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
annotationProcessor("org.hibernate.orm:hibernate-jpamodelgen")
annotationProcessor("org.glassfish.jaxb:jaxb-runtime")
annotationProcessor(libs.lombok)
// Keep mapstruct dependency below the lombok
api(libs.mapstruct)
annotationProcessor(libs.mapstruct.processor)
}

test {
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
package io.flowinquiry.config;

import static io.flowinquiry.security.SecurityUtils.JWT_ALGORITHM;

import com.nimbusds.jose.jwk.source.ImmutableSecret;
import com.nimbusds.jose.util.Base64;
import io.flowinquiry.security.management.SecurityMetersService;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.jwt.*;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.security.oauth2.jwt.JwtEncoder;
import org.springframework.security.oauth2.jwt.NimbusJwtDecoder;
import org.springframework.security.oauth2.jwt.NimbusJwtEncoder;

import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;

import static io.flowinquiry.security.SecurityUtils.JWT_ALGORITHM;

@Configuration
public class SecurityJwtConfiguration {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.flowinquiry.exceptions;

public class ResourceNotFoundException extends RuntimeException {

public ResourceNotFoundException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package io.flowinquiry.modules.audit;

import static j2html.TagCreator.*;

import j2html.tags.DomContent;

import java.util.List;

import static j2html.TagCreator.each;
import static j2html.TagCreator.table;
import static j2html.TagCreator.tbody;
import static j2html.TagCreator.td;
import static j2html.TagCreator.th;
import static j2html.TagCreator.thead;
import static j2html.TagCreator.tr;

public class ActivityLogUtils {

public static String generateHtmlLog(List<AuditUtils.FieldChange> changes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ public class ActivityLogController {

@GetMapping
public ResponseEntity<Page<ActivityLogDTO>> getActivityLogs(
@RequestParam EntityType entityType, @RequestParam Long entityId, Pageable pageable) {
@RequestParam("entityType") EntityType entityType, @RequestParam("entityId") Long entityId, Pageable pageable) {
Page<ActivityLogDTO> activityLogs =
activityLogService.getActivityLogs(entityType, entityId, pageable);
return ResponseEntity.ok(activityLogs);
}

@GetMapping("/user/{userId}")
public ResponseEntity<Page<ActivityLogDTO>> getUserActivities(
@PathVariable Long userId, Pageable pageable) {
@PathVariable("userId") Long userId, Pageable pageable) {
Page<ActivityLogDTO> activities = activityLogService.getActivitiesForUser(userId, pageable);
return ResponseEntity.ok(activities);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@
import io.flowinquiry.modules.collab.domain.EntityType;
import io.flowinquiry.modules.collab.service.CommentService;
import io.flowinquiry.modules.collab.service.dto.CommentDTO;
import java.util.List;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/comments")
Expand All @@ -25,20 +33,20 @@ public ResponseEntity<CommentDTO> saveComment(@RequestBody CommentDTO comment) {
}

@GetMapping("/{id}")
public ResponseEntity<Comment> getCommentById(@PathVariable Long id) {
public ResponseEntity<Comment> getCommentById(@PathVariable("id") Long id) {
Comment comment = commentService.getCommentById(id);
return ResponseEntity.ok(comment);
}

@GetMapping
public ResponseEntity<List<CommentDTO>> getCommentsForEntity(
@RequestParam EntityType entityType, @RequestParam Long entityId) {
@RequestParam("entityType") EntityType entityType, @RequestParam("entityId") Long entityId) {
List<CommentDTO> comments = commentService.getCommentsForEntity(entityType, entityId);
return ResponseEntity.ok(comments);
}

@DeleteMapping("/{id}")
public ResponseEntity<Void> deleteComment(@PathVariable Long id) {
public ResponseEntity<Void> deleteComment(@PathVariable("id") Long id) {
commentService.deleteComment(id);
return ResponseEntity.noContent().build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public NotificationController(NotificationService notificationService) {

@GetMapping("/user/{userId}")
public ResponseEntity<Page<NotificationDTO>> getUserNotifications(
@PathVariable Long userId, Pageable pageable) {
@PathVariable("userId") Long userId, Pageable pageable) {
return ResponseEntity.ok(notificationService.getNotificationsForUser(userId, pageable));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import java.nio.file.Files;
import java.nio.file.Paths;
import javax.imageio.ImageIO;
import org.jclouds.rest.ResourceNotFoundException;

import io.flowinquiry.exceptions.ResourceNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

import io.flowinquiry.modules.fss.service.StorageService;
import jakarta.servlet.http.HttpServletRequest;
import java.io.ByteArrayOutputStream;
import org.springframework.http.*;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.MediaTypeFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.ByteArrayOutputStream;

@RestController
@RequestMapping("/api/files")
public class FileDownloadController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public FileUploadController(StorageService storageService) {
@PostMapping(value = "/singleUpload")
public ResponseEntity<String> submit(
@RequestParam("file") MultipartFile file,
@RequestParam String type,
@RequestParam Optional<String> parentPath)
@RequestParam("type") String type,
@RequestParam("parentPath") Optional<String> parentPath)
throws Exception {
String currentUser = SecurityUtils.getCurrentUserLogin().map(UserKey::getEmail).orElse("");
LOG.debug(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
package io.flowinquiry.modules.teams.domain;

import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.Set;
import lombok.*;

@Entity
@Table(name = "fw_organization")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
package io.flowinquiry.modules.teams.domain;

import io.flowinquiry.modules.usermanagement.domain.User;
import jakarta.persistence.*;
import jakarta.persistence.CascadeType;
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.JoinTable;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.Formula;

import java.util.HashSet;
import java.util.Set;
import lombok.*;
import org.hibernate.annotations.Formula;

@Entity
@Table(name = "fw_team")
Expand Down
Loading

0 comments on commit 1a046fc

Please sign in to comment.