package ru.nbch.credit_tracker.mapper.signal;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import ru.nbch.credit_tracker.entities.dto.UserPackage;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface UserPackageMapper {

    boolean isPackageNotUnique(@Param("userId") String userId, @Param("packageName") String packageName);

    boolean isPackageExists(@Param("userId") String userId, @Param("packageName") String packageName, @Param("status") String status);

    boolean hasActivePackages(@Param("userId") String userId, @Param("packageName")  String packageName, @Param("statuses") List<String> statuses);

    void deletePackage(@Param("userId") String userId, @Param("packageName") String packageName, @Param("status") String newStatus, @Param("previousStatus") String previousStatus, @Param("deactivatedAt") LocalDateTime deactivatedAt);

    Integer insertPackage(@Param("userPackage") UserPackage userPackage);

    void updatePackageStatus(@Param("packageId") Integer packageId, @Param("status") String status);

    void updatePackageLastDownloadedReport(@Param("id") Integer id, @Param("fileName") String fileName);

    UserPackage findPackage(@Param("id") Integer id);

    List<UserPackage> findUserPackages(@Param("userId") String userId, @Param("statuses") List<String> status);

    List<UserPackage> findAllPackagesByStatus(@Param("status")  String status);

    List<UserPackage> findAllPackagesByUserId(@Param("userId") String userId);
}
