package com.fs.qw.service.impl;

import com.fs.common.utils.DateUtils;
import com.fs.company.service.ICompanyConfigService;
import com.fs.qw.domain.QwMaterialGroup;
import com.fs.qw.mapper.QwMaterialGroupMapper;
import com.fs.qw.mapper.QwMaterialMapper;
import com.fs.qw.service.IQwMaterialGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 企业微信素材分组Service业务层处理
 *
 * @author fs
 * @date 2024-06-20
 */
@Service
public class QwMaterialGroupServiceImpl implements IQwMaterialGroupService
{
    @Autowired
    private QwMaterialGroupMapper qwMaterialGroupMapper;
    @Autowired
    private ICompanyConfigService companyConfigService;

    @Autowired
    private QwMaterialMapper qwMaterialMapper;

    /**
     * 查询企业微信素材分组
     *
     * @param materialGroupId 企业微信素材分组主键
     * @return 企业微信素材分组
     */
    @Override
    public QwMaterialGroup selectQwMaterialGroupByMaterialGroupId(Long materialGroupId)
    {
        return qwMaterialGroupMapper.selectQwMaterialGroupByMaterialGroupId(materialGroupId);
    }

    /**
     * 查询企业微信素材分组列表
     *
     * @param qwMaterialGroup 企业微信素材分组
     * @return 企业微信素材分组
     */
    @Override
    public List<QwMaterialGroup> selectQwMaterialGroupList(QwMaterialGroup qwMaterialGroup)
    {
        return qwMaterialGroupMapper.selectQwMaterialGroupList(qwMaterialGroup);
    }

    /**
     * 新增企业微信素材分组
     *
     * @param qwMaterialGroup 企业微信素材分组
     * @return 结果
     */
    @Override
    public int insertQwMaterialGroup(QwMaterialGroup qwMaterialGroup)
    {
        qwMaterialGroup.setCreateTime(DateUtils.getNowDate());
        return qwMaterialGroupMapper.insertQwMaterialGroup(qwMaterialGroup);
    }

    /**
     * 修改企业微信素材分组
     *
     * @param qwMaterialGroup 企业微信素材分组
     * @return 结果
     */
    @Override
    public int updateQwMaterialGroup(QwMaterialGroup qwMaterialGroup)
    {
        qwMaterialGroup.setUpdateTime(DateUtils.getNowDate());
        return qwMaterialGroupMapper.updateQwMaterialGroup(qwMaterialGroup);
    }

    /**
     * 批量删除企业微信素材分组
     *
     * @param materialGroupIds 需要删除的企业微信素材分组主键
     * @return 结果
     */
    @Override
    public int deleteQwMaterialGroupByMaterialGroupIds(Long[] materialGroupIds)

    {
        qwMaterialMapper.deleteQwMaterialByGroupMaterialIds(materialGroupIds);
        return qwMaterialGroupMapper.deleteQwMaterialGroupByMaterialGroupIds(materialGroupIds);
    }

    /**
     * 删除企业微信素材分组信息
     *
     * @param materialGroupId 企业微信素材分组主键
     * @return 结果
     */
    @Override
    public int deleteQwMaterialGroupByMaterialGroupId(Long materialGroupId)
    {
        qwMaterialMapper.deleteQwMaterialByGroupMaterialId(materialGroupId);
        return qwMaterialGroupMapper.deleteQwMaterialGroupByMaterialGroupId(materialGroupId);
    }
}
