package jnpf.authority.service.impl;

import jnpf.authority.service.FtbPermissionGradesService;
import jnpf.enums.PermissionSourceCategoryEnum;
import jnpf.permission.V2GradesApi;
import jnpf.permission.dto.v2.AuthUserNodeDTO;
import jnpf.permission.vo.v2.TargetAuthIdsVO;
import jnpf.permission.vo.v2.grades.GradeNodeVO;
import jnpf.util.UserProvider;
import jnpf.util.auth.V2AuthPermissionUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 带权限的职级管理
 *
 * @author Flynn Chan
 * @create 2025-05-07
 */
@Service
@Slf4j
public class FtbPermissionGradesServiceImpl implements FtbPermissionGradesService {
    @Resource
    private V2GradesApi gradesApi;
    @Resource
    private V2AuthPermissionUtils authPermissionUtils;

    @Override
    public List<GradeNodeVO> gradeTree() {
        TargetAuthIdsVO authIdsVO = authPermissionUtils.processAuthIds();
        AuthUserNodeDTO dto = new AuthUserNodeDTO(authIdsVO, UserProvider.getUser().getTenantId());
        dto.setHavaAuth(authIdsVO != null);
        return gradesApi.gradeTree(dto).getData();
    }
}
