package cn.fateverse.admin.facade;

import cn.fateverse.admin.convert.RoleConvert;
import cn.fateverse.admin.query.RoleQuery;
import cn.fateverse.admin.service.RoleService;
import cn.fateverse.admin.service.UserRoleService;
import cn.fateverse.admin.vo.RoleVo;
import cn.fateverse.common.core.entity.Option;
import cn.fateverse.common.core.entity.Role;
import cn.fateverse.common.core.result.page.TableDataInfo;
import cn.fateverse.common.mybatisplus.utils.PageConditionUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
@RequiredArgsConstructor
public class RoleFacade {

    private final RoleService roleService;
    private final UserRoleService userRoleService;

    /**
     * 搜索选项
     *
     * @return {@link List }<{@link Option }>
     */
    public List<Option> searchOption() {
        List<Role> list = roleService.list();
        return null;
    }

    /**
     * 搜索列表
     *
     * @param query 查询
     * @return {@link TableDataInfo }<{@link RoleVo }>
     */
    public TableDataInfo<RoleVo> searchList(RoleQuery query) {
        IPage<Role> page = roleService.searchList(query);
        return PageConditionUtil.convertDataTable(page, RoleConvert.INSTANCE::entityToVo);
    }

    /**
     * 按id查询
     *
     * @param roleId 角色id
     * @return {@link RoleVo }
     */
    public RoleVo searchById(Long roleId) {
        Role role = roleService.getById(roleId);
        return RoleConvert.INSTANCE.entityToVo(role);
    }

    /**
     * 搜索列表排除菜单id
     *
     * @param menuId   菜单id
     * @param roleName 角色名
     * @param roleKey  关键角色
     * @return {@link TableDataInfo }<{@link RoleVo }>
     */
    public TableDataInfo<RoleVo> searchListExcludeMenuId(Long menuId, String roleName, String roleKey) {
        return null;
    }
}
