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


import com.schisandra.auth.common.enums.IsDeletedFlagEnum;
import com.schisandra.auth.domain.bo.SchisandraAuthRolePermissionBO;
import com.schisandra.auth.domain.convert.SchisandraAuthRolePermissionBOConverter;
import com.schisandra.auth.domain.service.SchisandraAuthRolePermissionDomainService;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthRolePermission;
import com.schisandra.auth.infra.basic.service.SchisandraAuthRolePermissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 *  领域service实现了
 *
 * @author landaiqing
 * @since 2024-06-02 00:14:38
 */
@Service
@Slf4j
public class SchisandraAuthRolePermissionDomainServiceImpl implements SchisandraAuthRolePermissionDomainService {

    @Resource
    private SchisandraAuthRolePermissionService schisandraAuthRolePermissionService;

    @Override
    public Boolean add(SchisandraAuthRolePermissionBO schisandraAuthRolePermissionBO) {
        SchisandraAuthRolePermission schisandraAuthRolePermission = SchisandraAuthRolePermissionBOConverter.INSTANCE.convertBOToEntity(schisandraAuthRolePermissionBO);
        schisandraAuthRolePermission.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return schisandraAuthRolePermissionService.insert(schisandraAuthRolePermission) > 0;
    }

    @Override
    public Boolean update(SchisandraAuthRolePermissionBO schisandraAuthRolePermissionBO) {
        SchisandraAuthRolePermission schisandraAuthRolePermission = SchisandraAuthRolePermissionBOConverter.INSTANCE.convertBOToEntity(schisandraAuthRolePermissionBO);
        return schisandraAuthRolePermissionService.update(schisandraAuthRolePermission) > 0;
    }

    @Override
    public Boolean delete(SchisandraAuthRolePermissionBO schisandraAuthRolePermissionBO) {
        SchisandraAuthRolePermission schisandraAuthRolePermission = new SchisandraAuthRolePermission();
        schisandraAuthRolePermission.setId(schisandraAuthRolePermissionBO.getId());
        schisandraAuthRolePermission.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return schisandraAuthRolePermissionService.update(schisandraAuthRolePermission) > 0;
    }

}
