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

import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
import com.schisandra.oss.domain.convert.SchisandraOssJdbcBOConverter;
import com.schisandra.oss.domain.bo.SchisandraOssJdbcBO;
import com.schisandra.oss.domain.service.SchisandraOssJdbcDomainService;
import com.schisandra.oss.infra.basic.entity.SchisandraOssJdbc;
import com.schisandra.oss.infra.basic.service.SchisandraOssJdbcService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * jdbc存储配置表 领域service实现了
 *
 * @author landaiqing
 * @since 2024-06-02 22:08:16
 */
@Service
@Slf4j
public class SchisandraOssJdbcDomainServiceImpl implements SchisandraOssJdbcDomainService {

    @Resource
    private SchisandraOssJdbcService schisandraOssJdbcService;

    @Override
    public Boolean add(SchisandraOssJdbcBO schisandraOssJdbcBO) {
        SchisandraOssJdbc schisandraOssJdbc = SchisandraOssJdbcBOConverter.INSTANCE.convertBOToEntity(schisandraOssJdbcBO);
        schisandraOssJdbc.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return schisandraOssJdbcService.insert(schisandraOssJdbc) > 0;
    }

    @Override
    public Boolean update(SchisandraOssJdbcBO schisandraOssJdbcBO) {
        SchisandraOssJdbc schisandraOssJdbc = SchisandraOssJdbcBOConverter.INSTANCE.convertBOToEntity(schisandraOssJdbcBO);
        return schisandraOssJdbcService.update(schisandraOssJdbc) > 0;
    }

    @Override
    public Boolean delete(SchisandraOssJdbcBO schisandraOssJdbcBO) {
        SchisandraOssJdbc schisandraOssJdbc = new SchisandraOssJdbc();
        schisandraOssJdbc.setId(schisandraOssJdbcBO.getId());
        schisandraOssJdbc.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return schisandraOssJdbcService.update(schisandraOssJdbc) > 0;
    }

}
