Skip to content

Commit

Permalink
Merge branch 'Aysenursasmaz:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
bilaleknc authored Feb 16, 2024
2 parents f140707 + d0accb5 commit 27fb5eb
Show file tree
Hide file tree
Showing 120 changed files with 1,889 additions and 842 deletions.
3 changes: 3 additions & 0 deletions pair-9/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ build/

### VS Code ###
.vscode/


src\main\resources\application.properties
9 changes: 8 additions & 1 deletion pair-9/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Java 19 base image
FROM openjdk:19-alpine

# Set the working directory
WORKDIR /app

# Add a volume pointing to /app
VOLUME /app

# Port 8080 will be exposed for the web server
EXPOSE 8080

Expand All @@ -11,4 +17,5 @@ COPY target/pair-9-0.0.1-SNAPSHOT.jar app.jar
LABEL maintainer="[email protected]"

# Run the JAR file
ENTRYPOINT ["java","-jar","/app.jar"]
#ENTRYPOINT ["java","-jar","/app.jar"]
CMD ["java", "-jar", "my-java-app.jar"]
28 changes: 16 additions & 12 deletions pair-9/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -29,7 +29,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
Expand Down Expand Up @@ -86,23 +85,28 @@
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies>


<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
<archive>
<manifest>
<mainClass>com.example.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
package com.tobeto.pair9.controllers;

