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

import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
import com.schisandra.oss.domain.convert.SchisandraOssJdbcStoreBOConverter;
import com.schisandra.oss.domain.bo.SchisandraOssJdbcStoreBO;
import com.schisandra.oss.domain.service.SchisandraOssJdbcStoreDomainService;
import com.schisandra.oss.infra.basic.entity.SchisandraOssJdbcStore;
import com.schisandra.oss.infra.basic.service.SchisandraOssJdbcStoreService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * jdbc存储信息表 领域service实现了
 *
 * @author landaiqing
 * @since 2024-06-02 22:11:22
 */
@Service
@Slf4j
public class SchisandraOssJdbcStoreDomainServiceImpl implements SchisandraOssJdbcStoreDomainService {

    @Resource
    private SchisandraOssJdbcStoreService schisandraOssJdbcStoreService;

    @Override
    public Boolean add(SchisandraOssJdbcStoreBO schisandraOssJdbcStoreBO) {
        SchisandraOssJdbcStore schisandraOssJdbcStore = SchisandraOssJdbcStoreBOConverter.INSTANCE.convertBOToEntity(schisandraOssJdbcStoreBO);
        schisandraOssJdbcStore.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return schisandraOssJdbcStoreService.insert(schisandraOssJdbcStore) > 0;
    }

    @Override
    public Boolean update(SchisandraOssJdbcStoreBO schisandraOssJdbcStoreBO) {
        SchisandraOssJdbcStore schisandraOssJdbcStore = SchisandraOssJdbcStoreBOConverter.INSTANCE.convertBOToEntity(schisandraOssJdbcStoreBO);
        return schisandraOssJdbcStoreService.update(schisandraOssJdbcStore) > 0;
    }

    @Override
    public Boolean delete(SchisandraOssJdbcStoreBO schisandraOssJdbcStoreBO) {
        SchisandraOssJdbcStore schisandraOssJdbcStore = new SchisandraOssJdbcStore();
        schisandraOssJdbcStore.setId(schisandraOssJdbcStoreBO.getId());
        schisandraOssJdbcStore.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return schisandraOssJdbcStoreService.update(schisandraOssJdbcStore) > 0;
    }

}
