package com.ruoyi.system.service.impl;

import cn.hutool.core.util.IdUtil;
import com.ruoyi.common.core.domain.entity.CategoryInfo;
import com.ruoyi.common.core.domain.entity.MusicInfo;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.mapper.CategoryInfoMapper;
import com.ruoyi.system.service.ICategoryInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author ruoyi
 * @date 2025-07-15
 */
@Service
public class CategoryInfoServiceImpl implements ICategoryInfoService
{
    @Autowired
    private CategoryInfoMapper categoryInfoMapper;


    /**
     * 查询【请填写功能名称】
     *
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public CategoryInfo selectCategoryInfoById(String id)
    {
        return categoryInfoMapper.selectCategoryInfoById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param categoryInfo 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<CategoryInfo> selectCategoryInfoList(CategoryInfo categoryInfo)
    {
        return categoryInfoMapper.selectCategoryInfoList(categoryInfo);
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param categoryInfo 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertCategoryInfo(CategoryInfo categoryInfo)
    {
        categoryInfo.setCategoryId(IdUtil.getSnowflakeNextId());
        categoryInfo.setCreateTime(DateUtils.getNowDate());
        return categoryInfoMapper.insertCategoryInfo(categoryInfo);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param categoryInfo 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateCategoryInfo(CategoryInfo categoryInfo)
    {
        categoryInfo.setUpdateTime(DateUtils.getNowDate());
        return categoryInfoMapper.updateCategoryInfo(categoryInfo);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteCategoryInfoByIds(String[] ids)
    {
        categoryInfoMapper.deleteCategoryInfoBycategoryIds(ids);
        return categoryInfoMapper.deleteCategoryInfoByIds(ids);
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteCategoryInfoById(String id)
    {
        return categoryInfoMapper.deleteCategoryInfoById(id);
    }

    @Override
    public List<CategoryInfo> getCategory() {
        return categoryInfoMapper.selectCategoryList();
    }

    @Override
    public int bindMusic(String categoryId,String[] ids) {
        // 先删除再绑定
        categoryInfoMapper.deleteCategoryInfoBycategoryId(categoryId);
        return categoryInfoMapper.bindMusic(categoryId,ids);
    }


}
