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

import com.schisandra.auth.common.enums.IsDeletedFlagEnum;
import com.schisandra.auth.domain.bo.SchisandraAuthSocialUserBO;
import com.schisandra.auth.domain.convert.SchisandraAuthSocialUserBOConverter;
import com.schisandra.auth.domain.service.SchisandraAuthSocialUserDomainService;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthSocialUser;
import com.schisandra.auth.infra.basic.service.SchisandraAuthSocialUserService;
import lombok.extern.slf4j.Slf4j;
import me.zhyd.oauth.model.AuthToken;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 领域service实现了
 *
 * @author landaiqing
 * @since 2024-05-23 20:07:57
 */
@Service
@Slf4j
public class SchisandraAuthSocialUserDomainServiceImpl implements SchisandraAuthSocialUserDomainService {

    @Resource
    private SchisandraAuthSocialUserService schisandraAuthSocialUserService;

    @Override
    public Boolean add(SchisandraAuthSocialUserBO schisandraAuthSocialUserBO) {
        SchisandraAuthSocialUser schisandraAuthSocialUser = SchisandraAuthSocialUserBOConverter.INSTANCE.convertBOToEntity(schisandraAuthSocialUserBO);
        schisandraAuthSocialUser.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return schisandraAuthSocialUserService.insert(schisandraAuthSocialUser) > 0;
    }

    @Override
    public Boolean update(SchisandraAuthSocialUserBO schisandraAuthSocialUserBO) {
        SchisandraAuthSocialUser schisandraAuthSocialUser = SchisandraAuthSocialUserBOConverter.INSTANCE.convertBOToEntity(schisandraAuthSocialUserBO);
        return schisandraAuthSocialUserService.update(schisandraAuthSocialUser) > 0;
    }

    @Override
    public Boolean delete(SchisandraAuthSocialUserBO schisandraAuthSocialUserBO) {
        SchisandraAuthSocialUser schisandraAuthSocialUser = new SchisandraAuthSocialUser();
        schisandraAuthSocialUser.setId(schisandraAuthSocialUserBO.getId());
        schisandraAuthSocialUser.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return schisandraAuthSocialUserService.update(schisandraAuthSocialUser) > 0;
    }

}
