NC_BACK-36_1
Test Workflow / test (push) Successful in 3s

This commit is contained in:
vladp
2026-02-06 19:27:25 +07:00
parent f52ce6db3c
commit a7e94639d2
14 changed files with 340 additions and 30 deletions
@@ -0,0 +1,40 @@
package ru.soune.nocopy.repository;
import org.springframework.data.domain.Pageable;
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 ru.soune.nocopy.entity.referral.Referral;
import java.util.List;
@Repository
public interface ReferralJpaRepository extends JpaRepository<Referral, Long> {
Referral findByReferralLink(String link);
Referral findByUserId(Long userId);
List<Referral> findByInviterId(Long inviterId);
@Query("SELECT r FROM Referral r WHERE r.inviterId = :userId AND r.isActive = true")
List<Referral> findByInviterId(Long inviterId, Pageable pageable);
@Modifying
@Query("UPDATE Referral r SET r.totalIncome = r.totalIncome + :amount WHERE r.userId = :userId")
void increaseIncome(@Param("userId") Long userId, @Param("amount") int amount);
@Modifying
@Query("UPDATE Referral r SET r.levelId = :newLevelId WHERE r.userId = :userId")
void updateLevel(@Param("userId") Long userId, @Param("newLevelId") String newLevelId);
@Modifying
@Query("UPDATE Referral r SET r.isActive = true WHERE r.userId = :userId")
void activateUser(@Param("userId") Long userId);
@Query("SELECT COUNT(r) FROM Referral r WHERE r.inviterId = :userId AND r.isActive = true")
int countActiveInvitees(@Param("userId") Long userId);
@Query("SELECT COUNT(r) FROM Referral r WHERE r.inviterId = :userId")
int countTotalInvitees(@Param("userId") Long userId);
}
@@ -0,0 +1,13 @@
package ru.soune.nocopy.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import ru.soune.nocopy.entity.referral.ReferralLevelEntity;
import java.util.List;
@Repository
public interface ReferralLevelRepository extends JpaRepository<ReferralLevelEntity, Long> {
List<ReferralLevelEntity> findAllByOrderByMinInviteesAsc();
ReferralLevelEntity findById(String id);
}