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

import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
import com.schisandra.oss.domain.convert.SchisandraOssJdBOConverter;
import com.schisandra.oss.domain.bo.SchisandraOssJdBO;
import com.schisandra.oss.domain.service.SchisandraOssJdDomainService;
import com.schisandra.oss.infra.basic.entity.SchisandraOssJd;
import com.schisandra.oss.infra.basic.service.SchisandraOssJdService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 京东云对象存储配置表 领域service实现了
 *
 * @author landaiqing
 * @since 2024-06-02 22:07:10
 */
@Service
@Slf4j
public class SchisandraOssJdDomainServiceImpl implements SchisandraOssJdDomainService {

    @Resource
    private SchisandraOssJdService schisandraOssJdService;

    @Override
    public Boolean add(SchisandraOssJdBO schisandraOssJdBO) {
        SchisandraOssJd schisandraOssJd = SchisandraOssJdBOConverter.INSTANCE.convertBOToEntity(schisandraOssJdBO);
        schisandraOssJd.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return schisandraOssJdService.insert(schisandraOssJd) > 0;
    }

    @Override
    public Boolean update(SchisandraOssJdBO schisandraOssJdBO) {
        SchisandraOssJd schisandraOssJd = SchisandraOssJdBOConverter.INSTANCE.convertBOToEntity(schisandraOssJdBO);
        return schisandraOssJdService.update(schisandraOssJd) > 0;
    }

    @Override
    public Boolean delete(SchisandraOssJdBO schisandraOssJdBO) {
        SchisandraOssJd schisandraOssJd = new SchisandraOssJd();
        schisandraOssJd.setId(schisandraOssJdBO.getId());
        schisandraOssJd.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return schisandraOssJdService.update(schisandraOssJd) > 0;
    }

}
