package com.ssj.dao.sys.parentrole.dao;

import com.ssj.bean.sys.parentrole.domain.SSJParentRole;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface SSJParentRoleDao extends JpaRepository<SSJParentRole, String> {

	public SSJParentRole findByVipIdAndRoleUserId(String vipId, String roleUserId);
	
	public int countByVipIdAndRoleName(String vipId, String roleName);
	
	@Query(nativeQuery = true, value = "delete from ssj_parent_role where vip_id = ?1 and role_user_id = ?2 ")
	@Modifying
	public void deleteByVipIdAndRoleUserId(String vipId, String roleUserId);
	
	@Query(nativeQuery = true, value = "delete from ssj_parent_role where vip_id = ?1 ")
	@Modifying
	public void deleteByVipId(String vipId);

	@Query(nativeQuery = true, value = "delete from ssj_parent_role where role_user_id = ?1 ")
	@Modifying
	public void deleteByRoleUserId(String roleId);

	@Query(nativeQuery = true,value = "select * from ssj_parent_role where role_user_id=?1 ")
	public List<SSJParentRole> findByRoleUserId(String userId);
}
