package com.usoftchina.bi.server.service.dashboard;

import com.usoftchina.bi.core.utils.GetTokenDataUtil;
import com.usoftchina.bi.server.dao.dashboard.DashboardFavoriteMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Author chenwei
 * @Date 2019-04-24
 */
@Service
public class DashboardFavoriteService {

    @Autowired
    private DashboardFavoriteMapper dashboardFavoriteMapper;

    public List<Map<String, String>> list(String token){
        int userId = Integer.parseInt(GetTokenDataUtil.getTokenData(token).get("id"));
        return dashboardFavoriteMapper.list(userId);
    }

    public void save(String token, Long dashboardId){
        int userId = Integer.parseInt(GetTokenDataUtil.getTokenData(token).get("id"));
        dashboardFavoriteMapper.insert(userId, dashboardId.intValue());
    }

    public void delete(String token, Long dashboardId) {
        dashboardFavoriteMapper.remove(dashboardId.intValue());
    }

}
