-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea/modules.xml | ||
.idea/jarRepositories.xml | ||
.idea/compiler.xml | ||
.idea/libraries/ | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store | ||
|
||
src/main/resources/.env |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM maven:3.9.6-eclipse-temurin-21-jammy | ||
WORKDIR /app/annotation | ||
COPY . /app/annotation | ||
RUN mvn clean install | ||
EXPOSE 8080 | ||
ENTRYPOINT ["java","-jar","/app/annotation/target/annotation-1.0-SNAPSHOT.jar"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>3.0.0</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
<groupId>com.app.annotation</groupId> | ||
<artifactId>annotation</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-mongodb</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>1.18.30</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
<version>3.0.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.modelmapper</groupId> | ||
<artifactId>modelmapper</artifactId> | ||
<version>3.1.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>me.paulschwarz</groupId> | ||
<artifactId>spring-dotenv</artifactId> | ||
<version>4.0.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.validation</groupId> | ||
<artifactId>jakarta.validation-api</artifactId> | ||
<version>3.0.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springdoc</groupId> | ||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> | ||
<version>2.0.0</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.swagger.core.v3</groupId> | ||
<artifactId>swagger-annotations-jakarta</artifactId> | ||
<version>2.2.7</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.security</groupId> | ||
<artifactId>spring-security-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.security</groupId> | ||
<artifactId>spring-security-config</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.app.annotation; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class Main { | ||
public static void main(String[] args) { | ||
SpringApplication.run(Main.class, args); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.app.annotation.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.cors.CorsConfiguration; | ||
import org.springframework.web.cors.CorsConfigurationSource; | ||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; | ||
|
||
import java.util.Arrays; | ||
|
||
@Configuration | ||
public class CorsConfig { | ||
|
||
@Bean | ||
public CorsConfigurationSource corsConfigurationSource() { | ||
final CorsConfiguration configuration = new CorsConfiguration(); | ||
configuration.setAllowedOrigins(Arrays.asList("http://localhost:5173", "http://localhost", "http://ec2-51-20-78-40.eu-north-1.compute.amazonaws.com/")); | ||
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS")); | ||
configuration.setAllowCredentials(true); | ||
configuration.setAllowedHeaders(Arrays.asList("Authorization", "Content-Type", "Set-Cookie", "credentials")); | ||
configuration.setExposedHeaders(Arrays.asList("Set-Cookie")); | ||
|
||
final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | ||
source.registerCorsConfiguration("/**", configuration); | ||
return source; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.app.annotation.config; | ||
|
||
import org.modelmapper.ModelMapper; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class MapperConfig { | ||
|
||
@Bean | ||
public static ModelMapper modelMapper() { | ||
ModelMapper modelMapper = new ModelMapper(); | ||
modelMapper.getConfiguration().setFieldMatchingEnabled(true); | ||
return modelMapper; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.app.annotation.config; | ||
|
||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | ||
import org.springframework.security.web.SecurityFilterChain; | ||
|
||
@Configuration | ||
@EnableWebSecurity | ||
public class SecurityConfig { | ||
|
||
@Bean | ||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { | ||
http | ||
.cors() | ||
.and() | ||
.csrf().disable() | ||
; | ||
|
||
return http.build(); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.app.annotation.config; | ||
|
||
import io.swagger.v3.oas.annotations.OpenAPIDefinition; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.info.Info; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@OpenAPIDefinition | ||
@Configuration | ||
public class SpringdocConfig { | ||
|
||
@Bean | ||
public OpenAPI baseOpenAPI() { | ||
return new OpenAPI().info(new Info().title("Spring Doc").version("1.0.0").description("Spring doc")); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.app.annotation.controller; | ||
|
||
import com.app.annotation.service.AnnotationService; | ||
import com.app.annotation.dto.request.CreateAnnotationRequestDto; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@RestController | ||
@RequestMapping("/api/annotation") | ||
public class AnnotationController { | ||
|
||
private final AnnotationService annotationService; | ||
|
||
public AnnotationController(AnnotationService annotationService) { | ||
this.annotationService = annotationService; | ||
} | ||
|
||
@PostMapping("/create") | ||
public ResponseEntity<Map<String, Object>> createAnnotation(@RequestBody CreateAnnotationRequestDto dto) { | ||
Map<String, Object> annotation = annotationService.createAnnotation(dto); | ||
return ResponseEntity.ok(annotation); | ||
} | ||
|
||
@DeleteMapping("/delete") | ||
public ResponseEntity<Boolean> deleteAnnotation(@RequestParam String id) { | ||
boolean isDeleted = annotationService.deleteAnnotation(id); | ||
if (!isDeleted) { | ||
return ResponseEntity.notFound().build(); | ||
} | ||
return ResponseEntity.ok(true); | ||
} | ||
|
||
@PutMapping("/update") | ||
public ResponseEntity<Map<String, Object>> updateAnnotation(@RequestBody CreateAnnotationRequestDto dto) { | ||
Map<String, Object> annotation = annotationService.updateAnnotation(dto); | ||
if(annotation == null) { | ||
return ResponseEntity.notFound().build(); | ||
} | ||
return ResponseEntity.ok(annotation); | ||
} | ||
|
||
@GetMapping("/get-source-annotations") | ||
public ResponseEntity<List<Map<String, Object>>> getAnnotation(@RequestParam String source) { | ||
List<Map<String, Object>> annotations = annotationService.getAnnotations(source); | ||
if(annotations == null || annotations.isEmpty()) { | ||
return ResponseEntity.notFound().build(); | ||
} | ||
return ResponseEntity.ok(annotations); | ||
} | ||
|
||
@GetMapping("/get-image-annotations") | ||
public ResponseEntity<List<Map<String, Object>>> getImageAnnotations(@RequestParam String source) { | ||
List<Map<String, Object>> annotations = annotationService.getImageAnnotations(source); | ||
if(annotations == null || annotations.isEmpty()) { | ||
return ResponseEntity.notFound().build(); | ||
} | ||
return ResponseEntity.ok(annotations); | ||
} | ||
} |