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

import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
import com.schisandra.oss.domain.convert.SchisandraOssHuaweiBOConverter;
import com.schisandra.oss.domain.bo.SchisandraOssHuaweiBO;
import com.schisandra.oss.domain.service.SchisandraOssHuaweiDomainService;
import com.schisandra.oss.infra.basic.entity.SchisandraOssHuawei;
import com.schisandra.oss.infra.basic.service.SchisandraOssHuaweiService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 华为云对象存储配置表 领域service实现了
 *
 * @author landaiqing
 * @since 2024-06-02 21:59:56
 */
@Service
@Slf4j
public class SchisandraOssHuaweiDomainServiceImpl implements SchisandraOssHuaweiDomainService {

    @Resource
    private SchisandraOssHuaweiService schisandraOssHuaweiService;

    @Override
    public Boolean add(SchisandraOssHuaweiBO schisandraOssHuaweiBO) {
        SchisandraOssHuawei schisandraOssHuawei = SchisandraOssHuaweiBOConverter.INSTANCE.convertBOToEntity(schisandraOssHuaweiBO);
        schisandraOssHuawei.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return schisandraOssHuaweiService.insert(schisandraOssHuawei) > 0;
    }

    @Override
    public Boolean update(SchisandraOssHuaweiBO schisandraOssHuaweiBO) {
        SchisandraOssHuawei schisandraOssHuawei = SchisandraOssHuaweiBOConverter.INSTANCE.convertBOToEntity(schisandraOssHuaweiBO);
        return schisandraOssHuaweiService.update(schisandraOssHuawei) > 0;
    }

    @Override
    public Boolean delete(SchisandraOssHuaweiBO schisandraOssHuaweiBO) {
        SchisandraOssHuawei schisandraOssHuawei = new SchisandraOssHuawei();
        schisandraOssHuawei.setId(schisandraOssHuaweiBO.getId());
        schisandraOssHuawei.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return schisandraOssHuaweiService.update(schisandraOssHuawei) > 0;
    }

}
