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

import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
import com.schisandra.oss.domain.convert.SchisandraOssWangyiBOConverter;
import com.schisandra.oss.domain.bo.SchisandraOssWangyiBO;
import com.schisandra.oss.domain.service.SchisandraOssWangyiDomainService;
import com.schisandra.oss.infra.basic.entity.SchisandraOssWangyi;
import com.schisandra.oss.infra.basic.service.SchisandraOssWangyiService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 网易数帆对象存储配置表 领域service实现了
 *
 * @author landaiqing
 * @since 2024-06-02 22:31:37
 */
@Service
@Slf4j
public class SchisandraOssWangyiDomainServiceImpl implements SchisandraOssWangyiDomainService {

    @Resource
    private SchisandraOssWangyiService schisandraOssWangyiService;

    @Override
    public Boolean add(SchisandraOssWangyiBO schisandraOssWangyiBO) {
        SchisandraOssWangyi schisandraOssWangyi = SchisandraOssWangyiBOConverter.INSTANCE.convertBOToEntity(schisandraOssWangyiBO);
        schisandraOssWangyi.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return schisandraOssWangyiService.insert(schisandraOssWangyi) > 0;
    }

    @Override
    public Boolean update(SchisandraOssWangyiBO schisandraOssWangyiBO) {
        SchisandraOssWangyi schisandraOssWangyi = SchisandraOssWangyiBOConverter.INSTANCE.convertBOToEntity(schisandraOssWangyiBO);
        return schisandraOssWangyiService.update(schisandraOssWangyi) > 0;
    }

    @Override
    public Boolean delete(SchisandraOssWangyiBO schisandraOssWangyiBO) {
        SchisandraOssWangyi schisandraOssWangyi = new SchisandraOssWangyi();
        schisandraOssWangyi.setId(schisandraOssWangyiBO.getId());
        schisandraOssWangyi.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return schisandraOssWangyiService.update(schisandraOssWangyi) > 0;
    }

}
