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

import com.schisandra.auth.domain.bo.SchisandraAuthRoleBO;
import com.schisandra.auth.domain.convert.SchisandraAuthRoleBOConverter;
import com.schisandra.auth.domain.service.SchisandraAuthRoleDomainService;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthRole;
import com.schisandra.auth.infra.basic.service.SchisandraAuthRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * ClassName:SchisandraAuthRoleDomainServiceImpl
 * Package:com.schisandra.auth.domain.service.impl
 * Description:角色信息的增删改查
 *
 * @Author:
 * @Create:2024/4/4 - 21:05
 * @Version: v1.0
 */
@Service
@Slf4j
public class SchisandraAuthRoleDomainServiceImpl implements SchisandraAuthRoleDomainService {
    @Resource
    private SchisandraAuthRoleService schisandraAuthRoleService;

    @Override
    public Object update(SchisandraAuthRoleBO schisandraAuthRoleBO) {
        SchisandraAuthRole schisandraAuthRole = SchisandraAuthRoleBOConverter.INSTANCE.convertBOToEntity(schisandraAuthRoleBO);
        SchisandraAuthRole update = schisandraAuthRoleService.update(schisandraAuthRole);
        return update;
    }

    @Override
    public Object delete(Long id) {
        boolean isDeleted = schisandraAuthRoleService.deleteById(id);
        return isDeleted;
    }

    @Override
    public int insert(SchisandraAuthRoleBO schisandraAuthRoleBO) {
        SchisandraAuthRole schisandraAuthRole = SchisandraAuthRoleBOConverter.INSTANCE.convertBOToEntity(schisandraAuthRoleBO);
        return schisandraAuthRoleService.insert(schisandraAuthRole);
    }

    @Override
    public Object select(SchisandraAuthRoleBO schisandraAuthRoleBO) {
        SchisandraAuthRole schisandraAuthRole = SchisandraAuthRoleBOConverter.INSTANCE.convertBOToEntity(schisandraAuthRoleBO);
        if (schisandraAuthRoleBO.getId() != null) {
            SchisandraAuthRole schisandraAuthRole1 = schisandraAuthRoleService.queryById(schisandraAuthRoleBO.getId());
            return schisandraAuthRole1;
        }
        return null;
    }
}
