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

import com.usoftchina.bi.server.dao.dashboard.DefaultDashboardMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @Author chenwei
 * @Date 2019-05-31
 */
@Service
public class DefaultDashboardService {

    @Autowired
    private DefaultDashboardMapper defaultDashboardMapper;

    public Map<String, String> read(int userId) {
        return defaultDashboardMapper.selectDashboardIdByUserId(userId);
    }

    public void save(int userId, int dashboardId) {
        //先删除用户已设置的默认报表
        defaultDashboardMapper.deleteByUserId(userId);

        defaultDashboardMapper.save(userId, dashboardId);
    }

    public void delete(int dashboardId) {
        defaultDashboardMapper.delete(dashboardId);
    }

}
