Commit 19eb03b96e140e9de67a8352e891dca2f79dde61
1 parent
aa94ae19
remove code
Showing
32 changed files
with
1332 additions
and
2733 deletions
Too many changes to show.
To preserve performance only 32 of 433 files are displayed.
titan-api/pom.xml
... | ... | @@ -138,6 +138,12 @@ |
138 | 138 | <groupId>org.slf4j</groupId> |
139 | 139 | <artifactId>slf4j-log4j12</artifactId> |
140 | 140 | <version>1.6.4</version> |
141 | + <exclusions> | |
142 | + <exclusion> | |
143 | + <artifactId>log4j</artifactId> | |
144 | + <groupId>log4j</groupId> | |
145 | + </exclusion> | |
146 | + </exclusions> | |
141 | 147 | </dependency> |
142 | 148 | <dependency> |
143 | 149 | <groupId>log4j</groupId> |
... | ... | @@ -177,14 +183,6 @@ |
177 | 183 | <version>5.1.25</version> |
178 | 184 | </dependency> |
179 | 185 | |
180 | - <!-- 工具类 --> | |
181 | - <!-- google sets,maps --> | |
182 | - <!--<dependency>--> | |
183 | - <!--<groupId>com.google.guava</groupId>--> | |
184 | - <!--<artifactId>guava</artifactId>--> | |
185 | - <!--<version>14.0.1</version>--> | |
186 | - <!--</dependency>--> | |
187 | - <!-- JSON --> | |
188 | 186 | <dependency> |
189 | 187 | <groupId>com.alibaba</groupId> |
190 | 188 | <artifactId>fastjson</artifactId> |
... | ... | @@ -195,11 +193,7 @@ |
195 | 193 | <artifactId>aspectjweaver</artifactId> |
196 | 194 | <version>1.7.2</version> |
197 | 195 | </dependency> |
198 | - <!--<dependency>--> | |
199 | - <!--<groupId>cglib</groupId>--> | |
200 | - <!--<artifactId>cglib-nodep</artifactId>--> | |
201 | - <!--<version>2.1_3</version>--> | |
202 | - <!--</dependency>--> | |
196 | + | |
203 | 197 | |
204 | 198 | <!-- common logging replacer --> |
205 | 199 | <dependency> |
... | ... | @@ -213,51 +207,11 @@ |
213 | 207 | <artifactId>aspectjrt</artifactId> |
214 | 208 | <version>${aspectj.version}</version> |
215 | 209 | </dependency> |
216 | - <!-- if you enable JSR303 (Bean Validation) in spring. --> | |
217 | - <!--<dependency>--> | |
218 | - <!--<groupId>org.hibernate</groupId>--> | |
219 | - <!--<artifactId>hibernate-validator</artifactId>--> | |
220 | - <!--<version>4.2.0.Final</version>--> | |
221 | - <!--</dependency>--> | |
222 | - <!-- if you use velocity view in springmvc --> | |
223 | - <dependency> | |
224 | - <groupId>org.apache.velocity</groupId> | |
225 | - <artifactId>velocity</artifactId> | |
226 | - <version>1.7</version> | |
227 | - </dependency> | |
228 | - <!-- if you use velocity layout view in springmvc --> | |
229 | 210 | <dependency> |
230 | 211 | <groupId>org.apache.velocity</groupId> |
231 | 212 | <artifactId>velocity-tools</artifactId> |
232 | 213 | <version>2.0</version> |
233 | - <exclusions> | |
234 | - <exclusion> | |
235 | - <groupId>org.apache.struts</groupId> | |
236 | - <artifactId>struts-core</artifactId> | |
237 | - </exclusion> | |
238 | - <exclusion> | |
239 | - <groupId>org.apache.struts</groupId> | |
240 | - <artifactId>struts-taglib</artifactId> | |
241 | - </exclusion> | |
242 | - <exclusion> | |
243 | - <groupId>org.apache.struts</groupId> | |
244 | - <artifactId>struts-tiles</artifactId> | |
245 | - </exclusion> | |
246 | - <exclusion> | |
247 | - <groupId>sslext</groupId> | |
248 | - <artifactId>sslext</artifactId> | |
249 | - </exclusion> | |
250 | - <exclusion> | |
251 | - <artifactId>servlet-api</artifactId> | |
252 | - <groupId>javax.servlet</groupId> | |
253 | - </exclusion> | |
254 | - <exclusion> | |
255 | - <artifactId>commons-digester</artifactId> | |
256 | - <groupId>commons-digester</groupId> | |
257 | - </exclusion> | |
258 | - </exclusions> | |
259 | 214 | </dependency> |
260 | - <!-- if you enable json support in spring mvc. --> | |
261 | 215 | <dependency> |
262 | 216 | <groupId>org.codehaus.jackson</groupId> |
263 | 217 | <artifactId>jackson-mapper-asl</artifactId> |
... | ... | @@ -300,19 +254,13 @@ |
300 | 254 | <groupId>org.springframework</groupId> |
301 | 255 | <artifactId>spring-context</artifactId> |
302 | 256 | </exclusion> |
303 | - </exclusions> | |
304 | - </dependency> | |
305 | - <dependency> | |
306 | - <artifactId>hbase-client</artifactId> | |
307 | - <exclusions> | |
308 | 257 | <exclusion> |
309 | - <artifactId>servlet-api</artifactId> | |
310 | - <groupId>javax.servlet</groupId> | |
258 | + <artifactId>slf4j-api</artifactId> | |
259 | + <groupId>org.slf4j</groupId> | |
311 | 260 | </exclusion> |
312 | 261 | </exclusions> |
313 | - <groupId>org.apache.hbase</groupId> | |
314 | - <version>0.96.1.1-cdh5.0.0</version> | |
315 | 262 | </dependency> |
263 | + | |
316 | 264 | <dependency> |
317 | 265 | <groupId>org.springframework</groupId> |
318 | 266 | <artifactId>spring-test</artifactId> |
... | ... | @@ -322,164 +270,27 @@ |
322 | 270 | <groupId>org.apache.httpcomponents</groupId> |
323 | 271 | <artifactId>httpclient</artifactId> |
324 | 272 | <version>4.3.3</version> |
325 | - </dependency> | |
326 | - <dependency> | |
327 | - <groupId>net.bull.javamelody</groupId> | |
328 | - <artifactId>javamelody-core</artifactId> | |
329 | - <version>1.37.0</version> | |
330 | - </dependency> | |
331 | - | |
332 | - <dependency> | |
333 | - <groupId>commons-fileupload</groupId> | |
334 | - <artifactId>commons-fileupload</artifactId> | |
335 | - <version>1.3</version> | |
336 | - <exclusions> | |
337 | - <exclusion> | |
338 | - <artifactId>commons-io</artifactId> | |
339 | - <groupId>commons-io</groupId> | |
340 | - </exclusion> | |
341 | - </exclusions> | |
342 | - </dependency> | |
343 | - <!--监控平台接入 --> | |
344 | - <dependency> | |
345 | - <groupId>com.dili.dd.monitor</groupId> | |
346 | - <artifactId>monitor</artifactId> | |
347 | - <version>0.0.3-SNAPSHOT</version> | |
348 | - <exclusions> | |
349 | - <exclusion> | |
350 | - <artifactId>servlet-api</artifactId> | |
351 | - <groupId>org.mortbay.jetty</groupId> | |
352 | - </exclusion> | |
353 | - </exclusions> | |
354 | - </dependency> | |
355 | - <dependency> | |
356 | - <groupId>com.yqyw.messageCenter.sdk</groupId> | |
357 | - <artifactId>diligrp-messageCenter-sdk</artifactId> | |
358 | - <version>0.0.4-SNAPSHOT</version> | |
359 | - </dependency> | |
360 | - <dependency> | |
361 | - <groupId>com.diligrp.website.web</groupId> | |
362 | - <artifactId>diligrp-website-api</artifactId> | |
363 | - <version>1.0.0-SNAPSHOT</version> | |
364 | - <exclusions> | |
365 | - <exclusion> | |
366 | - <artifactId>servlet-api</artifactId> | |
367 | - <groupId>javax.servlet</groupId> | |
368 | - </exclusion> | |
369 | - <exclusion> | |
370 | - <artifactId>fastjson</artifactId> | |
371 | - <groupId>com.alibaba</groupId> | |
372 | - </exclusion> | |
373 | - <exclusion> | |
374 | - <artifactId>mybatis</artifactId> | |
375 | - <groupId>org.mybatis</groupId> | |
376 | - </exclusion> | |
377 | - <exclusion> | |
378 | - <artifactId>guava</artifactId> | |
379 | - <groupId>com.google.guava</groupId> | |
380 | - </exclusion> | |
381 | - <exclusion> | |
382 | - <artifactId>spring-webmvc</artifactId> | |
383 | - <groupId>org.springframework</groupId> | |
384 | - </exclusion> | |
385 | - </exclusions> | |
386 | - </dependency> | |
387 | - <dependency> | |
388 | - <groupId>com.yqyw.website.web</groupId> | |
389 | - <artifactId>diligrp-website-api</artifactId> | |
390 | - <version>1.0.3-SNAPSHOT</version> | |
391 | - <exclusions> | |
392 | - <exclusion> | |
393 | - <artifactId>servlet-api</artifactId> | |
394 | - <groupId>javax.servlet</groupId> | |
395 | - </exclusion> | |
396 | - <exclusion> | |
397 | - <artifactId>fastjson</artifactId> | |
398 | - <groupId>com.alibaba</groupId> | |
399 | - </exclusion> | |
400 | - <exclusion> | |
401 | - <artifactId>mybatis</artifactId> | |
402 | - <groupId>org.mybatis</groupId> | |
403 | - </exclusion> | |
404 | - <exclusion> | |
405 | - <artifactId>guava</artifactId> | |
406 | - <groupId>com.google.guava</groupId> | |
407 | - </exclusion> | |
408 | - <exclusion> | |
409 | - <artifactId>spring-webmvc</artifactId> | |
410 | - <groupId>org.springframework</groupId> | |
411 | - </exclusion> | |
412 | - </exclusions> | |
413 | - </dependency> | |
414 | - <dependency> | |
415 | - <groupId>com.yqyw.filter</groupId> | |
416 | - <artifactId>filter-keysdk</artifactId> | |
417 | - <version>0.0.1-SNAPSHOT</version> | |
418 | 273 | <exclusions> |
419 | 274 | <exclusion> |
420 | - <artifactId>mybatis</artifactId> | |
421 | - <groupId>org.mybatis</groupId> | |
422 | - </exclusion> | |
423 | - <exclusion> | |
424 | - <artifactId>spring-context-support</artifactId> | |
425 | - <groupId>org.springframework</groupId> | |
426 | - </exclusion> | |
427 | - <exclusion> | |
428 | - <artifactId>spring-context</artifactId> | |
429 | - <groupId>org.springframework</groupId> | |
275 | + <artifactId>commons-logging</artifactId> | |
276 | + <groupId>commons-logging</groupId> | |
430 | 277 | </exclusion> |
431 | - </exclusions> | |
432 | - </dependency> | |
433 | - | |
434 | - <dependency> | |
435 | - <groupId>com.yqyw.user</groupId> | |
436 | - <artifactId>diligrp-user-client</artifactId> | |
437 | - <version>0.0.5-SNAPSHOT</version> | |
438 | - <exclusions> | |
439 | 278 | <exclusion> |
440 | - <artifactId>diligrp-website-util</artifactId> | |
441 | - <groupId>com.diligrp.website</groupId> | |
279 | + <artifactId>commons-codec</artifactId> | |
280 | + <groupId>commons-codec</groupId> | |
442 | 281 | </exclusion> |
443 | 282 | </exclusions> |
444 | 283 | </dependency> |
445 | 284 | <dependency> |
446 | - <groupId>com.yqyw.shop</groupId> | |
447 | - <artifactId>shop-sdk</artifactId> | |
448 | - <version>0.0.2-SNAPSHOT</version> | |
285 | + <groupId>org.apache.commons</groupId> | |
286 | + <artifactId>commons-lang3</artifactId> | |
287 | + <version>3.3.2</version> | |
449 | 288 | </dependency> |
450 | 289 | <dependency> |
451 | - <groupId>com.diligrp</groupId> | |
452 | - <artifactId>diligrp-crm-api</artifactId> | |
453 | - <!--更换最新的 chenzhiwei--> | |
454 | - <version>0.0.1-SNAPSHOT</version> | |
455 | - <exclusions> | |
456 | - <exclusion> | |
457 | - <groupId>org.apache.httpcomponents</groupId> | |
458 | - <artifactId>httpcore</artifactId> | |
459 | - </exclusion> | |
460 | - </exclusions> | |
461 | - </dependency> | |
462 | - | |
463 | - <dependency> | |
464 | - <groupId>com.yqyw.filter</groupId> | |
465 | - <artifactId>filter-keysdk</artifactId> | |
466 | - <version>0.0.1-SNAPSHOT</version> | |
467 | - <exclusions> | |
468 | - <exclusion> | |
469 | - <artifactId>mybatis</artifactId> | |
470 | - <groupId>org.mybatis</groupId> | |
471 | - </exclusion> | |
472 | - <exclusion> | |
473 | - <artifactId>spring-context-support</artifactId> | |
474 | - <groupId>org.springframework</groupId> | |
475 | - </exclusion> | |
476 | - <exclusion> | |
477 | - <artifactId>spring-context</artifactId> | |
478 | - <groupId>org.springframework</groupId> | |
479 | - </exclusion> | |
480 | - </exclusions> | |
290 | + <groupId>commons-collections</groupId> | |
291 | + <artifactId>commons-collections</artifactId> | |
292 | + <version>3.2.1</version> | |
481 | 293 | </dependency> |
482 | - | |
483 | 294 | </dependencies> |
484 | 295 | |
485 | 296 | <!-- 打包配置信息 --> |
... | ... | @@ -498,42 +309,14 @@ |
498 | 309 | <!-- 数据库 --> |
499 | 310 | <dili_titan.jdbc.driver>com.mysql.jdbc.Driver</dili_titan.jdbc.driver> |
500 | 311 | <!-- 主库配置 --> |
501 | - <dili_titan.master.jdbc.url>jdbc:MySql://10.28.11.162:3306/titan?useUnicode=true&characterEncoding=utf8</dili_titan.master.jdbc.url> | |
502 | - <dili_titan.master.jdbc.username>root</dili_titan.master.jdbc.username> | |
503 | - <dili_titan.master.jdbc.password>123456</dili_titan.master.jdbc.password> | |
504 | - <!-- 从库配置 --> | |
505 | - <dili_titan.slave.jdbc.url>jdbc:MySql://10.28.11.162:3306/titan?useUnicode=true&characterEncoding=utf8</dili_titan.slave.jdbc.url> | |
506 | - <dili_titan.slave.jdbc.username>root</dili_titan.slave.jdbc.username> | |
507 | - <dili_titan.slave.jdbc.password>123456</dili_titan.slave.jdbc.password> | |
508 | - <!-- crm接口地址 --> | |
509 | - <dili_titan.crm.url>supplier.1n4j.com</dili_titan.crm.url> | |
510 | - <!-- user接口地址 --> | |
511 | - <dili_titan.user.url>user.1n4j.com</dili_titan.user.url> | |
512 | - <!--关键字接口地址--> | |
513 | - <dili_titan.keywords.url>keyword.filter.1n4j.com</dili_titan.keywords.url> | |
514 | - <!--shop接口地址,需要测试自己修改 --> | |
515 | - <dili_titan.shop.url>http://shop.1n4j.com</dili_titan.shop.url> | |
312 | + <dili_titan.jdbc.url>jdbc:MySql://10.28.11.162:3306/titan?useUnicode=true&characterEncoding=utf8</dili_titan.jdbc.url> | |
313 | + <dili_titan.jdbc.username>root</dili_titan.jdbc.username> | |
314 | + <dili_titan.jdbc.password>123456</dili_titan.jdbc.password> | |
516 | 315 | <!-- redis接口地址 --> |
517 | 316 | <dili_titan.redis.url>10.28.11.205</dili_titan.redis.url> |
518 | 317 | <!--权限管理的redis配置--> |
519 | 318 | <manage.redis.url>10.28.11.205</manage.redis.url> |
520 | 319 | <manage.redis.port>6379</manage.redis.port> |
521 | - <!-- MQ 地址--> | |
522 | - <conf.mq.namesrvAddr>10.28.10.209:9876;10.28.10.149:9876</conf.mq.namesrvAddr> | |
523 | - <conf.mq.producerGroup>titanPNR</conf.mq.producerGroup> | |
524 | - <!-- website接口地址 --> | |
525 | - <dili_titan.website.url>manweb.1n4j.com</dili_titan.website.url> | |
526 | - <!-- 日志 --> | |
527 | - <dili_titan.log.level>INFO</dili_titan.log.level> | |
528 | - <dili_titan.log.path>/export/logs</dili_titan.log.path> | |
529 | - <dili_titan.log.root.appender>CONSOLE</dili_titan.log.root.appender> | |
530 | - <!--打包编码 --> | |
531 | - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
532 | - <!-- 图片服务器前缀 --> | |
533 | - <project.imageserver.prefix>http://img0.1n4j.com</project.imageserver.prefix> | |
534 | - <!--爱奇艺视频 --> | |
535 | - <titan.aqy.appkey>e64a09bece964bb484e5decc30c0b950</titan.aqy.appkey> | |
536 | - <titan.aqy.appSecret>f48d2b799f9661acdb6041e4ac7c142f</titan.aqy.appSecret> | |
537 | 320 | </properties> |
538 | 321 | </profile> |
539 | 322 | </profiles> | ... | ... |
titan-api/src/main/hbase-profiles/develop/core-site.xml deleted
100755 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | |
2 | -<configuration> | |
3 | - | |
4 | - <property> | |
5 | - <name>fs.defaultFS</name> | |
6 | - <value>hdfs://mycluster</value> | |
7 | - <final>true</final> | |
8 | - </property> | |
9 | - | |
10 | - <property> | |
11 | - <name>fs.trash.interval</name> | |
12 | - <value>360</value> | |
13 | - </property> | |
14 | - | |
15 | - <property> | |
16 | - <name>ha.failover-controller.active-standby-elector.zk.op.retries</name> | |
17 | - <value>120</value> | |
18 | - </property> | |
19 | - | |
20 | - <property> | |
21 | - <name>ha.zookeeper.quorum</name> | |
22 | - <value>node2:2181,node3:2181,node4:2181</value> | |
23 | - </property> | |
24 | - | |
25 | - <property> | |
26 | - <name>hadoop.http.authentication.simple.anonymous.allowed</name> | |
27 | - <value>true</value> | |
28 | - </property> | |
29 | - | |
30 | - <property> | |
31 | - <name>hadoop.security.auth_to_local</name> | |
32 | - <value>DEFAULT</value> | |
33 | - </property> | |
34 | - | |
35 | - <property> | |
36 | - <name>hadoop.security.authentication</name> | |
37 | - <value>simple</value> | |
38 | - </property> | |
39 | - | |
40 | - <property> | |
41 | - <name>hadoop.security.authorization</name> | |
42 | - <value>false</value> | |
43 | - </property> | |
44 | - | |
45 | - <property> | |
46 | - <name>io.compression.codecs</name> | |
47 | - <value>org.apache.hadoop.io.compress.GzipCodec,org.apache.hadoop.io.compress.DefaultCodec,org.apache.hadoop.io.compress.SnappyCodec</value> | |
48 | - </property> | |
49 | - | |
50 | - <property> | |
51 | - <name>io.file.buffer.size</name> | |
52 | - <value>131072</value> | |
53 | - </property> | |
54 | - | |
55 | - <property> | |
56 | - <name>io.serializations</name> | |
57 | - <value>org.apache.hadoop.io.serializer.WritableSerialization</value> | |
58 | - </property> | |
59 | - | |
60 | - <property> | |
61 | - <name>ipc.client.connect.max.retries</name> | |
62 | - <value>50</value> | |
63 | - </property> | |
64 | - | |
65 | - <property> | |
66 | - <name>ipc.client.connection.maxidletime</name> | |
67 | - <value>30000</value> | |
68 | - </property> | |
69 | - | |
70 | - <property> | |
71 | - <name>ipc.client.idlethreshold</name> | |
72 | - <value>8000</value> | |
73 | - </property> | |
74 | - | |
75 | - <property> | |
76 | - <name>ipc.server.tcpnodelay</name> | |
77 | - <value>true</value> | |
78 | - </property> | |
79 | - | |
80 | - <property> | |
81 | - <name>mapreduce.jobtracker.webinterface.trusted</name> | |
82 | - <value>false</value> | |
83 | - </property> | |
84 | - | |
85 | - <property> | |
86 | - <name>proxyuser_group</name> | |
87 | - <value>users</value> | |
88 | - </property> | |
89 | - | |
90 | -</configuration> |
titan-api/src/main/hbase-profiles/develop/hbase-site.xml deleted
100755 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | |
2 | -<configuration> | |
3 | - | |
4 | - <property> | |
5 | - <name>dfs.domain.socket.path</name> | |
6 | - <value>/var/lib/hadoop-hdfs/dn_socket</value> | |
7 | - </property> | |
8 | - | |
9 | - <property> | |
10 | - <name>hbase.client.keyvalue.maxsize</name> | |
11 | - <value>10485760</value> | |
12 | - </property> | |
13 | - | |
14 | - <property> | |
15 | - <name>hbase.client.scanner.caching</name> | |
16 | - <value>100</value> | |
17 | - </property> | |
18 | - | |
19 | - <property> | |
20 | - <name>hbase.cluster.distributed</name> | |
21 | - <value>true</value> | |
22 | - </property> | |
23 | - | |
24 | - <property> | |
25 | - <name>hbase.coprocessor.master.classes</name> | |
26 | - <value></value> | |
27 | - </property> | |
28 | - | |
29 | - <property> | |
30 | - <name>hbase.coprocessor.region.classes</name> | |
31 | - <value></value> | |
32 | - </property> | |
33 | - | |
34 | - <property> | |
35 | - <name>hbase.defaults.for.version.skip</name> | |
36 | - <value>true</value> | |
37 | - </property> | |
38 | - | |
39 | - <property> | |
40 | - <name>hbase.hregion.majorcompaction</name> | |
41 | - <value>604800000</value> | |
42 | - </property> | |
43 | - | |
44 | - <property> | |
45 | - <name>hbase.hregion.majorcompaction.jitter</name> | |
46 | - <value>0.50</value> | |
47 | - </property> | |
48 | - | |
49 | - <property> | |
50 | - <name>hbase.hregion.max.filesize</name> | |
51 | - <value>10737418240</value> | |
52 | - </property> | |
53 | - | |
54 | - <property> | |
55 | - <name>hbase.hregion.memstore.block.multiplier</name> | |
56 | - <value>4</value> | |
57 | - </property> | |
58 | - | |
59 | - <property> | |
60 | - <name>hbase.hregion.memstore.flush.size</name> | |
61 | - <value>134217728</value> | |
62 | - </property> | |
63 | - | |
64 | - <property> | |
65 | - <name>hbase.hregion.memstore.mslab.enabled</name> | |
66 | - <value>true</value> | |
67 | - </property> | |
68 | - | |
69 | - <property> | |
70 | - <name>hbase.hstore.blockingStoreFiles</name> | |
71 | - <value>10</value> | |
72 | - </property> | |
73 | - | |
74 | - <property> | |
75 | - <name>hbase.hstore.compactionThreshold</name> | |
76 | - <value>3</value> | |
77 | - </property> | |
78 | - | |
79 | - <property> | |
80 | - <name>hbase.local.dir</name> | |
81 | - <value>${hbase.tmp.dir}/local</value> | |
82 | - </property> | |
83 | - | |
84 | - <property> | |
85 | - <name>hbase.master.info.bindAddress</name> | |
86 | - <value>0.0.0.0</value> | |
87 | - </property> | |
88 | - | |
89 | - <property> | |
90 | - <name>hbase.master.info.port</name> | |
91 | - <value>60010</value> | |
92 | - </property> | |
93 | - | |
94 | - <property> | |
95 | - <name>hbase.master.port</name> | |
96 | - <value>60000</value> | |
97 | - </property> | |
98 | - | |
99 | - <property> | |
100 | - <name>hbase.regionserver.global.memstore.lowerLimit</name> | |
101 | - <value>0.38</value> | |
102 | - </property> | |
103 | - | |
104 | - <property> | |
105 | - <name>hbase.regionserver.global.memstore.upperLimit</name> | |
106 | - <value>0.4</value> | |
107 | - </property> | |
108 | - | |
109 | - <property> | |
110 | - <name>hbase.regionserver.handler.count</name> | |
111 | - <value>60</value> | |
112 | - </property> | |
113 | - | |
114 | - <property> | |
115 | - <name>hbase.regionserver.info.port</name> | |
116 | - <value>60030</value> | |
117 | - </property> | |
118 | - | |
119 | - <property> | |
120 | - <name>hbase.rootdir</name> | |
121 | - <value>hdfs://mycluster/apps/hbase/data</value> | |
122 | - </property> | |
123 | - | |
124 | - <property> | |
125 | - <name>hbase.rpc.protection</name> | |
126 | - <value>authentication</value> | |
127 | - </property> | |
128 | - | |
129 | - <property> | |
130 | - <name>hbase.security.authentication</name> | |
131 | - <value>simple</value> | |
132 | - </property> | |
133 | - | |
134 | - <property> | |
135 | - <name>hbase.security.authorization</name> | |
136 | - <value>false</value> | |
137 | - </property> | |
138 | - | |
139 | - <property> | |
140 | - <name>hbase.superuser</name> | |
141 | - <value>hadoop</value> | |
142 | - </property> | |
143 | - | |
144 | - <property> | |
145 | - <name>hbase.zookeeper.property.clientPort</name> | |
146 | - <value>2181</value> | |
147 | - </property> | |
148 | - | |
149 | - <property> | |
150 | - <name>hbase.zookeeper.quorum</name> | |
151 | - <value>node2,node3,node4</value> | |
152 | - </property> | |
153 | - | |
154 | - <property> | |
155 | - <name>hbase.zookeeper.useMulti</name> | |
156 | - <value>true</value> | |
157 | - </property> | |
158 | - | |
159 | - <property> | |
160 | - <name>hfile.block.cache.size</name> | |
161 | - <value>0.40</value> | |
162 | - </property> | |
163 | - | |
164 | - <property> | |
165 | - <name>zookeeper.session.timeout</name> | |
166 | - <value>30000</value> | |
167 | - </property> | |
168 | - | |
169 | - <property> | |
170 | - <name>zookeeper.znode.parent</name> | |
171 | - <value>/hbase</value> | |
172 | - </property> | |
173 | - | |
174 | -</configuration> |
titan-api/src/main/hbase-profiles/online/core-site.xml deleted
100755 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | |
2 | -<configuration> | |
3 | - | |
4 | - <property> | |
5 | - <name>fs.defaultFS</name> | |
6 | - <value>hdfs://bigdata1</value> | |
7 | - <final>true</final> | |
8 | - </property> | |
9 | - | |
10 | - <property> | |
11 | - <name>fs.trash.interval</name> | |
12 | - <value>360</value> | |
13 | - </property> | |
14 | - | |
15 | - <property> | |
16 | - <name>ha.failover-controller.active-standby-elector.zk.op.retries</name> | |
17 | - <value>120</value> | |
18 | - </property> | |
19 | - | |
20 | - <property> | |
21 | - <name>ha.zookeeper.quorum</name> | |
22 | - <value>ddbigdata.29.115.nong12.com:2181,ddbigdata.29.116.nong12.com:2181,ddbigdata.29.117.nong12.com:2181</value> | |
23 | - </property> | |
24 | - | |
25 | - <property> | |
26 | - <name>hadoop.http.authentication.simple.anonymous.allowed</name> | |
27 | - <value>true</value> | |
28 | - </property> | |
29 | - | |
30 | - <property> | |
31 | - <name>hadoop.security.auth_to_local</name> | |
32 | - <value>DEFAULT</value> | |
33 | - </property> | |
34 | - | |
35 | - <property> | |
36 | - <name>hadoop.security.authentication</name> | |
37 | - <value>simple</value> | |
38 | - </property> | |
39 | - | |
40 | - <property> | |
41 | - <name>hadoop.security.authorization</name> | |
42 | - <value>false</value> | |
43 | - </property> | |
44 | - | |
45 | - <property> | |
46 | - <name>io.compression.codecs</name> | |
47 | - <value>org.apache.hadoop.io.compress.GzipCodec,org.apache.hadoop.io.compress.DefaultCodec,org.apache.hadoop.io.compress.SnappyCodec</value> | |
48 | - </property> | |
49 | - | |
50 | - <property> | |
51 | - <name>io.file.buffer.size</name> | |
52 | - <value>131072</value> | |
53 | - </property> | |
54 | - | |
55 | - <property> | |
56 | - <name>io.serializations</name> | |
57 | - <value>org.apache.hadoop.io.serializer.WritableSerialization</value> | |
58 | - </property> | |
59 | - | |
60 | - <property> | |
61 | - <name>ipc.client.connect.max.retries</name> | |
62 | - <value>50</value> | |
63 | - </property> | |
64 | - | |
65 | - <property> | |
66 | - <name>ipc.client.connection.maxidletime</name> | |
67 | - <value>30000</value> | |
68 | - </property> | |
69 | - | |
70 | - <property> | |
71 | - <name>ipc.client.idlethreshold</name> | |
72 | - <value>8000</value> | |
73 | - </property> | |
74 | - | |
75 | - <property> | |
76 | - <name>ipc.server.tcpnodelay</name> | |
77 | - <value>true</value> | |
78 | - </property> | |
79 | - | |
80 | - <property> | |
81 | - <name>mapreduce.jobtracker.webinterface.trusted</name> | |
82 | - <value>false</value> | |
83 | - </property> | |
84 | - | |
85 | - <property> | |
86 | - <name>proxyuser_group</name> | |
87 | - <value>users</value> | |
88 | - </property> | |
89 | - | |
90 | -</configuration> |
titan-api/src/main/hbase-profiles/online/hbase-site.xml deleted
100755 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | |
2 | -<configuration> | |
3 | - | |
4 | - <property> | |
5 | - <name>dfs.domain.socket.path</name> | |
6 | - <value>/var/lib/hadoop-hdfs/dn_socket</value> | |
7 | - </property> | |
8 | - | |
9 | - <property> | |
10 | - <name>hbase.client.keyvalue.maxsize</name> | |
11 | - <value>10485760</value> | |
12 | - </property> | |
13 | - | |
14 | - <property> | |
15 | - <name>hbase.client.scanner.caching</name> | |
16 | - <value>100</value> | |
17 | - </property> | |
18 | - | |
19 | - <property> | |
20 | - <name>hbase.cluster.distributed</name> | |
21 | - <value>true</value> | |
22 | - </property> | |
23 | - | |
24 | - <property> | |
25 | - <name>hbase.coprocessor.master.classes</name> | |
26 | - <value></value> | |
27 | - </property> | |
28 | - | |
29 | - <property> | |
30 | - <name>hbase.coprocessor.region.classes</name> | |
31 | - <value></value> | |
32 | - </property> | |
33 | - | |
34 | - <property> | |
35 | - <name>hbase.defaults.for.version.skip</name> | |
36 | - <value>true</value> | |
37 | - </property> | |
38 | - | |
39 | - <property> | |
40 | - <name>hbase.hregion.majorcompaction</name> | |
41 | - <value>604800000</value> | |
42 | - </property> | |
43 | - | |
44 | - <property> | |
45 | - <name>hbase.hregion.majorcompaction.jitter</name> | |
46 | - <value>0.50</value> | |
47 | - </property> | |
48 | - | |
49 | - <property> | |
50 | - <name>hbase.hregion.max.filesize</name> | |
51 | - <value>10737418240</value> | |
52 | - </property> | |
53 | - | |
54 | - <property> | |
55 | - <name>hbase.hregion.memstore.block.multiplier</name> | |
56 | - <value>4</value> | |
57 | - </property> | |
58 | - | |
59 | - <property> | |
60 | - <name>hbase.hregion.memstore.flush.size</name> | |
61 | - <value>134217728</value> | |
62 | - </property> | |
63 | - | |
64 | - <property> | |
65 | - <name>hbase.hregion.memstore.mslab.enabled</name> | |
66 | - <value>true</value> | |
67 | - </property> | |
68 | - | |
69 | - <property> | |
70 | - <name>hbase.hstore.blockingStoreFiles</name> | |
71 | - <value>10</value> | |
72 | - </property> | |
73 | - | |
74 | - <property> | |
75 | - <name>hbase.hstore.compactionThreshold</name> | |
76 | - <value>3</value> | |
77 | - </property> | |
78 | - | |
79 | - <property> | |
80 | - <name>hbase.local.dir</name> | |
81 | - <value>${hbase.tmp.dir}/local</value> | |
82 | - </property> | |
83 | - | |
84 | - <property> | |
85 | - <name>hbase.master.info.bindAddress</name> | |
86 | - <value>0.0.0.0</value> | |
87 | - </property> | |
88 | - | |
89 | - <property> | |
90 | - <name>hbase.master.info.port</name> | |
91 | - <value>60010</value> | |
92 | - </property> | |
93 | - | |
94 | - <property> | |
95 | - <name>hbase.master.port</name> | |
96 | - <value>60000</value> | |
97 | - </property> | |
98 | - | |
99 | - <property> | |
100 | - <name>hbase.regionserver.global.memstore.lowerLimit</name> | |
101 | - <value>0.38</value> | |
102 | - </property> | |
103 | - | |
104 | - <property> | |
105 | - <name>hbase.regionserver.global.memstore.upperLimit</name> | |
106 | - <value>0.4</value> | |
107 | - </property> | |
108 | - | |
109 | - <property> | |
110 | - <name>hbase.regionserver.handler.count</name> | |
111 | - <value>60</value> | |
112 | - </property> | |
113 | - | |
114 | - <property> | |
115 | - <name>hbase.regionserver.info.port</name> | |
116 | - <value>60030</value> | |
117 | - </property> | |
118 | - | |
119 | - <property> | |
120 | - <name>hbase.rootdir</name> | |
121 | - <value>hdfs://bigdata1/apps/hbase/data</value> | |
122 | - </property> | |
123 | - | |
124 | - <property> | |
125 | - <name>hbase.rpc.protection</name> | |
126 | - <value>authentication</value> | |
127 | - </property> | |
128 | - | |
129 | - <property> | |
130 | - <name>hbase.security.authentication</name> | |
131 | - <value>simple</value> | |
132 | - </property> | |
133 | - | |
134 | - <property> | |
135 | - <name>hbase.security.authorization</name> | |
136 | - <value>false</value> | |
137 | - </property> | |
138 | - | |
139 | - <property> | |
140 | - <name>hbase.superuser</name> | |
141 | - <value>hbase</value> | |
142 | - </property> | |
143 | - | |
144 | - <!--<property> | |
145 | - <name>hbase.tmp.dir</name> | |
146 | - <value>/diliapp/data1/hadoop/hbase</value> | |
147 | - </property>--> | |
148 | - | |
149 | - <property> | |
150 | - <name>hbase.zookeeper.property.clientPort</name> | |
151 | - <value>2181</value> | |
152 | - </property> | |
153 | - | |
154 | - <property> | |
155 | - <name>hbase.zookeeper.quorum</name> | |
156 | - <value>ddbigdata.29.115.nong12.com:2181,ddbigdata.29.116.nong12.com:2181,ddbigdata.29.117.nong12.com:2181</value> | |
157 | - </property> | |
158 | - | |
159 | - <property> | |
160 | - <name>hbase.zookeeper.useMulti</name> | |
161 | - <value>true</value> | |
162 | - </property> | |
163 | - | |
164 | - <property> | |
165 | - <name>hfile.block.cache.size</name> | |
166 | - <value>0.40</value> | |
167 | - </property> | |
168 | - | |
169 | - <property> | |
170 | - <name>zookeeper.session.timeout</name> | |
171 | - <value>30000</value> | |
172 | - </property> | |
173 | - | |
174 | - <property> | |
175 | - <name>zookeeper.znode.parent</name> | |
176 | - <value>/hbase-unsecure</value> | |
177 | - </property> | |
178 | - | |
179 | -</configuration> |
titan-api/src/main/hbase-profiles/pre-online/core-site.xml deleted
100755 → 0
1 | -<!--Mon Nov 14 17:17:58 2016--> | |
2 | - <configuration> | |
3 | - | |
4 | - <property> | |
5 | - <name>fs.defaultFS</name> | |
6 | - <value>hdfs://hbase1.hadoop:8020</value> | |
7 | - <final>true</final> | |
8 | - </property> | |
9 | - | |
10 | - <property> | |
11 | - <name>fs.trash.interval</name> | |
12 | - <value>360</value> | |
13 | - </property> | |
14 | - | |
15 | - <property> | |
16 | - <name>ha.failover-controller.active-standby-elector.zk.op.retries</name> | |
17 | - <value>120</value> | |
18 | - </property> | |
19 | - | |
20 | - <property> | |
21 | - <name>hadoop.http.authentication.simple.anonymous.allowed</name> | |
22 | - <value>true</value> | |
23 | - </property> | |
24 | - | |
25 | - <property> | |
26 | - <name>hadoop.security.auth_to_local</name> | |
27 | - <value>DEFAULT</value> | |
28 | - </property> | |
29 | - | |
30 | - <property> | |
31 | - <name>hadoop.security.authentication</name> | |
32 | - <value>simple</value> | |
33 | - </property> | |
34 | - | |
35 | - <property> | |
36 | - <name>hadoop.security.authorization</name> | |
37 | - <value>false</value> | |
38 | - </property> | |
39 | - | |
40 | - <property> | |
41 | - <name>io.compression.codecs</name> | |
42 | - <value>org.apache.hadoop.io.compress.GzipCodec,org.apache.hadoop.io.compress.DefaultCodec,org.apache.hadoop.io.compress.SnappyCodec</value> | |
43 | - </property> | |
44 | - | |
45 | - <property> | |
46 | - <name>io.file.buffer.size</name> | |
47 | - <value>131072</value> | |
48 | - </property> | |
49 | - | |
50 | - <property> | |
51 | - <name>io.serializations</name> | |
52 | - <value>org.apache.hadoop.io.serializer.WritableSerialization</value> | |
53 | - </property> | |
54 | - | |
55 | - <property> | |
56 | - <name>ipc.client.connect.max.retries</name> | |
57 | - <value>50</value> | |
58 | - </property> | |
59 | - | |
60 | - <property> | |
61 | - <name>ipc.client.connection.maxidletime</name> | |
62 | - <value>30000</value> | |
63 | - </property> | |
64 | - | |
65 | - <property> | |
66 | - <name>ipc.client.idlethreshold</name> | |
67 | - <value>8000</value> | |
68 | - </property> | |
69 | - | |
70 | - <property> | |
71 | - <name>ipc.server.tcpnodelay</name> | |
72 | - <value>true</value> | |
73 | - </property> | |
74 | - | |
75 | - <property> | |
76 | - <name>mapreduce.jobtracker.webinterface.trusted</name> | |
77 | - <value>false</value> | |
78 | - </property> | |
79 | - | |
80 | - <property> | |
81 | - <name>proxyuser_group</name> | |
82 | - <value>users</value> | |
83 | - </property> | |
84 | - | |
85 | - </configuration> |
titan-api/src/main/hbase-profiles/pre-online/hbase-site.xml deleted
100755 → 0
1 | -<!--Mon Nov 14 17:18:24 2016--> | |
2 | - <configuration> | |
3 | - | |
4 | - <property> | |
5 | - <name>dfs.domain.socket.path</name> | |
6 | - <value>/var/lib/hadoop-hdfs/dn_socket</value> | |
7 | - </property> | |
8 | - | |
9 | - <property> | |
10 | - <name>hbase.client.keyvalue.maxsize</name> | |
11 | - <value>10485760</value> | |
12 | - </property> | |
13 | - | |
14 | - <property> | |
15 | - <name>hbase.client.scanner.caching</name> | |
16 | - <value>100</value> | |
17 | - </property> | |
18 | - | |
19 | - <property> | |
20 | - <name>hbase.cluster.distributed</name> | |
21 | - <value>true</value> | |
22 | - </property> | |
23 | - | |
24 | - <property> | |
25 | - <name>hbase.coprocessor.master.classes</name> | |
26 | - <value></value> | |
27 | - </property> | |
28 | - | |
29 | - <property> | |
30 | - <name>hbase.coprocessor.region.classes</name> | |
31 | - <value></value> | |
32 | - </property> | |
33 | - | |
34 | - <property> | |
35 | - <name>hbase.defaults.for.version.skip</name> | |
36 | - <value>true</value> | |
37 | - </property> | |
38 | - | |
39 | - <property> | |
40 | - <name>hbase.hregion.majorcompaction</name> | |
41 | - <value>604800000</value> | |
42 | - </property> | |
43 | - | |
44 | - <property> | |
45 | - <name>hbase.hregion.majorcompaction.jitter</name> | |
46 | - <value>0.50</value> | |
47 | - </property> | |
48 | - | |
49 | - <property> | |
50 | - <name>hbase.hregion.max.filesize</name> | |
51 | - <value>10737418240</value> | |
52 | - </property> | |
53 | - | |
54 | - <property> | |
55 | - <name>hbase.hregion.memstore.block.multiplier</name> | |
56 | - <value>4</value> | |
57 | - </property> | |
58 | - | |
59 | - <property> | |
60 | - <name>hbase.hregion.memstore.flush.size</name> | |
61 | - <value>134217728</value> | |
62 | - </property> | |
63 | - | |
64 | - <property> | |
65 | - <name>hbase.hregion.memstore.mslab.enabled</name> | |
66 | - <value>true</value> | |
67 | - </property> | |
68 | - | |
69 | - <property> | |
70 | - <name>hbase.hstore.blockingStoreFiles</name> | |
71 | - <value>10</value> | |
72 | - </property> | |
73 | - | |
74 | - <property> | |
75 | - <name>hbase.hstore.compactionThreshold</name> | |
76 | - <value>3</value> | |
77 | - </property> | |
78 | - | |
79 | - <property> | |
80 | - <name>hbase.local.dir</name> | |
81 | - <value>${hbase.tmp.dir}/local</value> | |
82 | - </property> | |
83 | - | |
84 | - <property> | |
85 | - <name>hbase.master.info.bindAddress</name> | |
86 | - <value>0.0.0.0</value> | |
87 | - </property> | |
88 | - | |
89 | - <property> | |
90 | - <name>hbase.master.info.port</name> | |
91 | - <value>60010</value> | |
92 | - </property> | |
93 | - | |
94 | - <property> | |
95 | - <name>hbase.master.port</name> | |
96 | - <value>60000</value> | |
97 | - </property> | |
98 | - | |
99 | - <property> | |
100 | - <name>hbase.regionserver.global.memstore.lowerLimit</name> | |
101 | - <value>0.38</value> | |
102 | - </property> | |
103 | - | |
104 | - <property> | |
105 | - <name>hbase.regionserver.global.memstore.upperLimit</name> | |
106 | - <value>0.4</value> | |
107 | - </property> | |
108 | - | |
109 | - <property> | |
110 | - <name>hbase.regionserver.handler.count</name> | |
111 | - <value>60</value> | |
112 | - </property> | |
113 | - | |
114 | - <property> | |
115 | - <name>hbase.regionserver.info.port</name> | |
116 | - <value>60030</value> | |
117 | - </property> | |
118 | - | |
119 | - <property> | |
120 | - <name>hbase.rootdir</name> | |
121 | - <value>hdfs://hbase1.hadoop:8020/apps/hbase/data</value> | |
122 | - </property> | |
123 | - | |
124 | - <property> | |
125 | - <name>hbase.rpc.protection</name> | |
126 | - <value>authentication</value> | |
127 | - </property> | |
128 | - | |
129 | - <property> | |
130 | - <name>hbase.security.authentication</name> | |
131 | - <value>simple</value> | |
132 | - </property> | |
133 | - | |
134 | - <property> | |
135 | - <name>hbase.security.authorization</name> | |
136 | - <value>false</value> | |
137 | - </property> | |
138 | - | |
139 | - <property> | |
140 | - <name>hbase.superuser</name> | |
141 | - <value>hbase</value> | |
142 | - </property> | |
143 | - | |
144 | - <property> | |
145 | - <name>hbase.tmp.dir</name> | |
146 | - <value>/hadoop/hbase</value> | |
147 | - </property> | |
148 | - | |
149 | - <property> | |
150 | - <name>hbase.zookeeper.property.clientPort</name> | |
151 | - <value>2181</value> | |
152 | - </property> | |
153 | - | |
154 | - <property> | |
155 | - <name>hbase.zookeeper.quorum</name> | |
156 | - <value>hbase2.hadoop,hbase1.hadoop,hbase3.hadoop</value> | |
157 | - </property> | |
158 | - | |
159 | - <property> | |
160 | - <name>hbase.zookeeper.useMulti</name> | |
161 | - <value>true</value> | |
162 | - </property> | |
163 | - | |
164 | - <property> | |
165 | - <name>hfile.block.cache.size</name> | |
166 | - <value>0.40</value> | |
167 | - </property> | |
168 | - | |
169 | - <property> | |
170 | - <name>zookeeper.session.timeout</name> | |
171 | - <value>30000</value> | |
172 | - </property> | |
173 | - | |
174 | - <property> | |
175 | - <name>zookeeper.znode.parent</name> | |
176 | - <value>/hbase-unsecure</value> | |
177 | - </property> | |
178 | - | |
179 | - </configuration> |
titan-api/src/main/hbase-profiles/test/core-site.xml deleted
100755 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | |
2 | -<?xml-stylesheet type="text/xsl" href="configuration.xsl"?> | |
3 | -<!-- | |
4 | - Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - you may not use this file except in compliance with the License. | |
6 | - You may obtain a copy of the License at | |
7 | - | |
8 | - http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - | |
10 | - Unless required by applicable law or agreed to in writing, software | |
11 | - distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - See the License for the specific language governing permissions and | |
14 | - limitations under the License. See accompanying LICENSE file. | |
15 | ---> | |
16 | - | |
17 | -<!-- Put site-specific property overrides in this file. --> | |
18 | - | |
19 | -<configuration> | |
20 | - <property> | |
21 | - <name>hadoop.tmp.dir</name> | |
22 | - <value>/usr/hadoop/tmp</value> | |
23 | - </property> | |
24 | - <property> | |
25 | - <name>io.file.buffer.size</name> | |
26 | - <value>131072</value> | |
27 | - </property> | |
28 | - <property> | |
29 | - <name>fs.defaultFS</name> | |
30 | - <value>hdfs://testcluster</value> | |
31 | - </property> | |
32 | - <property> | |
33 | - <name>hadoop.proxyuser.hadoop.groups</name> | |
34 | - <value>hadoop</value> | |
35 | - </property> | |
36 | - <property> | |
37 | - <name>hadoop.proxyuser.hadoop.hosts</name> | |
38 | - <value>*</value> | |
39 | - </property> | |
40 | -</configuration> |
titan-api/src/main/hbase-profiles/test/hbase-site.xml deleted
100755 → 0
1 | -<?xml version="1.0"?> | |
2 | -<?xml-stylesheet type="text/xsl" href="configuration.xsl"?> | |
3 | -<!-- | |
4 | -/** | |
5 | - * | |
6 | - * Licensed to the Apache Software Foundation (ASF) under one | |
7 | - * or more contributor license agreements. See the NOTICE file | |
8 | - * distributed with this work for additional information | |
9 | - * regarding copyright ownership. The ASF licenses this file | |
10 | - * to you under the Apache License, Version 2.0 (the | |
11 | - * "License"); you may not use this file except in compliance | |
12 | - * with the License. You may obtain a copy of the License at | |
13 | - * | |
14 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
15 | - * | |
16 | - * Unless required by applicable law or agreed to in writing, software | |
17 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
18 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
19 | - * See the License for the specific language governing permissions and | |
20 | - * limitations under the License. | |
21 | - */ | |
22 | ---> | |
23 | -<configuration> | |
24 | - <property> | |
25 | - <name>hbase.rootdir</name> | |
26 | - <value>hdfs://testcluster/hbase</value> | |
27 | - </property> | |
28 | - <property> | |
29 | - <name>hbase.cluster.distributed</name> | |
30 | - <value>true</value> | |
31 | - </property> | |
32 | - <property> | |
33 | - <name>hbase.zookeeper.quorum</name> | |
34 | - <value>server13,server12,server55</value> | |
35 | - </property> | |
36 | - | |
37 | - <!--HBase retry times--> | |
38 | - <property> | |
39 | - <name>hbase.client.retries.number</name> | |
40 | - <value>1</value> | |
41 | - </property> | |
42 | -</configuration> |
titan-api/src/main/java/com/diligrp/titan/common/Account.java
... | ... | @@ -2,147 +2,147 @@ package com.diligrp.titan.common; |
2 | 2 | |
3 | 3 | /** |
4 | 4 | * 账号类 |
5 | - * | |
5 | + * | |
6 | 6 | * @author dev-center |
7 | 7 | * @since 2014-05-10 |
8 | 8 | */ |
9 | 9 | public class Account { |
10 | 10 | |
11 | - private String personId; | |
11 | + private String personId; | |
12 | 12 | |
13 | - private String account; | |
13 | + private String account; | |
14 | 14 | |
15 | - private String personName; | |
15 | + private String personName; | |
16 | 16 | |
17 | - private String orgId; | |
17 | + private String orgId; | |
18 | 18 | |
19 | - private String orgName; | |
19 | + private String orgName; | |
20 | 20 | |
21 | - private int isPassModi; | |
21 | + private int isPassModi; | |
22 | 22 | |
23 | - private int passOverdue; | |
23 | + private int passOverdue; | |
24 | 24 | |
25 | - private String cvnPassModiTime; | |
25 | + private String cvnPassModiTime; | |
26 | 26 | |
27 | - private String cvnCreateTime; | |
27 | + private String cvnCreateTime; | |
28 | 28 | |
29 | - private String cvnModiTime; | |
29 | + private String cvnModiTime; | |
30 | 30 | |
31 | - private String cvnEffectiveStartTime; | |
31 | + private String cvnEffectiveStartTime; | |
32 | 32 | |
33 | - private String cvnEffectiveEndTime; | |
33 | + private String cvnEffectiveEndTime; | |
34 | 34 | |
35 | - private int isDefault; | |
35 | + private int isDefault; | |
36 | 36 | |
37 | - public String getPersonId() { | |
38 | - return personId; | |
39 | - } | |
37 | + public String getPersonId() { | |
38 | + return personId; | |
39 | + } | |
40 | 40 | |
41 | - public void setPersonId(String personId) { | |
42 | - this.personId = personId; | |
43 | - } | |
41 | + public void setPersonId(String personId) { | |
42 | + this.personId = personId; | |
43 | + } | |
44 | 44 | |
45 | - public String getAccount() { | |
46 | - return account; | |
47 | - } | |
45 | + public String getAccount() { | |
46 | + return account; | |
47 | + } | |
48 | 48 | |
49 | - public void setAccount(String account) { | |
50 | - this.account = account; | |
51 | - } | |
49 | + public void setAccount(String account) { | |
50 | + this.account = account; | |
51 | + } | |
52 | 52 | |
53 | - public String getPersonName() { | |
54 | - return personName; | |
55 | - } | |
53 | + public String getPersonName() { | |
54 | + return personName; | |
55 | + } | |
56 | 56 | |
57 | - public void setPersonName(String personName) { | |
58 | - this.personName = personName; | |
59 | - } | |
57 | + public void setPersonName(String personName) { | |
58 | + this.personName = personName; | |
59 | + } | |
60 | 60 | |
61 | - public String getOrgId() { | |
62 | - return orgId; | |
63 | - } | |
61 | + public String getOrgId() { | |
62 | + return orgId; | |
63 | + } | |
64 | 64 | |
65 | - public void setOrgId(String orgId) { | |
66 | - this.orgId = orgId; | |
67 | - } | |
65 | + public void setOrgId(String orgId) { | |
66 | + this.orgId = orgId; | |
67 | + } | |
68 | 68 | |
69 | - public String getOrgName() { | |
70 | - return orgName; | |
71 | - } | |
69 | + public String getOrgName() { | |
70 | + return orgName; | |
71 | + } | |
72 | 72 | |
73 | - public void setOrgName(String orgName) { | |
74 | - this.orgName = orgName; | |
75 | - } | |
73 | + public void setOrgName(String orgName) { | |
74 | + this.orgName = orgName; | |
75 | + } | |
76 | 76 | |
77 | - public int getIsPassModi() { | |
78 | - return isPassModi; | |
79 | - } | |
77 | + public int getIsPassModi() { | |
78 | + return isPassModi; | |
79 | + } | |
80 | 80 | |
81 | - public void setIsPassModi(int isPassModi) { | |
82 | - this.isPassModi = isPassModi; | |
83 | - } | |
81 | + public void setIsPassModi(int isPassModi) { | |
82 | + this.isPassModi = isPassModi; | |
83 | + } | |
84 | 84 | |
85 | - public int getPassOverdue() { | |
86 | - return passOverdue; | |
87 | - } | |
85 | + public int getPassOverdue() { | |
86 | + return passOverdue; | |
87 | + } | |
88 | 88 | |
89 | - public void setPassOverdue(int passOverdue) { | |
90 | - this.passOverdue = passOverdue; | |
91 | - } | |
89 | + public void setPassOverdue(int passOverdue) { | |
90 | + this.passOverdue = passOverdue; | |
91 | + } | |
92 | 92 | |
93 | - public String getCvnPassModiTime() { | |
94 | - return cvnPassModiTime; | |
95 | - } | |
93 | + public String getCvnPassModiTime() { | |
94 | + return cvnPassModiTime; | |
95 | + } | |
96 | 96 | |
97 | - public void setCvnPassModiTime(String cvnPassModiTime) { | |
98 | - this.cvnPassModiTime = cvnPassModiTime; | |
99 | - } | |
97 | + public void setCvnPassModiTime(String cvnPassModiTime) { | |
98 | + this.cvnPassModiTime = cvnPassModiTime; | |
99 | + } | |
100 | 100 | |
101 | - public String getCvnCreateTime() { | |
102 | - return cvnCreateTime; | |
103 | - } | |
101 | + public String getCvnCreateTime() { | |
102 | + return cvnCreateTime; | |
103 | + } | |
104 | 104 | |
105 | - public void setCvnCreateTime(String cvnCreateTime) { | |
106 | - this.cvnCreateTime = cvnCreateTime; | |
107 | - } | |
105 | + public void setCvnCreateTime(String cvnCreateTime) { | |
106 | + this.cvnCreateTime = cvnCreateTime; | |
107 | + } | |
108 | 108 | |
109 | - public String getCvnModiTime() { | |
110 | - return cvnModiTime; | |
111 | - } | |
109 | + public String getCvnModiTime() { | |
110 | + return cvnModiTime; | |
111 | + } | |
112 | 112 | |
113 | - public void setCvnModiTime(String cvnModiTime) { | |
114 | - this.cvnModiTime = cvnModiTime; | |
115 | - } | |
113 | + public void setCvnModiTime(String cvnModiTime) { | |
114 | + this.cvnModiTime = cvnModiTime; | |
115 | + } | |
116 | 116 | |
117 | - public String getCvnEffectiveStartTime() { | |
118 | - return cvnEffectiveStartTime; | |
119 | - } | |
117 | + public String getCvnEffectiveStartTime() { | |
118 | + return cvnEffectiveStartTime; | |
119 | + } | |
120 | 120 | |
121 | - public void setCvnEffectiveStartTime(String cvnEffectiveStartTime) { | |
122 | - this.cvnEffectiveStartTime = cvnEffectiveStartTime; | |
123 | - } | |
121 | + public void setCvnEffectiveStartTime(String cvnEffectiveStartTime) { | |
122 | + this.cvnEffectiveStartTime = cvnEffectiveStartTime; | |
123 | + } | |
124 | 124 | |
125 | - public String getCvnEffectiveEndTime() { | |
126 | - return cvnEffectiveEndTime; | |
127 | - } | |
125 | + public String getCvnEffectiveEndTime() { | |
126 | + return cvnEffectiveEndTime; | |
127 | + } | |
128 | 128 | |
129 | - public void setCvnEffectiveEndTime(String cvnEffectiveEndTime) { | |
130 | - this.cvnEffectiveEndTime = cvnEffectiveEndTime; | |
131 | - } | |
129 | + public void setCvnEffectiveEndTime(String cvnEffectiveEndTime) { | |
130 | + this.cvnEffectiveEndTime = cvnEffectiveEndTime; | |
131 | + } | |
132 | 132 | |
133 | - public int getIsDefault() { | |
134 | - return isDefault; | |
135 | - } | |
136 | - | |
137 | - public void setIsDefault(int isDefault) { | |
138 | - this.isDefault = isDefault; | |
139 | - } | |
140 | - | |
141 | - @Override | |
142 | - public String toString() { | |
143 | - return "Account [personId=" + personId + ", account=" + account + ", personName=" + personName + ", orgId=" + orgId + ", orgName=" + orgName | |
144 | - + ", isPassModi=" + isPassModi + ", passOverdue=" + passOverdue + ", cvnPassModiTime=" + cvnPassModiTime + ", cvnCreateTime=" | |
145 | - + cvnCreateTime + ", cvnModiTime=" + cvnModiTime + ", cvnEffectiveStartTime=" + cvnEffectiveStartTime + ", cvnEffectiveEndTime=" | |
146 | - + cvnEffectiveEndTime + ", isDefault=" + isDefault + "]"; | |
147 | - } | |
133 | + public int getIsDefault() { | |
134 | + return isDefault; | |
135 | + } | |
136 | + | |
137 | + public void setIsDefault(int isDefault) { | |
138 | + this.isDefault = isDefault; | |
139 | + } | |
140 | + | |
141 | + @Override | |
142 | + public String toString() { | |
143 | + return "Account [personId=" + personId + ", account=" + account + ", personName=" + personName + ", orgId=" + orgId + ", orgName=" + orgName | |
144 | + + ", isPassModi=" + isPassModi + ", passOverdue=" + passOverdue + ", cvnPassModiTime=" + cvnPassModiTime + ", cvnCreateTime=" | |
145 | + + cvnCreateTime + ", cvnModiTime=" + cvnModiTime + ", cvnEffectiveStartTime=" + cvnEffectiveStartTime + ", cvnEffectiveEndTime=" | |
146 | + + cvnEffectiveEndTime + ", isDefault=" + isDefault + "]"; | |
147 | + } | |
148 | 148 | } | ... | ... |
titan-api/src/main/java/com/diligrp/titan/common/HttpRequester.java
... | ... | @@ -12,218 +12,206 @@ import java.util.Vector; |
12 | 12 | |
13 | 13 | /** |
14 | 14 | * HTTP请求对象 |
15 | - * | |
15 | + * | |
16 | 16 | * @author dev-center |
17 | 17 | * @since 2014-05-10 |
18 | 18 | */ |
19 | 19 | public class HttpRequester { |
20 | - private String defaultContentEncoding; | |
21 | - | |
22 | - public HttpRequester() { | |
23 | - this.defaultContentEncoding = "UTF-8"; | |
24 | - } | |
25 | - | |
26 | - /** | |
27 | - * 发送GET请求 | |
28 | - * | |
29 | - * @param urlString | |
30 | - * URL地址 | |
31 | - * @return 响应对象 | |
32 | - * @throws IOException | |
33 | - */ | |
34 | - public HttpResponse sendGet(String urlString) throws IOException { | |
35 | - return this.send(urlString, "GET", null, null); | |
36 | - } | |
37 | - | |
38 | - /** | |
39 | - * 发送GET请求 | |
40 | - * | |
41 | - * @param urlString | |
42 | - * URL地址 | |
43 | - * @param params | |
44 | - * 参数集合 | |
45 | - * @return 响应对象 | |
46 | - * @throws IOException | |
47 | - */ | |
48 | - public HttpResponse sendGet(String urlString, Map<String, String> params) throws IOException { | |
49 | - return this.send(urlString, "GET", params, null); | |
50 | - } | |
51 | - | |
52 | - /** | |
53 | - * 发送GET请求 | |
54 | - * | |
55 | - * @param urlString | |
56 | - * URL地址 | |
57 | - * @param params | |
58 | - * 参数集合 | |
59 | - * @param propertys | |
60 | - * 请求属性 | |
61 | - * @return 响应对象 | |
62 | - * @throws IOException | |
63 | - */ | |
64 | - public HttpResponse sendGet(String urlString, Map<String, String> params, Map<String, String> propertys) throws IOException { | |
65 | - return this.send(urlString, "GET", params, propertys); | |
66 | - } | |
67 | - | |
68 | - /** | |
69 | - * 发送POST请求 | |
70 | - * | |
71 | - * @param urlString | |
72 | - * URL地址 | |
73 | - * @return 响应对象 | |
74 | - * @throws IOException | |
75 | - */ | |
76 | - public HttpResponse sendPost(String urlString) throws IOException { | |
77 | - return this.send(urlString, "POST", null, null); | |
78 | - } | |
79 | - | |
80 | - /** | |
81 | - * 发送POST请求 | |
82 | - * | |
83 | - * @param urlString | |
84 | - * URL地址 | |
85 | - * @param params | |
86 | - * 参数集合 | |
87 | - * @return 响应对象 | |
88 | - * @throws IOException | |
89 | - */ | |
90 | - public HttpResponse sendPost(String urlString, Map<String, String> params) throws IOException { | |
91 | - return this.send(urlString, "POST", params, null); | |
92 | - } | |
93 | - | |
94 | - /** | |
95 | - * 发送POST请求 | |
96 | - * | |
97 | - * @param urlString | |
98 | - * URL地址 | |
99 | - * @param params | |
100 | - * 参数集合 | |
101 | - * @param propertys | |
102 | - * 请求属性 | |
103 | - * @return 响应对象 | |
104 | - * @throws IOException | |
105 | - */ | |
106 | - public HttpResponse sendPost(String urlString, Map<String, String> params, Map<String, String> propertys) throws IOException { | |
107 | - return this.send(urlString, "POST", params, propertys); | |
108 | - } | |
109 | - | |
110 | - /** | |
111 | - * 发送HTTP请求 | |
112 | - * | |
113 | - * @param urlString | |
114 | - * @return 响映对象 | |
115 | - * @throws IOException | |
116 | - */ | |
117 | - private HttpResponse send(String urlString, String method, Map<String, String> parameters, Map<String, String> propertys) throws IOException { | |
118 | - HttpURLConnection urlConnection = null; | |
119 | - | |
120 | - if ("GET".equalsIgnoreCase(method) && parameters != null) { | |
121 | - StringBuffer param = new StringBuffer(); | |
122 | - int i = 0; | |
123 | - for (Map.Entry<String,String> entry : parameters.entrySet()) { | |
124 | - if (i == 0) | |
125 | - param.append("?"); | |
126 | - else | |
127 | - param.append("&"); | |
128 | - param.append(entry.getKey()).append("=").append(entry.getValue()); | |
129 | - i++; | |
130 | - } | |
131 | - urlString += param; | |
132 | - } | |
133 | - URL url = new URL(urlString); | |
134 | - urlConnection = (HttpURLConnection) url.openConnection(); | |
135 | - | |
136 | - urlConnection.setRequestMethod(method); | |
137 | - urlConnection.setDoOutput(true); | |
138 | - urlConnection.setDoInput(true); | |
139 | - urlConnection.setUseCaches(false); | |
140 | - | |
141 | - if (propertys != null) | |
142 | - for (Map.Entry<String,String> entry : propertys.entrySet()) { | |
143 | - urlConnection.addRequestProperty(entry.getKey(), entry.getValue()); | |
144 | - } | |
145 | - | |
146 | - if ("POST".equalsIgnoreCase(method) && parameters != null) { | |
147 | - StringBuffer param = new StringBuffer(); | |
148 | - for (Map.Entry<String,String> entry : parameters.entrySet()) { | |
149 | - param.append("&"); | |
150 | - param.append(entry.getKey()).append("=").append(entry.getValue()); | |
151 | - } | |
152 | - urlConnection.getOutputStream().write(param.toString().getBytes(Charset.forName(this.defaultContentEncoding))); | |
153 | - urlConnection.getOutputStream().flush(); | |
154 | - urlConnection.getOutputStream().close(); | |
155 | - } | |
156 | - | |
157 | - return this.makeContent(urlString, urlConnection); | |
158 | - } | |
159 | - | |
160 | - /** | |
161 | - * 得到响应对象 | |
162 | - * | |
163 | - * @param urlConnection | |
164 | - * @return 响应对象 | |
165 | - * @throws IOException | |
166 | - */ | |
167 | - private HttpResponse makeContent(String urlString, HttpURLConnection urlConnection) throws IOException { | |
168 | - HttpResponse httpResponser = new HttpResponse(); | |
169 | - try { | |
170 | - InputStream in = urlConnection.getInputStream(); | |
171 | - BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in,this.defaultContentEncoding)); | |
172 | - httpResponser.contentCollection = new Vector<String>(); | |
173 | - StringBuffer temp = new StringBuffer(); | |
174 | - String line = bufferedReader.readLine(); | |
175 | - while (line != null) { | |
176 | - httpResponser.contentCollection.add(line); | |
177 | - temp.append(line).append("\r\n"); | |
178 | - line = bufferedReader.readLine(); | |
179 | - } | |
180 | - bufferedReader.close(); | |
181 | - | |
182 | - String ecod = urlConnection.getContentEncoding(); | |
183 | - if (ecod == null) | |
184 | - ecod = this.defaultContentEncoding; | |
185 | - | |
186 | - httpResponser.urlString = urlString; | |
187 | - | |
188 | - httpResponser.defaultPort = urlConnection.getURL().getDefaultPort(); | |
189 | - httpResponser.file = urlConnection.getURL().getFile(); | |
190 | - httpResponser.host = urlConnection.getURL().getHost(); | |
191 | - httpResponser.path = urlConnection.getURL().getPath(); | |
192 | - httpResponser.port = urlConnection.getURL().getPort(); | |
193 | - httpResponser.protocol = urlConnection.getURL().getProtocol(); | |
194 | - httpResponser.query = urlConnection.getURL().getQuery(); | |
195 | - httpResponser.ref = urlConnection.getURL().getRef(); | |
196 | - httpResponser.userInfo = urlConnection.getURL().getUserInfo(); | |
197 | - | |
198 | - httpResponser.content = new String(temp.toString().getBytes(Charset.forName(this.defaultContentEncoding)), ecod); | |
199 | - httpResponser.contentEncoding = ecod; | |
200 | - httpResponser.code = urlConnection.getResponseCode(); | |
201 | - httpResponser.message = urlConnection.getResponseMessage(); | |
202 | - httpResponser.contentType = urlConnection.getContentType(); | |
203 | - httpResponser.method = urlConnection.getRequestMethod(); | |
204 | - httpResponser.connectTimeout = urlConnection.getConnectTimeout(); | |
205 | - httpResponser.readTimeout = urlConnection.getReadTimeout(); | |
206 | - | |
207 | - return httpResponser; | |
208 | - } catch (IOException e) { | |
209 | - throw e; | |
210 | - } finally { | |
211 | - if (urlConnection != null) | |
212 | - urlConnection.disconnect(); | |
213 | - } | |
214 | - } | |
215 | - | |
216 | - /** | |
217 | - * 默认的响应字符集 | |
218 | - */ | |
219 | - public String getDefaultContentEncoding() { | |
220 | - return this.defaultContentEncoding; | |
221 | - } | |
222 | - | |
223 | - /** | |
224 | - * 设置默认的响应字符集 | |
225 | - */ | |
226 | - public void setDefaultContentEncoding(String defaultContentEncoding) { | |
227 | - this.defaultContentEncoding = defaultContentEncoding; | |
228 | - } | |
20 | + private String defaultContentEncoding; | |
21 | + | |
22 | + public HttpRequester() { | |
23 | + this.defaultContentEncoding = "UTF-8"; | |
24 | + } | |
25 | + | |
26 | + /** | |
27 | + * 发送GET请求 | |
28 | + * | |
29 | + * @param urlString URL地址 | |
30 | + * @return 响应对象 | |
31 | + * @throws IOException | |
32 | + */ | |
33 | + public HttpResponse sendGet(String urlString) throws IOException { | |
34 | + return this.send(urlString, "GET", null, null); | |
35 | + } | |
36 | + | |
37 | + /** | |
38 | + * 发送GET请求 | |
39 | + * | |
40 | + * @param urlString URL地址 | |
41 | + * @param params 参数集合 | |
42 | + * @return 响应对象 | |
43 | + * @throws IOException | |
44 | + */ | |
45 | + public HttpResponse sendGet(String urlString, Map<String, String> params) throws IOException { | |
46 | + return this.send(urlString, "GET", params, null); | |
47 | + } | |
48 | + | |
49 | + /** | |
50 | + * 发送GET请求 | |
51 | + * | |
52 | + * @param urlString URL地址 | |
53 | + * @param params 参数集合 | |
54 | + * @param propertys 请求属性 | |
55 | + * @return 响应对象 | |
56 | + * @throws IOException | |
57 | + */ | |
58 | + public HttpResponse sendGet(String urlString, Map<String, String> params, Map<String, String> propertys) throws IOException { | |
59 | + return this.send(urlString, "GET", params, propertys); | |
60 | + } | |
61 | + | |
62 | + /** | |
63 | + * 发送POST请求 | |
64 | + * | |
65 | + * @param urlString URL地址 | |
66 | + * @return 响应对象 | |
67 | + * @throws IOException | |
68 | + */ | |
69 | + public HttpResponse sendPost(String urlString) throws IOException { | |
70 | + return this.send(urlString, "POST", null, null); | |
71 | + } | |
72 | + | |
73 | + /** | |
74 | + * 发送POST请求 | |
75 | + * | |
76 | + * @param urlString URL地址 | |
77 | + * @param params 参数集合 | |
78 | + * @return 响应对象 | |
79 | + * @throws IOException | |
80 | + */ | |
81 | + public HttpResponse sendPost(String urlString, Map<String, String> params) throws IOException { | |
82 | + return this.send(urlString, "POST", params, null); | |
83 | + } | |
84 | + | |
85 | + /** | |
86 | + * 发送POST请求 | |
87 | + * | |
88 | + * @param urlString URL地址 | |
89 | + * @param params 参数集合 | |
90 | + * @param propertys 请求属性 | |
91 | + * @return 响应对象 | |
92 | + * @throws IOException | |
93 | + */ | |
94 | + public HttpResponse sendPost(String urlString, Map<String, String> params, Map<String, String> propertys) throws IOException { | |
95 | + return this.send(urlString, "POST", params, propertys); | |
96 | + } | |
97 | + | |
98 | + /** | |
99 | + * 发送HTTP请求 | |
100 | + * | |
101 | + * @param urlString | |
102 | + * @return 响映对象 | |
103 | + * @throws IOException | |
104 | + */ | |
105 | + private HttpResponse send(String urlString, String method, Map<String, String> parameters, Map<String, String> propertys) throws IOException { | |
106 | + HttpURLConnection urlConnection = null; | |
107 | + | |
108 | + if ("GET".equalsIgnoreCase(method) && parameters != null) { | |
109 | + StringBuffer param = new StringBuffer(); | |
110 | + int i = 0; | |
111 | + for (Map.Entry<String, String> entry : parameters.entrySet()) { | |
112 | + if (i == 0) | |
113 | + param.append("?"); | |
114 | + else | |
115 | + param.append("&"); | |
116 | + param.append(entry.getKey()).append("=").append(entry.getValue()); | |
117 | + i++; | |
118 | + } | |
119 | + urlString += param; | |
120 | + } | |
121 | + URL url = new URL(urlString); | |
122 | + urlConnection = (HttpURLConnection) url.openConnection(); | |
123 | + | |
124 | + urlConnection.setRequestMethod(method); | |
125 | + urlConnection.setDoOutput(true); | |
126 | + urlConnection.setDoInput(true); | |
127 | + urlConnection.setUseCaches(false); | |
128 | + | |
129 | + if (propertys != null) | |
130 | + for (Map.Entry<String, String> entry : propertys.entrySet()) { | |
131 | + urlConnection.addRequestProperty(entry.getKey(), entry.getValue()); | |
132 | + } | |
133 | + | |
134 | + if ("POST".equalsIgnoreCase(method) && parameters != null) { | |
135 | + StringBuffer param = new StringBuffer(); | |
136 | + for (Map.Entry<String, String> entry : parameters.entrySet()) { | |
137 | + param.append("&"); | |
138 | + param.append(entry.getKey()).append("=").append(entry.getValue()); | |
139 | + } | |
140 | + urlConnection.getOutputStream().write(param.toString().getBytes(Charset.forName(this.defaultContentEncoding))); | |
141 | + urlConnection.getOutputStream().flush(); | |
142 | + urlConnection.getOutputStream().close(); | |
143 | + } | |
144 | + | |
145 | + return this.makeContent(urlString, urlConnection); | |
146 | + } | |
147 | + | |
148 | + /** | |
149 | + * 得到响应对象 | |
150 | + * | |
151 | + * @param urlConnection | |
152 | + * @return 响应对象 | |
153 | + * @throws IOException | |
154 | + */ | |
155 | + private HttpResponse makeContent(String urlString, HttpURLConnection urlConnection) throws IOException { | |
156 | + HttpResponse httpResponser = new HttpResponse(); | |
157 | + try { | |
158 | + InputStream in = urlConnection.getInputStream(); | |
159 | + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in, this.defaultContentEncoding)); | |
160 | + httpResponser.contentCollection = new Vector<String>(); | |
161 | + StringBuffer temp = new StringBuffer(); | |
162 | + String line = bufferedReader.readLine(); | |
163 | + while (line != null) { | |
164 | + httpResponser.contentCollection.add(line); | |
165 | + temp.append(line).append("\r\n"); | |
166 | + line = bufferedReader.readLine(); | |
167 | + } | |
168 | + bufferedReader.close(); | |
169 | + | |
170 | + String ecod = urlConnection.getContentEncoding(); | |
171 | + if (ecod == null) | |
172 | + ecod = this.defaultContentEncoding; | |
173 | + | |
174 | + httpResponser.urlString = urlString; | |
175 | + | |
176 | + httpResponser.defaultPort = urlConnection.getURL().getDefaultPort(); | |
177 | + httpResponser.file = urlConnection.getURL().getFile(); | |
178 | + httpResponser.host = urlConnection.getURL().getHost(); | |
179 | + httpResponser.path = urlConnection.getURL().getPath(); | |
180 | + httpResponser.port = urlConnection.getURL().getPort(); | |
181 | + httpResponser.protocol = urlConnection.getURL().getProtocol(); | |
182 | + httpResponser.query = urlConnection.getURL().getQuery(); | |
183 | + httpResponser.ref = urlConnection.getURL().getRef(); | |
184 | + httpResponser.userInfo = urlConnection.getURL().getUserInfo(); | |
185 | + | |
186 | + httpResponser.content = new String(temp.toString().getBytes(Charset.forName(this.defaultContentEncoding)), ecod); | |
187 | + httpResponser.contentEncoding = ecod; | |
188 | + httpResponser.code = urlConnection.getResponseCode(); | |
189 | + httpResponser.message = urlConnection.getResponseMessage(); | |
190 | + httpResponser.contentType = urlConnection.getContentType(); | |
191 | + httpResponser.method = urlConnection.getRequestMethod(); | |
192 | + httpResponser.connectTimeout = urlConnection.getConnectTimeout(); | |
193 | + httpResponser.readTimeout = urlConnection.getReadTimeout(); | |
194 | + | |
195 | + return httpResponser; | |
196 | + } catch (IOException e) { | |
197 | + throw e; | |
198 | + } finally { | |
199 | + if (urlConnection != null) | |
200 | + urlConnection.disconnect(); | |
201 | + } | |
202 | + } | |
203 | + | |
204 | + /** | |
205 | + * 默认的响应字符集 | |
206 | + */ | |
207 | + public String getDefaultContentEncoding() { | |
208 | + return this.defaultContentEncoding; | |
209 | + } | |
210 | + | |
211 | + /** | |
212 | + * 设置默认的响应字符集 | |
213 | + */ | |
214 | + public void setDefaultContentEncoding(String defaultContentEncoding) { | |
215 | + this.defaultContentEncoding = defaultContentEncoding; | |
216 | + } | |
229 | 217 | } | ... | ... |
titan-api/src/main/java/com/diligrp/titan/common/HttpResponse.java
... | ... | @@ -3,125 +3,123 @@ package com.diligrp.titan.common; |
3 | 3 | import java.util.Vector; |
4 | 4 | |
5 | 5 | /** |
6 | - * | |
7 | - * | |
8 | 6 | * @author dev-center |
9 | 7 | * @since 2014-05-10 |
10 | 8 | */ |
11 | 9 | public class HttpResponse { |
12 | 10 | |
13 | - String urlString; | |
11 | + String urlString; | |
14 | 12 | |
15 | - int defaultPort; | |
13 | + int defaultPort; | |
16 | 14 | |
17 | - String file; | |
15 | + String file; | |
18 | 16 | |
19 | - String host; | |
17 | + String host; | |
20 | 18 | |
21 | - String path; | |
19 | + String path; | |
22 | 20 | |
23 | - int port; | |
21 | + int port; | |
24 | 22 | |
25 | - String protocol; | |
23 | + String protocol; | |
26 | 24 | |
27 | - String query; | |
25 | + String query; | |
28 | 26 | |
29 | - String ref; | |
27 | + String ref; | |
30 | 28 | |
31 | - String userInfo; | |
29 | + String userInfo; | |
32 | 30 | |
33 | - String contentEncoding; | |
31 | + String contentEncoding; | |
34 | 32 | |
35 | - String content; | |
33 | + String content; | |
36 | 34 | |
37 | - String contentType; | |
35 | + String contentType; | |
38 | 36 | |
39 | - int code; | |
37 | + int code; | |
40 | 38 | |
41 | - String message; | |
39 | + String message; | |
42 | 40 | |
43 | - String method; | |
41 | + String method; | |
44 | 42 | |
45 | - int connectTimeout; | |
43 | + int connectTimeout; | |
46 | 44 | |
47 | - int readTimeout; | |
45 | + int readTimeout; | |
48 | 46 | |
49 | - Vector<String> contentCollection; | |
47 | + Vector<String> contentCollection; | |
50 | 48 | |
51 | - public String getContent() { | |
52 | - return content; | |
53 | - } | |
49 | + public String getContent() { | |
50 | + return content; | |
51 | + } | |
54 | 52 | |
55 | - public String getContentType() { | |
56 | - return contentType; | |
57 | - } | |
53 | + public String getContentType() { | |
54 | + return contentType; | |
55 | + } | |
58 | 56 | |
59 | - public int getCode() { | |
60 | - return code; | |
61 | - } | |
57 | + public int getCode() { | |
58 | + return code; | |
59 | + } | |
62 | 60 | |
63 | - public String getMessage() { | |
64 | - return message; | |
65 | - } | |
61 | + public String getMessage() { | |
62 | + return message; | |
63 | + } | |
66 | 64 | |
67 | - public Vector<String> getContentCollection() { | |
68 | - return contentCollection; | |
69 | - } | |
65 | + public Vector<String> getContentCollection() { | |
66 | + return contentCollection; | |
67 | + } | |
70 | 68 | |
71 | - public String getContentEncoding() { | |
72 | - return contentEncoding; | |
73 | - } | |
69 | + public String getContentEncoding() { | |
70 | + return contentEncoding; | |
71 | + } | |
74 | 72 | |
75 | - public String getMethod() { | |
76 | - return method; | |
77 | - } | |
73 | + public String getMethod() { | |
74 | + return method; | |
75 | + } | |
78 | 76 | |
79 | - public int getConnectTimeout() { | |
80 | - return connectTimeout; | |
81 | - } | |
77 | + public int getConnectTimeout() { | |
78 | + return connectTimeout; | |
79 | + } | |
82 | 80 | |
83 | - public int getReadTimeout() { | |
84 | - return readTimeout; | |
85 | - } | |
81 | + public int getReadTimeout() { | |
82 | + return readTimeout; | |
83 | + } | |
86 | 84 | |
87 | - public String getUrlString() { | |
88 | - return urlString; | |
89 | - } | |
85 | + public String getUrlString() { | |
86 | + return urlString; | |
87 | + } | |
90 | 88 | |
91 | - public int getDefaultPort() { | |
92 | - return defaultPort; | |
93 | - } | |
89 | + public int getDefaultPort() { | |
90 | + return defaultPort; | |
91 | + } | |
94 | 92 | |
95 | - public String getFile() { | |
96 | - return file; | |
97 | - } | |
93 | + public String getFile() { | |
94 | + return file; | |
95 | + } | |
98 | 96 | |
99 | - public String getHost() { | |
100 | - return host; | |
101 | - } | |
97 | + public String getHost() { | |
98 | + return host; | |
99 | + } | |
102 | 100 | |
103 | - public String getPath() { | |
104 | - return path; | |
105 | - } | |
101 | + public String getPath() { | |
102 | + return path; | |
103 | + } | |
106 | 104 | |
107 | - public int getPort() { | |
108 | - return port; | |
109 | - } | |
105 | + public int getPort() { | |
106 | + return port; | |
107 | + } | |
110 | 108 | |
111 | - public String getProtocol() { | |
112 | - return protocol; | |
113 | - } | |
109 | + public String getProtocol() { | |
110 | + return protocol; | |
111 | + } | |
114 | 112 | |
115 | - public String getQuery() { | |
116 | - return query; | |
117 | - } | |
113 | + public String getQuery() { | |
114 | + return query; | |
115 | + } | |
118 | 116 | |
119 | - public String getRef() { | |
120 | - return ref; | |
121 | - } | |
117 | + public String getRef() { | |
118 | + return ref; | |
119 | + } | |
122 | 120 | |
123 | - public String getUserInfo() { | |
124 | - return userInfo; | |
125 | - } | |
121 | + public String getUserInfo() { | |
122 | + return userInfo; | |
123 | + } | |
126 | 124 | |
127 | 125 | } | ... | ... |
titan-api/src/main/java/com/diligrp/titan/common/ProductStatus.java
... | ... | @@ -2,99 +2,27 @@ package com.diligrp.titan.common; |
2 | 2 | |
3 | 3 | public class ProductStatus { |
4 | 4 | |
5 | - /** | |
6 | - * 第三方销售 | |
7 | - */ | |
8 | - public static final String SALE_TYPE_POP = "30"; | |
9 | 5 | |
10 | - /** | |
11 | - * 第三方商品 | |
12 | - */ | |
13 | - public static final int PRODUCT_POP = 1; | |
14 | 6 | |
15 | - /** | |
16 | - * 商品预览状态 | |
17 | - */ | |
18 | - public static final int PRODUCT_PREVIEW = -2; | |
19 | 7 | |
20 | - /** | |
21 | - * 商品删除状态 | |
22 | - */ | |
23 | - public static final int PRODUCT_DELETED = -1; | |
8 | + /** | |
9 | + * 商品删除状态 | |
10 | + */ | |
11 | + public static final int PRODUCT_DELETED = -1; | |
24 | 12 | |
25 | - /** | |
26 | - * 新建待审核商品 | |
27 | - */ | |
28 | - public static final int PRODUCT_NEW = 1; | |
29 | 13 | |
30 | - /** | |
31 | - * 审核失败商品 | |
32 | - */ | |
33 | - public static final int PRODUCT_DENIED = 2; | |
34 | 14 | |
35 | - /** | |
36 | - * 在架商品,在售商品 | |
37 | - */ | |
38 | - public static final int PRODUCT_ONSALE = 3; | |
15 | + /** | |
16 | + * 在架商品,在售商品 | |
17 | + */ | |
18 | + public static final int PRODUCT_ONSALE = 3; | |
39 | 19 | |
40 | - /** | |
41 | - * 在仓库中的商品,审核后直接放入仓库的商品 | |
42 | - */ | |
43 | - public static final int PRODUCT_IN_WAREHOUSE = 4; | |
44 | - /** | |
45 | - * 等待上架的商品 | |
46 | - */ | |
47 | - public static final int PRODUCT_WAITING_ONSALE = 5; | |
48 | - /** | |
49 | - * 过期下架的商品 | |
50 | - */ | |
51 | - public static final int PRODUCT_OVERDUE_DROPS = 6; | |
52 | - /** | |
53 | - * 手动下架 | |
54 | - */ | |
55 | - public static final int PRODUCT_MANUALLY_DROPS = 7; | |
20 | + /** | |
21 | + * 下架商品 | |
22 | + */ | |
23 | + public static final int PRODUCT_OFFSALE = 4; | |
56 | 24 | |
57 | - /** | |
58 | - * 放入仓库 | |
59 | - */ | |
60 | - public static final int PRODUCT_PUBLISH_WAREHOUSE = 1; | |
61 | - /** | |
62 | - * 立即上架 | |
63 | - */ | |
64 | - public static final int PRODUCT_PUBLISH_IMMEDIATELY = 2; | |
65 | - /** | |
66 | - * 指定时间上架 | |
67 | - */ | |
68 | - public static final int PRODUCT_PUBLISH_SPECIFY_TIME = 3; | |
69 | - | |
70 | - /** | |
71 | - * 非价格区间商品 | |
72 | - */ | |
73 | - public static final int PRODUCT_QUOTATION_FALSE=1; | |
74 | - | |
75 | - /** | |
76 | - * 价格区间的商品 | |
77 | - */ | |
78 | - public static final int PRODUCT_QUOTATION_TRUE=2; | |
79 | 25 | |
80 | - /** | |
81 | - * 普通商品 | |
82 | - */ | |
83 | - public static final int PRODUCT_TYPE_GROUP_BUYING=0; | |
84 | 26 | |
85 | - /** | |
86 | - * 拼购商品 | |
87 | - */ | |
88 | - public static final int PRODUCT_TYPE_NOGROUP_BUYING=1; | |
89 | - | |
90 | - /** | |
91 | - * 无样品 | |
92 | - */ | |
93 | - public static final int PRODUCT_IS_AMPLE=0; | |
94 | - | |
95 | - /** | |
96 | - * 有样品 | |
97 | - */ | |
98 | - public static final int PRODUCT_ISNO_AMPLE=1; | |
99 | 27 | |
100 | 28 | } | ... | ... |
titan-api/src/main/java/com/diligrp/titan/common/datasource/DataSourceAspect.java deleted
100755 → 0
1 | -package com.diligrp.titan.common.datasource; | |
2 | - | |
3 | -import org.aspectj.lang.ProceedingJoinPoint; | |
4 | -import org.aspectj.lang.reflect.MethodSignature; | |
5 | -import org.slf4j.Logger; | |
6 | -import org.slf4j.LoggerFactory; | |
7 | -import org.springframework.transaction.annotation.Transactional; | |
8 | - | |
9 | -import java.lang.reflect.Method; | |
10 | - | |
11 | -/** | |
12 | - * <p>Title: 〈标题〉</p> | |
13 | - * <p>Description: 〈描述〉</p> | |
14 | - * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. <br /> | |
15 | - * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | |
16 | - * <B>Company</B> 地利集团 | |
17 | - * <p>CreateTime:2015/4/20</p> | |
18 | - * | |
19 | - * @author gongsz | |
20 | - */ | |
21 | -public class DataSourceAspect { | |
22 | - | |
23 | - private Integer mastersCount = 0 ; | |
24 | - private static final Logger log = LoggerFactory.getLogger(DataSourceAspect.class); | |
25 | - private static final ThreadLocal<Boolean> CONTEX_THOLDER = new ThreadLocal<Boolean>(){ | |
26 | - @Override | |
27 | - protected Boolean initialValue() { | |
28 | - return false; | |
29 | - } | |
30 | - }; | |
31 | - | |
32 | - private static final ThreadLocal<Method> CONTEX = new ThreadLocal<Method>(); | |
33 | - | |
34 | - public Object around(ProceedingJoinPoint pjp)throws Throwable{ | |
35 | - Method method = ((MethodSignature) pjp.getSignature()).getMethod(); | |
36 | - if(method == null ){ | |
37 | - return pjp.proceed(); | |
38 | - } | |
39 | - log.debug("before:" + method.getName()); | |
40 | - if (CONTEX.get() == null) { | |
41 | - log.debug("before:" + method.getName()); | |
42 | - CONTEX.set(method); | |
43 | - } | |
44 | - if (!CONTEX_THOLDER.get()) { | |
45 | - if (method.isAnnotationPresent(Transactional.class)) { | |
46 | - String lookUpKey = DataSourceSwitcher.WRITE + (DataSourceSwitcher.RANDOM.nextInt(mastersCount) + 1); | |
47 | - log.info("Aspect获取数据源" + lookUpKey); | |
48 | - DataSourceSwitcher.setDataSource(lookUpKey); | |
49 | - CONTEX_THOLDER.set(true); | |
50 | - } else { | |
51 | - DataSourceSwitcher.setDataSource(DataSourceSwitcher.READ); | |
52 | - } | |
53 | - } | |
54 | - Object val = pjp.proceed(); | |
55 | - if (CONTEX.get() == method) { | |
56 | - CONTEX.set(null); | |
57 | - CONTEX_THOLDER.set(false); | |
58 | - log.debug("after:" + method.getName()); | |
59 | - } | |
60 | - log.debug("after:" + method.getName()); | |
61 | - return val; | |
62 | - } | |
63 | - | |
64 | - public Integer getMastersCount() { | |
65 | - return mastersCount; | |
66 | - } | |
67 | - | |
68 | - public void setMastersCount(Integer mastersCount) { | |
69 | - this.mastersCount = mastersCount; | |
70 | - } | |
71 | -} |
titan-api/src/main/java/com/diligrp/titan/common/datasource/DataSourceSwitcher.java deleted
100755 → 0
1 | -package com.diligrp.titan.common.datasource; | |
2 | - | |
3 | -import org.springframework.util.Assert; | |
4 | - | |
5 | -import java.util.Random; | |
6 | - | |
7 | -/** | |
8 | - * 数据源切换. | |
9 | - * @author zhoumin@360buy.com | |
10 | - * 2011-9-13 下午6:11:40 | |
11 | - */ | |
12 | -public class DataSourceSwitcher { | |
13 | - | |
14 | - // 读库数量 | |
15 | - public static final String READ = "slave"; | |
16 | - public static final String WRITE = "master"; | |
17 | - | |
18 | - public static final Random RANDOM = new Random(17); | |
19 | - | |
20 | - private static final ThreadLocal<String> CONTEX_THOLDER = new ThreadLocal<String>(); | |
21 | - | |
22 | - public static void setDataSource(String dataSource) { | |
23 | - Assert.notNull(dataSource, "dataSource cannot be null"); | |
24 | - CONTEX_THOLDER.set(dataSource); | |
25 | - } | |
26 | - | |
27 | - public static String getDataSource() { | |
28 | - return CONTEX_THOLDER.get(); | |
29 | - } | |
30 | -} |
titan-api/src/main/java/com/diligrp/titan/common/datasource/DynamicDataSource.java deleted
100755 → 0
1 | -package com.diligrp.titan.common.datasource; | |
2 | - | |
3 | -import org.apache.commons.lang.StringUtils; | |
4 | -import org.slf4j.Logger; | |
5 | -import org.slf4j.LoggerFactory; | |
6 | -import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; | |
7 | - | |
8 | -import javax.annotation.PostConstruct; | |
9 | -import javax.sql.DataSource; | |
10 | -import java.util.HashMap; | |
11 | -import java.util.Map; | |
12 | - | |
13 | -/** | |
14 | - * 动态数据源. | |
15 | - * @author zhoumin@360buy.com | |
16 | - * 2011-9-13 下午6:12:18 | |
17 | - */ | |
18 | -public class DynamicDataSource extends AbstractRoutingDataSource { | |
19 | - private Map<String, DataSource> masterDataSources; | |
20 | - private Map<String, DataSource> slaveDataSources; | |
21 | - private static final Logger log = LoggerFactory.getLogger(DynamicDataSource.class); | |
22 | - @PostConstruct | |
23 | - public void setTargetDataSources() { | |
24 | - Map<Object, Object> allDataSource = new HashMap<Object, Object>(); | |
25 | - if (masterDataSources != null) { | |
26 | - allDataSource.putAll(masterDataSources); | |
27 | - } | |
28 | - if (masterDataSources != null) { | |
29 | - allDataSource.putAll(slaveDataSources); | |
30 | - } | |
31 | - super.setTargetDataSources(allDataSource); | |
32 | - } | |
33 | - | |
34 | - @Override | |
35 | - protected Object determineCurrentLookupKey() { | |
36 | - String lookupKey = DataSourceSwitcher.getDataSource(); | |
37 | - if(StringUtils.isNotEmpty(lookupKey) && lookupKey.indexOf(DataSourceSwitcher.READ)>=0){ | |
38 | - lookupKey = DataSourceSwitcher.READ+(DataSourceSwitcher.RANDOM.nextInt(slaveDataSources.size()) + 1); | |
39 | - } | |
40 | - log.debug("获取数据源" + lookupKey); | |
41 | - return lookupKey; | |
42 | - } | |
43 | - | |
44 | - public Map<String, DataSource> getMasterDataSources() { | |
45 | - return masterDataSources; | |
46 | - } | |
47 | - | |
48 | - public void setMasterDataSources(Map<String, DataSource> masterDataSources) { | |
49 | - this.masterDataSources = masterDataSources; | |
50 | - } | |
51 | - | |
52 | - public Map<String, DataSource> getSlaveDataSources() { | |
53 | - return slaveDataSources; | |
54 | - } | |
55 | - | |
56 | - public void setSlaveDataSources(Map<String, DataSource> slaveDataSources) { | |
57 | - this.slaveDataSources = slaveDataSources; | |
58 | - } | |
59 | -} |
titan-api/src/main/java/com/diligrp/titan/common/datasource/DynamicSource.java deleted
100755 → 0
1 | -package com.diligrp.titan.common.datasource; | |
2 | - | |
3 | -import java.lang.annotation.*; | |
4 | - | |
5 | -/** | |
6 | - * <p>Title: 〈标题〉</p> | |
7 | - * <p>Description: 〈描述〉</p> | |
8 | - * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. <br /> | |
9 | - * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | |
10 | - * <B>Company</B> 地利集团 | |
11 | - * <p>CreateTime:2015/4/20</p> | |
12 | - * | |
13 | - * @author gongsz | |
14 | - */ | |
15 | -@Target({ ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIME) @Inherited | |
16 | -public @interface DynamicSource { | |
17 | -} | |
18 | 0 | \ No newline at end of file |
titan-api/src/main/java/com/diligrp/titan/common/exception/AppException.java
... | ... | @@ -6,24 +6,26 @@ package com.diligrp.titan.common.exception; |
6 | 6 | |
7 | 7 | /** |
8 | 8 | * AppException |
9 | + * | |
9 | 10 | * @author dev-center |
10 | 11 | * @since 2014-05-10 |
11 | 12 | */ |
12 | -public class AppException extends RuntimeException{ | |
13 | - private static final long serialVersionUID = 1L; | |
14 | - public AppException() { | |
15 | - super(); | |
16 | - } | |
17 | - | |
18 | - public AppException(String message) { | |
19 | - super(message); | |
20 | - } | |
21 | - | |
22 | - public AppException(String message, Throwable cause) { | |
23 | - super(message, cause); | |
24 | - } | |
25 | - | |
26 | - public AppException(Throwable cause) { | |
27 | - super(cause); | |
28 | - } | |
13 | +public class AppException extends RuntimeException { | |
14 | + private static final long serialVersionUID = 1L; | |
15 | + | |
16 | + public AppException() { | |
17 | + super(); | |
18 | + } | |
19 | + | |
20 | + public AppException(String message) { | |
21 | + super(message); | |
22 | + } | |
23 | + | |
24 | + public AppException(String message, Throwable cause) { | |
25 | + super(message, cause); | |
26 | + } | |
27 | + | |
28 | + public AppException(Throwable cause) { | |
29 | + super(cause); | |
30 | + } | |
29 | 31 | } | ... | ... |
titan-api/src/main/java/com/diligrp/titan/common/exception/TitanError.java
... | ... | @@ -2,70 +2,70 @@ package com.diligrp.titan.common.exception; |
2 | 2 | |
3 | 3 | public final class TitanError extends Exception { |
4 | 4 | |
5 | - /** | |
6 | - * | |
5 | + /** | |
6 | + * | |
7 | 7 | */ |
8 | - private static final long serialVersionUID = 1L; | |
9 | - private int code; | |
10 | - private String result; | |
11 | - | |
12 | - public TitanError(int code, String result) { | |
13 | - super(); | |
14 | - this.code = code; | |
15 | - this.result = result; | |
16 | - } | |
17 | - | |
18 | - public final static TitanError DEFAULT_ERROR = new TitanError(0, "请求失败"); | |
19 | - | |
20 | - // 输入错误 | |
21 | - public final static TitanError JSON_CONVERT_ERROR = new TitanError(10, "JSON转换失败,请检查输入参数"); | |
22 | - public final static TitanError JSON_FORMAT_ERROR = new TitanError(11, "JSON格式错误"); | |
23 | - public final static TitanError NULL_PARAM_ERROR = new TitanError(12, "输入参数为空"); | |
24 | - public final static TitanError INVALID_PARAM_ERROR = new TitanError(13, "输入参数不正确"); | |
25 | - | |
26 | - public final static TitanError READ_BODY_ERROR = new TitanError(20, "读取请求内容失败"); | |
27 | - | |
28 | - /*** 业务错误 **/ | |
29 | - // 库存错误 | |
30 | - public final static TitanError LOW_STOCKS = new TitanError(30, "库存不足"); | |
31 | - public final static TitanError DUPLICATE_DECRASE = new TitanError(31, "重复扣减库存"); | |
32 | - public final static TitanError DUPLICATE_INCRASE = new TitanError(31, "重复增加库存"); | |
33 | - | |
34 | - public final static TitanError UPDATE_STATE_ERROR = new TitanError(33, "更新数据失败!"); | |
35 | - | |
36 | - public final static TitanError NOT_FOUND_CATEGORY = new TitanError(35, "没有找到该类目!"); | |
37 | - public final static TitanError CATEGORY_HAS_CHILD = new TitanError(36, "该类目不是最后一级!"); | |
38 | - public final static TitanError CATEGORY_STATE_ERROR = new TitanError(37, "该类目状态不正确!"); | |
39 | - | |
40 | - public final static TitanError SUPPLY_STATE_SHUT = new TitanError(38, "供应单已经关闭!"); | |
41 | - public final static TitanError NOT_FOUND_SUPPLY = new TitanError(39, "没有找到对应的供应单!"); | |
42 | - public final static TitanError SUPPLY_ALREADY_INQUIRY = new TitanError(40, "供应单已经询价!"); | |
43 | - | |
44 | - public final static TitanError PURCHASE_STATE_SHUT = new TitanError(41, "求购单已经关闭!"); | |
45 | - public final static TitanError NOT_FOUND_PURCHASE = new TitanError(42, "没有找到对应的求购单!"); | |
46 | - public final static TitanError PURCHASE_ALREADY_INQUIRY = new TitanError(43, "求购单已经报价!"); | |
47 | - | |
48 | - public final static TitanError NOT_OPERATION_DATA = new TitanError(43, "没有权限操作此数据!"); | |
49 | - | |
50 | - public int getCode() { | |
51 | - return code; | |
52 | - } | |
53 | - | |
54 | - public void setCode(int code) { | |
55 | - this.code = code; | |
56 | - } | |
57 | - | |
58 | - public String getResult() { | |
59 | - return result; | |
60 | - } | |
61 | - | |
62 | - public void setResult(String result) { | |
63 | - this.result = result; | |
64 | - } | |
65 | - | |
66 | - @Override | |
67 | - public String getMessage() { | |
68 | - return this.getResult(); | |
69 | - } | |
8 | + private static final long serialVersionUID = 1L; | |
9 | + private int code; | |
10 | + private String result; | |
11 | + | |
12 | + public TitanError(int code, String result) { | |
13 | + super(); | |
14 | + this.code = code; | |
15 | + this.result = result; | |
16 | + } | |
17 | + | |
18 | + public final static TitanError DEFAULT_ERROR = new TitanError(0, "请求失败"); | |
19 | + | |
20 | + // 输入错误 | |
21 | + public final static TitanError JSON_CONVERT_ERROR = new TitanError(10, "JSON转换失败,请检查输入参数"); | |
22 | + public final static TitanError JSON_FORMAT_ERROR = new TitanError(11, "JSON格式错误"); | |
23 | + public final static TitanError NULL_PARAM_ERROR = new TitanError(12, "输入参数为空"); | |
24 | + public final static TitanError INVALID_PARAM_ERROR = new TitanError(13, "输入参数不正确"); | |
25 | + | |
26 | + public final static TitanError READ_BODY_ERROR = new TitanError(20, "读取请求内容失败"); | |
27 | + | |
28 | + /*** 业务错误 **/ | |
29 | + // 库存错误 | |
30 | + public final static TitanError LOW_STOCKS = new TitanError(30, "库存不足"); | |
31 | + public final static TitanError DUPLICATE_DECRASE = new TitanError(31, "重复扣减库存"); | |
32 | + public final static TitanError DUPLICATE_INCRASE = new TitanError(31, "重复增加库存"); | |
33 | + | |
34 | + public final static TitanError UPDATE_STATE_ERROR = new TitanError(33, "更新数据失败!"); | |
35 | + | |
36 | + public final static TitanError NOT_FOUND_CATEGORY = new TitanError(35, "没有找到该类目!"); | |
37 | + public final static TitanError CATEGORY_HAS_CHILD = new TitanError(36, "该类目不是最后一级!"); | |
38 | + public final static TitanError CATEGORY_STATE_ERROR = new TitanError(37, "该类目状态不正确!"); | |
39 | + | |
40 | + public final static TitanError SUPPLY_STATE_SHUT = new TitanError(38, "供应单已经关闭!"); | |
41 | + public final static TitanError NOT_FOUND_SUPPLY = new TitanError(39, "没有找到对应的供应单!"); | |
42 | + public final static TitanError SUPPLY_ALREADY_INQUIRY = new TitanError(40, "供应单已经询价!"); | |
43 | + | |
44 | + public final static TitanError PURCHASE_STATE_SHUT = new TitanError(41, "求购单已经关闭!"); | |
45 | + public final static TitanError NOT_FOUND_PURCHASE = new TitanError(42, "没有找到对应的求购单!"); | |
46 | + public final static TitanError PURCHASE_ALREADY_INQUIRY = new TitanError(43, "求购单已经报价!"); | |
47 | + | |
48 | + public final static TitanError NOT_OPERATION_DATA = new TitanError(43, "没有权限操作此数据!"); | |
49 | + | |
50 | + public int getCode() { | |
51 | + return code; | |
52 | + } | |
53 | + | |
54 | + public void setCode(int code) { | |
55 | + this.code = code; | |
56 | + } | |
57 | + | |
58 | + public String getResult() { | |
59 | + return result; | |
60 | + } | |
61 | + | |
62 | + public void setResult(String result) { | |
63 | + this.result = result; | |
64 | + } | |
65 | + | |
66 | + @Override | |
67 | + public String getMessage() { | |
68 | + return this.getResult(); | |
69 | + } | |
70 | 70 | |
71 | 71 | } | ... | ... |
titan-api/src/main/java/com/diligrp/titan/common/log/LogBusinessIdUtils.java
... | ... | @@ -6,29 +6,31 @@ import java.util.UUID; |
6 | 6 | |
7 | 7 | /** |
8 | 8 | * 用于设置线程的UUID,用于打印日志 |
9 | - * @author cdwangyong3 | |
10 | 9 | * |
10 | + * @author cdwangyong3 | |
11 | 11 | */ |
12 | 12 | public class LogBusinessIdUtils { |
13 | - private static final ThreadLocal<String> businessLocal = new ThreadLocal<String>(); | |
13 | + private static final ThreadLocal<String> businessLocal = new ThreadLocal<String>(); | |
14 | + | |
14 | 15 | /** |
15 | 16 | * 返回当前线程对应的uuid |
17 | + * | |
16 | 18 | * @return |
17 | 19 | */ |
18 | - public static String getCurBusinessId(){ | |
20 | + public static String getCurBusinessId() { | |
19 | 21 | String uuid = businessLocal.get(); |
20 | - if(StringUtils.isEmpty(uuid)){ | |
22 | + if (StringUtils.isEmpty(uuid)) { | |
21 | 23 | uuid = UUID.randomUUID().toString().replace("-", ""); |
22 | 24 | businessLocal.set(uuid); |
23 | 25 | } |
24 | 26 | return uuid; |
25 | 27 | } |
26 | - | |
27 | - | |
28 | + | |
29 | + | |
28 | 30 | /** |
29 | 31 | * 给当前线程重新设置 |
30 | 32 | */ |
31 | - public static void clear(){ | |
33 | + public static void clear() { | |
32 | 34 | businessLocal.set(null); |
33 | 35 | } |
34 | 36 | } | ... | ... |
titan-api/src/main/java/com/diligrp/titan/common/log/LogHelper.java
... | ... | @@ -26,7 +26,6 @@ public class LogHelper { |
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
29 | - * | |
30 | 29 | * @param str |
31 | 30 | * @return |
32 | 31 | */ |
... | ... | @@ -41,7 +40,7 @@ public class LogHelper { |
41 | 40 | |
42 | 41 | /** |
43 | 42 | * 使用默认的文件记录debug信息 |
44 | - * | |
43 | + * | |
45 | 44 | * @param str 日志信息 |
46 | 45 | */ |
47 | 46 | public static void debug(String str, Object... args) { |
... | ... | @@ -50,7 +49,7 @@ public class LogHelper { |
50 | 49 | |
51 | 50 | /** |
52 | 51 | * 使用默认的文件记录info信息 |
53 | - * | |
52 | + * | |
54 | 53 | * @param str 日志信息 |
55 | 54 | */ |
56 | 55 | public static void info(String str, Object... args) { |
... | ... | @@ -59,7 +58,7 @@ public class LogHelper { |
59 | 58 | |
60 | 59 | /** |
61 | 60 | * 使用默认的文件记录warn信息 |
62 | - * | |
61 | + * | |
63 | 62 | * @param str 日志信息 |
64 | 63 | */ |
65 | 64 | public static void warn(String str, Object... args) { |
... | ... | @@ -68,7 +67,7 @@ public class LogHelper { |
68 | 67 | |
69 | 68 | /** |
70 | 69 | * 使用默认的文件记录error信息 |
71 | - * | |
70 | + * | |
72 | 71 | * @param str 日志信息 |
73 | 72 | */ |
74 | 73 | public static void error(Throwable e, String str, Object... args) { |
... | ... | @@ -77,7 +76,7 @@ public class LogHelper { |
77 | 76 | |
78 | 77 | /** |
79 | 78 | * 记录运行期错误信息 |
80 | - * | |
79 | + * | |
81 | 80 | * @param e |
82 | 81 | */ |
83 | 82 | public static void execption(Throwable e) { |
... | ... | @@ -86,7 +85,7 @@ public class LogHelper { |
86 | 85 | |
87 | 86 | /** |
88 | 87 | * 打印错误信息 |
89 | - * | |
88 | + * | |
90 | 89 | * @param e |
91 | 90 | * @return |
92 | 91 | */ |
... | ... | @@ -110,8 +109,8 @@ public class LogHelper { |
110 | 109 | |
111 | 110 | /** |
112 | 111 | * 日志消息占位符形式的替换,按照传入参数依次替换"{}" |
113 | - * | |
114 | - * @param str 带占位符的日志消息 | |
112 | + * | |
113 | + * @param str 带占位符的日志消息 | |
115 | 114 | * @param args 需要被替换的参数,除了字符串和基本类型的对象形式外,其他类型需要自己实现toString方法 |
116 | 115 | * @return |
117 | 116 | */ |
... | ... | @@ -142,7 +141,7 @@ public class LogHelper { |
142 | 141 | |
143 | 142 | /** |
144 | 143 | * 记录DEBUG信息 |
145 | - * | |
144 | + * | |
146 | 145 | * @param type 日志业务类型 |
147 | 146 | * @param str |
148 | 147 | */ |
... | ... | @@ -156,7 +155,7 @@ public class LogHelper { |
156 | 155 | |
157 | 156 | /** |
158 | 157 | * 记录INFO信息 |
159 | - * | |
158 | + * | |
160 | 159 | * @param type 日志业务类型 |
161 | 160 | * @param str |
162 | 161 | */ |
... | ... | @@ -170,7 +169,7 @@ public class LogHelper { |
170 | 169 | |
171 | 170 | /** |
172 | 171 | * 记录warn信息 |
173 | - * | |
172 | + * | |
174 | 173 | * @param type 日志业务类型 |
175 | 174 | * @param str |
176 | 175 | */ |
... | ... | @@ -184,7 +183,7 @@ public class LogHelper { |
184 | 183 | |
185 | 184 | /** |
186 | 185 | * 记录error信息 |
187 | - * | |
186 | + * | |
188 | 187 | * @param type 日志业务类型 |
189 | 188 | * @param str |
190 | 189 | */ |
... | ... | @@ -198,12 +197,12 @@ public class LogHelper { |
198 | 197 | |
199 | 198 | /** |
200 | 199 | * 记录error信息 |
201 | - * | |
200 | + * | |
202 | 201 | * @param type 日志业务类型 |
203 | 202 | * @param str |
204 | 203 | */ |
205 | 204 | public static void error(LogTypeEnum type, Throwable e, String str, |
206 | - Object... args) { | |
205 | + Object... args) { | |
207 | 206 | Logger log = getLog(type); |
208 | 207 | if (log.isErrorEnabled()) { |
209 | 208 | String msg = replace(str, args); | ... | ... |
titan-api/src/main/java/com/diligrp/titan/common/log/LogTypeEnum.java
... | ... | @@ -5,11 +5,11 @@ import org.slf4j.Logger; |
5 | 5 | |
6 | 6 | /** |
7 | 7 | * 日志的业务类型,对重要的业务日志需要在这里定义类型 |
8 | - * | |
8 | + * | |
9 | 9 | * @author dingjun |
10 | 10 | */ |
11 | 11 | public enum LogTypeEnum { |
12 | - DEFAULT("DEFAULT", "默认"), | |
12 | + DEFAULT("DEFAULT", "默认"), | |
13 | 13 | PRODUCT("TITAN_PRODUCT", "商品"), |
14 | 14 | CATEGORY("TITAN_CATEGORY", "类目"), |
15 | 15 | ATTRIBUTE("TITAN_ATTRIBUTE", "属性"), |
... | ... | @@ -23,59 +23,61 @@ public enum LogTypeEnum { |
23 | 23 | PRODUCT_TP("TITAN_SUPPLIER", "供应商商品"), |
24 | 24 | EXCEPTION("EXCEPTION", "运行错误"); |
25 | 25 | |
26 | - private String key; | |
27 | - private String value; | |
26 | + private String key; | |
27 | + private String value; | |
28 | 28 | |
29 | - LogTypeEnum() { | |
30 | - } | |
29 | + LogTypeEnum() { | |
30 | + } | |
31 | 31 | |
32 | - LogTypeEnum(String key, String value) { | |
33 | - this.key = key; | |
34 | - this.value = value; | |
35 | - } | |
32 | + LogTypeEnum(String key, String value) { | |
33 | + this.key = key; | |
34 | + this.value = value; | |
35 | + } | |
36 | 36 | |
37 | - public static String getValue(String key) { | |
38 | - for (LogTypeEnum ft : LogTypeEnum.values()) { | |
39 | - if (ft.getKey().equals(key)) { | |
40 | - return ft.getValue(); | |
41 | - } | |
42 | - } | |
43 | - return null; | |
44 | - } | |
37 | + public static String getValue(String key) { | |
38 | + for (LogTypeEnum ft : LogTypeEnum.values()) { | |
39 | + if (ft.getKey().equals(key)) { | |
40 | + return ft.getValue(); | |
41 | + } | |
42 | + } | |
43 | + return null; | |
44 | + } | |
45 | 45 | |
46 | - public String getKey() { | |
47 | - return key; | |
48 | - } | |
46 | + public String getKey() { | |
47 | + return key; | |
48 | + } | |
49 | 49 | |
50 | - public String getValue() { | |
51 | - return value; | |
52 | - } | |
50 | + public String getValue() { | |
51 | + return value; | |
52 | + } | |
53 | 53 | |
54 | - public Logger getLog() { | |
55 | - return LogHelper.getLog(this); | |
56 | - } | |
57 | - /** | |
58 | - * 增加日志打印calss信息----暂时未用 | |
59 | - * @param str | |
60 | - * @return | |
61 | - */ | |
62 | - public static String getClassAndlin(String str) { | |
63 | - if (StringUtils.isEmpty(str)) { | |
64 | - return str; | |
65 | - } | |
66 | - StackTraceElement stack[] = Thread.currentThread().getStackTrace(); | |
67 | - boolean boo = false; | |
68 | - for (StackTraceElement ste : stack) { | |
69 | - if ((ste.getFileName().indexOf("LogTypeEnum.java")) != -1) { | |
70 | - boo = true; | |
71 | - } else if (boo) { | |
72 | - return new StringBuffer(MarkConstant.LEFT_BRACKET).append(ste.getFileName()).append( | |
54 | + public Logger getLog() { | |
55 | + return LogHelper.getLog(this); | |
56 | + } | |
57 | + | |
58 | + /** | |
59 | + * 增加日志打印calss信息----暂时未用 | |
60 | + * | |
61 | + * @param str | |
62 | + * @return | |
63 | + */ | |
64 | + public static String getClassAndlin(String str) { | |
65 | + if (StringUtils.isEmpty(str)) { | |
66 | + return str; | |
67 | + } | |
68 | + StackTraceElement stack[] = Thread.currentThread().getStackTrace(); | |
69 | + boolean boo = false; | |
70 | + for (StackTraceElement ste : stack) { | |
71 | + if ((ste.getFileName().indexOf("LogTypeEnum.java")) != -1) { | |
72 | + boo = true; | |
73 | + } else if (boo) { | |
74 | + return new StringBuffer(MarkConstant.LEFT_BRACKET).append(ste.getFileName()).append( | |
73 | 75 | MarkConstant.SPLIT_CODE) |
74 | - .append(ste.getLineNumber()).append(MarkConstant.RIGHT_BRACKET).append( | |
76 | + .append(ste.getLineNumber()).append(MarkConstant.RIGHT_BRACKET).append( | |
75 | 77 | MarkConstant.BLANK).append(str).toString(); |
76 | - } | |
77 | - } | |
78 | - return str; | |
79 | - } | |
78 | + } | |
79 | + } | |
80 | + return str; | |
81 | + } | |
80 | 82 | |
81 | 83 | } | ... | ... |
titan-api/src/main/java/com/diligrp/titan/common/log/MarkConstant.java
... | ... | @@ -22,15 +22,16 @@ public class MarkConstant { |
22 | 22 | /** |
23 | 23 | * 左方括号 |
24 | 24 | */ |
25 | - public static final String LEFT_BRACKETS="["; | |
25 | + public static final String LEFT_BRACKETS = "["; | |
26 | 26 | /** |
27 | 27 | * 右方括号 |
28 | 28 | */ |
29 | - public static final String RIGHT_BRACKETS="]"; | |
29 | + public static final String RIGHT_BRACKETS = "]"; | |
30 | 30 | /** |
31 | 31 | * 换行 |
32 | 32 | */ |
33 | - public static final String NEW_LINE = "\n";; | |
33 | + public static final String NEW_LINE = "\n"; | |
34 | + ; | |
34 | 35 | |
35 | 36 | /** |
36 | 37 | * 符号:点 |
... | ... | @@ -52,16 +53,16 @@ public class MarkConstant { |
52 | 53 | /** |
53 | 54 | * 空格 |
54 | 55 | */ |
55 | - public static final String BLANK= " "; | |
56 | + public static final String BLANK = " "; | |
56 | 57 | |
57 | 58 | /** |
58 | 59 | * 左括号 |
59 | 60 | */ |
60 | - public static final String LEFT_BRACKET= "("; | |
61 | + public static final String LEFT_BRACKET = "("; | |
61 | 62 | |
62 | 63 | /** |
63 | 64 | * 右括号 |
64 | 65 | */ |
65 | - public static final String RIGHT_BRACKET= ")"; | |
66 | + public static final String RIGHT_BRACKET = ")"; | |
66 | 67 | |
67 | 68 | } | ... | ... |
titan-api/src/main/java/com/diligrp/titan/common/tools/DateUtils.java
... | ... | @@ -8,62 +8,62 @@ import java.util.Date; |
8 | 8 | |
9 | 9 | /** |
10 | 10 | * 日期工具类 |
11 | - * | |
11 | + * | |
12 | 12 | * @author dev-center |
13 | 13 | * @since 2014-05-10 |
14 | 14 | */ |
15 | 15 | public class DateUtils { |
16 | - private final static Logger LOGGER = LoggerFactory.getLogger(DateUtils.class); | |
16 | + private final static Logger LOGGER = LoggerFactory.getLogger(DateUtils.class); | |
17 | 17 | |
18 | - public static long getServerTime() { | |
19 | - return System.currentTimeMillis(); | |
20 | - } | |
18 | + public static long getServerTime() { | |
19 | + return System.currentTimeMillis(); | |
20 | + } | |
21 | 21 | |
22 | - /** | |
23 | - * 格式化日期,默认返回yyyy-MM-dd HH:mm:ss | |
24 | - * | |
25 | - * @param date | |
26 | - * @return | |
27 | - */ | |
28 | - public static String format(Date date) { | |
29 | - return format(date, "yyyy-MM-dd HH:mm:ss"); | |
30 | - } | |
22 | + /** | |
23 | + * 格式化日期,默认返回yyyy-MM-dd HH:mm:ss | |
24 | + * | |
25 | + * @param date | |
26 | + * @return | |
27 | + */ | |
28 | + public static String format(Date date) { | |
29 | + return format(date, "yyyy-MM-dd HH:mm:ss"); | |
30 | + } | |
31 | 31 | |
32 | - /** | |
33 | - * 格式化显示当前日期 | |
34 | - * | |
35 | - * @param format | |
36 | - * @return | |
37 | - */ | |
38 | - public static String format(String format) { | |
39 | - return format(new Date(), format); | |
40 | - } | |
32 | + /** | |
33 | + * 格式化显示当前日期 | |
34 | + * | |
35 | + * @param format | |
36 | + * @return | |
37 | + */ | |
38 | + public static String format(String format) { | |
39 | + return format(new Date(), format); | |
40 | + } | |
41 | 41 | |
42 | - /** | |
43 | - * 日期格式化 | |
44 | - * | |
45 | - * @param date | |
46 | - * @param format | |
47 | - * @return | |
48 | - */ | |
49 | - public static String format(Date date, String format) { | |
50 | - try { | |
51 | - SimpleDateFormat sdf = new SimpleDateFormat(format); | |
52 | - return sdf.format(date); | |
53 | - } catch (Exception e) { | |
54 | - LOGGER.warn("日期格式化失败.{}", e.getMessage()); | |
55 | - } | |
56 | - return null; | |
57 | - } | |
42 | + /** | |
43 | + * 日期格式化 | |
44 | + * | |
45 | + * @param date | |
46 | + * @param format | |
47 | + * @return | |
48 | + */ | |
49 | + public static String format(Date date, String format) { | |
50 | + try { | |
51 | + SimpleDateFormat sdf = new SimpleDateFormat(format); | |
52 | + return sdf.format(date); | |
53 | + } catch (Exception e) { | |
54 | + LOGGER.warn("日期格式化失败.{}", e.getMessage()); | |
55 | + } | |
56 | + return null; | |
57 | + } | |
58 | 58 | |
59 | - /** | |
60 | - * 时间格式化, 传入毫秒 | |
61 | - * | |
62 | - * @param time | |
63 | - * @return | |
64 | - */ | |
65 | - public static String dateFormat(long time) { | |
66 | - return format(new Date(time), "yyyy-MM-dd HH:mm:ss"); | |
67 | - } | |
59 | + /** | |
60 | + * 时间格式化, 传入毫秒 | |
61 | + * | |
62 | + * @param time | |
63 | + * @return | |
64 | + */ | |
65 | + public static String dateFormat(long time) { | |
66 | + return format(new Date(time), "yyyy-MM-dd HH:mm:ss"); | |
67 | + } | |
68 | 68 | |
69 | 69 | } | ... | ... |
titan-api/src/main/java/com/diligrp/titan/common/tools/NullTool.java
... | ... | @@ -23,27 +23,27 @@ import org.apache.velocity.context.Context; |
23 | 23 | * It provides a method to set a VTL reference back to <code>null</code>. |
24 | 24 | * Also provides methods to check if a VTL reference is <code>null</code> or not. |
25 | 25 | * <p> |
26 | - * NOTE: These examples assume you have placed an | |
27 | - * instance of the current context within itself as 'ctx'. | |
28 | - * And, of course, the NullTool is assumed to be available as 'null'. | |
26 | + * NOTE: These examples assume you have placed an | |
27 | + * instance of the current context within itself as 'ctx'. | |
28 | + * And, of course, the NullTool is assumed to be available as 'null'. | |
29 | 29 | * </p> |
30 | 30 | * <p><pre> |
31 | 31 | * Example uses: |
32 | 32 | * $foo -> bar |
33 | 33 | * $null.isNull($foo) -> false |
34 | 34 | * $null.isNotNull($foo) -> true |
35 | - * | |
35 | + * <p> | |
36 | 36 | * $null.setNull($ctx, "foo") |
37 | 37 | * $foo -> $foo (null) |
38 | 38 | * $null.isNull($foo) -> true |
39 | 39 | * $null.isNotNull($foo) -> false |
40 | - * | |
40 | + * <p> | |
41 | 41 | * $null.set($ctx, $foo, "hoge") |
42 | 42 | * $foo -> hoge |
43 | 43 | * $null.set($ctx, $foo, $null.null) |
44 | 44 | * $foo -> $foo (null) |
45 | 45 | * </pre></p> |
46 | - * | |
46 | + * <p> | |
47 | 47 | * <p>This tool is entirely threadsafe, and has no instance members. |
48 | 48 | * It may be used in any scope (request, session, or application). |
49 | 49 | * </p> |
... | ... | @@ -51,25 +51,22 @@ import org.apache.velocity.context.Context; |
51 | 51 | * @author <a href="mailto:shinobu@ieee.org">Shinobu Kawai</a> |
52 | 52 | * @version $Id: $ |
53 | 53 | */ |
54 | -public class NullTool | |
55 | -{ | |
54 | +public class NullTool { | |
56 | 55 | |
57 | 56 | /** |
58 | 57 | * Default constructor. |
59 | 58 | */ |
60 | - public NullTool() | |
61 | - { | |
59 | + public NullTool() { | |
62 | 60 | } |
63 | 61 | |
64 | 62 | /** |
65 | 63 | * Sets the given VTL reference back to <code>null</code>. |
64 | + * | |
66 | 65 | * @param context the current Context |
67 | - * @param key the VTL reference to set back to <code>null</code>. | |
66 | + * @param key the VTL reference to set back to <code>null</code>. | |
68 | 67 | */ |
69 | - public void setNull(Context context, String key) | |
70 | - { | |
71 | - if (this.isNull(context)) | |
72 | - { | |
68 | + public void setNull(Context context, String key) { | |
69 | + if (this.isNull(context)) { | |
73 | 70 | return; |
74 | 71 | } |
75 | 72 | context.remove(key); |
... | ... | @@ -79,18 +76,16 @@ public class NullTool |
79 | 76 | * Sets the given VTL reference to the given value. |
80 | 77 | * If the value is <code>null</code>, |
81 | 78 | * the VTL reference is set to <code>null</code>. |
79 | + * | |
82 | 80 | * @param context the current Context |
83 | - * @param key the VTL reference to set. | |
84 | - * @param value the value to set the VTL reference to. | |
81 | + * @param key the VTL reference to set. | |
82 | + * @param value the value to set the VTL reference to. | |
85 | 83 | */ |
86 | - public void set(Context context, String key, Object value) | |
87 | - { | |
88 | - if (this.isNull(context)) | |
89 | - { | |
84 | + public void set(Context context, String key, Object value) { | |
85 | + if (this.isNull(context)) { | |
90 | 86 | return; |
91 | 87 | } |
92 | - if (this.isNull(value)) | |
93 | - { | |
88 | + if (this.isNull(value)) { | |
94 | 89 | this.setNull(context, key); |
95 | 90 | return; |
96 | 91 | } |
... | ... | @@ -99,23 +94,23 @@ public class NullTool |
99 | 94 | |
100 | 95 | /** |
101 | 96 | * Checks if a VTL reference is <code>null</code>. |
97 | + * | |
102 | 98 | * @param object the VTL reference to check. |
103 | 99 | * @return <code>true</code> if the VTL reference is <code>null</code>, |
104 | - * <code>false</code> if otherwise. | |
100 | + * <code>false</code> if otherwise. | |
105 | 101 | */ |
106 | - public boolean isNull(Object object) | |
107 | - { | |
102 | + public boolean isNull(Object object) { | |
108 | 103 | return object == null; |
109 | 104 | } |
110 | 105 | |
111 | 106 | /** |
112 | 107 | * Checks if a VTL reference is not <code>null</code>. |
108 | + * | |
113 | 109 | * @param object the VTL reference to check. |
114 | 110 | * @return <code>true</code> if the VTL reference is not <code>null</code>, |
115 | - * <code>false</code> if otherwise. | |
111 | + * <code>false</code> if otherwise. | |
116 | 112 | */ |
117 | - public boolean isNotNull(Object object) | |
118 | - { | |
113 | + public boolean isNotNull(Object object) { | |
119 | 114 | return !this.isNull(object); |
120 | 115 | } |
121 | 116 | |
... | ... | @@ -123,10 +118,10 @@ public class NullTool |
123 | 118 | * A convinient method which returns <code>null</code>. |
124 | 119 | * Actually, this tool will work the same without this method, |
125 | 120 | * because Velocity treats non-existing methods as null. :) |
121 | + * | |
126 | 122 | * @return <code>null</code> |
127 | 123 | */ |
128 | - public Object getNull() | |
129 | - { | |
124 | + public Object getNull() { | |
130 | 125 | return null; |
131 | 126 | } |
132 | 127 | ... | ... |
titan-api/src/main/java/com/diligrp/titan/common/tools/RegexUtils.java
titan-api/src/main/java/com/diligrp/titan/common/tools/Tools.java
... | ... | @@ -6,100 +6,106 @@ import java.text.SimpleDateFormat; |
6 | 6 | import java.util.*; |
7 | 7 | import java.util.regex.Matcher; |
8 | 8 | import java.util.regex.Pattern; |
9 | + | |
9 | 10 | /** |
10 | 11 | * <B>Description</B> 工具类 |
11 | 12 | * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. <br /> |
12 | 13 | * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> |
13 | 14 | * <B>Company</B> 地利集团 |
14 | - * @createTime 2014年6月25日 下午2:15:09 | |
15 | + * | |
15 | 16 | * @author yangjianjun |
17 | + * @createTime 2014年6月25日 下午2:15:09 | |
16 | 18 | */ |
17 | 19 | public class Tools { |
18 | 20 | /** |
19 | 21 | * this method is 判断是否是ASCII编码 |
22 | + * | |
20 | 23 | * @param string |
21 | 24 | * @return |
22 | 25 | * @createTime 2014年6月25日 下午2:14:50 |
23 | 26 | * @author yangjianjun |
24 | 27 | */ |
25 | 28 | public static boolean isASCIIEncoded(String string) { |
26 | - if(string == null){ | |
27 | - string =""; | |
29 | + if (string == null) { | |
30 | + string = ""; | |
28 | 31 | } |
29 | 32 | return !Pattern.compile("[^\\x00-\\xff]").matcher(string).find(); |
30 | 33 | } |
31 | - | |
32 | - | |
34 | + | |
35 | + | |
33 | 36 | /** |
34 | 37 | * this method is 获取字符串长度,一个中文占2个长度 |
38 | + * | |
35 | 39 | * @param string |
36 | 40 | * @return |
37 | 41 | * @createTime 2014年6月25日 下午2:14:33 |
38 | 42 | * @author yangjianjun |
39 | 43 | */ |
40 | 44 | public static int getLength(String string) { |
41 | - if(string == null){ | |
45 | + if (string == null) { | |
42 | 46 | string = ""; |
43 | 47 | } |
44 | - // String reg = "[^\\x00-\\x7f]"; | |
45 | - String reg = "[^\\x00-\\xff]"; | |
46 | - Pattern pattern =Pattern.compile(reg); | |
48 | + // String reg = "[^\\x00-\\x7f]"; | |
49 | + String reg = "[^\\x00-\\xff]"; | |
50 | + Pattern pattern = Pattern.compile(reg); | |
47 | 51 | Matcher mathcher = pattern.matcher(string); |
48 | - if(mathcher.find()){ | |
49 | - return string.length()*2; | |
52 | + if (mathcher.find()) { | |
53 | + return string.length() * 2; | |
50 | 54 | } |
51 | 55 | return string.length(); |
52 | 56 | } |
53 | - | |
54 | - /** | |
55 | - * 时间格式化 | |
56 | - * @author yangjianjun | |
57 | - * @creaetime Jul 18, 2012 7:22:29 PM | |
58 | - * @param date date | |
59 | - * @param p parameter | |
60 | - * @return dateFormat | |
61 | - */ | |
62 | - public static String formatDateTime(Date date, int p) { | |
63 | - String pattern = "yyyy-MM-dd HH:mm:ss"; | |
64 | - switch (p) { | |
65 | - case 1: | |
66 | - pattern = "yyyy-MM-dd"; | |
67 | - break; | |
68 | - case 2: | |
69 | - pattern = "yyyy-MM-dd HH:mm:ss"; | |
70 | - break; | |
71 | - case 3: | |
72 | - pattern = "yyyy-MM-dd HH:mm:ss.SSS"; | |
73 | - break; | |
74 | - case 4: | |
75 | - pattern = "yyyy-MM"; | |
76 | - break; | |
77 | - case 5: | |
78 | - pattern = "MM-dd"; | |
79 | - break; | |
80 | - case 6: | |
81 | - pattern = "HH:mm:ss"; | |
82 | - break; | |
83 | - case 7: | |
84 | - pattern = "HH:mm"; | |
85 | - break; | |
86 | - case 8: | |
87 | - pattern = "MM-dd HH:mm:ss"; | |
88 | - break; | |
89 | - case 9: | |
90 | - pattern = "MM-dd HH:mm"; | |
91 | - break; | |
92 | - case 10: | |
93 | - pattern = "yyyyMMddHHmmssSSS"; | |
94 | - break; | |
95 | - default: | |
96 | - break; | |
97 | - } | |
98 | - return new SimpleDateFormat(pattern).format(date); | |
99 | - } | |
100 | - | |
57 | + | |
58 | + /** | |
59 | + * 时间格式化 | |
60 | + * | |
61 | + * @param date date | |
62 | + * @param p parameter | |
63 | + * @return dateFormat | |
64 | + * @author yangjianjun | |
65 | + * @creaetime Jul 18, 2012 7:22:29 PM | |
66 | + */ | |
67 | + public static String formatDateTime(Date date, int p) { | |
68 | + String pattern = "yyyy-MM-dd HH:mm:ss"; | |
69 | + switch (p) { | |
70 | + case 1: | |
71 | + pattern = "yyyy-MM-dd"; | |
72 | + break; | |
73 | + case 2: | |
74 | + pattern = "yyyy-MM-dd HH:mm:ss"; | |
75 | + break; | |
76 | + case 3: | |
77 | + pattern = "yyyy-MM-dd HH:mm:ss.SSS"; | |
78 | + break; | |
79 | + case 4: | |
80 | + pattern = "yyyy-MM"; | |
81 | + break; | |
82 | + case 5: | |
83 | + pattern = "MM-dd"; | |
84 | + break; | |
85 | + case 6: | |
86 | + pattern = "HH:mm:ss"; | |
87 | + break; | |
88 | + case 7: | |
89 | + pattern = "HH:mm"; | |
90 | + break; | |
91 | + case 8: | |
92 | + pattern = "MM-dd HH:mm:ss"; | |
93 | + break; | |
94 | + case 9: | |
95 | + pattern = "MM-dd HH:mm"; | |
96 | + break; | |
97 | + case 10: | |
98 | + pattern = "yyyyMMddHHmmssSSS"; | |
99 | + break; | |
100 | + default: | |
101 | + break; | |
102 | + } | |
103 | + return new SimpleDateFormat(pattern).format(date); | |
104 | + } | |
105 | + | |
101 | 106 | /** |
102 | 107 | * this method is 将字符串转化为日期格式 |
108 | + * | |
103 | 109 | * @param time |
104 | 110 | * @param type |
105 | 111 | * @return |
... | ... | @@ -107,188 +113,201 @@ public class Tools { |
107 | 113 | * @createTime 2014年6月25日 下午2:14:09 |
108 | 114 | * @author yangjianjun |
109 | 115 | */ |
110 | - public static Date stringToDate(String time,int type) throws Exception{ | |
111 | - SimpleDateFormat simple=null; | |
116 | + public static Date stringToDate(String time, int type) throws Exception { | |
117 | + SimpleDateFormat simple = null; | |
112 | 118 | switch (type) { |
113 | 119 | case 1: |
114 | - simple=new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
120 | + simple = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
115 | 121 | break; |
116 | 122 | case 2: |
117 | - simple=new SimpleDateFormat("yyyy-MM-dd"); | |
123 | + simple = new SimpleDateFormat("yyyy-MM-dd"); | |
118 | 124 | break; |
119 | 125 | default: |
120 | 126 | break; |
121 | 127 | } |
122 | - if(simple == null ){ | |
128 | + if (simple == null) { | |
123 | 129 | throw new Exception("参数有误!"); |
124 | 130 | } |
125 | 131 | Date date = simple.parse(time); |
126 | 132 | return date; |
127 | 133 | } |
128 | 134 | |
129 | - /** | |
130 | - * this method is 验证某个对象是否为空 | |
131 | - * @param obj | |
132 | - * @return | |
133 | - * @createTime 2014年6月25日 下午2:13:25 | |
134 | - * @author yangjianjun | |
135 | - */ | |
136 | - public static boolean objectIsNotNull(Object obj) { | |
137 | - return (null != obj) ? true : false; | |
138 | - } | |
139 | - | |
135 | + /** | |
136 | + * this method is 验证某个对象是否为空 | |
137 | + * | |
138 | + * @param obj | |
139 | + * @return | |
140 | + * @createTime 2014年6月25日 下午2:13:25 | |
141 | + * @author yangjianjun | |
142 | + */ | |
143 | + public static boolean objectIsNotNull(Object obj) { | |
144 | + return (null != obj) ? true : false; | |
145 | + } | |
146 | + | |
140 | 147 | /** |
141 | 148 | * this method is 判断某一个集合对象是否为空 |
149 | + * | |
142 | 150 | * @param list |
143 | 151 | * @return |
144 | 152 | * @createTime 2014年6月25日 下午2:11:46 |
145 | 153 | * @author yangjianjun |
146 | 154 | */ |
147 | - public static <T> boolean checkListNotNull(List<T> list){ | |
148 | - if(list == null || list.size() < 1){ | |
155 | + public static <T> boolean checkListNotNull(List<T> list) { | |
156 | + if (list == null || list.size() < 1) { | |
149 | 157 | return true; |
150 | 158 | } |
151 | 159 | return false; |
152 | 160 | } |
153 | - | |
161 | + | |
154 | 162 | /** |
155 | 163 | * 判断一个字符串是否在另一个字符串中存在 |
164 | + * | |
165 | + * @param str0 字符串规则 | |
166 | + * @param str1 要检查的字符串 | |
167 | + * @return boolean | |
156 | 168 | * @author yangjianjun |
157 | 169 | * @creaetime Nov 26, 2012 4:01:19 PM |
158 | - * @param str0 字符串规则 | |
159 | - * @param str1 要检查的字符串 | |
160 | - * @return boolean | |
161 | 170 | */ |
162 | - public static boolean isExistString(String str0,String str1){ | |
163 | - int indexOf=str0.indexOf(str1); | |
164 | - if(indexOf>=0){ | |
165 | - return true; | |
166 | - }else{ | |
167 | - return false; | |
168 | - } | |
171 | + public static boolean isExistString(String str0, String str1) { | |
172 | + int indexOf = str0.indexOf(str1); | |
173 | + if (indexOf >= 0) { | |
174 | + return true; | |
175 | + } else { | |
176 | + return false; | |
177 | + } | |
169 | 178 | } |
179 | + | |
170 | 180 | /** |
171 | 181 | * 计算某个时间到某个时间的时差等信息 |
182 | + * | |
183 | + * @param startTime beginTime | |
184 | + * @param endTime endTime | |
185 | + * @param format temple | |
186 | + * @param str 小时 | |
187 | + * @return 时差 | |
188 | + * @throws ParseException ParseException | |
172 | 189 | * @author yangjianjun |
173 | 190 | * @creaetime Nov 28, 2014 3:16:21 PM |
174 | - * @param startTime beginTime | |
175 | - * @param endTime endTime | |
176 | - * @param format temple | |
177 | - * @param str 小时 | |
178 | - * @return 时差 | |
179 | - * @throws ParseException ParseException | |
180 | 191 | */ |
181 | - public static Long dateDiff(String startTime, String endTime, | |
182 | - String format, String str) throws ParseException { | |
192 | + public static Long dateDiff(String startTime, String endTime, | |
193 | + String format, String str) throws ParseException { | |
183 | 194 | // 按照传入的格式生成一个simpledateformate对象 |
184 | - SimpleDateFormat sd = new SimpleDateFormat(format); | |
195 | + SimpleDateFormat sd = new SimpleDateFormat(format); | |
185 | 196 | long nd = 1000 * 24 * 60 * 60;// 一天的毫秒数 |
186 | 197 | long nh = 1000 * 60 * 60;// 一小时的毫秒数 |
187 | 198 | long nm = 1000 * 60;// 一分钟的毫秒数 |
188 | 199 | long ns = 1000;// 一秒钟的毫秒数 |
189 | - long diff; | |
190 | - long day = 0; | |
191 | - long hour = 0; | |
192 | - long min = 0; | |
193 | - long sec = 0; | |
200 | + long diff; | |
201 | + long day = 0; | |
202 | + long hour = 0; | |
203 | + long min = 0; | |
204 | + long sec = 0; | |
194 | 205 | // 获得两个时间的毫秒时间差异 |
195 | - diff = sd.parse(endTime).getTime() - sd.parse(startTime).getTime(); | |
196 | - day = diff / nd;// 计算差多少天 | |
197 | - hour = diff % nd / nh + day * 24;// 计算差多少小时 | |
198 | - min = diff % nd % nh / nm + day * 24 * 60;// 计算差多少分钟 | |
199 | - sec = diff % nd % nh % nm / ns;// 计算差多少秒 | |
200 | - // 输出结果 | |
201 | - System.out.println("时间相差:" + day + "天" + (hour - day * 24) + "小时" | |
202 | - + (min - day * 24 * 60) + "分钟" + sec + "秒。"); | |
203 | - System.out.println("hour=" + hour + ",min=" + min); | |
204 | - if (str.equalsIgnoreCase("h")) { | |
205 | - return hour; | |
206 | - } else { | |
207 | - return min; | |
208 | - } | |
206 | + diff = sd.parse(endTime).getTime() - sd.parse(startTime).getTime(); | |
207 | + day = diff / nd;// 计算差多少天 | |
208 | + hour = diff % nd / nh + day * 24;// 计算差多少小时 | |
209 | + min = diff % nd % nh / nm + day * 24 * 60;// 计算差多少分钟 | |
210 | + sec = diff % nd % nh % nm / ns;// 计算差多少秒 | |
211 | + // 输出结果 | |
212 | + System.out.println("时间相差:" + day + "天" + (hour - day * 24) + "小时" | |
213 | + + (min - day * 24 * 60) + "分钟" + sec + "秒。"); | |
214 | + System.out.println("hour=" + hour + ",min=" + min); | |
215 | + if (str.equalsIgnoreCase("h")) { | |
216 | + return hour; | |
217 | + } else { | |
218 | + return min; | |
219 | + } | |
209 | 220 | } |
221 | + | |
210 | 222 | /** |
211 | 223 | * 计算结束时间到开始时间的秒数 |
212 | - * @author yangjianjun | |
213 | - * @createtime 2014年6月25日 下午2:09:10 | |
224 | + * | |
214 | 225 | * @param startTime |
215 | 226 | * @param endTime |
216 | 227 | * @param format |
217 | - * @return | |
228 | + * @return | |
229 | + * @author yangjianjun | |
230 | + * @createtime 2014年6月25日 下午2:09:10 | |
231 | + */ | |
232 | + public static Long dateDiff(String startTime, String endTime, | |
233 | + String format) { | |
234 | + SimpleDateFormat sf = new SimpleDateFormat(format); | |
235 | + long time = -1; | |
236 | + try { | |
237 | + time = sf.parse(endTime).getTime() - sf.parse(startTime).getTime(); | |
238 | + } catch (ParseException e) { | |
239 | + // TODO Auto-generated catch block | |
240 | + } | |
241 | + return time / 1000; | |
242 | + } | |
243 | + | |
244 | + /** | |
245 | + * this method is 除法结果保留两位小数并按照第二位小数四舍五入 | |
246 | + * | |
247 | + * @param divisor 除数 | |
248 | + * @param dividend 被除数 | |
249 | + * @param k 保留小数的位数及四舍五入的位数 | |
250 | + * @return double数值 | |
251 | + * @createTime 2014年6月25日 下午2:09:10 | |
252 | + * @author yangjianjun | |
218 | 253 | */ |
219 | - public static Long dateDiff (String startTime, String endTime, | |
220 | - String format){ | |
221 | - SimpleDateFormat sf = new SimpleDateFormat(format); | |
222 | - long time=-1; | |
223 | - try { | |
224 | - time=sf.parse(endTime).getTime()- sf.parse(startTime).getTime(); | |
225 | - } catch (ParseException e) { | |
226 | - // TODO Auto-generated catch block | |
227 | - } | |
228 | - return time/1000; | |
254 | + public static double getRoundDecimal(long divisor, long dividend, int k) { | |
255 | + BigDecimal dec1 = new BigDecimal(divisor); | |
256 | + BigDecimal dec2 = new BigDecimal(dividend); | |
257 | + return dec1.divide(dec2, k, BigDecimal.ROUND_HALF_UP).doubleValue(); | |
229 | 258 | } |
230 | - /** | |
231 | - * this method is 除法结果保留两位小数并按照第二位小数四舍五入 | |
232 | - * @param divisor 除数 | |
233 | - * @param dividend 被除数 | |
234 | - * @param k 保留小数的位数及四舍五入的位数 | |
235 | - * @return double数值 | |
236 | - * @createTime 2014年6月25日 下午2:09:10 | |
237 | - * @author yangjianjun | |
238 | - */ | |
239 | - public static double getRoundDecimal(long divisor,long dividend,int k) { | |
240 | - BigDecimal dec1=new BigDecimal(divisor); | |
241 | - BigDecimal dec2=new BigDecimal(dividend); | |
242 | - return dec1.divide(dec2, k,BigDecimal.ROUND_HALF_UP).doubleValue(); | |
243 | - } | |
244 | - | |
245 | 259 | |
246 | - /** | |
247 | - * this method is 根据秒数求出时间 | |
248 | - * @param time | |
249 | - * @return | |
250 | - * @createTime 2014年6月25日 下午2:09:51 | |
251 | - * @author yangjianjun | |
252 | - */ | |
253 | - public static String paserTime(String time){ | |
254 | - System.setProperty("user.timezone", "Asia/Shanghai"); | |
255 | - TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai"); | |
256 | - TimeZone.setDefault(tz); | |
260 | + | |
261 | + /** | |
262 | + * this method is 根据秒数求出时间 | |
263 | + * | |
264 | + * @param time | |
265 | + * @return | |
266 | + * @createTime 2014年6月25日 下午2:09:51 | |
267 | + * @author yangjianjun | |
268 | + */ | |
269 | + public static String paserTime(String time) { | |
270 | + System.setProperty("user.timezone", "Asia/Shanghai"); | |
271 | + TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai"); | |
272 | + TimeZone.setDefault(tz); | |
257 | 273 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
258 | 274 | String times = format.format(new Date(Long.parseLong(time) * 1000L)); |
259 | 275 | // System.out.print("日期为:" + times); |
260 | - return times; | |
261 | - } | |
276 | + return times; | |
277 | + } | |
278 | + | |
279 | + /** | |
280 | + * this method is 根据时间求出秒数 | |
281 | + * | |
282 | + * @param date | |
283 | + * @return | |
284 | + * @createTime 2014年6月25日 下午2:10:08 | |
285 | + * @author yangjianjun | |
286 | + */ | |
287 | + public static long paserSecond(Date date) { | |
288 | + long dates = date.getTime() / 1000L; | |
289 | + return dates; | |
290 | + } | |
262 | 291 | |
263 | - /** | |
264 | - * this method is 根据时间求出秒数 | |
265 | - * @param date | |
266 | - * @return | |
267 | - * @createTime 2014年6月25日 下午2:10:08 | |
268 | - * @author yangjianjun | |
269 | - */ | |
270 | - public static long paserSecond(Date date){ | |
271 | - long dates = date.getTime()/1000L; | |
272 | - return dates; | |
273 | - } | |
274 | 292 | /** |
275 | 293 | * this method is 根据实际和天数计算出最新时间 |
276 | - * @param dates 当前时间 | |
277 | - * @param day 当前天数 | |
278 | - * @return 最新时间 | |
294 | + * | |
295 | + * @param dates 当前时间 | |
296 | + * @param day 当前天数 | |
297 | + * @return 最新时间 | |
279 | 298 | * @createTime 2014年7月10日 上午11:11:51 |
280 | 299 | * @author yangjianjun |
281 | 300 | */ |
282 | - public static Date getBeforeAfterDate(Date dates, int day) { | |
283 | - Calendar cal = new GregorianCalendar(); | |
284 | - cal.setTime(dates); | |
285 | - int Year = cal.get(Calendar.YEAR); | |
286 | - int Month = cal.get(Calendar.MONTH); | |
287 | - int Day = cal.get(Calendar.DAY_OF_MONTH); | |
288 | - int NewDay = Day + day; | |
289 | - cal.set(Calendar.YEAR, Year); | |
290 | - cal.set(Calendar.MONTH, Month); | |
291 | - cal.set(Calendar.DAY_OF_MONTH, NewDay); | |
292 | - return new Date(cal.getTimeInMillis()); | |
293 | - } | |
301 | + public static Date getBeforeAfterDate(Date dates, int day) { | |
302 | + Calendar cal = new GregorianCalendar(); | |
303 | + cal.setTime(dates); | |
304 | + int Year = cal.get(Calendar.YEAR); | |
305 | + int Month = cal.get(Calendar.MONTH); | |
306 | + int Day = cal.get(Calendar.DAY_OF_MONTH); | |
307 | + int NewDay = Day + day; | |
308 | + cal.set(Calendar.YEAR, Year); | |
309 | + cal.set(Calendar.MONTH, Month); | |
310 | + cal.set(Calendar.DAY_OF_MONTH, NewDay); | |
311 | + return new Date(cal.getTimeInMillis()); | |
312 | + } | |
294 | 313 | } | ... | ... |
titan-api/src/main/java/com/diligrp/titan/common/utils/ListCovertMapUtils.java
... | ... | @@ -21,7 +21,7 @@ import java.util.Map; |
21 | 21 | * <p> |
22 | 22 | * CreateTime:2015/4/1 |
23 | 23 | * </p> |
24 | - * | |
24 | + * | |
25 | 25 | * @author gongsz |
26 | 26 | */ |
27 | 27 | public class ListCovertMapUtils<KEY, T> { |
... | ... | @@ -57,18 +57,18 @@ public class ListCovertMapUtils<KEY, T> { |
57 | 57 | if (annotation != null) { |
58 | 58 | try { |
59 | 59 | map.put((KEY) field.get(obj), obj); |
60 | - isBreak=true; | |
60 | + isBreak = true; | |
61 | 61 | break; |
62 | 62 | } catch (Exception e) { |
63 | 63 | |
64 | 64 | } |
65 | 65 | } |
66 | 66 | } |
67 | - if(isBreak){ | |
67 | + if (isBreak) { | |
68 | 68 | break; |
69 | 69 | } |
70 | 70 | } |
71 | - | |
71 | + | |
72 | 72 | } |
73 | 73 | return map; |
74 | 74 | } | ... | ... |
titan-api/src/main/java/com/diligrp/titan/common/utils/SkuUtil.java
1 | 1 | package com.diligrp.titan.common.utils; |
2 | 2 | |
3 | -import com.diligrp.titan.common.ProductStatus; | |
4 | 3 | import com.diligrp.titan.common.exception.TitanError; |
5 | 4 | import org.apache.commons.lang.StringUtils; |
6 | 5 | import org.apache.log4j.Logger; |
... | ... | @@ -19,140 +18,149 @@ import java.util.regex.Pattern; |
19 | 18 | * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. <br /> |
20 | 19 | * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> |
21 | 20 | * <B>Company</B> 地利集团 |
22 | - * @createTime 2014年5月26日 下午11:15:12 | |
21 | + * | |
23 | 22 | * @author celine |
23 | + * @createTime 2014年5月26日 下午11:15:12 | |
24 | 24 | */ |
25 | 25 | public class SkuUtil { |
26 | 26 | |
27 | - private final static Logger logger = Logger.getLogger(SkuUtil.class); | |
28 | - private final static int ORI_RADIX = 11;// 原始SKU进制 | |
29 | - private final static int SKU_RADIX = 62; | |
30 | - public final static String SPLIT = ":"; | |
31 | - | |
32 | - /** | |
33 | - * 将编码后不带版本号的skuEncWithoutVersion和version编码成新的SKU | |
34 | - * @param skuEncWithoutVersion pid+attVal编码后的sku | |
35 | - * @param version sku版本号 | |
36 | - * @createTime 2014年6月18日 下午8:28:42 | |
37 | - */ | |
38 | - public static String encode(String skuEncWithoutVersion, Integer version) { | |
39 | - String skuOri = decode(skuEncWithoutVersion, false); | |
40 | - return SkuUtil.encode(version + SPLIT + skuOri); | |
41 | - } | |
42 | - | |
43 | - /** | |
27 | + private final static Logger logger = Logger.getLogger(SkuUtil.class); | |
28 | + private final static int ORI_RADIX = 11;// 原始SKU进制 | |
29 | + private final static int SKU_RADIX = 62; | |
30 | + public final static String SPLIT = ":"; | |
31 | + | |
32 | + /** | |
33 | + * 将编码后不带版本号的skuEncWithoutVersion和version编码成新的SKU | |
34 | + * | |
35 | + * @param skuEncWithoutVersion pid+attVal编码后的sku | |
36 | + * @param version sku版本号 | |
37 | + * @createTime 2014年6月18日 下午8:28:42 | |
38 | + */ | |
39 | + public static String encode(String skuEncWithoutVersion, Integer version) { | |
40 | + String skuOri = decode(skuEncWithoutVersion, false); | |
41 | + return SkuUtil.encode(version + SPLIT + skuOri); | |
42 | + } | |
43 | + | |
44 | + /** | |
44 | 45 | * 将带版本号的sku转换成不带版本号的SKU |
46 | + * | |
45 | 47 | * @param encSku |
46 | 48 | * @return |
47 | 49 | */ |
48 | - public static String covertVersionSku(String encSku){ | |
49 | - String sku = decode(encSku,true); | |
50 | + public static String covertVersionSku(String encSku) { | |
51 | + String sku = decode(encSku, true); | |
50 | 52 | return encode(sku); |
51 | 53 | } |
52 | - /** | |
53 | - * 生成商品由属性值ID拼接成的SKU字符串,attrMap为空时,默认为没有销售属性,返回0 | |
54 | - * | |
55 | - * @param attrMap 属性项-属性值的Map | |
56 | - * @return | |
57 | - * @createTime 2014年6月18日 下午2:59:24 | |
58 | - * @author celine | |
59 | - */ | |
60 | - public static String getSkuByAttrId(TreeMap<Long, Long> attrMap, Long pid) { | |
61 | - if (attrMap == null || attrMap.size() == 0) { | |
62 | - return pid == null ? null : pid + SPLIT + "0"; | |
63 | - } | |
64 | - Set<Entry<Long, Long>> entries = attrMap.entrySet(); | |
65 | - | |
66 | - if (pid != null) { | |
67 | - StringBuilder sb = new StringBuilder(); | |
68 | - sb.append(pid + SPLIT); | |
69 | - int i = 0; | |
70 | - for (Entry<Long, Long> entry : entries) { | |
71 | - i++; | |
72 | - if (i < entries.size()) { | |
73 | - sb.append(entry.getValue() + SPLIT); | |
74 | - } else { | |
75 | - sb.append(entry.getValue()); | |
76 | - } | |
77 | - } | |
78 | - return sb.toString(); | |
79 | - } | |
80 | - return null; | |
81 | - | |
82 | - } | |
83 | - | |
84 | - /** | |
85 | - * 解析sku中的版本号 | |
86 | - * @param encSku 编码后的sku | |
87 | - * @return | |
88 | - * @throws TitanError | |
89 | - * @createTime 2014年6月18日 下午6:52:32 | |
90 | - */ | |
91 | - public static Integer getVersion(String encSku) throws TitanError { | |
92 | - try { | |
93 | - BigInteger bi = sixtytwoToTen(encSku); | |
94 | - String skuDe = tenToM(bi, ORI_RADIX); | |
95 | - String[] skuSplit = skuDe.split(SPLIT); | |
96 | - String verStr = skuSplit[0]; | |
97 | - Integer version = Integer.parseInt(verStr); | |
98 | - return version; | |
99 | - } catch (Exception e) { | |
100 | - throw new TitanError(0, "解析版本号失败"); | |
101 | - } | |
102 | - | |
103 | - } | |
104 | - | |
105 | - /** | |
106 | - * 从带版本号的sku中获取不带版本号的sku | |
107 | - * @param encSku 编码后的sku,包含版本号 | |
108 | - * @return 编码后的sku,不带版本号 | |
109 | - * @throws TitanError | |
110 | - * @createTime 2014年6月18日 下午6:52:32 | |
111 | - */ | |
112 | - public static String getSkuEncWithOutVersion(String encSku) { | |
113 | - String skuDe = decode(encSku); | |
114 | - return encode(skuDe); | |
115 | - | |
116 | - } | |
117 | - | |
118 | - /** | |
119 | - * 解析sku中的PID | |
120 | - * @param encSku 编码后的sku | |
121 | - * @param hasVersion sku中是否包含版本 | |
122 | - * @return | |
123 | - * @throws TitanError | |
124 | - * @createTime 2014年6月18日 下午6:52:32 | |
125 | - */ | |
126 | - public static Long getPid(String encSku, boolean hasVersion){ | |
54 | + | |
55 | + /** | |
56 | + * 生成商品由属性值ID拼接成的SKU字符串,attrMap为空时,默认为没有销售属性,返回0 | |
57 | + * | |
58 | + * @param attrMap 属性项-属性值的Map | |
59 | + * @return | |
60 | + * @createTime 2014年6月18日 下午2:59:24 | |
61 | + * @author celine | |
62 | + */ | |
63 | + public static String getSkuByAttrId(TreeMap<Long, Long> attrMap, Long pid) { | |
64 | + if (attrMap == null || attrMap.size() == 0) { | |
65 | + return pid == null ? null : pid + SPLIT + "0"; | |
66 | + } | |
67 | + Set<Entry<Long, Long>> entries = attrMap.entrySet(); | |
68 | + | |
69 | + if (pid != null) { | |
70 | + StringBuilder sb = new StringBuilder(); | |
71 | + sb.append(pid + SPLIT); | |
72 | + int i = 0; | |
73 | + for (Entry<Long, Long> entry : entries) { | |
74 | + i++; | |
75 | + if (i < entries.size()) { | |
76 | + sb.append(entry.getValue() + SPLIT); | |
77 | + } else { | |
78 | + sb.append(entry.getValue()); | |
79 | + } | |
80 | + } | |
81 | + return sb.toString(); | |
82 | + } | |
83 | + return null; | |
84 | + | |
85 | + } | |
86 | + | |
87 | + /** | |
88 | + * 解析sku中的版本号 | |
89 | + * | |
90 | + * @param encSku 编码后的sku | |
91 | + * @return | |
92 | + * @throws TitanError | |
93 | + * @createTime 2014年6月18日 下午6:52:32 | |
94 | + */ | |
95 | + public static Integer getVersion(String encSku) throws TitanError { | |
96 | + try { | |
97 | + BigInteger bi = sixtytwoToTen(encSku); | |
98 | + String skuDe = tenToM(bi, ORI_RADIX); | |
99 | + String[] skuSplit = skuDe.split(SPLIT); | |
100 | + String verStr = skuSplit[0]; | |
101 | + Integer version = Integer.parseInt(verStr); | |
102 | + return version; | |
103 | + } catch (Exception e) { | |
104 | + throw new TitanError(0, "解析版本号失败"); | |
105 | + } | |
106 | + | |
107 | + } | |
108 | + | |
109 | + /** | |
110 | + * 从带版本号的sku中获取不带版本号的sku | |
111 | + * | |
112 | + * @param encSku 编码后的sku,包含版本号 | |
113 | + * @return 编码后的sku,不带版本号 | |
114 | + * @throws TitanError | |
115 | + * @createTime 2014年6月18日 下午6:52:32 | |
116 | + */ | |
117 | + public static String getSkuEncWithOutVersion(String encSku) { | |
118 | + String skuDe = decode(encSku); | |
119 | + return encode(skuDe); | |
120 | + | |
121 | + } | |
122 | + | |
123 | + /** | |
124 | + * 解析sku中的PID | |
125 | + * | |
126 | + * @param encSku 编码后的sku | |
127 | + * @param hasVersion sku中是否包含版本 | |
128 | + * @return | |
129 | + * @throws TitanError | |
130 | + * @createTime 2014年6月18日 下午6:52:32 | |
131 | + */ | |
132 | + public static Long getPid(String encSku, boolean hasVersion) { | |
127 | 133 | String skuDe = decode(encSku, hasVersion); |
128 | 134 | String[] skuSplit = skuDe.split(SPLIT); |
129 | 135 | String pidStr = skuSplit[0]; |
130 | 136 | Long pid = Long.parseLong(pidStr); |
131 | 137 | return pid; |
132 | - } | |
133 | - | |
134 | - /** | |
135 | - * 解析sku中的商品属性值ID | |
136 | - * @param encSku 编码后的sku | |
137 | - * @param hasVersion sku中是否包含版本 | |
138 | - * @return | |
139 | - * @throws TitanError | |
140 | - * @createTime 2014年6月18日 下午6:52:32 | |
141 | - */ | |
142 | - public static String getAttrVal(String encSku, boolean hasVersion){ | |
138 | + } | |
139 | + | |
140 | + /** | |
141 | + * 解析sku中的商品属性值ID | |
142 | + * | |
143 | + * @param encSku 编码后的sku | |
144 | + * @param hasVersion sku中是否包含版本 | |
145 | + * @return | |
146 | + * @throws TitanError | |
147 | + * @createTime 2014年6月18日 下午6:52:32 | |
148 | + */ | |
149 | + public static String getAttrVal(String encSku, boolean hasVersion) { | |
143 | 150 | String skuDe = decode(encSku, hasVersion); |
144 | 151 | return skuDe.substring(skuDe.indexOf(SPLIT) + 1, skuDe.length()); |
145 | - } | |
146 | - | |
147 | - /** | |
148 | - * 解析sku中的商品属性值ID | |
149 | - * @param encSku 编码后的sku | |
150 | - * @param hasVersion sku中是否包含版本 | |
151 | - * @return | |
152 | - * @throws TitanError | |
153 | - * @createTime 2014年6月18日 下午6:52:32 | |
154 | - */ | |
155 | - public static List<Long> getAttrValList(String encSku, boolean hasVersion){ | |
152 | + } | |
153 | + | |
154 | + /** | |
155 | + * 解析sku中的商品属性值ID | |
156 | + * | |
157 | + * @param encSku 编码后的sku | |
158 | + * @param hasVersion sku中是否包含版本 | |
159 | + * @return | |
160 | + * @throws TitanError | |
161 | + * @createTime 2014年6月18日 下午6:52:32 | |
162 | + */ | |
163 | + public static List<Long> getAttrValList(String encSku, boolean hasVersion) { | |
156 | 164 | String attrvalStr = getAttrVal(encSku, hasVersion); |
157 | 165 | if (StringUtils.isEmpty(attrvalStr)) |
158 | 166 | return null; |
... | ... | @@ -162,260 +170,189 @@ public class SkuUtil { |
162 | 170 | list.add(Long.parseLong(attrvalId)); |
163 | 171 | } |
164 | 172 | return list; |
165 | - } | |
166 | - | |
167 | - /** | |
168 | - * 通过sku确定商品的种类 1-第三方商品 2-供应商商品 3-网站商品 | |
169 | - * @param encSku | |
170 | - * @param hasVersion sku中是否包含version | |
171 | - * @return | |
172 | - * @createTime 2014年6月6日 下午6:28:58 | |
173 | - * @author celine | |
174 | - */ | |
175 | - public static int getProductType(String encSku, boolean hasVersion) { | |
176 | - String skuDe = decode(encSku, hasVersion); | |
177 | - String[] skuSplit = skuDe.split(SPLIT); | |
178 | - if (skuSplit.length > 0) { | |
179 | - String pidStart = skuSplit[0].substring(0, 1); | |
180 | - int flag = Integer.parseInt(pidStart); | |
181 | - return determineStype(flag); | |
182 | - } | |
183 | - return 0; | |
184 | - } | |
185 | - | |
186 | - /** | |
187 | - * 通过sku确定商品的种类 1-第三方商品 2-供应商商品 3-网站商品 | |
188 | - * @param encSku 编码后的sku,默认包含version | |
189 | - * @return | |
190 | - * @createTime 2014年6月6日 下午6:28:58 | |
191 | - * @author celine | |
192 | - */ | |
193 | - public static int getProductType(String encSku) { | |
194 | - return getProductType(encSku, true); | |
195 | - } | |
196 | - | |
197 | - /** | |
198 | - * 通过pid确定商品的种类 1-第三方商品 2-供应商商品 3-网站商品 | |
199 | - * @return | |
200 | - * @createTime 2014年6月6日 下午6:28:58 | |
201 | - * @author celine | |
202 | - */ | |
203 | - public static int getProductTypeByPid(String pid) { | |
204 | - if (pid != null && !pid.equals("")) { | |
205 | - String pidStart = pid.substring(0, 1); | |
206 | - int flag = Integer.parseInt(pidStart); | |
207 | - return determineStype(flag); | |
208 | - } | |
209 | - return 0; | |
210 | - } | |
211 | - | |
212 | - /** | |
213 | - * 对原始SKU串进行编码 | |
214 | - * @param oriStr | |
215 | - * @return | |
216 | - * @createTime 2014年5月27日 上午12:19:22 | |
217 | - * @author celine | |
218 | - */ | |
219 | - public static String encode(String oriStr) { | |
220 | - try { | |
221 | - BigInteger bi = elevenToTen(oriStr); | |
222 | - return tenToM(bi, SKU_RADIX); | |
223 | - } catch (Exception e) { | |
224 | - logger.error("Encode Error. ", e); | |
225 | - return null; | |
226 | - } | |
227 | - } | |
228 | - | |
229 | - /** | |
230 | - * 将编码后的SKU转换为PID:属性值形式 | |
231 | - * @param skuEnc 编码后的SKU,包含版本号 | |
232 | - * @return | |
233 | - * @createTime 2014年5月27日 上午12:20:17 | |
234 | - * @author celine | |
235 | - */ | |
236 | - public static String decode(String skuEnc) { | |
237 | - return decode(skuEnc, true); | |
238 | - } | |
239 | - | |
240 | - /** | |
241 | - * 将编码后的SKU转换为PID:属性值形式 | |
242 | - * @param skuEnc 编码后的SKU | |
243 | - * @param hasVersion sku中是否包含sku信息 | |
244 | - * @return | |
245 | - * @createTime 2014年5月27日 上午12:20:17 | |
246 | - * @author celine | |
247 | - */ | |
248 | - public static String decode(String skuEnc, boolean hasVersion) { | |
249 | - try { | |
250 | - BigInteger bi = sixtytwoToTen(skuEnc); | |
251 | - String skuOriWithVersion = tenToM(bi, ORI_RADIX); | |
252 | - if (hasVersion) { | |
253 | - return skuOriWithVersion.substring(skuOriWithVersion.indexOf(SPLIT) + 1, skuOriWithVersion.length()); | |
254 | - } | |
255 | - return skuOriWithVersion; | |
256 | - } catch (Exception e) { | |
257 | - logger.error("Decode Error. ", e); | |
258 | - return null; | |
259 | - } | |
260 | - } | |
261 | - | |
262 | - /** | |
263 | - * 将任意进制的数转换为十进制,本系统中用':'作为第十一位, | |
264 | - * @param s | |
265 | - * @return | |
266 | - * @createTime 2014年5月26日 下午10:27:05 | |
267 | - * @author celine | |
268 | - */ | |
269 | - private static BigInteger elevenToTen(String s) throws Exception { | |
270 | - | |
271 | - Pattern pattern = Pattern.compile("^[0-9:]+$"); | |
272 | - Matcher matcher = pattern.matcher(s); | |
273 | - | |
274 | - if (matcher.find()) { | |
275 | - BigInteger oriBi = BigInteger.valueOf(ORI_RADIX); | |
276 | - BigInteger tmpBi = new BigInteger("0"); | |
277 | - for (int i = 0; i < s.length(); i++) { | |
278 | - char tmpC = s.charAt(i); | |
279 | - int tmp = tmpC - '0'; | |
280 | - tmpBi = tmpBi.multiply(oriBi).add(BigInteger.valueOf(tmp)); | |
281 | - } | |
282 | - return tmpBi; | |
283 | - } else { | |
284 | - // 不全为数字和':' | |
285 | - logger.error("Invalid input " + s); | |
286 | - throw new Exception("Invalid input " + s); | |
287 | - } | |
288 | - } | |
289 | - | |
290 | - private static BigInteger sixtytwoToTen(String s) throws Exception { | |
291 | - Pattern pattern = Pattern.compile("^[0-9a-zA-z]+$"); | |
292 | - Matcher matcher = pattern.matcher(s); | |
293 | - | |
294 | - if (matcher.find()) { | |
295 | - BigInteger skuBi = BigInteger.valueOf(SKU_RADIX); | |
296 | - BigInteger tmpBi = new BigInteger("0"); | |
297 | - for (int i = 0; i < s.length(); i++) { | |
298 | - char tmpC = s.charAt(i); | |
299 | - int tmp = convertStringToInt62(tmpC); | |
300 | - tmpBi = tmpBi.multiply(skuBi).add(BigInteger.valueOf(tmp)); | |
301 | - } | |
302 | - return tmpBi; | |
303 | - } else { | |
304 | - // 不全为数字和大小写字母 | |
305 | - throw new Exception("Invalid input " + s); | |
306 | - } | |
307 | - } | |
308 | - | |
309 | - /** | |
310 | - * 将十进制转换为十一或六十二 | |
311 | - * @param bi | |
312 | - * @param m | |
313 | - * @createTime 2014年5月26日 下午10:58:20 | |
314 | - * @author celine | |
315 | - * @throws Exception | |
316 | - */ | |
317 | - private static String tenToM(BigInteger bi, int m) throws Exception { | |
318 | - StringBuffer bs = new StringBuffer(); | |
319 | - BigInteger zero = BigInteger.valueOf(0); | |
320 | - BigInteger targetBi = BigInteger.valueOf(m); | |
321 | - while (bi.compareTo(zero) > 0) { | |
322 | - BigInteger mod = bi.mod(targetBi); | |
323 | - if (m == ORI_RADIX) { | |
324 | - bs.insert(0, convertIntToString11(mod.intValue())); | |
325 | - } else if (m == SKU_RADIX) { | |
326 | - bs.insert(0, convertIntToString62(mod.intValue())); | |
327 | - } | |
328 | - bi = bi.divide(targetBi); | |
329 | - } | |
330 | - return bs.toString(); | |
331 | - } | |
332 | - | |
333 | - /** | |
334 | - * 将整数转换为对应62进制的字符 | |
335 | - * @param i | |
336 | - * @return | |
337 | - * @createTime 2014年5月26日 下午11:14:24 | |
338 | - * @author celine | |
339 | - * @throws Exception | |
340 | - */ | |
341 | - private static char convertIntToString62(int i) throws Exception { | |
342 | - if (i >= 0 && i <= 9) { | |
343 | - return (char) (i + '0'); | |
344 | - } else if (i > 9 && i < 36) { | |
345 | - return (char) ('a' + i - 10); | |
346 | - } else if (i >= 36 && i < 62) { | |
347 | - return (char) ('A' + i - 36); | |
348 | - } else { | |
349 | - throw new Exception("Invalid input " + i); | |
350 | - } | |
351 | - } | |
352 | - | |
353 | - /** | |
354 | - * 将整数转换为对应11进制的字符 | |
355 | - * @param i | |
356 | - * @return | |
357 | - * @throws Exception | |
358 | - * @createTime 2014年5月26日 下午11:30:15 | |
359 | - * @author celine | |
360 | - */ | |
361 | - private static char convertIntToString11(int i) throws Exception { | |
362 | - if (i >= 0 && i <= 10) { | |
363 | - return (char) (i + '0'); | |
364 | - } else { | |
365 | - throw new Exception("Invalid input " + i); | |
366 | - } | |
367 | - } | |
368 | - | |
369 | - private static int convertStringToInt62(char c) throws Exception { | |
370 | - if (c >= '0' && c <= '9') { | |
371 | - return c - '0'; | |
372 | - } else if (c >= 'a' && c <= 'z') { | |
373 | - return c - 'a' + 10; | |
374 | - } else if (c >= 'A' && c <= 'Z') { | |
375 | - return c - 'A' + 36; | |
376 | - } else { | |
377 | - throw new Exception("Invalid input " + c); | |
378 | - } | |
379 | - } | |
380 | - | |
381 | - /** | |
382 | - * 确定商品类型 | |
383 | - * @param flag | |
384 | - * @return | |
385 | - * @createTime 2014年6月6日 下午6:40:15 | |
386 | - * @author celine | |
387 | - */ | |
388 | - private static int determineStype(int flag) { | |
389 | - switch (flag) { | |
390 | - case 1: | |
391 | - case 2: | |
392 | - case 3: | |
393 | - case 4: | |
394 | - return ProductStatus.PRODUCT_POP; | |
395 | - case 5: | |
396 | - case 6: | |
397 | - case 7: | |
398 | - case 8: | |
399 | - case 9: | |
400 | - default: | |
401 | - break; | |
402 | - } | |
403 | - return 0; | |
404 | - } | |
173 | + } | |
174 | + | |
175 | + | |
176 | + | |
177 | + | |
405 | 178 | |
406 | 179 | /** |
407 | - * 获取销售类型 | |
408 | - * @param pid | |
180 | + * 对原始SKU串进行编码 | |
181 | + * | |
182 | + * @param oriStr | |
409 | 183 | * @return |
184 | + * @createTime 2014年5月27日 上午12:19:22 | |
185 | + * @author celine | |
410 | 186 | */ |
411 | - public static String getSaleType(Long pid) { | |
412 | - if (pid >= 1000000000l && pid < 5000000000l) { | |
413 | - return ProductStatus.SALE_TYPE_POP; | |
414 | - } else { | |
415 | - return null; | |
416 | - } | |
417 | - } | |
418 | - public static void main(String[] args) throws Exception{ | |
187 | + public static String encode(String oriStr) { | |
188 | + try { | |
189 | + BigInteger bi = elevenToTen(oriStr); | |
190 | + return tenToM(bi, SKU_RADIX); | |
191 | + } catch (Exception e) { | |
192 | + logger.error("Encode Error. ", e); | |
193 | + return null; | |
194 | + } | |
195 | + } | |
196 | + | |
197 | + /** | |
198 | + * 将编码后的SKU转换为PID:属性值形式 | |
199 | + * | |
200 | + * @param skuEnc 编码后的SKU,包含版本号 | |
201 | + * @return | |
202 | + * @createTime 2014年5月27日 上午12:20:17 | |
203 | + * @author celine | |
204 | + */ | |
205 | + public static String decode(String skuEnc) { | |
206 | + return decode(skuEnc, true); | |
207 | + } | |
208 | + | |
209 | + /** | |
210 | + * 将编码后的SKU转换为PID:属性值形式 | |
211 | + * | |
212 | + * @param skuEnc 编码后的SKU | |
213 | + * @param hasVersion sku中是否包含sku信息 | |
214 | + * @return | |
215 | + * @createTime 2014年5月27日 上午12:20:17 | |
216 | + * @author celine | |
217 | + */ | |
218 | + public static String decode(String skuEnc, boolean hasVersion) { | |
219 | + try { | |
220 | + BigInteger bi = sixtytwoToTen(skuEnc); | |
221 | + String skuOriWithVersion = tenToM(bi, ORI_RADIX); | |
222 | + if (hasVersion) { | |
223 | + return skuOriWithVersion.substring(skuOriWithVersion.indexOf(SPLIT) + 1, skuOriWithVersion.length()); | |
224 | + } | |
225 | + return skuOriWithVersion; | |
226 | + } catch (Exception e) { | |
227 | + logger.error("Decode Error. ", e); | |
228 | + return null; | |
229 | + } | |
230 | + } | |
231 | + | |
232 | + /** | |
233 | + * 将任意进制的数转换为十进制,本系统中用':'作为第十一位, | |
234 | + * | |
235 | + * @param s | |
236 | + * @return | |
237 | + * @createTime 2014年5月26日 下午10:27:05 | |
238 | + * @author celine | |
239 | + */ | |
240 | + private static BigInteger elevenToTen(String s) throws Exception { | |
241 | + | |
242 | + Pattern pattern = Pattern.compile("^[0-9:]+$"); | |
243 | + Matcher matcher = pattern.matcher(s); | |
244 | + | |
245 | + if (matcher.find()) { | |
246 | + BigInteger oriBi = BigInteger.valueOf(ORI_RADIX); | |
247 | + BigInteger tmpBi = new BigInteger("0"); | |
248 | + for (int i = 0; i < s.length(); i++) { | |
249 | + char tmpC = s.charAt(i); | |
250 | + int tmp = tmpC - '0'; | |
251 | + tmpBi = tmpBi.multiply(oriBi).add(BigInteger.valueOf(tmp)); | |
252 | + } | |
253 | + return tmpBi; | |
254 | + } else { | |
255 | + // 不全为数字和':' | |
256 | + logger.error("Invalid input " + s); | |
257 | + throw new Exception("Invalid input " + s); | |
258 | + } | |
259 | + } | |
260 | + | |
261 | + private static BigInteger sixtytwoToTen(String s) throws Exception { | |
262 | + Pattern pattern = Pattern.compile("^[0-9a-zA-z]+$"); | |
263 | + Matcher matcher = pattern.matcher(s); | |
264 | + | |
265 | + if (matcher.find()) { | |
266 | + BigInteger skuBi = BigInteger.valueOf(SKU_RADIX); | |
267 | + BigInteger tmpBi = new BigInteger("0"); | |
268 | + for (int i = 0; i < s.length(); i++) { | |
269 | + char tmpC = s.charAt(i); | |
270 | + int tmp = convertStringToInt62(tmpC); | |
271 | + tmpBi = tmpBi.multiply(skuBi).add(BigInteger.valueOf(tmp)); | |
272 | + } | |
273 | + return tmpBi; | |
274 | + } else { | |
275 | + // 不全为数字和大小写字母 | |
276 | + throw new Exception("Invalid input " + s); | |
277 | + } | |
278 | + } | |
279 | + | |
280 | + /** | |
281 | + * 将十进制转换为十一或六十二 | |
282 | + * | |
283 | + * @param bi | |
284 | + * @param m | |
285 | + * @throws Exception | |
286 | + * @createTime 2014年5月26日 下午10:58:20 | |
287 | + * @author celine | |
288 | + */ | |
289 | + private static String tenToM(BigInteger bi, int m) throws Exception { | |
290 | + StringBuffer bs = new StringBuffer(); | |
291 | + BigInteger zero = BigInteger.valueOf(0); | |
292 | + BigInteger targetBi = BigInteger.valueOf(m); | |
293 | + while (bi.compareTo(zero) > 0) { | |
294 | + BigInteger mod = bi.mod(targetBi); | |
295 | + if (m == ORI_RADIX) { | |
296 | + bs.insert(0, convertIntToString11(mod.intValue())); | |
297 | + } else if (m == SKU_RADIX) { | |
298 | + bs.insert(0, convertIntToString62(mod.intValue())); | |
299 | + } | |
300 | + bi = bi.divide(targetBi); | |
301 | + } | |
302 | + return bs.toString(); | |
303 | + } | |
304 | + | |
305 | + /** | |
306 | + * 将整数转换为对应62进制的字符 | |
307 | + * | |
308 | + * @param i | |
309 | + * @return | |
310 | + * @throws Exception | |
311 | + * @createTime 2014年5月26日 下午11:14:24 | |
312 | + * @author celine | |
313 | + */ | |
314 | + private static char convertIntToString62(int i) throws Exception { | |
315 | + if (i >= 0 && i <= 9) { | |
316 | + return (char) (i + '0'); | |
317 | + } else if (i > 9 && i < 36) { | |
318 | + return (char) ('a' + i - 10); | |
319 | + } else if (i >= 36 && i < 62) { | |
320 | + return (char) ('A' + i - 36); | |
321 | + } else { | |
322 | + throw new Exception("Invalid input " + i); | |
323 | + } | |
324 | + } | |
325 | + | |
326 | + /** | |
327 | + * 将整数转换为对应11进制的字符 | |
328 | + * | |
329 | + * @param i | |
330 | + * @return | |
331 | + * @throws Exception | |
332 | + * @createTime 2014年5月26日 下午11:30:15 | |
333 | + * @author celine | |
334 | + */ | |
335 | + private static char convertIntToString11(int i) throws Exception { | |
336 | + if (i >= 0 && i <= 10) { | |
337 | + return (char) (i + '0'); | |
338 | + } else { | |
339 | + throw new Exception("Invalid input " + i); | |
340 | + } | |
341 | + } | |
342 | + | |
343 | + private static int convertStringToInt62(char c) throws Exception { | |
344 | + if (c >= '0' && c <= '9') { | |
345 | + return c - '0'; | |
346 | + } else if (c >= 'a' && c <= 'z') { | |
347 | + return c - 'a' + 10; | |
348 | + } else if (c >= 'A' && c <= 'Z') { | |
349 | + return c - 'A' + 36; | |
350 | + } else { | |
351 | + throw new Exception("Invalid input " + c); | |
352 | + } | |
353 | + } | |
354 | + | |
355 | + public static void main(String[] args) throws Exception { | |
419 | 356 | // String [] str={"2t3on7sJ8o","dUFFyuPwZ","2t3on7A9ZX","2t3on7A9ZZ","dUFFyvvqA","dUFFyvvqC","dUFFywbFG","dUFFywbFF","dUFFywbFE"}; |
420 | 357 | // String [] str={"8HaxIIqWR","8HaxIIqWT","N0XqBUPp","N0XqBUPr","N0XqC2rJ","N0XqC2rI"}; |
421 | 358 | // for(int i=0;i<str.length;i++){ |
... | ... | @@ -427,10 +364,10 @@ public class SkuUtil { |
427 | 364 | // System.out.println(SkuUtil.decode("2t3on6CVif", false)); |
428 | 365 | // System.out.println(SkuUtil.encode("2t3on6CVif",123123123)); |
429 | 366 | // System.out.println(SkuUtil.decode("1aP75Z99Kmb", true)); |
430 | - System.out.println(SkuUtil.getVersion("9NNcC936")); | |
431 | - System.out.println(SkuUtil.getSkuEncWithOutVersion("9NNcC936")); | |
367 | + System.out.println(SkuUtil.getVersion("9NNcC936")); | |
368 | + System.out.println(SkuUtil.getSkuEncWithOutVersion("9NNcC936")); | |
432 | 369 | |
433 | 370 | // System.out.println(SkuUtil.decode("6HGkoES51V")); |
434 | 371 | |
435 | - } | |
372 | + } | |
436 | 373 | } | ... | ... |
titan-api/src/main/java/com/diligrp/titan/common/utils/SortList.java
... | ... | @@ -10,35 +10,37 @@ import java.util.List; |
10 | 10 | * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. <br /> |
11 | 11 | * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> |
12 | 12 | * <B>Company</B> 地利集团 |
13 | + * | |
13 | 14 | * @param <E> |
14 | - * @createTime 2014年6月10日 下午8:29:27 | |
15 | 15 | * @author yangjianjun |
16 | + * @createTime 2014年6月10日 下午8:29:27 | |
16 | 17 | */ |
17 | -public class SortList<E>{ | |
18 | +public class SortList<E> { | |
18 | 19 | /** |
19 | 20 | * this method is 对象排序 |
20 | - * @param list list的泛型对象 | |
21 | - * @param method 排序的字段<getXXX> | |
22 | - * @param sort 若倒序填写desc;否则填null | |
21 | + * | |
22 | + * @param list list的泛型对象 | |
23 | + * @param method 排序的字段<getXXX> | |
24 | + * @param sort 若倒序填写desc;否则填null | |
23 | 25 | * @createTime 2014年6月11日 上午10:00:21 |
24 | 26 | * @author yangjianjun |
25 | 27 | */ |
26 | - public void sort(List<E> list, final String method, final String sort){ | |
27 | - Collections.sort(list, new Comparator() { | |
28 | - public int compare(Object a, Object b) { | |
29 | - int ret = 0; | |
30 | - try{ | |
31 | - Method m1 = ((E)a).getClass().getMethod(method, null); | |
32 | - Method m2 = ((E)b).getClass().getMethod(method, null); | |
33 | - if(sort != null && "desc".equals(sort))//倒序 | |
34 | - ret = m2.invoke(((E)b), null).toString().compareTo(m1.invoke(((E)a), null).toString()); | |
28 | + public void sort(List<E> list, final String method, final String sort) { | |
29 | + Collections.sort(list, new Comparator() { | |
30 | + public int compare(Object a, Object b) { | |
31 | + int ret = 0; | |
32 | + try { | |
33 | + Method m1 = ((E) a).getClass().getMethod(method, null); | |
34 | + Method m2 = ((E) b).getClass().getMethod(method, null); | |
35 | + if (sort != null && "desc".equals(sort))//倒序 | |
36 | + ret = m2.invoke(((E) b), null).toString().compareTo(m1.invoke(((E) a), null).toString()); | |
35 | 37 | else//正序 |
36 | - ret = m1.invoke(((E)a), null).toString().compareTo(m2.invoke(((E)b), null).toString()); | |
37 | - }catch(Exception ex){ | |
38 | - System.out.println(ex); | |
39 | - } | |
40 | - return ret; | |
41 | - } | |
42 | - }); | |
43 | - } | |
38 | + ret = m1.invoke(((E) a), null).toString().compareTo(m2.invoke(((E) b), null).toString()); | |
39 | + } catch (Exception ex) { | |
40 | + System.out.println(ex); | |
41 | + } | |
42 | + return ret; | |
43 | + } | |
44 | + }); | |
45 | + } | |
44 | 46 | } | ... | ... |
titan-api/src/main/java/com/diligrp/titan/common/utils/html/EscapeHtmlReference.java
... | ... | @@ -8,25 +8,25 @@ import org.apache.velocity.app.event.implement.EscapeReference; |
8 | 8 | */ |
9 | 9 | public class EscapeHtmlReference extends EscapeReference { |
10 | 10 | |
11 | - protected String escape(Object text) { | |
12 | - if (!(text instanceof String)) { | |
13 | - return text.toString(); | |
14 | - } | |
15 | - StringBuffer str = new StringBuffer(); | |
16 | - char[] cs = text.toString().toCharArray(); | |
17 | - for (char c : cs) { | |
18 | - if (c == '>') { | |
19 | - str.append(">"); | |
20 | - } else if (c == '<') { | |
21 | - str.append("<"); | |
22 | - } else { | |
23 | - str.append(c); | |
24 | - } | |
25 | - } | |
26 | - return str.toString(); | |
27 | - } | |
11 | + protected String escape(Object text) { | |
12 | + if (!(text instanceof String)) { | |
13 | + return text.toString(); | |
14 | + } | |
15 | + StringBuffer str = new StringBuffer(); | |
16 | + char[] cs = text.toString().toCharArray(); | |
17 | + for (char c : cs) { | |
18 | + if (c == '>') { | |
19 | + str.append(">"); | |
20 | + } else if (c == '<') { | |
21 | + str.append("<"); | |
22 | + } else { | |
23 | + str.append(c); | |
24 | + } | |
25 | + } | |
26 | + return str.toString(); | |
27 | + } | |
28 | 28 | |
29 | - protected String getMatchAttribute() { | |
30 | - return "eventhandler.escape.html.match"; | |
31 | - } | |
29 | + protected String getMatchAttribute() { | |
30 | + return "eventhandler.escape.html.match"; | |
31 | + } | |
32 | 32 | } | ... | ... |
titan-api/src/main/java/com/diligrp/titan/common/utils/web/BaseController.java
... | ... | @@ -18,140 +18,138 @@ import java.util.Map; |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * BaseController |
21 | - * | |
22 | 21 | */ |
23 | 22 | public class BaseController extends VelocitySupport { |
24 | - protected final static String DEFAULT_CHARTSET = "UTF-8"; | |
25 | - protected final static String DEFAULT_JSON_CONTENT_TYPE = "application/json;charset=" | |
26 | - + DEFAULT_CHARTSET; | |
23 | + protected final static String DEFAULT_CHARTSET = "UTF-8"; | |
24 | + protected final static String DEFAULT_JSON_CONTENT_TYPE = "application/json;charset=" | |
25 | + + DEFAULT_CHARTSET; | |
27 | 26 | |
28 | - @Resource | |
29 | - private HttpServletRequest request; | |
30 | - | |
31 | - /** | |
32 | - * 输出文本 | |
33 | - * | |
34 | - * @param txt | |
35 | - * @param contextType | |
36 | - */ | |
37 | - protected void write(HttpServletResponse response, String txt, | |
38 | - String contextType) { | |
39 | - try { | |
40 | - if (!StringUtils.isEmpty(txt)) { | |
41 | - return; | |
42 | - } | |
43 | - response.setContentType(contextType); | |
44 | - response.getOutputStream().write(txt.getBytes(DEFAULT_CHARTSET)); | |
45 | - } catch (Exception ex) { | |
46 | - throw new WebException(ex); | |
47 | - } | |
48 | - } | |
27 | + @Resource | |
28 | + private HttpServletRequest request; | |
49 | 29 | |
50 | - /** | |
51 | - * 输出JSON对象 | |
52 | - * | |
53 | - * @param model | |
54 | - */ | |
55 | - protected void writeJSON(HttpServletResponse response, Object model) { | |
56 | - write(response, JSON.toJSONString(model), DEFAULT_JSON_CONTENT_TYPE); | |
57 | - } | |
30 | + /** | |
31 | + * 输出文本 | |
32 | + * | |
33 | + * @param txt | |
34 | + * @param contextType | |
35 | + */ | |
36 | + protected void write(HttpServletResponse response, String txt, | |
37 | + String contextType) { | |
38 | + try { | |
39 | + if (!StringUtils.isEmpty(txt)) { | |
40 | + return; | |
41 | + } | |
42 | + response.setContentType(contextType); | |
43 | + response.getOutputStream().write(txt.getBytes(DEFAULT_CHARTSET)); | |
44 | + } catch (Exception ex) { | |
45 | + throw new WebException(ex); | |
46 | + } | |
47 | + } | |
58 | 48 | |
59 | - protected Map<String, Object> getDefaultContext() { | |
60 | - Map<String, Object> context = new HashMap<String, Object>(); | |
61 | - return context; | |
62 | - } | |
49 | + /** | |
50 | + * 输出JSON对象 | |
51 | + * | |
52 | + * @param model | |
53 | + */ | |
54 | + protected void writeJSON(HttpServletResponse response, Object model) { | |
55 | + write(response, JSON.toJSONString(model), DEFAULT_JSON_CONTENT_TYPE); | |
56 | + } | |
63 | 57 | |
64 | - protected ViewBuilder toView(String template) { | |
65 | - ViewBuilder vb = new ViewBuilder(template, this); | |
66 | - return vb; | |
67 | - } | |
68 | - | |
69 | - /** | |
70 | - * java bean to json | |
71 | - * | |
72 | - * @param object | |
73 | - * @return | |
74 | - */ | |
75 | - protected String objectToJSON(Object object) { | |
76 | - // try { | |
77 | - // return new ObjectMapper().writeValueAsString(object); | |
78 | - // } catch (JsonGenerationException e) { | |
79 | - // e.printStackTrace(); | |
80 | - // } catch (JsonMappingException e) { | |
81 | - // e.printStackTrace(); | |
82 | - // } catch (IOException e) { | |
83 | - // e.printStackTrace(); | |
84 | - // } | |
85 | - return ""; | |
86 | - } | |
58 | + protected Map<String, Object> getDefaultContext() { | |
59 | + Map<String, Object> context = new HashMap<String, Object>(); | |
60 | + return context; | |
61 | + } | |
87 | 62 | |
88 | - /** | |
89 | - * json to java bean | |
90 | - * | |
91 | - * @param <T> | |
92 | - * @param jsonStr | |
93 | - * @param t | |
94 | - * @return | |
95 | - */ | |
96 | - protected <T> T JSONToObject(String jsonStr, Class<T> t) { | |
97 | - // try { | |
98 | - // return new ObjectMapper().readValue(jsonStr, t); | |
99 | - // } catch (JsonParseException e) { | |
100 | - // e.printStackTrace(); | |
101 | - // } catch (JsonMappingException e) { | |
102 | - // e.printStackTrace(); | |
103 | - // } catch (IOException e) { | |
104 | - // e.printStackTrace(); | |
105 | - // } | |
106 | - return null; | |
107 | - } | |
63 | + protected ViewBuilder toView(String template) { | |
64 | + ViewBuilder vb = new ViewBuilder(template, this); | |
65 | + return vb; | |
66 | + } | |
108 | 67 | |
109 | - protected void writeStringToResponse(HttpServletResponse response, | |
110 | - String text) throws IOException { | |
111 | - response.setContentType("text/plain;charset=UTF-8"); | |
112 | - PrintWriter out = response.getWriter(); | |
113 | - out.write(text); | |
114 | - } | |
115 | - | |
116 | - /** | |
117 | - * 便利地判断输入参数是否合法,如果输入参数不符合预期,则会抛出 IllegalArgumentException | |
118 | - * | |
119 | - * @param expect 期望输入结果 | |
120 | - * @param msg 错误消息 | |
121 | - */ | |
122 | - protected void checkParam(boolean expect, String msg) throws IllegalArgumentException{ | |
123 | - if(!expect){ | |
124 | - throw new IllegalArgumentException(msg); | |
125 | - } | |
126 | - } | |
127 | - | |
128 | - /** | |
129 | - * 接收前端提交的list类型参数,并把list内部元素转换成响应PO对象 | |
130 | - * | |
131 | - * @author xiaoyang@diligrp.com 2014年5月19日 | |
132 | - * | |
133 | - * @param paramName 参数名 | |
134 | - * @param clazz list内部po类型 | |
135 | - * @return | |
136 | - * @throws Exception | |
137 | - */ | |
138 | - protected <E> List<E> parseParam(String paramName, Class<E> clazz) throws Exception{ | |
139 | - List<E> result = new ArrayList<E>(); | |
140 | - String param = request.getParameter(paramName); | |
141 | - if(param == null){ | |
142 | - throw new IllegalArgumentException("指定的参数 :" + paramName + " 不存在" ); | |
143 | - } | |
144 | - JSONArray array = JSON.parseArray(param); | |
145 | - for(Object a : array){ | |
146 | - result.add(JSON.parseObject(a.toString(), clazz)); | |
147 | - } | |
148 | - | |
149 | - return result; | |
150 | - } | |
151 | - | |
152 | - protected String generateResultString(JSONObject result, String msg, boolean success){ | |
153 | - result.put("msg", msg); | |
154 | - result.put("success", success); | |
155 | - return result.toJSONString(); | |
156 | - } | |
68 | + /** | |
69 | + * java bean to json | |
70 | + * | |
71 | + * @param object | |
72 | + * @return | |
73 | + */ | |
74 | + protected String objectToJSON(Object object) { | |
75 | + // try { | |
76 | + // return new ObjectMapper().writeValueAsString(object); | |
77 | + // } catch (JsonGenerationException e) { | |
78 | + // e.printStackTrace(); | |
79 | + // } catch (JsonMappingException e) { | |
80 | + // e.printStackTrace(); | |
81 | + // } catch (IOException e) { | |
82 | + // e.printStackTrace(); | |
83 | + // } | |
84 | + return ""; | |
85 | + } | |
86 | + | |
87 | + /** | |
88 | + * json to java bean | |
89 | + * | |
90 | + * @param <T> | |
91 | + * @param jsonStr | |
92 | + * @param t | |
93 | + * @return | |
94 | + */ | |
95 | + protected <T> T JSONToObject(String jsonStr, Class<T> t) { | |
96 | + // try { | |
97 | + // return new ObjectMapper().readValue(jsonStr, t); | |
98 | + // } catch (JsonParseException e) { | |
99 | + // e.printStackTrace(); | |
100 | + // } catch (JsonMappingException e) { | |
101 | + // e.printStackTrace(); | |
102 | + // } catch (IOException e) { | |
103 | + // e.printStackTrace(); | |
104 | + // } | |
105 | + return null; | |
106 | + } | |
107 | + | |
108 | + protected void writeStringToResponse(HttpServletResponse response, | |
109 | + String text) throws IOException { | |
110 | + response.setContentType("text/plain;charset=UTF-8"); | |
111 | + PrintWriter out = response.getWriter(); | |
112 | + out.write(text); | |
113 | + } | |
114 | + | |
115 | + /** | |
116 | + * 便利地判断输入参数是否合法,如果输入参数不符合预期,则会抛出 IllegalArgumentException | |
117 | + * | |
118 | + * @param expect 期望输入结果 | |
119 | + * @param msg 错误消息 | |
120 | + */ | |
121 | + protected void checkParam(boolean expect, String msg) throws IllegalArgumentException { | |
122 | + if (!expect) { | |
123 | + throw new IllegalArgumentException(msg); | |
124 | + } | |
125 | + } | |
126 | + | |
127 | + /** | |
128 | + * 接收前端提交的list类型参数,并把list内部元素转换成响应PO对象 | |
129 | + * | |
130 | + * @param paramName 参数名 | |
131 | + * @param clazz list内部po类型 | |
132 | + * @return | |
133 | + * @throws Exception | |
134 | + * @author xiaoyang@diligrp.com 2014年5月19日 | |
135 | + */ | |
136 | + protected <E> List<E> parseParam(String paramName, Class<E> clazz) throws Exception { | |
137 | + List<E> result = new ArrayList<E>(); | |
138 | + String param = request.getParameter(paramName); | |
139 | + if (param == null) { | |
140 | + throw new IllegalArgumentException("指定的参数 :" + paramName + " 不存在"); | |
141 | + } | |
142 | + JSONArray array = JSON.parseArray(param); | |
143 | + for (Object a : array) { | |
144 | + result.add(JSON.parseObject(a.toString(), clazz)); | |
145 | + } | |
146 | + | |
147 | + return result; | |
148 | + } | |
149 | + | |
150 | + protected String generateResultString(JSONObject result, String msg, boolean success) { | |
151 | + result.put("msg", msg); | |
152 | + result.put("success", success); | |
153 | + return result.toJSONString(); | |
154 | + } | |
157 | 155 | } | ... | ... |