Optional<TicketUserDto> ticketuser=ticketUserDao.findByUserIdAndPassword(userId, password);
道:
@Repository
public interface TicketUsersDao extends MongoRepository<TicketUserDto, Serializable> {
Optional<TicketUserDto> findByUserIdAndPassword(String userId, String password);
}
这是DTO定义
@Document(collection="ticket_users")
public class TicketUserDto {
private String userId;
private String password;
public String getUserId() { return userId; }
public void setUserId(String userId) { this.userId = userId; }
public String getPassword() { return password; }
public void setPassword(String password) { this.password = password; }
@Override public String toString() {
return "TicketUserDto [userId=" + userId +
", password=" + password + "]";
}
}