package cn.palmte.work.model;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.Date;
import java.util.List;


public interface SysUserRoleRepository extends JpaRepository<SysUserRole, Integer> {


    /**
     * 根据userID 查询角色id
     */
    @Query(" select userId from SysUserRole where roleId=?1 and isDeleted=0 ")
    public List<SysUserRole> findRoleByRoleId(int role_id);

    @Transactional
    @Query("update  SysUserRole sysUserRole set isDeleted = 1,lastUpdatedBy=?1,lastUpdatedTime=?2 where userId=?3 ")
    @Modifying
    int deleteSysUserRoleByUserId(int createAdminId, Date date, int userId);

}
