ThirdAccountRepository.java 2.2 KB
/*
package com.reyun.repository;

import com.reyun.model.ThirdAccount;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

*/
/**
 * Created by sunhao on 17/3/21.
 *//*

@Transactional
public interface ThirdAccountRepository extends JpaRepository<ThirdAccount, Long> {

    @Query(value = "select * from third_account where account_id = ?1 and channel_unique_name = ?2 and validation is true", nativeQuery = true)
    ThirdAccount findValidAccountById(Long accountId,String accountType);

    @Query(value = "select * from third_account where account_id = ?1 and channel_unique_name = ?2 and validation is false", nativeQuery = true)
    ThirdAccount findInvalidAccountById(Long accountId,String accountType);

    @Query(value = "select * from third_account where account_id = ?1 and channel_unique_name = ?2 ", nativeQuery = true)
    ThirdAccount findAccountById(Long accountId,String accountType);

    @Query(value = "select * from third_account where  validation is true", nativeQuery = true)
    List<ThirdAccount> findAllValidAccount();

    @Transactional
    @Modifying
    @Query(value = "update third_account set token = ?1 ,refresh_token = ?2 , token_invalid_date = ?3,modify_date = CURRENT_TIMESTAMP(),validation = true where account_id = ?4 and channel_unique_name = ?5 ", nativeQuery = true)
    int updateThirdAccountToken(String token, String refreshToken, Date tokenDate, Long accountId,String channelUniqueName);

    @Transactional
    @Modifying
    @Query(value = "update third_account set validation = ?1,modify_date = CURRENT_TIMESTAMP() where id = ?2 and validation is true", nativeQuery = true)
    int updateThirdAccountStatus(Boolean status, Long thirdAccountId);

    @Transactional
    @Modifying
    @Query(value = "update third_account set name = ?2,password = ?3,validation = ?4, modify_date = CURRENT_TIMESTAMP() where id = ?1 and validation is false", nativeQuery = true)
    int updateThirdAccountNamePwd(Long thirdAccountId,String userName,String password,Boolean validation);
}
*/