package org.springblade.system.service.impl;

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

import java.util.List;

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

    @Resource
    private FilesMultiClassifyMapper filesMultiClassifyMapper;

    /**
     * 获取档案多维度分类管理列表
     * @param kyFilesMultiClassify
     * @return
     */
    @Override
    public List<KyFilesMultiClassify> selectKyFilesMultiClassifyList(KyFilesMultiClassify kyFilesMultiClassify) {
        return filesMultiClassifyMapper.selectKyFilesMultiClassifyList(kyFilesMultiClassify);
    }

    /**
     * 新增档案多维度分类管理
     * @param kyFilesMultiClassify
     * @return
     */
    @Override
    public int addKyFilesMultiClassify(KyFilesMultiClassify kyFilesMultiClassify) {
        //查看分类名称是否存在
        KyFilesMultiClassify kyFilesMultiClassifyOld = filesMultiClassifyMapper.getKyFilesMultiClassifyByClassifyName(kyFilesMultiClassify);
        if (StringUtils.isNotNull(kyFilesMultiClassifyOld)){
            return 0;
        }
        return filesMultiClassifyMapper.addKyFilesMultiClassify(kyFilesMultiClassify);
    }

    /**
     * 修改档案多维度分类管理
     * @param kyFilesMultiClassify
     * @return
     */
    @Override
    public int updateKyFilesMultiClassify(KyFilesMultiClassify kyFilesMultiClassify) {
        //查看分类名称是否存在
        KyFilesMultiClassify kyFilesMultiClassifyOld = filesMultiClassifyMapper.getKyFilesMultiClassifyByClassifyName(kyFilesMultiClassify);
        if (StringUtils.isNotNull(kyFilesMultiClassifyOld) && !kyFilesMultiClassify.getId().equals(kyFilesMultiClassifyOld.getId())){
            return 0;
        }
        return filesMultiClassifyMapper.updateKyFilesMultiClassify(kyFilesMultiClassify);
    }

    /**
     * 删除档案多维度分类管理
     * @param kyFilesMultiClassify
     * @return
     */
    @Override
    public int delKyFilesMultiClassify(KyFilesMultiClassify kyFilesMultiClassify) {
        return filesMultiClassifyMapper.delKyFilesMultiClassify(kyFilesMultiClassify);
    }

	@Override
	public KyFilesMultiClassify getDetail(KyFilesMultiClassify dto) {
		return filesMultiClassifyMapper.getDetail(dto);
	}
}
