-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #128 from Tech-Harbor/Bezsmertnyi
Bezsmertnyi
- Loading branch information
Showing
51 changed files
with
554 additions
and
456 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ bin/ | |
|
||
### IntelliJ IDEA ### | ||
.idea | ||
.env | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
src/main/java/com/example/backend/security/models/request/GoogleTokenRequest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/com/example/backend/web/Advertisement/AdvertisementController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.example.backend.web.Advertisement; | ||
|
||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.graphql.data.method.annotation.Argument; | ||
import org.springframework.graphql.data.method.annotation.MutationMapping; | ||
import org.springframework.graphql.data.method.annotation.QueryMapping; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@Tag(name = "AdvertisementService") | ||
@RequestMapping("/api/advertisement") | ||
public class AdvertisementController { | ||
|
||
private final AdvertisementServiceImpl advertisementService; | ||
private static final String URI_ADVERTISEMENT_ID = "/{id}"; | ||
private static final String URL_DELETE_ALL = "/deleteAll"; | ||
|
||
@PostMapping(URI_ADVERTISEMENT_ID) | ||
@MutationMapping | ||
public AdvertisementDTO createAdvertisementIdByUser(@PathVariable(value = "id") @Argument final Long userId, | ||
@RequestBody @Argument final AdvertisementDTO entity) { | ||
return advertisementService.createAdvertisement(userId, entity); | ||
} | ||
|
||
@QueryMapping | ||
public List<AdvertisementDTO> getAllAdvertisement() { | ||
return advertisementService.getAllAdvertisement(); | ||
} | ||
|
||
@QueryMapping | ||
public AdvertisementDTO getByIdAdvertisement(@Argument final Long id) { | ||
return advertisementService.getOneAdvertisement(id); | ||
} | ||
|
||
@PutMapping(URI_ADVERTISEMENT_ID) | ||
public AdvertisementDTO editAdvertisement(@PathVariable final Long id, @RequestBody final AdvertisementDTO entity) { | ||
return advertisementService.editAdvertisement(id, entity); | ||
} | ||
|
||
@DeleteMapping(URI_ADVERTISEMENT_ID) | ||
public void deleteIdAdvertisement(@PathVariable final Long id) { | ||
advertisementService.deleteIdAdvertisement(id); | ||
} | ||
|
||
@DeleteMapping(URL_DELETE_ALL) | ||
public void deleteAllAdvertisement() { | ||
advertisementService.deleteAll(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/example/backend/web/Advertisement/AdvertisementDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.example.backend.web.Advertisement; | ||
|
||
import com.example.backend.web.File.store.ImageEntity; | ||
import lombok.Builder; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@Builder | ||
public record AdvertisementDTO(Long id, | ||
String name, | ||
String descriptionAdvertisement, | ||
String characteristicAdvertisement, | ||
double price, | ||
LocalDateTime createDate, | ||
List<ImageEntity> images, | ||
String location, | ||
String category, | ||
String delivery) { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/com/example/backend/web/Advertisement/AdvertisementFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.example.backend.web.Advertisement; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.function.Function; | ||
|
||
@Component | ||
public class AdvertisementFactory implements Function<AdvertisementEntity, AdvertisementDTO> { | ||
@Override | ||
public AdvertisementDTO apply(final AdvertisementEntity entity) { | ||
return AdvertisementDTO.builder() | ||
.id(entity.getId()) | ||
.descriptionAdvertisement(entity.getDescriptionAdvertisement()) | ||
.characteristicAdvertisement(entity.getCharacteristicAdvertisement()) | ||
.name(entity.getName()) | ||
.price(entity.getPrice()) | ||
.createDate(entity.getCreateDate()) | ||
.category(entity.getCategory().getCategoryName()) | ||
.images(entity.getImages()) | ||
.location(entity.getLocation()) | ||
.delivery(entity.getDelivery()) | ||
.build(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/example/backend/web/Advertisement/AdvertisementRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.example.backend.web.Advertisement; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface AdvertisementRepository extends JpaRepository<AdvertisementEntity, Long> { | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/example/backend/web/Advertisement/AdvertisementService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.example.backend.web.Advertisement; | ||
|
||
import java.util.List; | ||
|
||
public interface AdvertisementService { | ||
AdvertisementDTO createAdvertisement(Long id, AdvertisementDTO entity); | ||
List<AdvertisementDTO> getAllAdvertisement(); | ||
AdvertisementDTO getOneAdvertisement(Long id); | ||
AdvertisementDTO editAdvertisement(Long id, AdvertisementDTO entity); | ||
void deleteIdAdvertisement(Long id); | ||
void deleteAll(); | ||
} |
Oops, something went wrong.