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

import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
import com.schisandra.oss.domain.convert.SchisandraOssBaiduBOConverter;
import com.schisandra.oss.domain.bo.SchisandraOssBaiduBO;
import com.schisandra.oss.domain.service.SchisandraOssBaiduDomainService;
import com.schisandra.oss.infra.basic.entity.SchisandraOssBaidu;
import com.schisandra.oss.infra.basic.service.SchisandraOssBaiduService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 百度云对象存储配置表 领域service实现了
 *
 * @author landaiqing
 * @since 2024-06-02 22:02:15
 */
@Service
@Slf4j
public class SchisandraOssBaiduDomainServiceImpl implements SchisandraOssBaiduDomainService {

    @Resource
    private SchisandraOssBaiduService schisandraOssBaiduService;

    @Override
    public Boolean add(SchisandraOssBaiduBO schisandraOssBaiduBO) {
        SchisandraOssBaidu schisandraOssBaidu = SchisandraOssBaiduBOConverter.INSTANCE.convertBOToEntity(schisandraOssBaiduBO);
        schisandraOssBaidu.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return schisandraOssBaiduService.insert(schisandraOssBaidu) > 0;
    }

    @Override
    public Boolean update(SchisandraOssBaiduBO schisandraOssBaiduBO) {
        SchisandraOssBaidu schisandraOssBaidu = SchisandraOssBaiduBOConverter.INSTANCE.convertBOToEntity(schisandraOssBaiduBO);
        return schisandraOssBaiduService.update(schisandraOssBaidu) > 0;
    }

    @Override
    public Boolean delete(SchisandraOssBaiduBO schisandraOssBaiduBO) {
        SchisandraOssBaidu schisandraOssBaidu = new SchisandraOssBaidu();
        schisandraOssBaidu.setId(schisandraOssBaiduBO.getId());
        schisandraOssBaidu.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return schisandraOssBaiduService.update(schisandraOssBaidu) > 0;
    }

}
