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

import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
import com.schisandra.oss.domain.convert.SchisandraOssTencentBOConverter;
import com.schisandra.oss.domain.bo.SchisandraOssTencentBO;
import com.schisandra.oss.domain.service.SchisandraOssTencentDomainService;
import com.schisandra.oss.infra.basic.entity.SchisandraOssTencent;
import com.schisandra.oss.infra.basic.service.SchisandraOssTencentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 腾讯云对象存储配置表 领域service实现了
 *
 * @author landaiqing
 * @since 2024-06-02 21:38:56
 */
@Service
@Slf4j
public class SchisandraOssTencentDomainServiceImpl implements SchisandraOssTencentDomainService {

    @Resource
    private SchisandraOssTencentService schisandraOssTencentService;

    @Override
    public Boolean add(SchisandraOssTencentBO schisandraOssTencentBO) {
        SchisandraOssTencent schisandraOssTencent = SchisandraOssTencentBOConverter.INSTANCE.convertBOToEntity(schisandraOssTencentBO);
        schisandraOssTencent.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return schisandraOssTencentService.insert(schisandraOssTencent) > 0;
    }

    @Override
    public Boolean update(SchisandraOssTencentBO schisandraOssTencentBO) {
        SchisandraOssTencent schisandraOssTencent = SchisandraOssTencentBOConverter.INSTANCE.convertBOToEntity(schisandraOssTencentBO);
        return schisandraOssTencentService.update(schisandraOssTencent) > 0;
    }

    @Override
    public Boolean delete(SchisandraOssTencentBO schisandraOssTencentBO) {
        SchisandraOssTencent schisandraOssTencent = new SchisandraOssTencent();
        schisandraOssTencent.setId(schisandraOssTencentBO.getId());
        schisandraOssTencent.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return schisandraOssTencentService.update(schisandraOssTencent) > 0;
    }

}
