package com.crunii.micro.domain.repo.main;

import com.crunii.micro.domain.common.BaseRepo;
import com.crunii.micro.domain.entity.main.TsmRole;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author 田平 create 2019-01-28 05:01:09
 */
@Repository
public interface TsmRoleRepo extends BaseRepo<TsmRole, Integer> {

    @Query(value = "select * from tsm_role where state=1 and role_id <> 9999 ",nativeQuery = true)
    List<TsmRole> findAllRole();

    @Query(value = "select * from tsm_role where state=1 and role_name like concat('%',:roleName,'%') and role_id <> 9999",nativeQuery = true)
    List<TsmRole> findRoleByRoleName(@Param("roleName") String roleName);

    @Query(value = "select * from tsm_role where state=1 and role_name=:roleName and role_id <> 9999 limit 1",nativeQuery = true)
    TsmRole findByRoleName(@Param("roleName") String roleName);
}
