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

import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
import com.schisandra.oss.domain.convert.SchisandraOssUpBOConverter;
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
import com.schisandra.oss.domain.service.SchisandraOssUpDomainService;
import com.schisandra.oss.infra.basic.entity.SchisandraOssUp;
import com.schisandra.oss.infra.basic.service.SchisandraOssUpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 又拍云对象存储配置表 领域service实现了
 *
 * @author landaiqing
 * @since 2024-06-02 22:29:27
 */
@Service
@Slf4j
public class SchisandraOssUpDomainServiceImpl implements SchisandraOssUpDomainService {

    @Resource
    private SchisandraOssUpService schisandraOssUpService;

    @Override
    public Boolean add(SchisandraOssUpBO schisandraOssUpBO) {
        SchisandraOssUp schisandraOssUp = SchisandraOssUpBOConverter.INSTANCE.convertBOToEntity(schisandraOssUpBO);
        schisandraOssUp.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return schisandraOssUpService.insert(schisandraOssUp) > 0;
    }

    @Override
    public Boolean update(SchisandraOssUpBO schisandraOssUpBO) {
        SchisandraOssUp schisandraOssUp = SchisandraOssUpBOConverter.INSTANCE.convertBOToEntity(schisandraOssUpBO);
        return schisandraOssUpService.update(schisandraOssUp) > 0;
    }

    @Override
    public Boolean delete(SchisandraOssUpBO schisandraOssUpBO) {
        SchisandraOssUp schisandraOssUp = new SchisandraOssUp();
        schisandraOssUp.setId(schisandraOssUpBO.getId());
        schisandraOssUp.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return schisandraOssUpService.update(schisandraOssUp) > 0;
    }

}
