-
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 #140 from Tech-Harbor/Bezsmertnyi
Bezsmertnyi
- Loading branch information
Showing
36 changed files
with
354 additions
and
72 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
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
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
10 changes: 3 additions & 7 deletions
10
src/main/java/com/example/backend/security/service/details/MyUserDetails.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
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
20 changes: 20 additions & 0 deletions
20
src/main/java/com/example/backend/utils/enums/Delivery.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,20 @@ | ||
package com.example.backend.utils.enums; | ||
|
||
import lombok.Getter; | ||
|
||
import static com.example.backend.utils.general.Constants.DELIVERY_MESSAGE; | ||
|
||
@Getter | ||
public enum Delivery { | ||
NOVA_POSHTA(DELIVERY_MESSAGE + "Нову Пошту"), | ||
MEEST_EXPRESS(DELIVERY_MESSAGE + "Meest Express"), | ||
JUSTIN(DELIVERY_MESSAGE + "Justin"), | ||
UKRPOSHTA(DELIVERY_MESSAGE + "УкрПошту"), | ||
PICKUP(DELIVERY_MESSAGE + "Самовивізом"); | ||
|
||
private final String name; | ||
|
||
Delivery(final String name) { | ||
this.name = name; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,12 @@ | ||
package com.example.backend.utils.enums; | ||
|
||
public enum Role { | ||
ADMIN, USER | ||
import org.springframework.security.core.GrantedAuthority; | ||
|
||
public enum Role implements GrantedAuthority { | ||
ADMIN, USER; | ||
|
||
@Override | ||
public String getAuthority() { | ||
return name(); | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
src/main/java/com/example/backend/utils/general/SchedulerProject.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,32 @@ | ||
package com.example.backend.utils.general; | ||
|
||
import com.example.backend.web.Advertisement.AdvertisementRepository; | ||
import com.example.backend.web.User.UserRepository; | ||
import lombok.AllArgsConstructor; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Component | ||
@AllArgsConstructor | ||
public class SchedulerProject { | ||
|
||
private final AdvertisementRepository advertisementRepository; | ||
private final UserRepository userRepository; | ||
|
||
@Scheduled(fixedRate = 3600000) | ||
public void deleteUsers() { | ||
userRepository.deleteNotValidatedUsers(LocalDateTime.now().minusHours(1)); | ||
} | ||
|
||
@Scheduled(cron = "0 0 0 1 * ?") | ||
public void deleteActiveAdvertisement() { | ||
advertisementRepository.deleteActiveAdvertisements(LocalDateTime.now()); | ||
} | ||
|
||
@Scheduled(cron = "0 0 0 1 * ?") | ||
public void updateActiveAdvertisement() { | ||
advertisementRepository.updateActiveAdvertisements(LocalDateTime.now(), LocalDateTime.now()); | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
src/main/java/com/example/backend/utils/general/UserDeleteScheduler.java
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
src/main/java/com/example/backend/utils/props/WebSocketProperties.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,16 @@ | ||
package com.example.backend.utils.props; | ||
|
||
import lombok.Data; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@Data | ||
@ConfigurationProperties(prefix = "spring.socket") | ||
public class WebSocketProperties { | ||
private String[] destPrefixes; | ||
private String appPrefix; | ||
private String endpoint; | ||
private String topicPrefix; | ||
private String userPrefix; | ||
} |
23 changes: 23 additions & 0 deletions
23
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 |
---|---|---|
@@ -1,10 +1,33 @@ | ||
package com.example.backend.web.Advertisement; | ||
|
||
import com.example.backend.web.Advertisement.store.AdvertisementEntity; | ||
import jakarta.transaction.Transactional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Modifying; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Repository | ||
public interface AdvertisementRepository extends JpaRepository<AdvertisementEntity, Long> { | ||
AdvertisementEntity getByName(String name); | ||
|
||
@Transactional | ||
@Modifying | ||
@Query("UPDATE AdvertisementEntity ad " | ||
+ "SET ad.createDate = :now WHERE ad.updateActiveDate <= :updateDate AND ad.active = false") | ||
void updateActiveAdvertisements(@Param("now") LocalDateTime now, | ||
@Param("updateDate") LocalDateTime updateDate); | ||
|
||
//TODO Поямнення updateActiveAdvertisements! | ||
// 01.08.2022 створення без true, а стоїть false | ||
// 01.09.2022 треба обновити дату всі які є на false | ||
// 01.10.2022 видалиться через місяць, якщо не активують оголошення | ||
|
||
@Transactional | ||
@Modifying | ||
@Query("DELETE FROM AdvertisementEntity ad WHERE ad.createDate <= :dateTime AND ad.active = false") | ||
void deleteActiveAdvertisements(@Param("dateTime") LocalDateTime dateTime); | ||
} |
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
Oops, something went wrong.