package cn.novalon.gym.manage.db.converter;

import cn.novalon.gym.manage.sys.core.domain.SysDictType;
import cn.novalon.gym.manage.db.entity.SysDictTypeEntity;

import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 字典类型实体转换器
 * 
 * @author 张翔
 * @date 2026-03-13
 */
@Component
public class SysDictTypeConverter {

    public SysDictType toDomain(SysDictTypeEntity entity) {
        if (entity == null) {
            return null;
        }
        SysDictType domain = new SysDictType();
        domain.setId(entity.getId());
        domain.setDictName(entity.getDictName());
        domain.setDictType(entity.getDictType());
        domain.setStatus(entity.getStatus());
        domain.setRemark(entity.getRemark());
        domain.setCreatedAt(entity.getCreatedAt());
        domain.setUpdatedAt(entity.getUpdatedAt());
        return domain;
    }

    public SysDictTypeEntity toEntity(SysDictType domain) {
        if (domain == null) {
            return null;
        }
        SysDictTypeEntity entity = new SysDictTypeEntity();
        entity.setId(domain.getId());
        entity.setDictName(domain.getDictName());
        entity.setDictType(domain.getDictType());
        entity.setStatus(domain.getStatus());
        entity.setRemark(domain.getRemark());
        entity.setCreatedAt(domain.getCreatedAt());
        entity.setUpdatedAt(domain.getUpdatedAt());
        return entity;
    }

    public List<SysDictType> toDomainList(List<SysDictTypeEntity> entities) {
        if (entities == null) {
            return null;
        }
        return entities.stream()
                .map(this::toDomain)
                .collect(Collectors.toList());
    }

    public List<SysDictTypeEntity> toEntityList(List<SysDictType> domains) {
        if (domains == null) {
            return null;
        }
        return domains.stream()
                .map(this::toEntity)
                .collect(Collectors.toList());
    }
}
