package com.uas.platform.b2b.manage.service.impl;

import com.uas.platform.b2b.manage.core.support.SystemSession;
import com.uas.platform.b2b.manage.dao.AccessTokenDao;
import com.uas.platform.b2b.manage.model.AccessToken;
import com.uas.platform.b2b.manage.service.AccessTokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("AccessTokenServiceImpl")
public class AccessTokenServiceImpl implements AccessTokenService {

	@Autowired
	private AccessTokenDao accessTokenDao;

	@Override
	public AccessToken createNew(Object bindObject) {
		AccessToken token = new AccessToken(SystemSession.getUser(), bindObject);
		accessTokenDao.save(token);
		return token;
	}

	@Override
	public AccessToken createNew(Object bindObject, int expires_in) {
		AccessToken token = new AccessToken(SystemSession.getUser(), bindObject, expires_in);
		accessTokenDao.save(token);
		return token;
	}

	@Override
	public AccessToken findOne(String id) {
		return accessTokenDao.findOne(id);
	}

	@Override
	public void delete(String id) {
		accessTokenDao.delete(id);
	}

}
