package com.jwipc.sys.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.jwipc.sys.entity.DealtWithTargetType;
import com.jwipc.sys.mapper.DealtWithTargetTypeMapper;
import com.jwipc.sys.model.dto.WorkbenchDwtDto;
import com.jwipc.sys.model.po.DealtWithTargetTypePO;
import com.jwipc.sys.model.query.DealtTypeQuery;
import com.jwipc.sys.service.IDealtWithTargetTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 指标分类 服务实现类
 * </p>
 *
 * @author shenyang.ou
 * @since 2024-01-30
 */
@Service
public class DealtWithTargetTypeServiceImpl extends ServiceImpl<DealtWithTargetTypeMapper, DealtWithTargetType> implements IDealtWithTargetTypeService {

    @Override
    public List<DealtWithTargetTypePO> findPageByQuery(Page<DealtWithTargetType> dbPage, DealtTypeQuery query) {
        if (dbPage==null){
            return baseMapper.findPageByQuery(query);
        }
        return baseMapper.findPageByQuery(dbPage,query);
    }

    /**
     * 根据指标分类ID获取工作台页面中指标分类数据
     *
     * @param ttIdList 指标分类ID集合(已包含了当前登录人的角色权限了)
     * @return 结果
     */
    @Override
    public List<WorkbenchDwtDto> findByTtIdList(List<Long> ttIdList) {
        if(CollectionUtils.isEmpty(ttIdList)) {
            return Lists.newArrayList();
        }
        return baseMapper.findByTtIdList(ttIdList);
    }
    /**
     * 根据指标分类ID获取工作台页面中指标分类数据
     *
     * @param ttIdList 指标分类ID集合(已包含了当前登录人的角色权限了)
     * @return 结果
     */
    @Override
    public List<DealtWithTargetType> findByIds(List<Long> ttIdList) {
        if(CollectionUtils.isEmpty(ttIdList)) {
            return Lists.newArrayList();
        }
        return baseMapper.findByIds(ttIdList);
    }
}
