WangHan
2025-04-03 a1b85ef72062ca80db35546e4216dd564f3e0f57
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
//package com.iplatform.base;
//
//import com.fasterxml.jackson.databind.JsonNode;
//import com.fasterxml.jackson.databind.node.ObjectNode;
//import com.iplatform.base.pojo.form.FormDataItem;
//import com.iplatform.base.util.MenuUtils;
//import com.iplatform.base.util.NotificationUtils;
//import com.iplatform.model.po.S_user_core;
//import com.walker.infrastructure.utils.GenericTypeUtils;
//import com.walker.infrastructure.utils.JsonUtils;
//import com.walker.infrastructure.utils.PhoneNumberUtils;
//import org.springframework.core.ResolvableType;
//
//import java.util.ArrayList;
//import java.util.Iterator;
//import java.util.List;
//
//public class TestMenu {
//
//    private List<String> typeList1 = new ArrayList<String>();
//
////    @Test
//    public void testPhoneNumber(){
//        String input = "1001";
//        boolean value = PhoneNumberUtils.isCellPhoneNumber(input);
//        System.out.println(value + ", " + input);
//    }
//
////    @Test
//    public void testFasterxml() throws Exception{
////        String json = "[\\\"23:53\\\",\\\"23:59\\\"]";
//        String json_2 = "[\"23:53\",\"23:59\"]";
//        List<String> listJson = JsonUtils.jsonStringToObject(json_2, List.class);
//        System.out.println("listJson = " + listJson);
////        System.out.println("json 01 = " + json.replaceAll("\"", ""));
////        System.out.println("json 02 = " + json_2.replaceAll("\"", ""));
//
//        List<String> list = new ArrayList<>(4);
//        list.add("10:20");
//        list.add("11:32");
//
//        FormDataItem dataItem = new FormDataItem();
//        dataItem.setName("测试01");
//        dataItem.setTitle("时间段");
//
//        String listJsonString = JsonUtils.objectToJsonString(list);
//        System.out.println("listJsonString = " + listJsonString);
//        dataItem.setValue(listJsonString);
//
//        String formDataItemJson = JsonUtils.objectToJsonString(dataItem);
//        System.out.println("formDataItemJson = " + formDataItemJson);
//
//        FormDataItem dataItem1From = JsonUtils.jsonStringToObject(formDataItemJson, FormDataItem.class);
//        System.out.println("formDataItem.value = " + dataItem1From.getValue());
//
//        List<String> listFrom = JsonUtils.jsonStringToObject(listJsonString, List.class);
////        ObjectNode objectNode = new ObjectNode();
//        System.out.println("listFrom = " + listFrom);
//
//        // 判断字符串是否json
////        String noneJsonStr = JsonUtils.objectToJsonString()
//    }
//
////    @Test
//    public void testPushMessageType(){
////        String input = "tcp && web_socket && wx && system";
////        String input = "tcp || web_socket || wx || system";
//        String input = "tcp ";
//        Object[] data = NotificationUtils.acquireMessagePushRules(input);
//        System.out.println(data[0]);
//        String[] indexList = (String[])data[1];
//        for(String s : indexList){
//            System.out.println("index = " + s);
//        }
//    }
//
////    @Test
//    public void testGenericType() throws Exception{
////        List<String> typeList1 = new ArrayList<String>();
//        Class type1 = GenericTypeUtils.getSuperClassGenericType(typeList1.getClass());
//        System.out.println(type1);
////        Type[] types = typeList1.getClass().getGenericInterfaces();
////        TypeVariable[] types = typeList1.getClass().getTypeParameters();
////        for(Type type : types){
////            System.out.println(type);
////        }
//        System.out.println(typeList1.getClass().getTypeName());
//
//        // 获取对象包含的泛型类型,不能直接通过class定义获得(此时并不知道),只能在运行环境中获得。2022-11-16
////        ResolvableType t = ResolvableType.forClass(typeList1.getClass());
//        ResolvableType t = ResolvableType.forField(getClass().getDeclaredField("typeList1"));
//        System.out.println(t.getGeneric(0).resolve());
//    }
//
////    @Test
//    public void testUserPrincipal2Json() throws Exception{
//        S_user_core user = new S_user_core();
//        user.setId(1L);
//        user.setUser_name("shikeying");
//        user.setCreate_time(0L);
//        user.setNick_name("时工");
//        user.setPassword("$2a$10$9lSwwUFMULR6/KhPsUbTj.0PTZfTnq0fB3OtS6PWoKAibpa8hL1cy");
//        user.setUser_type(2);
//        user.setDel_flag(0);
//        user.setStatus(0);
//        user.setSex("0");
//        user.setOrg_id(0L);
//        user.setDept_id(0L);
//        user.setAvatar("avatar.jpg");
//        DefaultUserPrincipal userPrincipal = new DefaultUserPrincipal(user);
//
//        List<String> roleIdList = new ArrayList<>(4);
//        roleIdList.add("role1");
//        roleIdList.add("role2");
////        userPrincipal.setRoleIdList(roleIdList);
//
//        String jsonString = JsonUtils.objectToJsonString(userPrincipal);
//        System.out.println("json = " + jsonString);
//
////        DefaultUserPrincipal testUser = JsonUtils.jsonStringToObject(jsonString, DefaultUserPrincipal.class);
////        System.out.println("user = " + testUser.getUserName());
//        ObjectNode objectNode = JsonUtils.jsonStringToObjectNode(jsonString);
//        String id = objectNode.get("id").asText();
//        System.out.println("id = " + id);
//
//        JsonNode userInfoNode = objectNode.get("userInfo");
//        String userName = userInfoNode.get("user_name").asText();
//        System.out.println("user_name = " + userName);
//
//        S_user_core user_core = new S_user_core();
//        user_core.setId(userInfoNode.get("id").asLong());
//        user_core.setUser_name(userInfoNode.get("user_name").asText());
//        user_core.setPassword(userInfoNode.get("password").asText());
//        user_core.setDept_id(userInfoNode.get("dept_id").asLong());
//        user_core.setNick_name(userInfoNode.get("nick_name").asText());
//        user_core.setUser_type(userInfoNode.get("user_type").asInt());
//        user_core.setCreate_time(userInfoNode.get("create_time").asLong());
//        user_core.setOrg_id(userInfoNode.get("org_id").asLong());
//        user_core.setStatus(userInfoNode.get("status").asInt());
//        user_core.setDel_flag(userInfoNode.get("del_flag").asInt());
//        if(!JsonUtils.isEmptyObject(userInfoNode.get("sex"))){
//            user_core.setSex(userInfoNode.get("sex").asText());
//        } else {
//            user_core.setSex("2");
//        }
//        if(!JsonUtils.isEmptyObject(userInfoNode.get("phonenumber"))){
//            user_core.setPhonenumber(userInfoNode.get("phonenumber").asText());
//        }
//        if(!JsonUtils.isEmptyObject(userInfoNode.get("avatar"))){
//            user_core.setAvatar(userInfoNode.get("avatar").asText());
//        }
//        if(!JsonUtils.isEmptyObject(userInfoNode.get("email"))){
//            user_core.setEmail(userInfoNode.get("email").asText());
//        }
//        if(!JsonUtils.isEmptyObject(userInfoNode.get("remark"))){
//            user_core.setRemark(userInfoNode.get("remark").asText());
//        }
//        if(!JsonUtils.isEmptyObject(userInfoNode.get("create_by"))){
//            user_core.setCreate_by(userInfoNode.get("create_by").asText());
//        }
//        if(!JsonUtils.isEmptyObject(userInfoNode.get("login_date"))){
//            user_core.setLogin_date(userInfoNode.get("login_date").asLong());
//        }
//        if(!JsonUtils.isEmptyObject(userInfoNode.get("login_ip"))){
//            user_core.setLogin_ip(userInfoNode.get("login_ip").asText());
//        }
//        if(!JsonUtils.isEmptyObject(userInfoNode.get("update_by"))){
//            user_core.setUpdate_by(userInfoNode.get("update_by").asText());
//        }
//        if(!JsonUtils.isEmptyObject(userInfoNode.get("update_time"))){
//            user_core.setUpdate_time(userInfoNode.get("update_time").asLong());
//        }
//
//        JsonNode roleIdListJson = objectNode.get("roleIdList");
//        List<String> roleList = new ArrayList<>(4);
//        if(roleIdListJson.isArray()){
//            for(Iterator<JsonNode> it = roleIdListJson.iterator(); it.hasNext();){
//                roleList.add(it.next().asText());
//            }
//        }
//        System.out.println(roleList);
//        DefaultUserPrincipal testPrincipal1 = new DefaultUserPrincipal(user_core);
//        System.out.println(testPrincipal1);
//    }
//
////    @Test
//    public void testAcquireUrlFromPerms(){
//        String perms = "system:user:query";
////        String perms = "system:role:list";
//        String url = MenuUtils.acquireUrlFromPerms(perms);
//        System.out.println("perms = " + perms + ", url = " + url);
//    }
//}