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

import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
import com.schisandra.oss.domain.convert.SchisandraOssQiniuBOConverter;
import com.schisandra.oss.domain.bo.SchisandraOssQiniuBO;
import com.schisandra.oss.domain.service.SchisandraOssQiniuDomainService;
import com.schisandra.oss.infra.basic.entity.SchisandraOssQiniu;
import com.schisandra.oss.infra.basic.service.SchisandraOssQiniuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 七牛云对象存储配置表 领域service实现了
 *
 * @author landaiqing
 * @since 2024-06-02 22:25:11
 */
@Service
@Slf4j
public class SchisandraOssQiniuDomainServiceImpl implements SchisandraOssQiniuDomainService {

    @Resource
    private SchisandraOssQiniuService schisandraOssQiniuService;

    @Override
    public Boolean add(SchisandraOssQiniuBO schisandraOssQiniuBO) {
        SchisandraOssQiniu schisandraOssQiniu = SchisandraOssQiniuBOConverter.INSTANCE.convertBOToEntity(schisandraOssQiniuBO);
        schisandraOssQiniu.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return schisandraOssQiniuService.insert(schisandraOssQiniu) > 0;
    }

    @Override
    public Boolean update(SchisandraOssQiniuBO schisandraOssQiniuBO) {
        SchisandraOssQiniu schisandraOssQiniu = SchisandraOssQiniuBOConverter.INSTANCE.convertBOToEntity(schisandraOssQiniuBO);
        return schisandraOssQiniuService.update(schisandraOssQiniu) > 0;
    }

    @Override
    public Boolean delete(SchisandraOssQiniuBO schisandraOssQiniuBO) {
        SchisandraOssQiniu schisandraOssQiniu = new SchisandraOssQiniu();
        schisandraOssQiniu.setId(schisandraOssQiniuBO.getId());
        schisandraOssQiniu.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return schisandraOssQiniuService.update(schisandraOssQiniu) > 0;
    }

}
