package com.ruixuan.isc.service.impl;

import com.ruixuan.common.utils.Result;
import com.ruixuan.isc.entity.KuaishouLabel;
import com.ruixuan.isc.mapper.KuaishouLabelMapper;
import com.ruixuan.isc.service.IKuaishouLabelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 快手标签Service业务层处理
 *
 * @author ruoyi
 * @date 2023-03-28
 */
@Service
public class KuaishouLabelServiceImpl implements IKuaishouLabelService {
    @Autowired
    private KuaishouLabelMapper kuaishouLabelMapper;

    /**
     * 查询快手标签
     *
     * @param id 快手标签主键
     * @return 快手标签
     */
    @Override
    public KuaishouLabel selectKuaishouLabelById(Long id) {
        return kuaishouLabelMapper.selectKuaishouLabelById(id);
    }

    /**
     * 查询快手标签列表
     *
     * @param kuaishouLabel 快手标签
     * @return 快手标签
     */
    @Override
    public List<KuaishouLabel> selectKuaishouLabelList(KuaishouLabel kuaishouLabel) {
        return kuaishouLabelMapper.selectKuaishouLabelList(kuaishouLabel);
    }

    /**
     * 新增快手标签
     */
    @Override
    public Result insertKuaishouLabel(KuaishouLabel kuaishouLabel) {
        String colour = kuaishouLabelMapper.getLabelColour();
        kuaishouLabel.setLabelColour(colour);
        int i = kuaishouLabelMapper.insertKuaishouLabel(kuaishouLabel);
        if (i > 0) {
             kuaishouLabelMapper.updateLabelColourStatus(colour);
        }
        return Result.success(kuaishouLabel);
    }

    /**
     * 修改快手标签
     */
    @Override
    public int updateKuaishouLabel(KuaishouLabel kuaishouLabel) {
        return kuaishouLabelMapper.updateKuaishouLabel(kuaishouLabel);
    }

    /**
     * 批量删除快手标签
     *
     * @param ids 需要删除的快手标签主键
     * @return 结果
     */
    @Override
    public int deleteKuaishouLabelByIds(Long[] ids) {
        return kuaishouLabelMapper.deleteKuaishouLabelByIds(ids);
    }

    /**
     * 删除快手标签信息
     *
     * @param id 快手标签主键
     * @return 结果
     */
    @Override
    public int deleteKuaishouLabelById(Long id) {
        return kuaishouLabelMapper.deleteKuaishouLabelById(id);
    }
}