UserOperateEnum.java 6.44 KB
package com.ui.User;

import org.apache.commons.lang.StringUtils;

/**
 * Created by  craig.qin
 * 用户操作uri
 */
public enum UserOperateEnum {

    //user服务相关
    manage_saveUser("/manage/saveUser","用户新增/更新",false),
    manage_deleteUser("/manage/deleteUser","用户删除",false),

    /************************  主机管理 ************************/
    hostInfoList_saveHostInfo("/hostInfoList/saveHostInfo","保存主机",true),
    hostInfoList_delHostInfo("/hostInfoList/delHostInfo","删除主机",true),
    hostInfoList_synHostInfo("/hostInfoList/synHostInfo","同步主机",true),
    hostInfoList_saveHostTags("/hostInfoList/saveHostTags","主机标签",true),



    /************************  dns切换接口调用  ************************/
    outer_dnsJustForShellUpdate("/outer/dnsJustForShellUpdate","yohoops.orgDNS更新",true),
    outer_dnsJustForShellCommit("/outer/dnsJustForShellCommit","yohoops.orgDNS提交",true),
    outer_dnsJustForShell("/outer/dnsJustForShell","DNS更新/提交",true),

    /************************  关键切换  ************************/
    //java重启
    javaRestart_stopOrRestart("/javaRestart/stopOrRestart","java重启/停止",true),
    //node重启
    nodeBuild_build("/nodeBuild/build","node发布/云重启/删除路径重启",true),
    //双中心切换_新
    centerSwitch_doExeAndCheck("/centerSwitch/doExeAndCheck","双中心切换",true),
    //NGINX切换-lua切换
    luaswitch_viewToChangeLuaConf("/luaswitch/viewToChangeLuaConf","NGINX切换-lua切换",true),
    luaswitch_switchConf("/luaswitch/switchConf","NGINX切换-lua切换执行",true),
    //NGINX切换-dns切换
    luaswitch_dnsSwitchConf("/luaswitch/dnsSwitchConf","NGINX切换-直连切换",true),
    //NGINX切换-nginx
    nginxswitch_viewToChangeNginxConf("/nginxswitch/viewToChangeNginxConf","NGINX切换预览",true),
    nginxswitch_switchNginxConf("/nginxswitch/switchNginxConf","NGINX切换",true),
    //搜索流量切换    dns发布
    internalDns_updateNameForSearch("/internalDns/updateNameForSearch","搜索流量切换",true),
    internalDns_refresh("/internalDns/refresh","dns域名服务器刷新",true),
    internalDns_save("/internalDns/save","dns域名新增/更新",true),
    internalDns_deleteById("/internalDns/deleteById","dns域名删除",true),
    //线下店nginx切换
    storeSwitch_viewStoreNginxToChangeConf("/storeSwitch/viewStoreNginxToChangeConf","线下店NGINX切换预览",true),
    storeSwitch_switchStoreNginx("/storeSwitch/switchStoreNginx","线下店NGINX切换",true),
    //pch5切换
    pch5Switch_switchArea("/pch5Switch/switchArea","pch5可用区切换",true),
    pch5Switch_switchAz2("/pch5Switch/switchAz2","pch5-az2区域灰度与线上切换",true),

    /************************  管理员 ************************/
    //redis缓存清理
    redisClear_clear("/redisClear/clear","redis缓存清理",true),
    //告警开发
    OpsSmsOnOff_switchAlarm("/OpsSmsOnOff/switchAlarm","告警开关",true),
    //伸缩组
    autoScalingTool_modifyScalingGroup("/autoScalingTool/modifyScalingGroup","伸缩组-伸缩",true),
    autoScalingTool_stopNoneProtectedJavaProcess("/autoScalingTool/stopNoneProtectedJavaProcess","伸缩组-停止非保护java机器",true),
    autoScalingTool_deployCloudProject("/autoScalingTool/deployCloudProject","伸缩组-发布java",true),
    autoScalingTool_deployCloudProjectForNode("/autoScalingTool/deployCloudProjectForNode","伸缩组-发布node",true),
    autoScalingTool_updateIpToGit("/autoScalingTool/updateIpToGit","伸缩组-更新iptable",true),
    autoScalingTool_updateEsConfig("/autoScalingTool/updateEsConfig","伸缩组-更新es配置",true),
    autoScalingTool_updateGatewayUpstream("/autoScalingTool/updateGatewayUpstream","伸缩组-gateway项目更新upstream",true),
    autoScalingTool_updateAnsibleDeployForNode("/autoScalingTool/updateAnsibleDeployForNode","伸缩组-node项目更新ansible",true),
    autoScalingTool_updateToHost("/autoScalingTool/updateToHost","伸缩组-更新主机到cmdb",true),
    autoScalingTool_updateMemcacheInfoForInternalDomain("/autoScalingTool/updateMemcacheInfoForInternalDomain","伸缩组-memcache更新内部dns",true),
    autoScalingTool_updateMobjectInfo("/autoScalingTool/updateMobjectInfo","伸缩组-更新监控对象",true),
    autoScalingTool_updateNginxConfig("/autoScalingTool/updateNginxConfig","伸缩组-nginx类型伸缩后执行脚本",true),

    /************************  项目发布 ************************/
    //java发布
    project_build("/project/build","java发布",true),
    project_buildProjectWithIPs("/project/buildProjectWithIPs","java发布-指定ip",true),

    project_deregisterHostYohoSearchService("/project/deregisterHostYohoSearchService","java发布-lb卸载",true),
    project_registerHostYohoSearchService("/project/registerHostYohoSearchService","java发布-lb挂载",true),
    //node发布 (已经配置,参见关键切换-node重启)

    //dns发布 (已经配置,参见关键切换-搜索流量切换)

    //php发布
    phpBuild_build("/phpBuild/build","php发布",true),

    //docker发布
    dockerBuild_mirrorAndDeploy("/dockerBuild/mirrorAndDeploy","docker发布",true),
    dockerBuild_rollback("/dockerBuild/rollback","docker回滚",true),
    outer_gitWebHook("/outer/gitWebHook","docker自动发布",true),
    outer_updateJenkinsStatus("/outer/updateJenkinsStatus","docker工单发布更新Jenkins",true),

    //java按天回滚
    project_doRollbackByTime("/project/doRollbackByTime","java按天回滚",true)
    ;

    private String uri;
    private String desc;
    private boolean aspectFlag;

    UserOperateEnum(String uri, String desc,boolean aspectFlag){
        this.uri = uri;
        this.desc = desc;
        this.aspectFlag=aspectFlag;
    }

    /**
     * 根据uri获取具有拦截标识的操作对象
     * @param uri
     * @return
     */
    public static UserOperateEnum getAspectByUri(String uri){
        if(StringUtils.isBlank(uri)){
            return null;
        }
        UserOperateEnum[] allOperate = UserOperateEnum.values();
        for(UserOperateEnum oper:allOperate){
            if(oper.aspectFlag&&oper.uri.equals(uri)){
                return oper;
            }
        }
        return null;
    }

    /**
     * 获取操作的描述信息
     * @param operate
     * @return
     */
    public  String getDesc(UserOperateEnum operate){
        if(operate==null){
            return "";
        }
        return operate.desc;
    }
}