package com.schisandra.oss.domain.service.impl;

import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
import com.schisandra.oss.domain.convert.SchisandraOssFtpBOConverter;
import com.schisandra.oss.domain.bo.SchisandraOssFtpBO;
import com.schisandra.oss.domain.service.SchisandraOssFtpDomainService;
import com.schisandra.oss.infra.basic.entity.SchisandraOssFtp;
import com.schisandra.oss.infra.basic.service.SchisandraOssFtpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * ftp存储配置表 领域service实现了
 *
 * @author landaiqing
 * @since 2024-06-02 21:54:20
 */
@Service
@Slf4j
public class SchisandraOssFtpDomainServiceImpl implements SchisandraOssFtpDomainService {

    @Resource
    private SchisandraOssFtpService schisandraOssFtpService;

    @Override
    public Boolean add(SchisandraOssFtpBO schisandraOssFtpBO) {
        SchisandraOssFtp schisandraOssFtp = SchisandraOssFtpBOConverter.INSTANCE.convertBOToEntity(schisandraOssFtpBO);
        schisandraOssFtp.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return schisandraOssFtpService.insert(schisandraOssFtp) > 0;
    }

    @Override
    public Boolean update(SchisandraOssFtpBO schisandraOssFtpBO) {
        SchisandraOssFtp schisandraOssFtp = SchisandraOssFtpBOConverter.INSTANCE.convertBOToEntity(schisandraOssFtpBO);
        return schisandraOssFtpService.update(schisandraOssFtp) > 0;
    }

    @Override
    public Boolean delete(SchisandraOssFtpBO schisandraOssFtpBO) {
        SchisandraOssFtp schisandraOssFtp = new SchisandraOssFtp();
        schisandraOssFtp.setId(schisandraOssFtpBO.getId());
        schisandraOssFtp.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return schisandraOssFtpService.update(schisandraOssFtp) > 0;
    }

}
