28 lines
838 B
Java
28 lines
838 B
Java
package restImplementation;
|
|
|
|
import database.session.Session;
|
|
import database.session.SessionDao;
|
|
|
|
import java.time.Instant;
|
|
|
|
public class SessionImplementation {
|
|
|
|
public int startSession(String user_hash, String user_email) throws Exception {
|
|
SessionDao sessionDao = new SessionDao();
|
|
UserImplementation userImplementation = new UserImplementation();
|
|
int userId = userImplementation.getUserId(user_hash,user_email);
|
|
|
|
Session session = new Session();
|
|
session.setUser_id(userId);
|
|
long now = Instant.now().toEpochMilli();
|
|
session.setStart_session(now);
|
|
|
|
return sessionDao.setStartSession(session);
|
|
}
|
|
|
|
public void endSession(int session_id) throws Exception {
|
|
SessionDao sessionDao = new SessionDao();
|
|
sessionDao.setEndSession(session_id);
|
|
}
|
|
}
|