package cn.novalon.manage.sys.core.service.impl;

import cn.novalon.manage.sys.core.domain.SysDictData;
import cn.novalon.manage.sys.core.repository.ISysDictDataRepository;
import cn.novalon.manage.sys.core.service.ISysDictDataService;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * 字典数据服务实现类
 * 
 * @author 张翔
 * @date 2026-03-14
 */
@Service
public class SysDictDataService implements ISysDictDataService {

    private final ISysDictDataRepository repository;

    public SysDictDataService(ISysDictDataRepository repository) {
        this.repository = repository;
    }

    @Override
    public Flux<SysDictData> findAll() {
        return repository.findByDeletedAtIsNull();
    }

    @Override
    public Flux<SysDictData> findByDictType(String dictType) {
        return repository.findByDictTypeAndDeletedAtIsNull(dictType);
    }

    @Override
    public Flux<SysDictData> findByDictTypeAndStatus(String dictType, String status) {
        return repository.findByDictTypeAndStatusAndDeletedAtIsNull(dictType, status);
    }

    @Override
    public Mono<SysDictData> findById(Long id) {
        return repository.findById(id);
    }

    @Override
    public Mono<SysDictData> save(SysDictData dictData) {
        return repository.save(dictData);
    }

    @Override
    public Mono<Void> deleteById(Long id) {
        return repository.deleteByIdAndDeletedAtIsNull(id);
    }
}
