LimitUtils

权限判断表

/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.iallchain.beasts.utils; import java.util.Arrays; import java.util.List; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. *//** * @author RulerBug */ public class LimitUtils {private static String splitString = "\\*"; private static int t0000 = 0; private static int t1000 = 8; private static int t0100 = 4; private static int t0010 = 2; private static int t0001 = 1; private static int tOnlyAdd = t1000; private static int tOnlyDel = t0100; private static int tOnlyUpdate = t0010; private static int tOnlySearch = t0001; private static int tOnlyNone = t0000; public static List xm_datatables = Arrays.asList(new String[]{ "xm_farmer", "xm_artel", "xm_pasture", "xm_animal", "xm_veterinary_drug", "xm_feed", "xm_vaccine", "xm_change_ear_tag", "xm_harmless_deal", "xm_such", "xm_organic_authentication", "sy_butcher_info", "sy_packing_info", "sy_transfer_info"}); public static List datatables = Arrays.asList(new String[]{"sy_butcher_info", "sy_packing_info", "sy_transfer_info"}); /* *需要确定权限的表 * */ public static enum TABLES {XM_FARMER(0), XM_ARTEL(1), XM_PASTURE(2), XM_ANIMAL(3), XM_VETERINARY_DRUG(4), XM_FEED(5), XM_VACCINE(6), XM_CHANGE_EAR_TAG(7), XM_HARMLESS_DEAL(8), XM_SUCH(9), XM_ORGANIC_AUTHENTICATION(10), SY_BUTCHER_INFO(11), SY_PACKING_INFO(12), SY_TRANSFER_INFO(13); private int index; private TABLES(int index) { this.index = index; }public int getIndex() { return index; } }protected static int error = -1; public static boolean isHaveAdd(int index, String msg) { if (index == error) { return false; } final String[] split = msg.split(splitString); String limitALL = split[index]; int AddLimit = tOnlyAdd & Integer.parseInt(limitALL); return AddLimit == tOnlyAdd; }public static boolean isHavedEL(int index, String msg) { if (index == error) { return false; } final String[] split = msg.split(splitString); String limitALL = split[index]; int DelLimit = tOnlyDel & Integer.parseInt(limitALL); return DelLimit == tOnlyDel; }public static boolean isHaveUpdate(int index, String msg) { if (index == error) { return false; } final String[] split = msg.split(splitString); String limitALL = split[index]; int UpdateLimit = tOnlyUpdate & Integer.parseInt(limitALL); return UpdateLimit == tOnlyUpdate; }public static boolean isHaveSearch(int index, String msg) { if (index == error) { return false; } final String[] split = msg.split(splitString); String limitALL = split[index]; int SearchLimit = tOnlySearch & Integer.parseInt(limitALL); return SearchLimit == tOnlySearch; }protected static int getTablesIndex(String tableName) { for (String nameString : xm_datatables) { if (nameString.equals(tableName)) { return xm_datatables.indexOf(nameString); } } return error; }protected static int getTablesIndex(TABLES table) { return table.getIndex(); }public static boolean isHaveAdd(String table, String msg) { return isHaveAdd(getTablesIndex(table), msg); }public static boolean isHaveAdd(TABLES table, String msg) { return isHaveAdd(getTablesIndex(table), msg); }public static boolean isHavedEL(String table, String msg) { return isHavedEL(getTablesIndex(table), msg); }public static boolean isHavedEL(TABLES table, String msg) { return isHavedEL(getTablesIndex(table), msg); }public static boolean isHaveUpdate(String table, String msg) { return isHaveUpdate(getTablesIndex(table), msg); }public static boolean isHaveUpdate(TABLES table, String msg) { return isHaveUpdate(getTablesIndex(table), msg); }public static boolean isHaveSearch(String table, String msg) { return isHaveSearch(getTablesIndex(table), msg); }public static boolean isHaveSearch(TABLES table, String msg) { return isHaveSearch(getTablesIndex(table), msg); }public static boolean inBigRank(Long rank) { return rank <= CommTeys.BigRank; }public static boolean inSupperBigRank(Long rank) { return rank <= CommTeys.SupperBigRank; } }

【LimitUtils】

    推荐阅读