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

import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
import com.schisandra.oss.domain.convert.SchisandraOssQingyunBOConverter;
import com.schisandra.oss.domain.bo.SchisandraOssQingyunBO;
import com.schisandra.oss.domain.service.SchisandraOssQingyunDomainService;
import com.schisandra.oss.infra.basic.entity.SchisandraOssQingyun;
import com.schisandra.oss.infra.basic.service.SchisandraOssQingyunService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 青云对象存储配置表 领域service实现了
 *
 * @author landaiqing
 * @since 2024-06-02 22:21:09
 */
@Service
@Slf4j
public class SchisandraOssQingyunDomainServiceImpl implements SchisandraOssQingyunDomainService {

    @Resource
    private SchisandraOssQingyunService schisandraOssQingyunService;

    @Override
    public Boolean add(SchisandraOssQingyunBO schisandraOssQingyunBO) {
        SchisandraOssQingyun schisandraOssQingyun = SchisandraOssQingyunBOConverter.INSTANCE.convertBOToEntity(schisandraOssQingyunBO);
        schisandraOssQingyun.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return schisandraOssQingyunService.insert(schisandraOssQingyun) > 0;
    }

    @Override
    public Boolean update(SchisandraOssQingyunBO schisandraOssQingyunBO) {
        SchisandraOssQingyun schisandraOssQingyun = SchisandraOssQingyunBOConverter.INSTANCE.convertBOToEntity(schisandraOssQingyunBO);
        return schisandraOssQingyunService.update(schisandraOssQingyun) > 0;
    }

    @Override
    public Boolean delete(SchisandraOssQingyunBO schisandraOssQingyunBO) {
        SchisandraOssQingyun schisandraOssQingyun = new SchisandraOssQingyun();
        schisandraOssQingyun.setId(schisandraOssQingyunBO.getId());
        schisandraOssQingyun.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return schisandraOssQingyunService.update(schisandraOssQingyun) > 0;
    }

}
