package com.ruoyi.cs.service.impl;

import java.util.List;
import java.util.Map;
import cn.hutool.core.util.IdUtil;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.cs.domain.CsMessageInfo;
import org.springframework.stereotype.Service;
import com.ruoyi.cs.mapper.CsExpansionRecordMapper;
import com.ruoyi.cs.domain.CsExpansionRecord;
import com.ruoyi.cs.service.ICsExpansionRecordService;
import javax.annotation.Resource;

/**
 * 扩容记录Service业务层处理
 *
 * @author ruoyi
 * @date 2024-05-29
 */
@Service
public class CsExpansionRecordServiceImpl implements ICsExpansionRecordService
{
    @Resource
    private CsExpansionRecordMapper csExpansionRecordMapper;

    /**
     * 查询扩容记录
     *
     * @param expansionRecordId 扩容记录主键
     * @return 扩容记录
     */
    @Override
    public CsExpansionRecord selectCsExpansionRecordByExpansionRecordId(String expansionRecordId)
    {
        return csExpansionRecordMapper.selectCsExpansionRecordByExpansionRecordId(expansionRecordId);
    }

    /**
     * 查询扩容记录列表
     *
     * @param csExpansionRecord 扩容记录
     * @return 扩容记录
     */
    @Override
    public List<CsExpansionRecord> selectCsExpansionRecordList(CsExpansionRecord csExpansionRecord)
    {
        return csExpansionRecordMapper.selectCsExpansionRecordList(csExpansionRecord);
    }

    /**
     * 新增扩容记录
     *
     * @param csExpansionRecord 扩容记录
     * @return 结果
     */
    @Override
    public int insertCsExpansionRecord(CsExpansionRecord csExpansionRecord)
    {
        csExpansionRecord.setExpansionRecordId(IdUtil.getSnowflakeNextIdStr());
        csExpansionRecord.setCreateAt(DateUtils.getNowDate());
        csExpansionRecord.setDelFlag("0");
        return csExpansionRecordMapper.insertCsExpansionRecord(csExpansionRecord);
    }

    /**
     * 修改扩容记录
     *
     * @param csExpansionRecord 扩容记录
     * @return 结果
     */
    @Override
    public int updateCsExpansionRecord(CsExpansionRecord csExpansionRecord)
    {
        csExpansionRecord.setUpdateAt(DateUtils.getNowDate());
        return csExpansionRecordMapper.updateCsExpansionRecord(csExpansionRecord);
    }

    /**
     * 批量删除扩容记录
     *
     * @param expansionRecordIds 需要删除的扩容记录主键
     * @return 结果
     */
    @Override
    public int deleteCsExpansionRecordByExpansionRecordIds(String[] expansionRecordIds)
    {
        return csExpansionRecordMapper.deleteCsExpansionRecordByExpansionRecordIds(expansionRecordIds);
    }

    /**
     * 删除扩容记录信息
     *
     * @param expansionRecordId 扩容记录主键
     * @return 结果
     */
    @Override
    public int deleteCsExpansionRecordByExpansionRecordId(String expansionRecordId)
    {
        return csExpansionRecordMapper.deleteCsExpansionRecordByExpansionRecordId(expansionRecordId);
    }

    /**
     * 查询消息列表
     *
     * @param csMessageInfo
     * @return
     */
    @Override
    public List<CsMessageInfo> searchMessageList(CsMessageInfo csMessageInfo){
        return csExpansionRecordMapper.searchMessageList(csMessageInfo);
    }

    /**
     * 查询用户列表
     *
     * @return
     */
    @Override
    public List<Map<String,Object>> searchMemberList(){
        return csExpansionRecordMapper.searchMemberList();
    }

    /**
     * 查询单位列表
     *
     * @return
     */
    @Override
    public List<Map<String,Object>> searchCompanyList(){
        return csExpansionRecordMapper.searchCompanyList();
    }

    /**
     * 查询到期的扩容记录列表
     *
     * @return
     */
    @Override
    public List<CsExpansionRecord> searchExpansionMemberUserIdList(){
        return csExpansionRecordMapper.searchExpansionMemberUserIdList();
    }

    /**
     * 保存消息
     *
     * @param csMessageInfo
     * @return
     */
    @Override
    public int saveMessageInfo(CsMessageInfo csMessageInfo){
        return csExpansionRecordMapper.saveMessageInfo(csMessageInfo);
    }

    /**
     * 根据业务ID查询消息数量
     *
     * @param businessId
     * @return
     */
    @Override
    public int searchMessageCountByBusinessId(String businessId){
        return csExpansionRecordMapper.searchMessageCountByBusinessId(businessId);
    }

}