import com.tobeto.pair9.services.abstracts.AuthService;
import com.tobeto.pair9.services.dtos.auth.responses.TokenResponse;
import com.tobeto.pair9.services.dtos.user.requests.CreateUserRequest;
import com.tobeto.pair9.services.dtos.user.requests.LoginRequest;
import lombok.AllArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/auth")
@AllArgsConstructor
@CrossOrigin
@AllArgsConstructor
public class AuthController {

private final AuthService authService;

@PostMapping("/signUp")
@ResponseStatus(HttpStatus.CREATED)
private void register(@RequestBody CreateUserRequest request){
Expand All @@ -22,7 +25,21 @@ private void register(@RequestBody CreateUserRequest request){

@PostMapping("/login")
@ResponseStatus(HttpStatus.OK)
public String login(@RequestBody LoginRequest loginRequest){
public TokenResponse login(@RequestBody LoginRequest loginRequest){
return authService.login(loginRequest);
}

@PostMapping("/refreshToken")
public ResponseEntity<?> refreshToken(@RequestParam("userName") String userName) {
return ResponseEntity.ok(authService.refreshToken(userName));
}

// Logout işlemi için endpoint
@PostMapping("/logout")
public ResponseEntity<?> logout(@RequestParam("userName") String userName) {
authService.logout(userName);
return ResponseEntity.ok().body("Logout successful");
}


}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.tobeto.pair9.controllers;

import com.tobeto.pair9.core.utilities.results.DataResult;
import com.tobeto.pair9.core.utilities.results.Result;
import com.tobeto.pair9.core.utilities.results.BaseResponse;
import com.tobeto.pair9.services.abstracts.BrandService;
import com.tobeto.pair9.services.dtos.brand.requests.AddBrandRequest;
import com.tobeto.pair9.services.dtos.brand.requests.UpdateBrandRequest;
Expand All @@ -21,20 +20,20 @@ public class BrandsController {
private BrandService brandService;

@GetMapping("/getAll")
public DataResult<List<GetListBrandResponse>> getAll(){
public BaseResponse<List<GetListBrandResponse>> getAll(){
return brandService.getAll();
}
@PostMapping("/add")
@ResponseStatus(code = HttpStatus.CREATED)
public Result add(@RequestBody @Valid AddBrandRequest request){
public BaseResponse add(@RequestBody @Valid AddBrandRequest request){
return brandService.add(request);
}
@PutMapping("/update")
public Result update(@RequestBody @Valid UpdateBrandRequest request){
public BaseResponse update(@RequestBody @Valid UpdateBrandRequest request){
return this.brandService.update(request);
}
@DeleteMapping("{id}")
public Result delete(@PathVariable int id){
public BaseResponse delete(@PathVariable int id){
return brandService.delete(id);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.tobeto.pair9.controllers;

import com.tobeto.pair9.core.utilities.results.DataResult;
import com.tobeto.pair9.core.utilities.results.Result;
import com.tobeto.pair9.core.utilities.results.BaseResponse;
import com.tobeto.pair9.services.abstracts.CarService;
import com.tobeto.pair9.services.dtos.car.requests.AddCarRequest;
import com.tobeto.pair9.services.dtos.car.requests.UpdateCarRequest;
Expand All @@ -20,30 +19,36 @@
@CrossOrigin
public class CarsController {

private CarService carService;
private final CarService carService;


@GetMapping("/getAll")
public DataResult<List<GetListCarResponse>> getAll(){
public BaseResponse<List<GetListCarResponse>> getAll(){
return carService.getAll();
}


@GetMapping("/getById/{id}")
public DataResult<GetByIdCarResponse> getById(@PathVariable int id){
public BaseResponse<GetByIdCarResponse> getById(@PathVariable Integer id){
return carService.getById(id);
}


@PostMapping("/add")
@ResponseStatus(code = HttpStatus.CREATED)
public Result add(@RequestBody @Valid AddCarRequest request){
public BaseResponse add(@RequestBody @Valid AddCarRequest request){
return carService.add(request);
}


@PutMapping("/update")
public Result update(@RequestBody @Valid UpdateCarRequest request){
public BaseResponse update(@RequestBody @Valid UpdateCarRequest request){
return this.carService.update(request);
}


@DeleteMapping("{id}")
public Result delete(@PathVariable int id){
public BaseResponse delete(@PathVariable Integer id){
return carService.delete(id);
}
}
Original file line number Diff line number Diff line change
@@ -1,47 +1,52 @@
package com.tobeto.pair9.controllers;

import com.tobeto.pair9.core.utilities.results.DataResult;
import com.tobeto.pair9.core.utilities.results.Result;
import com.tobeto.pair9.core.utilities.results.BaseResponse;
import com.tobeto.pair9.services.abstracts.ColorService;
import com.tobeto.pair9.services.dtos.color.requests.AddColorRequest;
import com.tobeto.pair9.services.dtos.color.requests.UpdateColorRequest;
import com.tobeto.pair9.services.dtos.color.responses.GetListColorResponse;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/colors")
@AllArgsConstructor

@CrossOrigin
public class ColorsController {

private ColorService colorService;

@GetMapping("/getAll")
public DataResult<List<GetListColorResponse>> getAll(){
@PreAuthorize("hasAuthority('admin:read')")
public BaseResponse<List<GetListColorResponse>> getAll(){
return colorService.getAll();
}


@PostMapping("/add")
@ResponseStatus(code = HttpStatus.CREATED)
public Result add(@RequestBody @Valid AddColorRequest request){
@PreAuthorize("hasAuthority('admin:add')")
public BaseResponse add(@RequestBody @Valid AddColorRequest request){
return colorService.add(request);
}


@PutMapping("/update")
public Result update(@RequestBody @Valid UpdateColorRequest request){
@PreAuthorize("hasAuthority('admin:update')")
public BaseResponse update(@RequestBody @Valid UpdateColorRequest request){
return colorService.update(request);
}


@DeleteMapping("{id}")
public Result delete(@PathVariable int id){
@PreAuthorize("hasAuthority('admin:delete')")
public BaseResponse delete(@PathVariable Integer id){
return colorService.delete(id);
}



}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tobeto.pair9.controllers;

import com.tobeto.pair9.core.utilities.results.BaseResponse;
import com.tobeto.pair9.services.abstracts.CustomerService;
import com.tobeto.pair9.services.dtos.customer.requests.AddCustomerRequest;
import com.tobeto.pair9.services.dtos.customer.requests.UpdateCustomerRequest;
Expand All @@ -14,25 +15,33 @@
@AllArgsConstructor
@RestController
@RequestMapping("/api/customers")
@CrossOrigin
public class CustomersController {

private CustomerService customerService;

@GetMapping("/getAll")
public List<GetListCustomerResponse> getAll(){
public BaseResponse<List<GetListCustomerResponse>> getAll(){
return customerService.getAll();
}


@PostMapping("/add")
@ResponseStatus(code = HttpStatus.CREATED)
public void add(@RequestBody @Valid AddCustomerRequest request){
customerService.add(request);
public BaseResponse add(@RequestBody @Valid AddCustomerRequest request){
return customerService.add(request);
}


@PutMapping("/update")
public void update(@RequestBody @Valid UpdateCustomerRequest request){
this.customerService.update(request);
public BaseResponse update(@RequestBody @Valid UpdateCustomerRequest request){
return this.customerService.update(request);
}


@DeleteMapping("{id}")
public void delete(@PathVariable int id){
customerService.delete(id);
public BaseResponse delete(@PathVariable Integer id){
return customerService.delete(id);
}

}
Loading

0 comments on commit 27fb5eb

Please sign in to comment.