com.mmj.app.common.authority.Right.java Source code

Java tutorial

Introduction

Here is the source code for com.mmj.app.common.authority.Right.java

Source

/*
 * Copyright 2011-2016 MSUN.com All right reserved. This software is the confidential and proprietary information of
 * MSUN.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only
 * in accordance with the terms of the license agreement you entered into with MSUN.com.
 */
package com.mmj.app.common.authority;

import org.apache.commons.lang.StringUtils;

/**
 * @author zxc Jul 14, 2014 10:49:12 PM
 */
public enum Right {

    // *******************??***************//
    //
    SHOW_ORDER_MENU("showOrderMenu", "??", 0),
    //
    VIEW_ORDER("viewOrder", "?", 1),
    //
    CANCEL_ORDER("cancelOrder", "??", 2),
    //
    MODIFY_ORDER("modifyOrder", "?", 3),

    // *******************??***************//
    //
    SHOW_PRODUCT_MENU("showProductMenu", "??", 10),
    //
    CREATE_PRODUCT("createProduct", "?", 11),
    //
    MODIFY_PRODUCT("modifyProduct", "?", 12),
    //
    REMOVE_PRODUCT("removeProduct", "?", 13),
    //
    SAVE_PRODUCT("saveProduct", "??", 14),
    //
    CREATE_LINE_TEMPLATE("createLineTemplate", "", 15),
    //
    MODIFY_LINE_TEMPLATE("modifyLineTemplate", "", 16),
    //
    COPY_LINE_TEMPLATE("copyLineTemplate", "?", 17),
    //
    DELETE_LINE_TEMPLATE("deleteLineTemplate", "", 18),
    //
    CREATE_TRAFFIC_TEMPLATE("createTrafficTemplate", "", 19),
    //
    MODIFY_TRAFFIC_TEMPLATE("modiftTrafficTemplate", "", 20),
    //
    DELETE_TRAFFIC_TEMPLATE("deleteTrafficTemplate", "", 21),
    //
    UPLOAD_PHOTOS("uploadPhotos", "", 22),
    //
    MODIFY_PHOTOS("modiftPhotos", "", 23),
    //
    DELETE_PHOTOS("deletePhotos", "", 24),

    // *******************?***************//
    //
    SHOW_COMPANY_MENU("showCompanyMenu", "??", 30),
    //
    COMPANY_NEWS("companyNews", "?", 31),
    //
    COMPANY_INFO("companyInfo", "??", 32),
    //
    USER_MANAGE("userMange", "?", 33),
    //
    ONLINE_SERVICE("onlineService", "?", 34)

    ;

    private String desc;
    private String name;
    private int index;

    private Right(String desc, String name, int index) {
        this.desc = desc;
        this.name = name;
        this.index = index;
    }

    public static Right getAction(int index) {
        for (Right type : values()) {
            if (index == type.getIndex())
                return type;
        }
        return null;
    }

    public static Right getAction(String desc) {
        if (StringUtils.isEmpty(desc)) {
            return null;
        }
        for (Right type : values()) {
            if (StringUtils.equals(desc, type.getDesc()))
                return type;
        }
        return null;
    }

    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }
}