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

import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
import com.schisandra.oss.domain.convert.SchisandraOssJdbcDataBOConverter;
import com.schisandra.oss.domain.bo.SchisandraOssJdbcDataBO;
import com.schisandra.oss.domain.service.SchisandraOssJdbcDataDomainService;
import com.schisandra.oss.infra.basic.entity.SchisandraOssJdbcData;
import com.schisandra.oss.infra.basic.service.SchisandraOssJdbcDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * jdbc存储数据表 领域service实现了
 *
 * @author landaiqing
 * @since 2024-06-02 22:08:55
 */
@Service
@Slf4j
public class SchisandraOssJdbcDataDomainServiceImpl implements SchisandraOssJdbcDataDomainService {

    @Resource
    private SchisandraOssJdbcDataService schisandraOssJdbcDataService;

    @Override
    public Boolean add(SchisandraOssJdbcDataBO schisandraOssJdbcDataBO) {
        SchisandraOssJdbcData schisandraOssJdbcData = SchisandraOssJdbcDataBOConverter.INSTANCE.convertBOToEntity(schisandraOssJdbcDataBO);
        schisandraOssJdbcData.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return schisandraOssJdbcDataService.insert(schisandraOssJdbcData) > 0;
    }

    @Override
    public Boolean update(SchisandraOssJdbcDataBO schisandraOssJdbcDataBO) {
        SchisandraOssJdbcData schisandraOssJdbcData = SchisandraOssJdbcDataBOConverter.INSTANCE.convertBOToEntity(schisandraOssJdbcDataBO);
        return schisandraOssJdbcDataService.update(schisandraOssJdbcData) > 0;
    }

    @Override
    public Boolean delete(SchisandraOssJdbcDataBO schisandraOssJdbcDataBO) {
        SchisandraOssJdbcData schisandraOssJdbcData = new SchisandraOssJdbcData();
        schisandraOssJdbcData.setId(schisandraOssJdbcDataBO.getId());
        schisandraOssJdbcData.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return schisandraOssJdbcDataService.update(schisandraOssJdbcData) > 0;
    }

}
