package com.ssj.dao.kmt.kmtsys.dao;

import java.util.List;

import com.ssj.bean.kmt.kmtsys.domain.KmtSysUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;


@Repository
public interface KmtSysUserDao extends JpaRepository<KmtSysUser, String>{
	
	@Query(nativeQuery = true, value = " SELECT * from kmt_sys_user t GROUP BY t.`name`   ORDER BY t.create_time asc ")
	public List<KmtSysUser> findKmtSysUser();
	
	@Query(nativeQuery = true, value = " SELECT * from kmt_sys_user t where t.login_name =?1  ")
	public List<KmtSysUser> findKmtSysUserByLoginName(String loginName);


	@Query(nativeQuery = true, value = " SELECT * from kmt_sys_user t where t.login_name =?1 and t.type=?2 limit 1 ")
	public KmtSysUser findKmtSysUserByLoginNameAndType(String loginName, String type);


	/**
	 * 批量查询用户
	 * @param ids
	 * @return
	 */
	public List<KmtSysUser> findByIdIn(List<String> ids);

	@Query(nativeQuery = true, value = " SELECT * from kmt_sys_user t where t.login_name regexp ?1 ")
	List<KmtSysUser> findByName(String name);
	
}
