package com.ruoyi.ibs.dashboard.service.impl;

import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.ibs.dashboard.domain.dto.TabRankingDTO;
import com.ruoyi.ibs.dashboard.domain.entity.TabRanking;
import com.ruoyi.ibs.dashboard.domain.vo.TabCommentVO;
import com.ruoyi.ibs.dashboard.mapper.TabRankingMapper;
import com.ruoyi.ibs.dashboard.service.ITabRankingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 指标排名Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-26
 */
@Service
public class TabRankingServiceImpl implements ITabRankingService
{
    @Autowired
    private TabRankingMapper tabRankingMapper;

    /**
     * 查询指标排名
     * 
     * @param id 指标排名主键
     * @return 指标排名
     */
    @Override
    public List<TabCommentVO> selectTabRankingById(Long id)
    {
        return tabRankingMapper.selectConmmentById(id);
    }

    /**
     * 查询指标排名列表
     * 
     * @param tabRanking 指标排名
     * @return 指标排名
     */
    @Override
    public List<TabRanking> selectTabRankingList(TabRanking tabRanking)
    {
        return tabRankingMapper.selectTabRankingList(tabRanking);
    }

    /**
     * 新增指标排名
     * 
     * @param tabRanking 指标排名
     * @return 结果
     */
    @Override
    public int insertTabRanking(TabRanking tabRanking)
    {
        return tabRankingMapper.insertTabRanking(tabRanking);
    }

    /**
     * 修改指标排名
     * 
     * @param tabRanking 指标排名
     * @return 结果
     */
    @Override
    public int updateTabRanking(TabRanking tabRanking)
    {
        return tabRankingMapper.updateTabRanking(tabRanking);
    }

    /**
     * 批量删除指标排名
     * 
     * @param ids 需要删除的指标排名主键
     * @return 结果
     */
    @Override
    public int deleteTabRankingByIds(Long[] ids)
    {
        return tabRankingMapper.deleteTabRankingByIds(ids);
    }

    /**
     * 删除指标排名信息
     * 
     * @param id 指标排名主键
     * @return 结果
     */
    @Override
    public int deleteTabRankingById(Long id)
    {
        return tabRankingMapper.deleteTabRankingById(id);
    }


    public int insertComment(String comment,String rankingId){
        TabCommentVO tabCommentVO = new TabCommentVO();
        tabCommentVO.setRankingId(Long.valueOf(rankingId));
        tabCommentVO.setComment(comment);
        tabCommentVO.setBelongId(SecurityUtils.getLoginUser().getUser().getNickName()+"-"+SecurityUtils.getUsername());
        return tabRankingMapper.insertComment(tabCommentVO);
    }
}
