source: src/main/java/com/tourMate/dao/impl/TokenDaoImpl.java@ e9b4ba9

Last change on this file since e9b4ba9 was e9b4ba9, checked in by darsov2 <62809499+darsov2@…>, 12 months ago

prototype

  • Property mode set to 100644
File size: 1019 bytes
Line 
1package com.tourMate.dao.impl;
2
3import com.tourMate.dao.TokenDao;
4import com.tourMate.entities.Token;
5import jakarta.persistence.Entity;
6import jakarta.persistence.EntityManager;
7import jakarta.persistence.PersistenceContext;
8import jakarta.transaction.Transactional;
9import org.springframework.beans.factory.annotation.Autowired;
10import org.springframework.stereotype.Service;
11
12import java.time.LocalDateTime;
13
14@Service
15public class TokenDaoImpl implements TokenDao {
16
17 @PersistenceContext
18 EntityManager em;
19 @Override
20 public void saveToken(Token token) {
21 em.persist(token);
22 }
23
24 @Override
25 public Token getToken(String token) {
26 return (Token) em.createQuery("select t from Token t where t.token = :token").setParameter("token", token).getSingleResult();
27 }
28
29 @Override
30 @Transactional
31 public void setConfirmedAt(String token, LocalDateTime dateTime) {
32 Token t = getToken(token);
33 t.setConfirmedAt(LocalDateTime.now());
34 em.persist(t);
35 }
36}
Note: See TracBrowser for help on using the repository browser.