package com.ruoyi.project.business.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.project.business.domain.TbAgentHistory;
import com.ruoyi.project.business.mapper.TbAgentHistoryMapper;
import com.ruoyi.project.business.service.ITbAgentHistoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 代理商档案Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-07-31
 */
@Service
public class TbAgentHistoryServiceImpl extends ServiceImpl<TbAgentHistoryMapper, TbAgentHistory> implements ITbAgentHistoryService
{
    @Resource
    private TbAgentHistoryMapper tbAgentHistoryMapper;

    /**
     * 查询代理商档案
     * 
     * @param id 代理商档案主键
     * @return 代理商档案
     */
    @Override
    public TbAgentHistory selectTbAgentHistoryById(Long id)
    {
        return tbAgentHistoryMapper.selectTbAgentHistoryById(id);
    }

    /**
     * 查询代理商档案列表
     * 
     * @param tbAgentHistory 代理商档案
     * @return 代理商档案
     */
    @Override
    public List<TbAgentHistory> selectTbAgentHistoryList(TbAgentHistory tbAgentHistory)
    {
        tbAgentHistory.setPermissionChar(SecurityUtils.getPermissionCharIns());
        return tbAgentHistoryMapper.selectTbAgentHistoryList(tbAgentHistory);
    }

    /**
     * 新增代理商档案
     * 
     * @param tbAgentHistory 代理商档案
     * @return 结果
     */
    @Override
    public int insertTbAgentHistory(TbAgentHistory tbAgentHistory)
    {
        tbAgentHistory.setCreateTime(DateUtils.getNowDate());
        return tbAgentHistoryMapper.insertTbAgentHistory(tbAgentHistory);
    }

    /**
     * 修改代理商档案
     * 
     * @param tbAgentHistory 代理商档案
     * @return 结果
     */
    @Override
    public int updateTbAgentHistory(TbAgentHistory tbAgentHistory)
    {
        tbAgentHistory.setUpdateTime(DateUtils.getNowDate());
        return tbAgentHistoryMapper.updateTbAgentHistory(tbAgentHistory);
    }

    /**
     * 批量删除代理商档案
     * 
     * @param ids 需要删除的代理商档案主键
     * @return 结果
     */
    @Override
    public int deleteTbAgentHistoryByIds(Long[] ids)
    {
        return tbAgentHistoryMapper.deleteTbAgentHistoryByIds(ids);
    }

    /**
     * 删除代理商档案信息
     * 
     * @param id 代理商档案主键
     * @return 结果
     */
    @Override
    public int deleteTbAgentHistoryById(Long id)
    {
        return tbAgentHistoryMapper.deleteTbAgentHistoryById(id);
    }

    @Override
    public boolean save(TbAgentHistory entity) {
        return super.save(entity);
    }
}
