package com.maintain.common.helper;

import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.jmreport.api.JmReportTokenServiceI;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * 自定义积木报表鉴权(如果不进行自定义，则所有请求不做权限控制)
 *  * 1.自定义获取登录token
 *  * 2.自定义获取登录用户
 * @author: jeecg-boot
 */


@Slf4j
@Component
public class JimuReportTokenService implements JmReportTokenServiceI {


    @Override
    public String getUsername(String s) {
        return "";
    }

    /**
     * 自定义获取TOKEN
     * @param request
     * @return
     */
    @Override
    public String getToken(HttpServletRequest request) {
        //System.out.println("---------call---------getToken-----------------------");
        return "token令牌";
    }
    /**
     * Token校验
     * @param token
     * @return
     */
    @Override
    public Boolean verifyToken(String token) {
        //System.out.println("---------verify-----Token---------------");
        return true;
    }

    /**
     * 自定义用户拥有的角色
     *
     * @param token
     * @return
     */
    @Override
    public String[] getRoles(String token) {
        return new String[]{"admin","lowdeveloper","dbadeveloper"};
    }

    /**
     * 自定义用户拥有的权限指令
     *
     * @param token
     * @return
     */
    @Override
    public String[] getPermissions(String token) {
        return new String[]{"drag:datasource:testConnection","onl:drag:clear:recovery","drag:analysis:sql","drag:design:getTotalData"};
    }
}
