dangsn
2024-12-26 4e9ff2ce6a830bb2340d7c8612c72eea0c5a553e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/**
 * 
 */
package com.vci.client.framework.util;
 
import java.awt.Container;
 
 
/**
 * <p>Title: 传递操作</p>
 * @author wangxl
 *
 */
public class PermissionUtil {
    public enum PermissionType{ Object, Rule }
    /**
     * 对象模块的功能
     * @author wangxl
     *
     */
    public enum ObjectFunction{
        /**
         * 查询
         */
        Query, 
        /**
         * 创建
         */
        Create, 
        /**
         * 删除
         */
        Delete, 
        /**
         * 更新
         */
        Update, 
        /**
         * 复制
         */
        Copy, 
        /**
         * 更改所有权
         */
        ChangeOwnership, 
        /**
         * 导入
         */
        Import, 
        /**
         * 导出
         */
        Export
    }
    
    /**
     * 规则的功能
     * @author wangxl
     *
     */
    public enum RuleFunction{
        /**
         * 申请
         */
        Apply, 
        /**
         * 审核
         */
        Audit, 
        /**
         * 解析
         */
        Parse, 
        /**
         * 查询
         */
        Query, 
        /**
         * 导入
         */
        Import, 
        /**
         * 导出
         */
        Export, 
        /**
         * 冻结
         */
        Freeze, 
        /**
         * 解冻
         */
        UnFreeze, 
        /**
         * 报废
         */
        Scrap, 
        /**
         * 回收
         */
        Retrieve, 
        /**
         * 码值修改
         */
        CodeValModify
    }
    
    
    /**
     * <p>Description: 对象权限</p>
     * @param moduleId 模块id
     * @param function 检查的功能
     * @param button 功能代表的控件对象
     */
    public static boolean checkObjectPermission(String moduleId, ObjectFunction function){
//        UserEntityObject userEntity = CodeClientApplication.getUserEntityObject();
//        boolean enable = checkObjectPermission(userEntity, moduleId, function);
        return true;
    }
//    /**
//     * �������Ȩ��
//     * @param moduleId ģ��ID
//     * @param function ���Ĺ���
//     * @param button ���ܴ��Ŀؼ�����
//     */
    public static boolean checkObjectPermission(String moduleId, ObjectFunction function, Container button){
//        UserEntityObject userEntity = CodeClientApplication.getUserEntityObject();
//        boolean enable = checkObjectPermission(userEntity, moduleId, function);
//        button.setEnabled(enable);
        return true;
    }
//    
//    /**
//     * ������Ȩ��
//     * @param userEntity �û�
//     * @param moduleId ģ��ID
//     * @param function ģ�鹦��
//     * @return
//     */
//    public static boolean checkObjectPermission(UserEntityObject userEntity, String moduleId, ObjectFunction function){
//        boolean res = false;
//        UserEntityInfo info = UserEntityClientDelegate.changeUserEntityToInfo(userEntity);
//        int functionIndex = getObjectFunctionIndex(function);
//        String type = "OBJ";
//        try {
//            res = Code2ClientSession._code2.checkPermission(info, type, moduleId, functionIndex);
//        } catch (VCIError e) {
//            // TODO Auto-generated catch block
//            e.printStackTrace();
//        }
//        return res;
//    }
//    
    /**
     * ������Ȩ��
     * @param ruleId ����ID
     * @param function ����
     * @return
     */
    public static boolean checkRulePermission(String ruleId, RuleFunction function, Container button){
        boolean enable = checkRulePermission(ruleId, function);
        button.setEnabled(enable);
        return enable;
    }
    
    /**
     * ������Ȩ��
     * @param ruleId ����ID
     * @param function ����
     * @return
     */
    public static boolean checkRulePermission(String ruleId, RuleFunction function){
//        boolean res = false;
//        UserEntityObject userEntity = CodeClientApplication.frame.getUserEntityObject();
//        UserEntityInfo info = UserEntityClientDelegate.changeUserEntityToInfo(userEntity);
//        int functionIndex = getRuleFunctionIndex(function);
//        String type = "RULE";
//        try {
//            res = Code2ClientSession._code2.checkPermission(info, type, ruleId, functionIndex);
//        } catch (VCIError e) {
//            // TODO Auto-generated catch block
//            e.printStackTrace();
//        }
        return true;
    }
    
    
    
    private static int getObjectFunctionIndex(ObjectFunction function){
        int index = 1;
        if(function == ObjectFunction.Query){ index = 1;}
        else if(function == ObjectFunction.Create){ index = 2;}
        else if(function == ObjectFunction.Delete){ index = 3;}
        else if(function == ObjectFunction.Update){ index = 4;}
        else if(function == ObjectFunction.Copy){ index = 5;}
        else if(function == ObjectFunction.ChangeOwnership){ index = 6;}
        else if(function == ObjectFunction.Import){ index = 7;}
        else if(function == ObjectFunction.Export){ index = 8;}
        return index;
    }
    
    private static int getRuleFunctionIndex(RuleFunction function){
        int index = 1;
        if(function == RuleFunction.Apply){ index = 1;}
        else if(function == RuleFunction.Audit){ index = 2;}
        else if(function == RuleFunction.Parse){ index = 3;}
        else if(function == RuleFunction.Query){ index = 4;}
        else if(function == RuleFunction.Import){ index = 5;}
        else if(function == RuleFunction.Export){ index = 6;}
        else if(function == RuleFunction.Freeze){ index = 7;}
        else if(function == RuleFunction.UnFreeze){ index = 8;}
        else if(function == RuleFunction.Scrap){ index = 9;}
        else if(function == RuleFunction.Retrieve){ index = 10;}
        else if(function == RuleFunction.CodeValModify){ index = 11;}
        return index;
    }
}