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

import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
import com.schisandra.oss.domain.convert.SchisandraOssUcloudBOConverter;
import com.schisandra.oss.domain.bo.SchisandraOssUcloudBO;
import com.schisandra.oss.domain.service.SchisandraOssUcloudDomainService;
import com.schisandra.oss.infra.basic.entity.SchisandraOssUcloud;
import com.schisandra.oss.infra.basic.service.SchisandraOssUcloudService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * ucloud对象存储配置表 领域service实现了
 *
 * @author landaiqing
 * @since 2024-06-02 22:27:45
 */
@Service
@Slf4j
public class SchisandraOssUcloudDomainServiceImpl implements SchisandraOssUcloudDomainService {

    @Resource
    private SchisandraOssUcloudService schisandraOssUcloudService;

    @Override
    public Boolean add(SchisandraOssUcloudBO schisandraOssUcloudBO) {
        SchisandraOssUcloud schisandraOssUcloud = SchisandraOssUcloudBOConverter.INSTANCE.convertBOToEntity(schisandraOssUcloudBO);
        schisandraOssUcloud.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return schisandraOssUcloudService.insert(schisandraOssUcloud) > 0;
    }

    @Override
    public Boolean update(SchisandraOssUcloudBO schisandraOssUcloudBO) {
        SchisandraOssUcloud schisandraOssUcloud = SchisandraOssUcloudBOConverter.INSTANCE.convertBOToEntity(schisandraOssUcloudBO);
        return schisandraOssUcloudService.update(schisandraOssUcloud) > 0;
    }

    @Override
    public Boolean delete(SchisandraOssUcloudBO schisandraOssUcloudBO) {
        SchisandraOssUcloud schisandraOssUcloud = new SchisandraOssUcloud();
        schisandraOssUcloud.setId(schisandraOssUcloudBO.getId());
        schisandraOssUcloud.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return schisandraOssUcloudService.update(schisandraOssUcloud) > 0;
    }

}
