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


import com.schisandra.auth.common.enums.IsDeletedFlagEnum;
import com.schisandra.auth.domain.bo.SchisandraAuthSocialUserMapperBO;
import com.schisandra.auth.domain.convert.SchisandraAuthSocialUserMapperBOConverter;
import com.schisandra.auth.domain.service.SchisandraAuthSocialUserMapperDomainService;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthSocialUserMapper;
import com.schisandra.auth.infra.basic.service.SchisandraAuthSocialUserMapperService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 领域service实现了
 *
 * @author landaiqing
 * @since 2024-05-23 20:13:10
 */
@Service
@Slf4j
public class SchisandraAuthSocialUserMapperDomainServiceImpl implements SchisandraAuthSocialUserMapperDomainService {

    @Resource
    private SchisandraAuthSocialUserMapperService schisandraAuthSocialUserMapperService;

    @Override
    public Boolean add(SchisandraAuthSocialUserMapperBO schisandraAuthSocialUserMapperBO) {
        SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper = SchisandraAuthSocialUserMapperBOConverter.INSTANCE.convertBOToEntity(schisandraAuthSocialUserMapperBO);
        schisandraAuthSocialUserMapper.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return schisandraAuthSocialUserMapperService.insert(schisandraAuthSocialUserMapper) > 0;
    }

    @Override
    public Boolean update(SchisandraAuthSocialUserMapperBO schisandraAuthSocialUserMapperBO) {
        SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper = SchisandraAuthSocialUserMapperBOConverter.INSTANCE.convertBOToEntity(schisandraAuthSocialUserMapperBO);
        return schisandraAuthSocialUserMapperService.update(schisandraAuthSocialUserMapper) > 0;
    }

    @Override
    public Boolean delete(SchisandraAuthSocialUserMapperBO schisandraAuthSocialUserMapperBO) {
        SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper = new SchisandraAuthSocialUserMapper();
        schisandraAuthSocialUserMapper.setId(schisandraAuthSocialUserMapperBO.getId());
        schisandraAuthSocialUserMapper.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return schisandraAuthSocialUserMapperService.update(schisandraAuthSocialUserMapper) > 0;
    }
}
