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

import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
import com.schisandra.oss.domain.convert.SchisandraOssPinganBOConverter;
import com.schisandra.oss.domain.bo.SchisandraOssPinganBO;
import com.schisandra.oss.domain.service.SchisandraOssPinganDomainService;
import com.schisandra.oss.infra.basic.entity.SchisandraOssPingan;
import com.schisandra.oss.infra.basic.service.SchisandraOssPinganService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 平安云对象存储配置表 领域service实现了
 *
 * @author landaiqing
 * @since 2024-06-02 22:19:22
 */
@Service
@Slf4j
public class SchisandraOssPinganDomainServiceImpl implements SchisandraOssPinganDomainService {

    @Resource
    private SchisandraOssPinganService schisandraOssPinganService;

    @Override
    public Boolean add(SchisandraOssPinganBO schisandraOssPinganBO) {
        SchisandraOssPingan schisandraOssPingan = SchisandraOssPinganBOConverter.INSTANCE.convertBOToEntity(schisandraOssPinganBO);
        schisandraOssPingan.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return schisandraOssPinganService.insert(schisandraOssPingan) > 0;
    }

    @Override
    public Boolean update(SchisandraOssPinganBO schisandraOssPinganBO) {
        SchisandraOssPingan schisandraOssPingan = SchisandraOssPinganBOConverter.INSTANCE.convertBOToEntity(schisandraOssPinganBO);
        return schisandraOssPinganService.update(schisandraOssPingan) > 0;
    }

    @Override
    public Boolean delete(SchisandraOssPinganBO schisandraOssPinganBO) {
        SchisandraOssPingan schisandraOssPingan = new SchisandraOssPingan();
        schisandraOssPingan.setId(schisandraOssPinganBO.getId());
        schisandraOssPingan.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return schisandraOssPinganService.update(schisandraOssPingan) > 0;
    }

}
