package com.fs.company.service.impl;

import com.fs.common.utils.DateUtils;
import com.fs.company.domain.CompanyTag;
import com.fs.company.mapper.CompanyTagMapper;
import com.fs.company.service.ICompanyTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * companyService业务层处理
 *
 * @author fs
 * @date 2025-04-02
 */
@Service
public class CompanyTagServiceImpl implements ICompanyTagService
{
    @Autowired
    private CompanyTagMapper companyTagMapper;

    /**
     * 查询company
     *
     * @param tagId companyID
     * @return company
     */
    @Override
    public CompanyTag selectCompanyTagById(Long tagId)
    {
        return companyTagMapper.selectCompanyTagById(tagId);
    }

    /**
     * 查询company列表
     *
     * @param companyTag company
     * @return company
     */
    @Override
    public List<CompanyTag> selectCompanyTagList(CompanyTag companyTag)
    {
        return companyTagMapper.selectCompanyTagList(companyTag);
    }

    /**
     * 新增company
     *
     * @param companyTag company
     * @return 结果
     */
    @Override
    public int insertCompanyTag(CompanyTag companyTag)
    {
        companyTag.setCreateTime(DateUtils.getNowDate());
        return companyTagMapper.insertCompanyTag(companyTag);
    }

    /**
     * 修改company
     *
     * @param companyTag company
     * @return 结果
     */
    @Override
    public int updateCompanyTag(CompanyTag companyTag)
    {
        return companyTagMapper.updateCompanyTag(companyTag);
    }

    /**
     * 批量删除company
     *
     * @param tagIds 需要删除的companyID
     * @return 结果
     */
    @Override
    public int deleteCompanyTagByIds(Long[] tagIds)
    {
        return companyTagMapper.deleteCompanyTagByIds(tagIds);
    }

    /**
     * 删除company信息
     *
     * @param tagId companyID
     * @return 结果
     */
    @Override
    public int deleteCompanyTagById(Long tagId)
    {
        return companyTagMapper.deleteCompanyTagById(tagId);
    }

    /**
     * 删除标签
     * @param tagIds 标签ID
     */
    @Override
    public void deleteCompanyTagByTagIds(List<Long> tagIds) {
        if (tagIds.isEmpty()) {
            return;
        }
        companyTagMapper.deleteCompanyTagByIds(tagIds.toArray(new Long[0]));
    }

    /**
     * 查询标签列表
     * @param params 条件
     * @return list
     */
    @Override
    public List<CompanyTag> selectCompanyTagListByMap(Map<String, Object> params) {
        return companyTagMapper.selectCompanyTagListByMap(params);
    }

    @Override
    public Map<Long, CompanyTag> queryAllTagMap() {
        return companyTagMapper.queryAllTagMap();
    }

    @Override
    public String findUserTagByUserId(Long key,Long companyUserId) {
        return companyTagMapper.findUserTagByUserId(key,companyUserId);
    }

    /**
     * 查询标签列表
     * @param params 条件
     * @return list
     */
    @Override
    public List<CompanyTag> selectCompanyTagByList(Map<String, Object> params) {
        return companyTagMapper.selectCompanyTagByList(params);
    }
}
