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

import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
import com.schisandra.oss.domain.convert.SchisandraOssLocalBOConverter;
import com.schisandra.oss.domain.bo.SchisandraOssLocalBO;
import com.schisandra.oss.domain.service.SchisandraOssLocalDomainService;
import com.schisandra.oss.infra.basic.entity.SchisandraOssLocal;
import com.schisandra.oss.infra.basic.service.SchisandraOssLocalService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 本地存储配置表 领域service实现了
 *
 * @author landaiqing
 * @since 2024-06-02 22:18:08
 */
@Service
@Slf4j
public class SchisandraOssLocalDomainServiceImpl implements SchisandraOssLocalDomainService {

    @Resource
    private SchisandraOssLocalService schisandraOssLocalService;

    @Override
    public Boolean add(SchisandraOssLocalBO schisandraOssLocalBO) {
        SchisandraOssLocal schisandraOssLocal = SchisandraOssLocalBOConverter.INSTANCE.convertBOToEntity(schisandraOssLocalBO);
        schisandraOssLocal.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return schisandraOssLocalService.insert(schisandraOssLocal) > 0;
    }

    @Override
    public Boolean update(SchisandraOssLocalBO schisandraOssLocalBO) {
        SchisandraOssLocal schisandraOssLocal = SchisandraOssLocalBOConverter.INSTANCE.convertBOToEntity(schisandraOssLocalBO);
        return schisandraOssLocalService.update(schisandraOssLocal) > 0;
    }

    @Override
    public Boolean delete(SchisandraOssLocalBO schisandraOssLocalBO) {
        SchisandraOssLocal schisandraOssLocal = new SchisandraOssLocal();
        schisandraOssLocal.setId(schisandraOssLocalBO.getId());
        schisandraOssLocal.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return schisandraOssLocalService.update(schisandraOssLocal) > 0;
    }

}
