package com.ruoyi.tcZz.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.tcZz.domain.TcBzhan;
import com.ruoyi.tcZz.mapper.TcBzhanMapper;
import com.ruoyi.tcZz.service.ITcBzhanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * B站、小红书Service业务层处理
 *
 * @author ruoyi
 * @date 2023-10-13
 */
@Service
public class TcBzhanServiceImpl implements ITcBzhanService {
    @Autowired
    private TcBzhanMapper tcBzhanMapper;

    /**
     * 查询B站、小红书
     *
     * @param id B站、小红书主键
     * @return B站、小红书
     */
    @Override
    public TcBzhan selectTcBzhanById(Long id) {
        return tcBzhanMapper.selectTcBzhanById(id);
    }

    /**
     * 查询B站、小红书列表
     *
     * @param tcBzhan B站、小红书
     * @return B站、小红书
     */
    @Override
    public List<TcBzhan> selectTcBzhanList(TcBzhan tcBzhan) {
        return tcBzhanMapper.selectTcBzhanList(tcBzhan);
    }

    /**
     * 新增B站、小红书
     *
     * @param tcBzhan B站、小红书
     * @return 结果
     */
    @Override
    public int insertTcBzhan(TcBzhan tcBzhan) {
        tcBzhan.setCreateTime(DateUtils.getNowDate());
        return tcBzhanMapper.insertTcBzhan(tcBzhan);
    }

    /**
     * 修改B站、小红书
     *
     * @param tcBzhan B站、小红书
     * @return 结果
     */
    @Override
    public int updateTcBzhan(TcBzhan tcBzhan) {
        tcBzhan.setUpdateTime(DateUtils.getNowDate());
        return tcBzhanMapper.updateTcBzhan(tcBzhan);
    }

    /**
     * 批量删除B站、小红书
     *
     * @param ids 需要删除的B站、小红书主键
     * @return 结果
     */
    @Override
    public int deleteTcBzhanByIds(Long[] ids) {
        return tcBzhanMapper.deleteTcBzhanByIds(ids);
    }

    /**
     * 删除B站、小红书信息
     *
     * @param id B站、小红书主键
     * @return 结果
     */
    @Override
    public int deleteTcBzhanById(Long id) {
        return tcBzhanMapper.deleteTcBzhanById(id);
    }

    @Override
    public String importUser(List<TcBzhan> tcBzhanList) {

        StringBuilder successMsg = new StringBuilder();
        if (!tcBzhanList.isEmpty()) {
            for (TcBzhan tcBzhan : tcBzhanList) {
                tcBzhanMapper.insertTcBzhan(tcBzhan);
            }
            successMsg.append("导入成功");
        }

        return successMsg.toString();
    }
    @Override
    public void updateByisStatus(Integer isStatus,List<String> ids) {
        tcBzhanMapper.updateByisStatus(isStatus,ids);
    }
}
