package org.springblade.system.service.impl;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.core.domain.entity.KyFilesCustomizeClassify;
import org.springblade.common.utils.StringUtils;
import org.springblade.system.mapper.FilesCustomizeClassifyMapper;
import org.springblade.system.service.FilesCustomizeClassifyService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 马三炮
 * @date 2025/9/11
 */
@Service
@Slf4j
public class FilesCustomizeClassifyServiceImpl implements FilesCustomizeClassifyService {

    @Resource
    private FilesCustomizeClassifyMapper filesCustomizeClassifyMapper;

    @Override
    public List<KyFilesCustomizeClassify> getKyFilesCustomizeClassifyList(KyFilesCustomizeClassify kyFilesCustomizeClassify) {
        return filesCustomizeClassifyMapper.getKyFilesCustomizeClassifyList(kyFilesCustomizeClassify);
    }

    @Override
    public int addKyFilesCustomizeClassify(KyFilesCustomizeClassify kyFilesCustomizeClassify) {
        KyFilesCustomizeClassify kyFilesCustomizeClassifyOld = filesCustomizeClassifyMapper.getKyFilesCustomizeClassify(kyFilesCustomizeClassify);
        if (StringUtils.isNotNull(kyFilesCustomizeClassifyOld)){
            return 0;
        }
        return filesCustomizeClassifyMapper.addKyFilesCustomizeClassify(kyFilesCustomizeClassify);
    }

    @Override
    public int updateKyFilesCustomizeClassify(KyFilesCustomizeClassify kyFilesCustomizeClassify) {
        KyFilesCustomizeClassify kyFilesCustomizeClassifyOld = filesCustomizeClassifyMapper.getKyFilesCustomizeClassify(kyFilesCustomizeClassify);
        if (StringUtils.isNotNull(kyFilesCustomizeClassifyOld) && !kyFilesCustomizeClassify.getId().equals(kyFilesCustomizeClassifyOld.getId())){
            return 0;
        }
        return filesCustomizeClassifyMapper.updateKyFilesCustomizeClassify(kyFilesCustomizeClassify);
    }

    @Override
    public int delKyFilesCustomizeClassify(KyFilesCustomizeClassify kyFilesCustomizeClassify) {
        return filesCustomizeClassifyMapper.delKyFilesCustomizeClassify(kyFilesCustomizeClassify);
    }
}
