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

import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
import com.schisandra.oss.domain.convert.SchisandraOssAwsBOConverter;
import com.schisandra.oss.domain.bo.SchisandraOssAwsBO;
import com.schisandra.oss.domain.service.SchisandraOssAwsDomainService;
import com.schisandra.oss.infra.basic.entity.SchisandraOssAws;
import com.schisandra.oss.infra.basic.service.SchisandraOssAwsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 亚马逊对象存储配置表 领域service实现了
 *
 * @author landaiqing
 * @since 2024-06-02 21:48:16
 */
@Service
@Slf4j
public class SchisandraOssAwsDomainServiceImpl implements SchisandraOssAwsDomainService {

    @Resource
    private SchisandraOssAwsService schisandraOssAwsService;

    @Override
    public Boolean add(SchisandraOssAwsBO schisandraOssAwsBO) {
        SchisandraOssAws schisandraOssAws = SchisandraOssAwsBOConverter.INSTANCE.convertBOToEntity(schisandraOssAwsBO);
        schisandraOssAws.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return schisandraOssAwsService.insert(schisandraOssAws) > 0;
    }

    @Override
    public Boolean update(SchisandraOssAwsBO schisandraOssAwsBO) {
        SchisandraOssAws schisandraOssAws = SchisandraOssAwsBOConverter.INSTANCE.convertBOToEntity(schisandraOssAwsBO);
        return schisandraOssAwsService.update(schisandraOssAws) > 0;
    }

    @Override
    public Boolean delete(SchisandraOssAwsBO schisandraOssAwsBO) {
        SchisandraOssAws schisandraOssAws = new SchisandraOssAws();
        schisandraOssAws.setId(schisandraOssAwsBO.getId());
        schisandraOssAws.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return schisandraOssAwsService.update(schisandraOssAws) > 0;
    }

}
