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

import cn.novalon.manage.sys.core.domain.SysDictType;
import cn.novalon.manage.sys.core.repository.ISysDictTypeRepository;
import cn.novalon.manage.sys.core.service.ISysDictTypeService;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * 字典类型服务实现类
 * 
 * @author 张翔
 * @date 2026-03-14
 */
@Service
public class SysDictTypeService implements ISysDictTypeService {

    private final ISysDictTypeRepository repository;

    public SysDictTypeService(ISysDictTypeRepository repository) {
        this.repository = repository;
    }

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

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

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

    @Override
    public Mono<SysDictType> save(SysDictType dictType) {
        return repository.save(dictType);
    }

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