package com.fs.course.service.impl;

import java.util.List;
import com.fs.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fs.course.mapper.FsUserTalentMapper;
import com.fs.course.domain.FsUserTalent;
import com.fs.course.service.IFsUserTalentService;

/**
 * 达人Service业务层处理
 *
 * @author fs
 * @date 2024-05-31
 */
@Service
public class FsUserTalentServiceImpl implements IFsUserTalentService
{
    @Autowired
    private FsUserTalentMapper fsUserTalentMapper;

    /**
     * 查询达人
     *
     * @param talentId 达人主键
     * @return 达人
     */
    @Override
    public FsUserTalent selectFsUserTalentByTalentId(Long talentId)
    {
        return fsUserTalentMapper.selectFsUserTalentByTalentId(talentId);
    }

    /**
     * 查询达人列表
     *
     * @param fsUserTalent 达人
     * @return 达人
     */
    @Override
    public List<FsUserTalent> selectFsUserTalentList(FsUserTalent fsUserTalent)
    {
        return fsUserTalentMapper.selectFsUserTalentList(fsUserTalent);
    }

    /**
     * 新增达人
     *
     * @param fsUserTalent 达人
     * @return 结果
     */
    @Override
    public int insertFsUserTalent(FsUserTalent fsUserTalent)
    {
        fsUserTalent.setCreateTime(DateUtils.getNowDate());
        return fsUserTalentMapper.insertFsUserTalent(fsUserTalent);
    }

    /**
     * 修改达人
     *
     * @param fsUserTalent 达人
     * @return 结果
     */
    @Override
    public int updateFsUserTalent(FsUserTalent fsUserTalent)
    {
        return fsUserTalentMapper.updateFsUserTalent(fsUserTalent);
    }

    /**
     * 批量删除达人
     *
     * @param talentIds 需要删除的达人主键
     * @return 结果
     */
    @Override
    public int deleteFsUserTalentByTalentIds(Long[] talentIds)
    {
        return fsUserTalentMapper.deleteFsUserTalentByTalentIds(talentIds);
    }

    /**
     * 删除达人信息
     *
     * @param talentId 达人主键
     * @return 结果
     */
    @Override
    public int deleteFsUserTalentByTalentId(Long talentId)
    {
        return fsUserTalentMapper.deleteFsUserTalentByTalentId(talentId);
    }

    @Override
    public int updateFans(Long talentId, Integer type) {
        if (type == 1){
            return fsUserTalentMapper.addFans(talentId);
        }else {
            return fsUserTalentMapper.minusFans(talentId);
        }
    }
}
