package com.qmth.jkserver.service.impl;

import java.util.UUID;

import com.qmth.jkserver.constant.SystemConstant;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.qmth.jkserver.core.Token;
import com.qmth.jkserver.service.ApiSecurityService;

@Service
@Scope(proxyMode = ScopedProxyMode.INTERFACES)
public class ApiSecurityServiceImpl implements ApiSecurityService {

    @Override
    public String generateToken(String mac, String examCode) throws JsonProcessingException {
        long createTime = System.currentTimeMillis();
        String random = SystemConstant.getNanoId();
        String token = Token.serialize(mac, examCode, createTime, random);
        return token;
    }
}
