Skip to content

Commit c679ffd

Browse files
committed
Server:新增访问权限表Access
1 parent 13b3e0a commit c679ffd

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

APIJSON-Java-Server/APIJSONDemo/src/main/java/apijson/demo/server/DemoFunction.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,16 @@ public double doubleValue(@NotNull JSONObject request, String value) {
539539
}
540540
//获取非基本类型对应基本类型的非空值 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
541541

542+
/**获取value,当value为null时获取defaultValue
543+
* @param request
544+
* @param value
545+
* @param defaultValue
546+
* @return v == null ? request.get(defaultValue) : v
547+
*/
548+
public Object getWithDefault(@NotNull JSONObject request, String value, String defaultValue) {
549+
Object v = request.get(value);
550+
return v == null ? request.get(defaultValue) : v;
551+
}
542552

543553

544554

APIJSON-Java-Server/APIJSONLibrary/src/main/java/zuo/biao/apijson/server/AbstractVerifier.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import zuo.biao.apijson.StringUtil;
4343
import zuo.biao.apijson.server.exception.ConflictException;
4444
import zuo.biao.apijson.server.exception.NotLoggedInException;
45+
import zuo.biao.apijson.server.model.Access;
4546
import zuo.biao.apijson.server.model.Column;
4647
import zuo.biao.apijson.server.model.Document;
4748
import zuo.biao.apijson.server.model.Function;
@@ -72,6 +73,7 @@ public abstract class AbstractVerifier implements Verifier {
7273
ACCESS_MAP.put(Document.class.getSimpleName(), getAccessMap(Document.class.getAnnotation(MethodAccess.class)));
7374
ACCESS_MAP.put(TestRecord.class.getSimpleName(), getAccessMap(TestRecord.class.getAnnotation(MethodAccess.class)));
7475
ACCESS_MAP.put(Function.class.getSimpleName(), getAccessMap(Function.class.getAnnotation(MethodAccess.class)));
76+
ACCESS_MAP.put(Access.class.getSimpleName(), getAccessMap(Access.class.getAnnotation(MethodAccess.class)));
7577
}
7678

7779
/**获取权限Map,每种操作都只允许对应的角色
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.*/
14+
15+
package zuo.biao.apijson.server.model;
16+
17+
import zuo.biao.apijson.MethodAccess;
18+
19+
/**访问权限
20+
* @author Lemon
21+
*/
22+
@MethodAccess(POST = {}, PUT = {}, DELETE = {})
23+
public class Access {
24+
}

0 commit comments

Comments
 (0)