Last change
on this file since ac19a0c was e9b4ba9, checked in by darsov2 <62809499+darsov2@…>, 12 months ago |
prototype
|
-
Property mode
set to
100644
|
File size:
1019 bytes
|
Line | |
---|
1 | package com.tourMate.dao.impl;
|
---|
2 |
|
---|
3 | import com.tourMate.dao.TokenDao;
|
---|
4 | import com.tourMate.entities.Token;
|
---|
5 | import jakarta.persistence.Entity;
|
---|
6 | import jakarta.persistence.EntityManager;
|
---|
7 | import jakarta.persistence.PersistenceContext;
|
---|
8 | import jakarta.transaction.Transactional;
|
---|
9 | import org.springframework.beans.factory.annotation.Autowired;
|
---|
10 | import org.springframework.stereotype.Service;
|
---|
11 |
|
---|
12 | import java.time.LocalDateTime;
|
---|
13 |
|
---|
14 | @Service
|
---|
15 | public 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.