package cn.reghao.devops.web.util;

import cn.reghao.devops.web.admin.account.model.constant.RoleType;
import cn.reghao.devops.web.admin.account.service.UserContext;
import cn.reghao.devops.web.mgr.app.model.constant.AppType;
import cn.reghao.devops.web.mgr.build.model.constant.EnvType;

import java.util.Set;

/**
 * @author reghao
 * @date 2023-12-01 11:29:21
 */
public class DefaultSetting {
    public static String getDefaultEnv() {
        /*Set<String> roles = UserContext.getUserRoles();
        if (roles.contains(RoleType.ROLE_DEVOPS.name())) {
            return EnvType.test.name();
        } else if (roles.contains(RoleType.ROLE_BACKEND.name())
                || roles.contains(RoleType.ROLE_FRONTEND.name())) {
            return EnvType.test.name();
        }*/
        return EnvType.test.name();
    }

    public static String getDefaultAppType() {
        String defaultAppType = AppType.java.getName();
        Set<String> roles = UserContext.getUserRoles();
        if (roles.contains(RoleType.ROLE_JAVA.name())) {
            defaultAppType = AppType.java.getName();
        } else if (roles.contains(RoleType.ROLE_DOTNET.name())) {
            defaultAppType = AppType.dotnet.getName();
        } else if (roles.contains(RoleType.ROLE_NPM.name())) {
            defaultAppType = AppType.npm.getName();
        }

        return defaultAppType;
    }
}
