package com.zehong.system.service.impl;

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

import com.zehong.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TEnterpriseRankingMapper;
import com.zehong.system.domain.TEnterpriseRanking;
import com.zehong.system.service.ITEnterpriseRankingService;

/**
 * 企业评价Service业务层处理
 * 
 * @author zehong
 * @date 2026-03-17
 */
@Service
public class TEnterpriseRankingServiceImpl implements ITEnterpriseRankingService 
{
    @Autowired
    private TEnterpriseRankingMapper tEnterpriseRankingMapper;

    /**
     * 查询企业评价
     * 
     * @param rankingId 企业评价ID
     * @return 企业评价
     */
    @Override
    public TEnterpriseRanking selectTEnterpriseRankingById(Long rankingId)
    {
        return tEnterpriseRankingMapper.selectTEnterpriseRankingById(rankingId);
    }

    /**
     * 查询企业评价列表
     * 
     * @param tEnterpriseRanking 企业评价
     * @return 企业评价
     */
    @Override
    public List<TEnterpriseRanking> selectTEnterpriseRankingList(TEnterpriseRanking tEnterpriseRanking)
    {
        return tEnterpriseRankingMapper.selectTEnterpriseRankingList(tEnterpriseRanking);
    }

    /**
     * 新增企业评价
     * 
     * @param tEnterpriseRanking 企业评价
     * @return 结果
     */
    @Override
    public int insertTEnterpriseRanking(TEnterpriseRanking tEnterpriseRanking)
    {
        tEnterpriseRanking.setCreateTime(DateUtils.getNowDate());
        return tEnterpriseRankingMapper.insertTEnterpriseRanking(tEnterpriseRanking);
    }

    /**
     * 修改企业评价
     * 
     * @param tEnterpriseRanking 企业评价
     * @return 结果
     */
    @Override
    public int updateTEnterpriseRanking(TEnterpriseRanking tEnterpriseRanking)
    {
        return tEnterpriseRankingMapper.updateTEnterpriseRanking(tEnterpriseRanking);
    }

    /**
     * 批量删除企业评价
     * 
     * @param rankingIds 需要删除的企业评价ID
     * @return 结果
     */
    @Override
    public int deleteTEnterpriseRankingByIds(Long[] rankingIds)
    {
        return tEnterpriseRankingMapper.deleteTEnterpriseRankingByIds(rankingIds);
    }

    /**
     * 根据年份查询企业评论分
     * @return
     */
    public List<Map<String,Object>> selectFractionByYear(Integer yearNum){
        List<Map<String,Object>> list = new ArrayList<>();
        for (int i=0;i<6;i++){
            yearNum++;
            Map<String,Object> map = tEnterpriseRankingMapper.selectFractionByYear(yearNum);
            map.put("yearNum",yearNum);
            list.add(map);
        }
        return list;
    }

    /**
     * 删除企业评价信息
     * 
     * @param rankingId 企业评价ID
     * @return 结果
     */
    @Override
    public int deleteTEnterpriseRankingById(Long rankingId)
    {
        return tEnterpriseRankingMapper.deleteTEnterpriseRankingById(rankingId);
    }
}
