package com.ruoyi.mall.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.SysUserRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mall.mapper.MallLinkIndustryCareerMapper;
import com.ruoyi.mall.domain.MallLinkIndustryCareer;
import com.ruoyi.mall.service.IMallLinkIndustryCareerService;

import javax.annotation.Resource;

/**
 * 行业与职业关联Service业务层处理
 *
 * @author LCL
 * @date 2023-10-20
 */
@Service
public class MallLinkIndustryCareerServiceImpl implements IMallLinkIndustryCareerService
{
    @Resource
    private MallLinkIndustryCareerMapper mallLinkIndustryCareerMapper;

    /**
     * 查询行业与职业关联
     *
     * @param linkId 行业与职业关联主键
     * @return 行业与职业关联
     */
    @Override
    public MallLinkIndustryCareer selectMallLinkIndustryCareerByLinkId(Long linkId)
    {
        return mallLinkIndustryCareerMapper.selectMallLinkIndustryCareerByLinkId(linkId);
    }

    /**
     * 查询行业与职业关联列表
     *
     * @param mallLinkIndustryCareer 行业与职业关联
     * @return 行业与职业关联
     */
    @Override
    public List<MallLinkIndustryCareer> selectMallLinkIndustryCareerList(MallLinkIndustryCareer mallLinkIndustryCareer)
    {
        return mallLinkIndustryCareerMapper.selectMallLinkIndustryCareerList(mallLinkIndustryCareer);
    }

    /**
     * 新增行业与职业关联
     *
     * @param mallLinkIndustryCareer 行业与职业关联
     * @return 结果
     */
    @Override
    public int insertMallLinkIndustryCareer(MallLinkIndustryCareer mallLinkIndustryCareer)
    {
        mallLinkIndustryCareer.setCreateAt(DateUtils.getTime());
        return mallLinkIndustryCareerMapper.insertMallLinkIndustryCareer(mallLinkIndustryCareer);
    }

    /**
     * 修改行业与职业关联
     *
     * @param mallLinkIndustryCareer 行业与职业关联
     * @return 结果
     */
    @Override
    public int updateMallLinkIndustryCareer(MallLinkIndustryCareer mallLinkIndustryCareer)
    {
        mallLinkIndustryCareer.setUpdateAt(DateUtils.getTime());
        return mallLinkIndustryCareerMapper.updateMallLinkIndustryCareer(mallLinkIndustryCareer);
    }

    /**
     * 批量删除行业与职业关联
     *
     * @param linkIds 需要删除的行业与职业关联主键
     * @return 结果
     */
    @Override
    public int deleteMallLinkIndustryCareerByLinkIds(Long[] linkIds)
    {
        return mallLinkIndustryCareerMapper.deleteMallLinkIndustryCareerByLinkIds(linkIds);
    }

    /**
     * 删除行业与职业关联信息
     *
     * @param linkId 行业与职业关联主键
     * @return 结果
     */
    @Override
    public int deleteMallLinkIndustryCareerByLinkId(Long linkId)
    {
        return mallLinkIndustryCareerMapper.deleteMallLinkIndustryCareerByLinkId(linkId);
    }

    /**
     * 根据行业ID删除行业与职业关联信息
     *
     * @param industryId 行业ID
     * @return 结果
     */
    @Override
    public int deleteMallLinkIndustryCareerByIndustryId(Long industryId) {
        return mallLinkIndustryCareerMapper.deleteMallLinkIndustryCareerByIndustryId(industryId);
    }

    /**
     * 批量新增行业与职业关联信息
     *
     * @param industryId 行业ID
     * @param careerList 职业ID集合
     * @return 结果
     */
    @Override
    public int batchInsertMallLinkIndustryCareer(Long industryId, Long[] careerList) {
        // 行业与职业关联列表
        List<MallLinkIndustryCareer> list = new ArrayList<MallLinkIndustryCareer>();
        for (Long careerId : careerList)
        {
            MallLinkIndustryCareer industryCareer = new MallLinkIndustryCareer();
            industryCareer.setIndustryId(industryId);
            industryCareer.setCareerId(careerId);
            list.add(industryCareer);
        }
        return mallLinkIndustryCareerMapper.batchInsertMallLinkIndustryCareer(list);
    }
}
