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

import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
import com.schisandra.oss.domain.convert.SchisandraOssJinshanBOConverter;
import com.schisandra.oss.domain.bo.SchisandraOssJinshanBO;
import com.schisandra.oss.domain.service.SchisandraOssJinshanDomainService;
import com.schisandra.oss.infra.basic.entity.SchisandraOssJinshan;
import com.schisandra.oss.infra.basic.service.SchisandraOssJinshanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 金山云对象存储配置表 领域service实现了
 *
 * @author landaiqing
 * @since 2024-06-02 22:13:26
 */
@Service
@Slf4j
public class SchisandraOssJinshanDomainServiceImpl implements SchisandraOssJinshanDomainService {

    @Resource
    private SchisandraOssJinshanService schisandraOssJinshanService;

    @Override
    public Boolean add(SchisandraOssJinshanBO schisandraOssJinshanBO) {
        SchisandraOssJinshan schisandraOssJinshan = SchisandraOssJinshanBOConverter.INSTANCE.convertBOToEntity(schisandraOssJinshanBO);
        schisandraOssJinshan.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return schisandraOssJinshanService.insert(schisandraOssJinshan) > 0;
    }

    @Override
    public Boolean update(SchisandraOssJinshanBO schisandraOssJinshanBO) {
        SchisandraOssJinshan schisandraOssJinshan = SchisandraOssJinshanBOConverter.INSTANCE.convertBOToEntity(schisandraOssJinshanBO);
        return schisandraOssJinshanService.update(schisandraOssJinshan) > 0;
    }

    @Override
    public Boolean delete(SchisandraOssJinshanBO schisandraOssJinshanBO) {
        SchisandraOssJinshan schisandraOssJinshan = new SchisandraOssJinshan();
        schisandraOssJinshan.setId(schisandraOssJinshanBO.getId());
        schisandraOssJinshan.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return schisandraOssJinshanService.update(schisandraOssJinshan) > 0;
    }

}
