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

import com.schisandra.auth.common.enums.IsDeletedFlagEnum;
import com.schisandra.auth.domain.bo.SchisandraAuthUserRoleBO;
import com.schisandra.auth.domain.convert.SchisandraAuthUserRoleBOConverter;
import com.schisandra.auth.domain.service.SchisandraAuthUserRoleDomainService;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUserRole;
import com.schisandra.auth.infra.basic.service.SchisandraAuthUserRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 *  领域service实现了
 *
 * @author zlg
 * @since 2024-05-25 18:05:40
 */
@Service
@Slf4j
public class SchisandraAuthUserRoleDomainServiceImpl implements SchisandraAuthUserRoleDomainService {

    @Resource
    private SchisandraAuthUserRoleService schisandraAuthUserRoleService;

    @Override
    public Boolean add(SchisandraAuthUserRoleBO schisandraAuthUserRoleBO) {
        SchisandraAuthUserRole schisandraAuthUserRole = SchisandraAuthUserRoleBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserRoleBO);
        schisandraAuthUserRole.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return schisandraAuthUserRoleService.insert(schisandraAuthUserRole) > 0;
    }

    @Override
    public Boolean update(SchisandraAuthUserRoleBO schisandraAuthUserRoleBO) {
        SchisandraAuthUserRole schisandraAuthUserRole = SchisandraAuthUserRoleBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserRoleBO);
        return schisandraAuthUserRoleService.update(schisandraAuthUserRole) > 0;
    }

    @Override
    public Boolean delete(SchisandraAuthUserRoleBO schisandraAuthUserRoleBO) {
        SchisandraAuthUserRole schisandraAuthUserRole = new SchisandraAuthUserRole();
        schisandraAuthUserRole.setId(schisandraAuthUserRoleBO.getId());
        schisandraAuthUserRole.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return schisandraAuthUserRoleService.update(schisandraAuthUserRole) > 0;
    }

}
