package com.yd.csf.service.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yd.csf.service.model.AgentAccumulatedFyc;
import com.yd.csf.service.dao.AgentAccumulatedFycMapper;
import com.yd.csf.service.service.IAgentAccumulatedFycService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 业务员累计积分表 - 存储业务员的累计FYC积分和当前等级信息 服务实现类
 * </p>
 *
 * @author zxm
 * @since 2025-10-15
 */
@Service
public class AgentAccumulatedFycServiceImpl extends ServiceImpl<AgentAccumulatedFycMapper, AgentAccumulatedFyc> implements IAgentAccumulatedFycService {

    /**
     * 查询单个对象
     * @param agentId
     * @return
     */
    @Override
    public AgentAccumulatedFyc queryOne(String agentId) {
        return this.getOne(new LambdaQueryWrapper<AgentAccumulatedFyc>()
                .eq(AgentAccumulatedFyc::getAgentId,agentId).last("limit 1"));
    }

    @Override
    public List<AgentAccumulatedFyc> queryList(List<String> agentIdList) {
        return this.baseMapper.selectList(new LambdaQueryWrapper<AgentAccumulatedFyc>()
                .in(CollectionUtils.isNotEmpty(agentIdList),AgentAccumulatedFyc::getAgentId,agentIdList));
    }

    @Override
    public List<AgentAccumulatedFyc> queryAll() {
        return this.baseMapper.selectList(null);
    }

}
