package com.ankaibei.workFlow.webadmin.ankaibei.mapper;

import com.ankaibei.workFlow.webadmin.ankaibei.entity.UserInfoEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

/**
 * @author
 * @version 1.0
 * @description:
 * @date 2022/9/5 14:20
 */
public interface UserInfoMapper extends JpaRepository<UserInfoEntity, String> , JpaSpecificationExecutor<UserInfoEntity> {


    @Query(value = "SELECT user.user_id userId,user.show_name userName FROM work_sys_user user  ",
            countQuery = "SELECT count(1) FROM work_sys_user ",nativeQuery = true)
    List<Map<String,String>> getProUserAll();

    /**
     *
     * 根据id查询用户信息
     */
    @Query(value = "SELECT * FROM work_sys_user where user_id in (?1)"
            ,countQuery ="SELECT count(1) FROM work_sys_user where user_id in (?1)",nativeQuery = true)
    List<UserInfoEntity> findAllByUserId(List<String> userIds);

    /**
     *
     * 根据id查询用户信息
     * @param userId
     */
    @Query(value = "SELECT * FROM work_sys_user where user_id = ?1"
            ,countQuery ="SELECT count(1) FROM work_sys_user where user_id in ?1",nativeQuery = true)
    UserInfoEntity findByUserIdEquals(String userId);
}
