| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- package nju.seec.helper.dao;
- import nju.seec.helper.entity.User;
- import nju.seec.helper.enums.ExceptionType;
- import nju.seec.helper.exception.HelperException;
- 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.stereotype.Repository;
- import java.util.Optional;
- import java.util.Set;
- /**
- * @author cst
- */
- @Repository
- public interface UserDAO extends JpaRepository<User, Long>, JpaSpecificationExecutor<User> {
- /**
- * 封装findById
- *
- * @param id
- * @return
- */
- default User findUserById(Long id) {
- return this.findById(id)
- .orElseThrow(() -> HelperException.of(ExceptionType.NOT_FOUND, "找不到用户信息"));
- }
- // /**
- //// * 检查邮箱是否已存在
- //// *
- //// * @param email
- //// * @return
- //// */
- //// boolean existsByEmail(String email);
- ////
- ////
- //// /**
- //// * 检查手机号是否已存在
- //// *
- //// * @param phone
- //// * @return
- //// */
- //// boolean existsByPhone(String phone);
- ////
- //// /**
- //// * 邮箱密码匹配
- //// *
- //// * @param email
- //// * @param password
- //// * @return
- //// */
- //// Optional<User> findByEmailAndPassword(String email, String password);
- ////
- //// /**
- //// * 根据邮箱查询
- //// *
- //// * @param email
- //// * @return
- //// */
- //// Optional<User> findByEmail(String email);
- /**
- * 根据手机号查询
- *
- * @param phone
- * @return
- */
- Optional<User> findByPhone(String phone);
- /**
- * 根据PID查询
- *
- * @param pid
- * @return
- */
- Optional<User> findByPid(Long pid);
- /**
- * ID列表查询
- *
- * @param ids
- * @param pageable
- * @return
- */
- Page<User> findByIdIn(Set<Long> ids, Pageable pageable);
- }
|