Commit 3c3cd271000c9f4cdf4bc27af39be2596e50ea5f
1 parent
b7cb7cb7
ini
Showing
40 changed files
with
4844 additions
and
0 deletions
Too many changes to show.
To preserve performance only 40 of 1459 files are displayed.
titan-web/pom.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | |
3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |
4 | + <modelVersion>4.0.0</modelVersion> | |
5 | + <parent> | |
6 | + <groupId>com.dili</groupId> | |
7 | + <artifactId>titan</artifactId> | |
8 | + <version>1.0</version> | |
9 | + </parent> | |
10 | + | |
11 | + <artifactId>titan-web</artifactId> | |
12 | + <packaging>war</packaging> | |
13 | + <name>titan-web</name> | |
14 | + | |
15 | + <properties> | |
16 | + <jdk.version>1.7</jdk.version> | |
17 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
18 | + <maven.compiler.encoding>UTF-8</maven.compiler.encoding> | |
19 | + <spring.version>3.2.9.RELEASE</spring.version> | |
20 | + <aspectj.version>1.6.11</aspectj.version> | |
21 | + <jackson.version>1.9.2</jackson.version> | |
22 | + <slf4j.version>1.6.4</slf4j.version> | |
23 | + </properties> | |
24 | + | |
25 | + <build> | |
26 | + <resources> | |
27 | + <resource> | |
28 | + <directory>src/main/resources</directory> | |
29 | + <filtering>true</filtering> | |
30 | + </resource> | |
31 | + </resources> | |
32 | + <plugins> | |
33 | + <plugin> | |
34 | + <!-- war插件 --> | |
35 | + <groupId>org.apache.maven.plugins</groupId> | |
36 | + <artifactId>maven-war-plugin</artifactId> | |
37 | + <version>2.3</version> | |
38 | + </plugin> | |
39 | + <plugin> | |
40 | + <groupId>org.apache.maven.plugins</groupId> | |
41 | + <artifactId>maven-compiler-plugin</artifactId> | |
42 | + <version>2.5.1</version> | |
43 | + <configuration> | |
44 | + <source>1.7</source> | |
45 | + <target>1.7</target> | |
46 | + <encoding>UTF-8</encoding> | |
47 | + </configuration> | |
48 | + </plugin> | |
49 | + <!-- 配置构建时忽略测试用例 --> | |
50 | + <plugin> | |
51 | + <groupId>org.apache.maven.plugins</groupId> | |
52 | + <artifactId>maven-surefire-plugin</artifactId> | |
53 | + <configuration> | |
54 | + <skipTests>true</skipTests> | |
55 | + </configuration> | |
56 | + </plugin> | |
57 | + <plugin> | |
58 | + <groupId>org.mortbay.jetty</groupId> | |
59 | + <artifactId>maven-jetty-plugin</artifactId> | |
60 | + <version>6.1.26</version> | |
61 | + <configuration> | |
62 | + <scanIntervalSeconds>3</scanIntervalSeconds> | |
63 | + <contextPath>/</contextPath> | |
64 | + <connectors> | |
65 | + <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> | |
66 | + <port>80</port> | |
67 | + </connector> | |
68 | + </connectors> | |
69 | + </configuration> | |
70 | + </plugin> | |
71 | + <plugin> | |
72 | + <groupId>org.apache.tomcat.maven</groupId> | |
73 | + <artifactId>tomcat7-maven-plugin</artifactId> | |
74 | + <version>2.2</version> | |
75 | + <configuration> | |
76 | + <port>80</port> | |
77 | + <path>/</path> | |
78 | + </configuration> | |
79 | + </plugin> | |
80 | + <plugin> | |
81 | + <artifactId>maven-resources-plugin</artifactId> | |
82 | + <version>2.5</version> | |
83 | + <executions> | |
84 | + <execution> | |
85 | + <id>copy-xmls</id> | |
86 | + <phase>process-sources</phase> | |
87 | + <goals> | |
88 | + <goal>copy-resources</goal> | |
89 | + </goals> | |
90 | + <configuration> | |
91 | + <outputDirectory>${basedir}/target/classes</outputDirectory> | |
92 | + <resources> | |
93 | + <resource> | |
94 | + <directory>${basedir}/src/main/hbase-profiles/${package.env}</directory> | |
95 | + <includes> | |
96 | + <include>**/*.xml</include> | |
97 | + </includes> | |
98 | + </resource> | |
99 | + </resources> | |
100 | + </configuration> | |
101 | + </execution> | |
102 | + </executions> | |
103 | + </plugin> | |
104 | + </plugins> | |
105 | + </build> | |
106 | + | |
107 | + <dependencies> | |
108 | + <!-- spring --> | |
109 | + <dependency> | |
110 | + <groupId>org.springframework</groupId> | |
111 | + <artifactId>spring-webmvc</artifactId> | |
112 | + <version>${spring.version}</version> | |
113 | + <exclusions> | |
114 | + <exclusion> | |
115 | + <groupId>commons-logging</groupId> | |
116 | + <artifactId>commons-logging</artifactId> | |
117 | + </exclusion> | |
118 | + </exclusions> | |
119 | + </dependency> | |
120 | + <dependency> | |
121 | + <groupId>org.springframework</groupId> | |
122 | + <artifactId>spring-jdbc</artifactId> | |
123 | + <version>${spring.version}</version> | |
124 | + </dependency> | |
125 | + <dependency> | |
126 | + <groupId>org.springframework</groupId> | |
127 | + <artifactId>spring-tx</artifactId> | |
128 | + <version>${spring.version}</version> | |
129 | + </dependency> | |
130 | + <dependency> | |
131 | + <groupId>org.springframework</groupId> | |
132 | + <artifactId>spring-asm</artifactId> | |
133 | + <version>${spring.version}</version> | |
134 | + </dependency> | |
135 | + <dependency> | |
136 | + <groupId>org.springframework</groupId> | |
137 | + <artifactId>spring-context-support</artifactId> | |
138 | + <version>${spring.version}</version> | |
139 | + </dependency> | |
140 | + <dependency> | |
141 | + <groupId>org.springframework</groupId> | |
142 | + <artifactId>spring-expression</artifactId> | |
143 | + <version>${spring.version}</version> | |
144 | + </dependency> | |
145 | + <dependency> | |
146 | + <groupId>org.springframework</groupId> | |
147 | + <artifactId>spring-web</artifactId> | |
148 | + <version>${spring.version}</version> | |
149 | + </dependency> | |
150 | + | |
151 | + <!-- LOG4J日志记录 --> | |
152 | + <dependency> | |
153 | + <groupId>org.slf4j</groupId> | |
154 | + <artifactId>slf4j-api</artifactId> | |
155 | + <version>1.6.4</version> | |
156 | + </dependency> | |
157 | + <dependency> | |
158 | + <groupId>org.slf4j</groupId> | |
159 | + <artifactId>slf4j-log4j12</artifactId> | |
160 | + <version>1.6.4</version> | |
161 | + </dependency> | |
162 | + <dependency> | |
163 | + <groupId>log4j</groupId> | |
164 | + <artifactId>log4j</artifactId> | |
165 | + <version>1.2.17</version> | |
166 | + </dependency> | |
167 | + | |
168 | + <dependency> | |
169 | + <groupId>commons-lang</groupId> | |
170 | + <artifactId>commons-lang</artifactId> | |
171 | + <version>2.5</version> | |
172 | + </dependency> | |
173 | + | |
174 | + <dependency> | |
175 | + <groupId>commons-codec</groupId> | |
176 | + <artifactId>commons-codec</artifactId> | |
177 | + <version>1.6</version> | |
178 | + </dependency> | |
179 | + <dependency> | |
180 | + <groupId>org.mybatis</groupId> | |
181 | + <artifactId>mybatis</artifactId> | |
182 | + <version>3.2.1</version> | |
183 | + </dependency> | |
184 | + <dependency> | |
185 | + <groupId>org.mybatis</groupId> | |
186 | + <artifactId>mybatis-spring</artifactId> | |
187 | + <version>1.2.0</version> | |
188 | + </dependency> | |
189 | + <!--<dependency>--> | |
190 | + <!--<groupId>com.jolbox</groupId>--> | |
191 | + <!--<artifactId>bonecp</artifactId>--> | |
192 | + <!--<version>0.7.1.RELEASE</version>--> | |
193 | + <!--</dependency>--> | |
194 | + <dependency> | |
195 | + <groupId>com.alibaba</groupId> | |
196 | + <artifactId>druid</artifactId> | |
197 | + <version>1.0.11</version> | |
198 | + </dependency> | |
199 | + | |
200 | + <dependency> | |
201 | + <groupId>mysql</groupId> | |
202 | + <artifactId>mysql-connector-java</artifactId> | |
203 | + <version>5.1.25</version> | |
204 | + </dependency> | |
205 | + | |
206 | + <!-- 工具类 --> | |
207 | + <!-- google sets,maps --> | |
208 | + <dependency> | |
209 | + <groupId>com.google.guava</groupId> | |
210 | + <artifactId>guava</artifactId> | |
211 | + <version>14.0.1</version> | |
212 | + </dependency> | |
213 | + <!-- JSON --> | |
214 | + <dependency> | |
215 | + <groupId>com.alibaba</groupId> | |
216 | + <artifactId>fastjson</artifactId> | |
217 | + <version>1.1.31</version> | |
218 | + </dependency> | |
219 | + <dependency> | |
220 | + <groupId>org.aspectj</groupId> | |
221 | + <artifactId>aspectjweaver</artifactId> | |
222 | + <version>1.7.2</version> | |
223 | + </dependency> | |
224 | + <dependency> | |
225 | + <groupId>cglib</groupId> | |
226 | + <artifactId>cglib-nodep</artifactId> | |
227 | + <version>2.1_3</version> | |
228 | + </dependency> | |
229 | + | |
230 | + <!-- common logging replacer --> | |
231 | + <dependency> | |
232 | + <groupId>org.slf4j</groupId> | |
233 | + <artifactId>jcl-over-slf4j</artifactId> | |
234 | + <version>${slf4j.version}</version> | |
235 | + </dependency> | |
236 | + <!-- if you enable @AspectJ style AOP in spring. --> | |
237 | + <dependency> | |
238 | + <groupId>org.aspectj</groupId> | |
239 | + <artifactId>aspectjrt</artifactId> | |
240 | + <version>${aspectj.version}</version> | |
241 | + </dependency> | |
242 | + <!-- if you enable JSR303 (Bean Validation) in spring. --> | |
243 | + <dependency> | |
244 | + <groupId>org.hibernate</groupId> | |
245 | + <artifactId>hibernate-validator</artifactId> | |
246 | + <version>4.2.0.Final</version> | |
247 | + </dependency> | |
248 | + <!-- if you use velocity view in springmvc --> | |
249 | + <dependency> | |
250 | + <groupId>org.apache.velocity</groupId> | |
251 | + <artifactId>velocity</artifactId> | |
252 | + <version>1.7</version> | |
253 | + </dependency> | |
254 | + <!-- if you use velocity layout view in springmvc --> | |
255 | + <dependency> | |
256 | + <groupId>org.apache.velocity</groupId> | |
257 | + <artifactId>velocity-tools</artifactId> | |
258 | + <version>2.0</version> | |
259 | + <exclusions> | |
260 | + <exclusion> | |
261 | + <groupId>org.apache.struts</groupId> | |
262 | + <artifactId>struts-core</artifactId> | |
263 | + </exclusion> | |
264 | + <exclusion> | |
265 | + <groupId>org.apache.struts</groupId> | |
266 | + <artifactId>struts-taglib</artifactId> | |
267 | + </exclusion> | |
268 | + <exclusion> | |
269 | + <groupId>org.apache.struts</groupId> | |
270 | + <artifactId>struts-tiles</artifactId> | |
271 | + </exclusion> | |
272 | + <exclusion> | |
273 | + <groupId>sslext</groupId> | |
274 | + <artifactId>sslext</artifactId> | |
275 | + </exclusion> | |
276 | + </exclusions> | |
277 | + </dependency> | |
278 | + <!-- if you enable json support in spring mvc. --> | |
279 | + <dependency> | |
280 | + <groupId>org.codehaus.jackson</groupId> | |
281 | + <artifactId>jackson-mapper-asl</artifactId> | |
282 | + <version>${jackson.version}</version> | |
283 | + </dependency> | |
284 | + <!-- if you use fileupload in spring mvc --> | |
285 | + <dependency> | |
286 | + <groupId>commons-fileupload</groupId> | |
287 | + <artifactId>commons-fileupload</artifactId> | |
288 | + <version>1.2.2</version> | |
289 | + <optional>true</optional> | |
290 | + </dependency> | |
291 | + <!-- test scope --> | |
292 | + <dependency> | |
293 | + <groupId>junit</groupId> | |
294 | + <artifactId>junit</artifactId> | |
295 | + <version>4.10</version> | |
296 | + <scope>test</scope> | |
297 | + </dependency> | |
298 | + <dependency> | |
299 | + <groupId>javax.servlet</groupId> | |
300 | + <artifactId>servlet-api</artifactId> | |
301 | + <version>2.4</version> | |
302 | + <scope>provided</scope> | |
303 | + </dependency> | |
304 | + <dependency> | |
305 | + <groupId>redis.clients</groupId> | |
306 | + <artifactId>jedis</artifactId> | |
307 | + <version>2.4.2</version> | |
308 | + </dependency> | |
309 | + <dependency> | |
310 | + <groupId>org.springframework.data</groupId> | |
311 | + <artifactId>spring-data-redis</artifactId> | |
312 | + <version>1.3.0.RELEASE</version> | |
313 | + <exclusions> | |
314 | + <exclusion> | |
315 | + <groupId>org.springframework</groupId> | |
316 | + <artifactId>spring-core</artifactId> | |
317 | + </exclusion> | |
318 | + <exclusion> | |
319 | + <groupId>org.springframework</groupId> | |
320 | + <artifactId>spring-aop</artifactId> | |
321 | + </exclusion> | |
322 | + <exclusion> | |
323 | + <groupId>org.springframework</groupId> | |
324 | + <artifactId>spring-context</artifactId> | |
325 | + </exclusion> | |
326 | + </exclusions> | |
327 | + </dependency> | |
328 | + <dependency> | |
329 | + <artifactId>hbase-client</artifactId> | |
330 | + <groupId>org.apache.hbase</groupId> | |
331 | + <version>0.96.1.1-cdh5.0.0</version> | |
332 | + </dependency> | |
333 | + <dependency> | |
334 | + <groupId>org.springframework</groupId> | |
335 | + <artifactId>spring-test</artifactId> | |
336 | + <version>${spring.version}</version> | |
337 | + </dependency> | |
338 | + <!--<dependency>--> | |
339 | + <!--<groupId>org.apache.activemq</groupId>--> | |
340 | + <!--<artifactId>activemq-spring</artifactId>--> | |
341 | + <!--<version>5.9.1</version>--> | |
342 | + <!--</dependency>--> | |
343 | + | |
344 | + | |
345 | + | |
346 | + <!--<dependency>--> | |
347 | + <!--<groupId>org.springframework</groupId>--> | |
348 | + <!--<artifactId>spring-jms</artifactId>--> | |
349 | + <!--<version>${spring.version}</version>--> | |
350 | + <!--</dependency>--> | |
351 | + <dependency> | |
352 | + <groupId>org.apache.httpcomponents</groupId> | |
353 | + <artifactId>httpclient</artifactId> | |
354 | + <version>4.3.3</version> | |
355 | + </dependency> | |
356 | + | |
357 | + <dependency> | |
358 | + <groupId>com.diligrp.log.util</groupId> | |
359 | + <artifactId>diligrp-log-util</artifactId> | |
360 | + <version>0.0.1-SNAPSHOT</version> | |
361 | + </dependency> | |
362 | + <dependency> | |
363 | + <groupId>edit</groupId> | |
364 | + <artifactId>edit</artifactId> | |
365 | + <version>1.0</version> | |
366 | + <scope>system</scope> | |
367 | + <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/ueditor-1.1.1.jar</systemPath> | |
368 | + </dependency> | |
369 | + <dependency> | |
370 | + <groupId>net.bull.javamelody</groupId> | |
371 | + <artifactId>javamelody-core</artifactId> | |
372 | + <version>1.37.0</version> | |
373 | + </dependency> | |
374 | + | |
375 | + </dependencies> | |
376 | + | |
377 | +<!-- 打包配置信息 --> | |
378 | + <profiles> | |
379 | + <profile> | |
380 | + <!-- 开发环境 --> | |
381 | + <id>develop</id> | |
382 | + <!-- 默认 --> | |
383 | + <activation> | |
384 | + <activeByDefault>true</activeByDefault> | |
385 | + </activation> | |
386 | + <properties> | |
387 | + <package.env>develop</package.env> | |
388 | + <!--jdbc type --> | |
389 | + <dili_titan.jdbc.datasource.type>dbcp</dili_titan.jdbc.datasource.type> | |
390 | + <!-- 数据库 --> | |
391 | + <dili_titan.jdbc.driver>com.mysql.jdbc.Driver</dili_titan.jdbc.driver> | |
392 | + <!-- 主库配置 --> | |
393 | + <dili_titan.master.jdbc.url>jdbc:MySql://10.28.10.188:3306/agriez_titan?useUnicode=true&characterEncoding=utf8</dili_titan.master.jdbc.url> | |
394 | + <dili_titan.master.jdbc.username>root</dili_titan.master.jdbc.username> | |
395 | + <dili_titan.master.jdbc.password>123456</dili_titan.master.jdbc.password> | |
396 | + <!-- 从库配置--> | |
397 | + <dili_titan.slave.jdbc.url>jdbc:MySql://10.28.10.188:3306/agriez_titan?useUnicode=true&characterEncoding=utf8</dili_titan.slave.jdbc.url> | |
398 | + <dili_titan.slave.jdbc.username>du</dili_titan.slave.jdbc.username> | |
399 | + <dili_titan.slave.jdbc.password>123456</dili_titan.slave.jdbc.password> | |
400 | + <!-- crm接口地址 --> | |
401 | + <dili_titan.crm.url>supplier.1n4j.com</dili_titan.crm.url> | |
402 | + <!-- user接口地址 --> | |
403 | + <dili_titan.user.url>user.1n4j.com</dili_titan.user.url> | |
404 | + <!--shop接口地址,需要测试自己修改 --> | |
405 | + <dili_titan.shop.url>http://shop.1n4j.com</dili_titan.shop.url> | |
406 | + <!-- redis接口地址 --> | |
407 | + <dili_titan.redis.url>10.28.10.208</dili_titan.redis.url> | |
408 | + <!--权限管理的redis配置--> | |
409 | + <manage.redis.url>10.28.10.208</manage.redis.url> | |
410 | + <manage.redis.port>6379</manage.redis.port> | |
411 | + <!-- MQ 地址--> | |
412 | + <conf.mq.namesrvAddr>10.28.10.209:9876;10.28.10.149:9876</conf.mq.namesrvAddr> | |
413 | + <conf.mq.producerGroup>titanPNR</conf.mq.producerGroup> | |
414 | + <!--<dili_titan.mq.url>tcp://10.28.6.114:61616</dili_titan.mq.url>--> | |
415 | + <!-- website接口地址 --> | |
416 | + <dili_titan.website.url>manweb.1n4j.com</dili_titan.website.url> | |
417 | + <!-- 日志 --> | |
418 | + <dili_titan.log.level>INFO</dili_titan.log.level> | |
419 | + <dili_titan.log.path>/export/logs</dili_titan.log.path> | |
420 | + <dili_titan.log.root.appender>CONSOLE</dili_titan.log.root.appender> | |
421 | + <!--打包编码 --> | |
422 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
423 | + <!-- 图片服务器 --> | |
424 | + <project.imageserver.prefix>http://img0.1n4j.com</project.imageserver.prefix> | |
425 | + <project.store.url>http://up.1n4j.com</project.store.url> | |
426 | + <project.store.accessKey>d6a300418bd6fa2178b3bbb06a421f32</project.store.accessKey> | |
427 | + <project.store.secretKey>8d2d1ac5541dcfbbd78ac1793ce4f782</project.store.secretKey> | |
428 | + <!--权限相关配置--> | |
429 | + <conf.manage.enable>true</conf.manage.enable> | |
430 | + <conf.manage.spider>true</conf.manage.spider> | |
431 | + <conf.manage.system>titan</conf.manage.system> | |
432 | + <conf.manage.domain>http://manage.1n4j.com/</conf.manage.domain> | |
433 | + <conf.manage.includes>^/.*</conf.manage.includes> | |
434 | + <conf.manage.excludes>^/noAccess.do$,^/welcome.do$,^/loginControl/.*,^/api/.*,^/common/.*,^/img/.*,^/css/.*,^/assets/.*,^/js/.*,.*?/exportExcel,^/moni,^/init.*,^/titan/productPop/queryProductPopData</conf.manage.excludes> | |
435 | + <!--上传视频--> | |
436 | + <project.fastdfs.trackercount>2</project.fastdfs.trackercount> | |
437 | + <project.fastdfs.connectTimeout>2000</project.fastdfs.connectTimeout> | |
438 | + <project.fastdfs.networkTimeout>30000</project.fastdfs.networkTimeout> | |
439 | + <project.fastdfs.charset>utf-8</project.fastdfs.charset> | |
440 | + <project.fastdfs.trackers>10.28.6.148:22122,10.28.6.149:22122</project.fastdfs.trackers> | |
441 | + <!-- 团购 --> | |
442 | + <project.grouppurchase.url>http://group.1n4j.com</project.grouppurchase.url> | |
443 | + <project.grouppurchase.token>123</project.grouppurchase.token> | |
444 | + <!--爱奇艺视频 --> | |
445 | + <titan.aqy.appkey>e64a09bece964bb484e5decc30c0b950</titan.aqy.appkey> | |
446 | + <titan.aqy.appSecret>f48d2b799f9661acdb6041e4ac7c142f</titan.aqy.appSecret> | |
447 | + </properties> | |
448 | + </profile> | |
449 | + <profile> | |
450 | + <!-- 测试环境 --> | |
451 | + <id>test</id> | |
452 | + <activation> | |
453 | + <activeByDefault>false</activeByDefault> | |
454 | + </activation> | |
455 | + <properties> | |
456 | + <package.env>test</package.env> | |
457 | + <!--jdbc type --> | |
458 | + <dili_titan.jdbc.datasource.type>dbcp</dili_titan.jdbc.datasource.type> | |
459 | + <!-- 数据库 --> | |
460 | + <dili_titan.jdbc.driver>com.mysql.jdbc.Driver</dili_titan.jdbc.driver> | |
461 | + <!-- 主库配置 --> | |
462 | + <dili_titan.master.jdbc.url>jdbc:MySql://10.28.6.156:3306/agriez_titan?useUnicode=true&characterEncoding=utf8</dili_titan.master.jdbc.url> | |
463 | + <dili_titan.master.jdbc.username>root</dili_titan.master.jdbc.username> | |
464 | + <dili_titan.master.jdbc.password>123456</dili_titan.master.jdbc.password> | |
465 | + <!-- 从库配置 --> | |
466 | + <dili_titan.slave.jdbc.url>jdbc:MySql://10.28.6.155:3306/agriez_titan?useUnicode=true&characterEncoding=utf8</dili_titan.slave.jdbc.url> | |
467 | + <dili_titan.slave.jdbc.username>agriez_titan_reader</dili_titan.slave.jdbc.username> | |
468 | + <dili_titan.slave.jdbc.password>123456</dili_titan.slave.jdbc.password> | |
469 | + <!-- crm接口地址 --> | |
470 | + <dili_titan.crm.url>supplier.1n4j.com</dili_titan.crm.url> | |
471 | + <!-- user接口地址,需要测试自己修改 --> | |
472 | + <dili_titan.user.url>user.1n4j.com</dili_titan.user.url> | |
473 | + <!--shop接口地址,需要测试自己修改 --> | |
474 | + <dili_titan.shop.url>http://shop.1n4j.com</dili_titan.shop.url> | |
475 | + <!-- redis接口地址 --> | |
476 | + <dili_titan.redis.url>10.28.10.207</dili_titan.redis.url> | |
477 | + <!--权限管理的redis配置--> | |
478 | + <manage.redis.url>10.28.10.207</manage.redis.url> | |
479 | + <manage.redis.port>6379</manage.redis.port> | |
480 | + <!-- MQ 地址--> | |
481 | + <conf.mq.namesrvAddr>10.28.10.230:9876</conf.mq.namesrvAddr> | |
482 | + <conf.mq.producerGroup>titanPNR</conf.mq.producerGroup> | |
483 | + <!--<dili_titan.mq.url>tcp://10.28.6.54:61616</dili_titan.mq.url>--> | |
484 | + <!-- website接口地址 --> | |
485 | + <dili_titan.website.url>manweb.1n4j.com</dili_titan.website.url> | |
486 | + <!-- 日志 --> | |
487 | + <dili_titan.log.level>INFO</dili_titan.log.level> | |
488 | + <dili_titan.log.path>/home/tomcat/export</dili_titan.log.path> | |
489 | + <dili_titan.log.root.appender>CONSOLE</dili_titan.log.root.appender> | |
490 | + <!--打包编码 --> | |
491 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
492 | + <!-- 图片服务器前缀 --> | |
493 | + <project.imageserver.prefix>http://img0.1n4j.com</project.imageserver.prefix> | |
494 | + <project.store.url>http://up.1n4j.com</project.store.url> | |
495 | + <project.store.accessKey>d6a300418bd6fa2178b3bbb06a421f32</project.store.accessKey> | |
496 | + <project.store.secretKey>8d2d1ac5541dcfbbd78ac1793ce4f782</project.store.secretKey> | |
497 | + <!--权限相关配置--> | |
498 | + <conf.manage.enable>true</conf.manage.enable> | |
499 | + <conf.manage.spider>true</conf.manage.spider> | |
500 | + <conf.manage.system>titan</conf.manage.system> | |
501 | + <conf.manage.domain>http://manage.1n4j.com/</conf.manage.domain> | |
502 | + <conf.manage.includes>^/.*</conf.manage.includes> | |
503 | + <conf.manage.excludes>^/noAccess.do$,^/welcome.do$,^/loginControl/.*,^/api/.*,^/common/.*,^/img/.*,^/css/.*,^/assets/.*,^/js/.*,.*?/exportExcel,^/moni,^/init.*,^/titan/productPop/queryProductPopData</conf.manage.excludes> | |
504 | + <!--上传视频--> | |
505 | + <project.fastdfs.trackercount>2</project.fastdfs.trackercount> | |
506 | + <project.fastdfs.connectTimeout>2000</project.fastdfs.connectTimeout> | |
507 | + <project.fastdfs.networkTimeout>30000</project.fastdfs.networkTimeout> | |
508 | + <project.fastdfs.charset>utf-8</project.fastdfs.charset> | |
509 | + <project.fastdfs.trackers>10.28.6.148:22122,10.28.6.149:22122</project.fastdfs.trackers> | |
510 | + <!-- 团购 --> | |
511 | + <project.grouppurchase.url>http://group.1n4j.com</project.grouppurchase.url> | |
512 | + <project.grouppurchase.token>123</project.grouppurchase.token> | |
513 | + <!--爱奇艺视频 --> | |
514 | + <titan.aqy.appkey>e64a09bece964bb484e5decc30c0b950</titan.aqy.appkey> | |
515 | + <titan.aqy.appSecret>f48d2b799f9661acdb6041e4ac7c142f</titan.aqy.appSecret> | |
516 | + </properties> | |
517 | + </profile> | |
518 | + | |
519 | + <profile> | |
520 | + <!--预发布环境--> | |
521 | + <id>pre-online</id> | |
522 | + <!-- 默认 --> | |
523 | + <activation> | |
524 | + <activeByDefault>false</activeByDefault> | |
525 | + </activation> | |
526 | + <properties> | |
527 | + <package.env>pre-online</package.env> | |
528 | + <!--jdbc type --> | |
529 | + <dili_titan.jdbc.datasource.type>dbcp</dili_titan.jdbc.datasource.type> | |
530 | + <!-- 数据库 --> | |
531 | + <dili_titan.jdbc.driver>com.mysql.jdbc.Driver</dili_titan.jdbc.driver> | |
532 | + <!-- 主库配置 --> | |
533 | + <dili_titan.master.jdbc.url>jdbc:MySql://titan.db.1n4j.com:3306/agriez_titan?useUnicode=true&characterEncoding=utf8</dili_titan.master.jdbc.url> | |
534 | + <dili_titan.master.jdbc.username>root</dili_titan.master.jdbc.username> | |
535 | + <dili_titan.master.jdbc.password>123456</dili_titan.master.jdbc.password> | |
536 | + <!-- 从库配置 --> | |
537 | + <dili_titan.slave.jdbc.url>jdbc:MySql://titan.db.1n4j.com:3306/agriez_titan?useUnicode=true&characterEncoding=utf8</dili_titan.slave.jdbc.url> | |
538 | + <dili_titan.slave.jdbc.username>root</dili_titan.slave.jdbc.username> | |
539 | + <dili_titan.slave.jdbc.password>123456</dili_titan.slave.jdbc.password> | |
540 | + <!-- crm接口地址 --> | |
541 | + <dili_titan.crm.url>supplier.1n4j.com</dili_titan.crm.url> | |
542 | + <!-- user接口地址 --> | |
543 | + <dili_titan.user.url>user.1n4j.com</dili_titan.user.url> | |
544 | + <!--shop接口地址,需要测试自己修改 --> | |
545 | + <dili_titan.shop.url>http://shop.1n4j.com</dili_titan.shop.url> | |
546 | + <!-- redis接口地址 --> | |
547 | + <dili_titan.redis.url>redis.1n4j.com</dili_titan.redis.url> | |
548 | + <!--权限管理的redis配置--> | |
549 | + <manage.redis.url>redis.1n4j.com</manage.redis.url> | |
550 | + <manage.redis.port>6379</manage.redis.port> | |
551 | + <!-- MQ 地址--> | |
552 | + <conf.mq.namesrvAddr>10.28.6.51:9876</conf.mq.namesrvAddr> | |
553 | + <conf.mq.producerGroup>titanPNR</conf.mq.producerGroup> | |
554 | + <!--<dili_titan.mq.url>tcp://192.168.28.28:61616</dili_titan.mq.url>--> | |
555 | + <!-- website接口地址 --> | |
556 | + <dili_titan.website.url>manweb.1n4j.com</dili_titan.website.url> | |
557 | + <!-- 日志 --> | |
558 | + <dili_titan.log.level>INFO</dili_titan.log.level> | |
559 | + <dili_titan.log.path>/diliapp/servers/logs</dili_titan.log.path> | |
560 | + <dili_titan.log.root.appender>FILE_ALL</dili_titan.log.root.appender> | |
561 | + <!--打包编码 --> | |
562 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
563 | + <!-- 图片服务器前缀 --> | |
564 | + <project.imageserver.prefix>http://img0.1n4j.com</project.imageserver.prefix> | |
565 | + <project.store.url>http://up.1n4j.com</project.store.url> | |
566 | + <project.store.accessKey>d6a300418bd6fa2178b3bbb06a421f32</project.store.accessKey> | |
567 | + <project.store.secretKey>8d2d1ac5541dcfbbd78ac1793ce4f782</project.store.secretKey> | |
568 | + <!-- hbase --> | |
569 | + <dili_titan.hbase.url>node2:2181,node3:2181,node4:2181</dili_titan.hbase.url> | |
570 | + <!--权限相关配置--> | |
571 | + <conf.manage.enable>true</conf.manage.enable> | |
572 | + <conf.manage.spider>false</conf.manage.spider> | |
573 | + <conf.manage.system>titan</conf.manage.system> | |
574 | + <conf.manage.domain>http://manage.1n4j.com/</conf.manage.domain> | |
575 | + <conf.manage.includes>^/.*</conf.manage.includes> | |
576 | + <conf.manage.excludes>^/noAccess.do$,^/welcome.do$,^/loginControl/.*,^/api/.*,^/common/.*,^/img/.*,^/css/.*,^/assets/.*,^/js/.*,.*?/exportExcel,^/moni,^/init.*,^/titan/productPop/queryProductPopData</conf.manage.excludes> | |
577 | + <!--上传视频--> | |
578 | + <project.fastdfs.trackercount>2</project.fastdfs.trackercount> | |
579 | + <project.fastdfs.connectTimeout>2000</project.fastdfs.connectTimeout> | |
580 | + <project.fastdfs.networkTimeout>30000</project.fastdfs.networkTimeout> | |
581 | + <project.fastdfs.charset>utf-8</project.fastdfs.charset> | |
582 | + <project.fastdfs.trackers>192.168.28.38:22122,192.168.28.39:22122</project.fastdfs.trackers> | |
583 | + <!-- 团购 --> | |
584 | + <project.grouppurchase.url>http://group.1n4j.com</project.grouppurchase.url> | |
585 | + <project.grouppurchase.token>123</project.grouppurchase.token> | |
586 | + <!--爱奇艺视频 --> | |
587 | + <titan.aqy.appkey>f689d13d9dce48039cae27e6e03940c6</titan.aqy.appkey> | |
588 | + <titan.aqy.appSecret>8633dfebb9f4443d0f1244262bca94f6</titan.aqy.appSecret> | |
589 | + </properties> | |
590 | + </profile> | |
591 | + | |
592 | + <profile> | |
593 | + <!--上线环境--> | |
594 | + <id>online</id> | |
595 | + <!-- 默认 --> | |
596 | + <activation> | |
597 | + <activeByDefault>false</activeByDefault> | |
598 | + </activation> | |
599 | + <properties> | |
600 | + <package.env>online</package.env> | |
601 | + <!--jdbc type --> | |
602 | + <dili_titan.jdbc.datasource.type>dbcp</dili_titan.jdbc.datasource.type> | |
603 | + <!-- 数据库 --> | |
604 | + <dili_titan.jdbc.driver>com.mysql.jdbc.Driver</dili_titan.jdbc.driver> | |
605 | + <!-- 主库配置 --> | |
606 | + <dili_titan.master.jdbc.url>jdbc:MySql://titan.db.1n4j.com:3306/agriez_titan?useUnicode=true&characterEncoding=utf8</dili_titan.master.jdbc.url> | |
607 | + <dili_titan.master.jdbc.username>appAccPayor</dili_titan.master.jdbc.username> | |
608 | + <dili_titan.master.jdbc.password>iTDYVBtI6MX4NQ3Er2Oh</dili_titan.master.jdbc.password> | |
609 | + <!-- 从库配置 --> | |
610 | + <dili_titan.slave.jdbc.url>jdbc:MySql://192.168.60.61:3306/agriez_titan?useUnicode=true&characterEncoding=utf8</dili_titan.slave.jdbc.url> | |
611 | + <dili_titan.slave.jdbc.username>appAccPayor</dili_titan.slave.jdbc.username> | |
612 | + <dili_titan.slave.jdbc.password>iTDYVBtI6MX4NQ3Er2Oh</dili_titan.slave.jdbc.password> | |
613 | + <!-- crm接口地址 --> | |
614 | + <dili_titan.crm.url>supplier.1n4j.com</dili_titan.crm.url> | |
615 | + <!-- user接口地址 --> | |
616 | + <dili_titan.user.url>user.1n4j.com</dili_titan.user.url> | |
617 | + <!--shop接口地址,需要测试自己修改 --> | |
618 | + <dili_titan.shop.url>http://shop.1n4j.com</dili_titan.shop.url> | |
619 | + <!-- redis接口地址 --> | |
620 | + <dili_titan.redis.url>redis.1n4j.com</dili_titan.redis.url> | |
621 | + <!--权限管理的redis配置--> | |
622 | + <manage.redis.url>redis.1n4j.com</manage.redis.url> | |
623 | + <manage.redis.port>6379</manage.redis.port> | |
624 | + <!-- MQ 地址--> | |
625 | + <conf.mq.namesrvAddr>192.168.60.62:9876;192.168.60.63:9876</conf.mq.namesrvAddr> | |
626 | + <conf.mq.producerGroup>titanPNR</conf.mq.producerGroup> | |
627 | + <!--<dili_titan.mq.url>tcp://192.168.28.28:61616</dili_titan.mq.url>--> | |
628 | + <!-- website接口地址 --> | |
629 | + <dili_titan.website.url>manweb.1n4j.com</dili_titan.website.url> | |
630 | + <!-- 日志 --> | |
631 | + <dili_titan.log.level>INFO</dili_titan.log.level> | |
632 | + <dili_titan.log.path>/diliapp/servers/logs</dili_titan.log.path> | |
633 | + <dili_titan.log.root.appender>FILE_ALL</dili_titan.log.root.appender> | |
634 | + <!--打包编码 --> | |
635 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
636 | + <!-- 图片服务器前缀 --> | |
637 | + <project.imageserver.prefix>http://img0.1n4j.com</project.imageserver.prefix> | |
638 | + <project.store.url>http://up.1n4j.com</project.store.url> | |
639 | + <project.store.accessKey>d6a300418bd6fa2178b3bbb06a421f32</project.store.accessKey> | |
640 | + <project.store.secretKey>8d2d1ac5541dcfbbd78ac1793ce4f782</project.store.secretKey> | |
641 | + <!--权限相关配置--> | |
642 | + <conf.manage.enable>true</conf.manage.enable> | |
643 | + <conf.manage.spider>false</conf.manage.spider> | |
644 | + <conf.manage.system>titan</conf.manage.system> | |
645 | + <conf.manage.domain>http://manage.1n4j.com/</conf.manage.domain> | |
646 | + <conf.manage.includes>^/.*</conf.manage.includes> | |
647 | + <conf.manage.excludes>^/noAccess.do$,^/welcome.do$,^/loginControl/.*,^/api/.*,^/common/.*,^/img/.*,^/css/.*,^/assets/.*,^/js/.*,.*?/exportExcel,^/moni,^/init.*,^/titan/productPop/queryProductPopData</conf.manage.excludes> | |
648 | + <!--上传视频--> | |
649 | + <project.fastdfs.trackercount>2</project.fastdfs.trackercount> | |
650 | + <project.fastdfs.connectTimeout>2000</project.fastdfs.connectTimeout> | |
651 | + <project.fastdfs.networkTimeout>30000</project.fastdfs.networkTimeout> | |
652 | + <project.fastdfs.charset>utf-8</project.fastdfs.charset> | |
653 | + <project.fastdfs.trackers>192.168.28.38:22122,192.168.28.39:22122</project.fastdfs.trackers> | |
654 | + <!-- 团购 --> | |
655 | + <project.grouppurchase.url>http://group.1n4j.com</project.grouppurchase.url> | |
656 | + <project.grouppurchase.token>123</project.grouppurchase.token> | |
657 | + <!--爱奇艺视频 --> | |
658 | + <titan.aqy.appkey>f689d13d9dce48039cae27e6e03940c6</titan.aqy.appkey> | |
659 | + <titan.aqy.appSecret>8633dfebb9f4443d0f1244262bca94f6</titan.aqy.appSecret> | |
660 | + </properties> | |
661 | + </profile> | |
662 | + | |
663 | + <profile> | |
664 | + <!-- 测试环境 --> | |
665 | + <id>pnr-clone</id> | |
666 | + <activation> | |
667 | + <activeByDefault>false</activeByDefault> | |
668 | + </activation> | |
669 | + <properties> | |
670 | + <!--jdbc type --> | |
671 | + <dili_titan.jdbc.datasource.type>dbcp</dili_titan.jdbc.datasource.type> | |
672 | + <!-- 数据库 --> | |
673 | + <dili_titan.jdbc.driver>com.mysql.jdbc.Driver</dili_titan.jdbc.driver> | |
674 | + <!-- 主库配置 --> | |
675 | + <dili_titan.master.jdbc.url>jdbc:MySql://10.28.5.236:3306/titan?useUnicode=true&characterEncoding=utf8</dili_titan.master.jdbc.url> | |
676 | + <dili_titan.master.jdbc.username>root</dili_titan.master.jdbc.username> | |
677 | + <dili_titan.master.jdbc.password>123456</dili_titan.master.jdbc.password> | |
678 | + <!-- 从库配置 --> | |
679 | + <dili_titan.slave.jdbc.url>jdbc:MySql://10.28.5.235:3306/titan?useUnicode=true&characterEncoding=utf8</dili_titan.slave.jdbc.url> | |
680 | + <dili_titan.slave.jdbc.username>titan_reader</dili_titan.slave.jdbc.username> | |
681 | + <dili_titan.slave.jdbc.password>123456</dili_titan.slave.jdbc.password> | |
682 | + <!-- crm接口地址 --> | |
683 | + <dili_titan.crm.url>supplier.1n4j.com</dili_titan.crm.url> | |
684 | + <!-- user接口地址,需要测试自己修改 --> | |
685 | + <dili_titan.user.url>user.1n4j.com</dili_titan.user.url> | |
686 | + <!--shop接口地址,需要测试自己修改 --> | |
687 | + <dili_titan.shop.url>http://shop.1n4j.com</dili_titan.shop.url> | |
688 | + <!-- redis接口地址 --> | |
689 | + <dili_titan.redis.url>10.28.5.200</dili_titan.redis.url> | |
690 | + <!--权限管理的redis配置--> | |
691 | + <manage.redis.url>10.28.5.200</manage.redis.url> | |
692 | + <manage.redis.port>6379</manage.redis.port> | |
693 | + <!-- MQ 地址--> | |
694 | + <conf.mq.namesrvAddr>10.28.5.202:9876;10.28.5.203:9876</conf.mq.namesrvAddr> | |
695 | + <conf.mq.producerGroup>titanPNR</conf.mq.producerGroup> | |
696 | + <!--<dili_titan.mq.url>tcp://10.28.6.54:61616</dili_titan.mq.url>--> | |
697 | + <!-- website接口地址 --> | |
698 | + <dili_titan.website.url>manweb.1n4j.com</dili_titan.website.url> | |
699 | + <!-- 日志 --> | |
700 | + <dili_titan.log.level>INFO</dili_titan.log.level> | |
701 | + <dili_titan.log.path>/home/tomcat/export</dili_titan.log.path> | |
702 | + <dili_titan.log.root.appender>CONSOLE</dili_titan.log.root.appender> | |
703 | + <!--打包编码 --> | |
704 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
705 | + <!-- 图片服务器前缀 --> | |
706 | + <project.imageserver.prefix>http://img0.1n4j.com</project.imageserver.prefix> | |
707 | + <project.store.url>http://up.1n4j.com</project.store.url> | |
708 | + <project.store.accessKey>d6a300418bd6fa2178b3bbb06a421f32</project.store.accessKey> | |
709 | + <project.store.secretKey>8d2d1ac5541dcfbbd78ac1793ce4f782</project.store.secretKey> | |
710 | + <!--权限相关配置--> | |
711 | + <conf.manage.enable>true</conf.manage.enable> | |
712 | + <conf.manage.spider>true</conf.manage.spider> | |
713 | + <conf.manage.system>titan</conf.manage.system> | |
714 | + <conf.manage.domain>http://manage.1n4j.com/ | |
715 | + </conf.manage.domain> | |
716 | + <conf.manage.includes>^/.*</conf.manage.includes> | |
717 | + <conf.manage.excludes> | |
718 | + ^/noAccess.do$,^/welcome.do$,^/loginControl/.*,^/api/.*,^/common/.*,^/img/.*,^/css/.*,^/assets/.*,^/js/.*,.*?/exportExcel,^/moni,^/init.*,^/titan/productPop/queryProductPopData | |
719 | + </conf.manage.excludes> | |
720 | + <!--上传视频--> | |
721 | + <project.fastdfs.trackercount>2</project.fastdfs.trackercount> | |
722 | + <project.fastdfs.connectTimeout>2000 | |
723 | + </project.fastdfs.connectTimeout> | |
724 | + <project.fastdfs.networkTimeout>30000 | |
725 | + </project.fastdfs.networkTimeout> | |
726 | + <project.fastdfs.charset>utf-8</project.fastdfs.charset> | |
727 | + <project.fastdfs.trackers>10.28.6.148:22122,10.28.6.149:22122 | |
728 | + </project.fastdfs.trackers> | |
729 | + <!-- 团购 --> | |
730 | + <project.grouppurchase.url>http://group.1n4j.com | |
731 | + </project.grouppurchase.url> | |
732 | + <project.grouppurchase.token>123</project.grouppurchase.token> | |
733 | + <!--爱奇艺视频 --> | |
734 | + <titan.aqy.appkey>e64a09bece964bb484e5decc30c0b950</titan.aqy.appkey> | |
735 | + <titan.aqy.appSecret>f48d2b799f9661acdb6041e4ac7c142f</titan.aqy.appSecret> | |
736 | + </properties> | |
737 | + </profile> | |
738 | + </profiles> | |
739 | +</project> | ... | ... |
titan-web/src/main/hbase-profiles/develop/core-site.xml
0 → 100644
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-web/src/main/hbase-profiles/develop/hbase-site.xml
0 → 100644
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-web/src/main/hbase-profiles/online/core-site.xml
0 → 100644
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-web/src/main/hbase-profiles/online/hbase-site.xml
0 → 100644
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-web/src/main/hbase-profiles/pre-online/core-site.xml
0 → 100644
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-web/src/main/hbase-profiles/pre-online/hbase-site.xml
0 → 100644
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-web/src/main/hbase-profiles/test/core-site.xml
0 → 100644
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-web/src/main/hbase-profiles/test/hbase-site.xml
0 → 100644
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-web/src/main/java/com/dili/titan/common/Account.java
0 → 100644
1 | +package com.dili.titan.common; | |
2 | + | |
3 | +/** | |
4 | + * 账号类 | |
5 | + * | |
6 | + * @author dev-center | |
7 | + * @since 2014-05-10 | |
8 | + */ | |
9 | +public class Account { | |
10 | + | |
11 | + private String personId; | |
12 | + | |
13 | + private String account; | |
14 | + | |
15 | + private String personName; | |
16 | + | |
17 | + private String orgId; | |
18 | + | |
19 | + private String orgName; | |
20 | + | |
21 | + private int isPassModi; | |
22 | + | |
23 | + private int passOverdue; | |
24 | + | |
25 | + private String cvnPassModiTime; | |
26 | + | |
27 | + private String cvnCreateTime; | |
28 | + | |
29 | + private String cvnModiTime; | |
30 | + | |
31 | + private String cvnEffectiveStartTime; | |
32 | + | |
33 | + private String cvnEffectiveEndTime; | |
34 | + | |
35 | + private int isDefault; | |
36 | + | |
37 | + public String getPersonId() { | |
38 | + return personId; | |
39 | + } | |
40 | + | |
41 | + public void setPersonId(String personId) { | |
42 | + this.personId = personId; | |
43 | + } | |
44 | + | |
45 | + public String getAccount() { | |
46 | + return account; | |
47 | + } | |
48 | + | |
49 | + public void setAccount(String account) { | |
50 | + this.account = account; | |
51 | + } | |
52 | + | |
53 | + public String getPersonName() { | |
54 | + return personName; | |
55 | + } | |
56 | + | |
57 | + public void setPersonName(String personName) { | |
58 | + this.personName = personName; | |
59 | + } | |
60 | + | |
61 | + public String getOrgId() { | |
62 | + return orgId; | |
63 | + } | |
64 | + | |
65 | + public void setOrgId(String orgId) { | |
66 | + this.orgId = orgId; | |
67 | + } | |
68 | + | |
69 | + public String getOrgName() { | |
70 | + return orgName; | |
71 | + } | |
72 | + | |
73 | + public void setOrgName(String orgName) { | |
74 | + this.orgName = orgName; | |
75 | + } | |
76 | + | |
77 | + public int getIsPassModi() { | |
78 | + return isPassModi; | |
79 | + } | |
80 | + | |
81 | + public void setIsPassModi(int isPassModi) { | |
82 | + this.isPassModi = isPassModi; | |
83 | + } | |
84 | + | |
85 | + public int getPassOverdue() { | |
86 | + return passOverdue; | |
87 | + } | |
88 | + | |
89 | + public void setPassOverdue(int passOverdue) { | |
90 | + this.passOverdue = passOverdue; | |
91 | + } | |
92 | + | |
93 | + public String getCvnPassModiTime() { | |
94 | + return cvnPassModiTime; | |
95 | + } | |
96 | + | |
97 | + public void setCvnPassModiTime(String cvnPassModiTime) { | |
98 | + this.cvnPassModiTime = cvnPassModiTime; | |
99 | + } | |
100 | + | |
101 | + public String getCvnCreateTime() { | |
102 | + return cvnCreateTime; | |
103 | + } | |
104 | + | |
105 | + public void setCvnCreateTime(String cvnCreateTime) { | |
106 | + this.cvnCreateTime = cvnCreateTime; | |
107 | + } | |
108 | + | |
109 | + public String getCvnModiTime() { | |
110 | + return cvnModiTime; | |
111 | + } | |
112 | + | |
113 | + public void setCvnModiTime(String cvnModiTime) { | |
114 | + this.cvnModiTime = cvnModiTime; | |
115 | + } | |
116 | + | |
117 | + public String getCvnEffectiveStartTime() { | |
118 | + return cvnEffectiveStartTime; | |
119 | + } | |
120 | + | |
121 | + public void setCvnEffectiveStartTime(String cvnEffectiveStartTime) { | |
122 | + this.cvnEffectiveStartTime = cvnEffectiveStartTime; | |
123 | + } | |
124 | + | |
125 | + public String getCvnEffectiveEndTime() { | |
126 | + return cvnEffectiveEndTime; | |
127 | + } | |
128 | + | |
129 | + public void setCvnEffectiveEndTime(String cvnEffectiveEndTime) { | |
130 | + this.cvnEffectiveEndTime = cvnEffectiveEndTime; | |
131 | + } | |
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 | + } | |
148 | +} | ... | ... |
titan-web/src/main/java/com/dili/titan/common/HttpRequester.java
0 → 100644
1 | +package com.dili.titan.common; | |
2 | + | |
3 | +import java.io.BufferedReader; | |
4 | +import java.io.IOException; | |
5 | +import java.io.InputStream; | |
6 | +import java.io.InputStreamReader; | |
7 | +import java.net.HttpURLConnection; | |
8 | +import java.net.URL; | |
9 | +import java.util.Map; | |
10 | +import java.util.Vector; | |
11 | + | |
12 | +/** | |
13 | + * HTTP请求对象 | |
14 | + * | |
15 | + * @author dev-center | |
16 | + * @since 2014-05-10 | |
17 | + */ | |
18 | +//TODO 我觉得是有用的,但没用 | |
19 | +@Deprecated | |
20 | +public class HttpRequester { | |
21 | + private String defaultContentEncoding; | |
22 | + | |
23 | + public HttpRequester() { | |
24 | + this.defaultContentEncoding = "UTF-8"; | |
25 | + } | |
26 | + | |
27 | + /** | |
28 | + * 发送GET请求 | |
29 | + * | |
30 | + * @param urlString | |
31 | + * URL地址 | |
32 | + * @return 响应对象 | |
33 | + * @throws IOException | |
34 | + */ | |
35 | + public HttpResponse sendGet(String urlString) throws IOException { | |
36 | + return this.send(urlString, "GET", null, null); | |
37 | + } | |
38 | + | |
39 | + /** | |
40 | + * 发送GET请求 | |
41 | + * | |
42 | + * @param urlString | |
43 | + * URL地址 | |
44 | + * @param params | |
45 | + * 参数集合 | |
46 | + * @return 响应对象 | |
47 | + * @throws IOException | |
48 | + */ | |
49 | + public HttpResponse sendGet(String urlString, Map<String, String> params) throws IOException { | |
50 | + return this.send(urlString, "GET", params, null); | |
51 | + } | |
52 | + | |
53 | + /** | |
54 | + * 发送GET请求 | |
55 | + * | |
56 | + * @param urlString | |
57 | + * URL地址 | |
58 | + * @param params | |
59 | + * 参数集合 | |
60 | + * @param propertys | |
61 | + * 请求属性 | |
62 | + * @return 响应对象 | |
63 | + * @throws IOException | |
64 | + */ | |
65 | + public HttpResponse sendGet(String urlString, Map<String, String> params, Map<String, String> propertys) throws IOException { | |
66 | + return this.send(urlString, "GET", params, propertys); | |
67 | + } | |
68 | + | |
69 | + /** | |
70 | + * 发送POST请求 | |
71 | + * | |
72 | + * @param urlString | |
73 | + * URL地址 | |
74 | + * @return 响应对象 | |
75 | + * @throws IOException | |
76 | + */ | |
77 | + public HttpResponse sendPost(String urlString) throws IOException { | |
78 | + return this.send(urlString, "POST", null, null); | |
79 | + } | |
80 | + | |
81 | + /** | |
82 | + * 发送POST请求 | |
83 | + * | |
84 | + * @param urlString | |
85 | + * URL地址 | |
86 | + * @param params | |
87 | + * 参数集合 | |
88 | + * @return 响应对象 | |
89 | + * @throws IOException | |
90 | + */ | |
91 | + public HttpResponse sendPost(String urlString, Map<String, String> params) throws IOException { | |
92 | + return this.send(urlString, "POST", params, null); | |
93 | + } | |
94 | + | |
95 | + /** | |
96 | + * 发送POST请求 | |
97 | + * | |
98 | + * @param urlString | |
99 | + * URL地址 | |
100 | + * @param params | |
101 | + * 参数集合 | |
102 | + * @param propertys | |
103 | + * 请求属性 | |
104 | + * @return 响应对象 | |
105 | + * @throws IOException | |
106 | + */ | |
107 | + public HttpResponse sendPost(String urlString, Map<String, String> params, Map<String, String> propertys) throws IOException { | |
108 | + return this.send(urlString, "POST", params, propertys); | |
109 | + } | |
110 | + | |
111 | + /** | |
112 | + * 发送HTTP请求 | |
113 | + * | |
114 | + * @param urlString | |
115 | + * @return 响映对象 | |
116 | + * @throws IOException | |
117 | + */ | |
118 | + private HttpResponse send(String urlString, String method, Map<String, String> parameters, Map<String, String> propertys) throws IOException { | |
119 | + HttpURLConnection urlConnection = null; | |
120 | + | |
121 | + if ("GET".equalsIgnoreCase(method) && parameters != null) { | |
122 | + StringBuffer param = new StringBuffer(); | |
123 | + int i = 0; | |
124 | + for (Map.Entry<String, String> entry : parameters.entrySet()) { | |
125 | + if (i == 0) | |
126 | + param.append("?"); | |
127 | + else | |
128 | + param.append("&"); | |
129 | + param.append(entry.getKey()).append("=").append(entry.getValue()); | |
130 | + i++; | |
131 | + } | |
132 | + urlString += param; | |
133 | + } | |
134 | + URL url = new URL(urlString); | |
135 | + urlConnection = (HttpURLConnection) url.openConnection(); | |
136 | + | |
137 | + urlConnection.setRequestMethod(method); | |
138 | + urlConnection.setDoOutput(true); | |
139 | + urlConnection.setDoInput(true); | |
140 | + urlConnection.setUseCaches(false); | |
141 | + | |
142 | + if (propertys != null) | |
143 | + for (Map.Entry<String,String> entry : propertys.entrySet()) { | |
144 | + urlConnection.addRequestProperty(entry.getKey(), entry.getValue()); | |
145 | + } | |
146 | + | |
147 | + if ("POST".equalsIgnoreCase(method) && parameters != null) { | |
148 | + StringBuffer param = new StringBuffer(); | |
149 | + for (Map.Entry<String,String> entry : parameters.entrySet()) { | |
150 | + param.append("&"); | |
151 | + param.append(entry.getKey()).append("=").append(entry.getValue()); | |
152 | + } | |
153 | + urlConnection.getOutputStream().write(param.toString().getBytes(this.defaultContentEncoding)); | |
154 | + urlConnection.getOutputStream().flush(); | |
155 | + urlConnection.getOutputStream().close(); | |
156 | + } | |
157 | + | |
158 | + return this.makeContent(urlString, urlConnection); | |
159 | + } | |
160 | + | |
161 | + /** | |
162 | + * 得到响应对象 | |
163 | + * | |
164 | + * @param urlConnection | |
165 | + * @return 响应对象 | |
166 | + * @throws IOException | |
167 | + */ | |
168 | + private HttpResponse makeContent(String urlString, HttpURLConnection urlConnection) throws IOException { | |
169 | + HttpResponse httpResponser = new HttpResponse(); | |
170 | + try { | |
171 | + InputStream in = urlConnection.getInputStream(); | |
172 | + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in,defaultContentEncoding)); | |
173 | + httpResponser.contentCollection = new Vector<String>(); | |
174 | + StringBuffer temp = new StringBuffer(); | |
175 | + String line = bufferedReader.readLine(); | |
176 | + while (line != null) { | |
177 | + httpResponser.contentCollection.add(line); | |
178 | + temp.append(line).append("\r\n"); | |
179 | + line = bufferedReader.readLine(); | |
180 | + } | |
181 | + bufferedReader.close(); | |
182 | + | |
183 | + String ecod = urlConnection.getContentEncoding(); | |
184 | + if (ecod == null) | |
185 | + ecod = this.defaultContentEncoding; | |
186 | + | |
187 | + httpResponser.urlString = urlString; | |
188 | + | |
189 | + httpResponser.defaultPort = urlConnection.getURL().getDefaultPort(); | |
190 | + httpResponser.file = urlConnection.getURL().getFile(); | |
191 | + httpResponser.host = urlConnection.getURL().getHost(); | |
192 | + httpResponser.path = urlConnection.getURL().getPath(); | |
193 | + httpResponser.port = urlConnection.getURL().getPort(); | |
194 | + httpResponser.protocol = urlConnection.getURL().getProtocol(); | |
195 | + httpResponser.query = urlConnection.getURL().getQuery(); | |
196 | + httpResponser.ref = urlConnection.getURL().getRef(); | |
197 | + httpResponser.userInfo = urlConnection.getURL().getUserInfo(); | |
198 | + | |
199 | + httpResponser.content = new String(temp.toString().getBytes(ecod), ecod); | |
200 | + httpResponser.contentEncoding = ecod; | |
201 | + httpResponser.code = urlConnection.getResponseCode(); | |
202 | + httpResponser.message = urlConnection.getResponseMessage(); | |
203 | + httpResponser.contentType = urlConnection.getContentType(); | |
204 | + httpResponser.method = urlConnection.getRequestMethod(); | |
205 | + httpResponser.connectTimeout = urlConnection.getConnectTimeout(); | |
206 | + httpResponser.readTimeout = urlConnection.getReadTimeout(); | |
207 | + | |
208 | + return httpResponser; | |
209 | + } catch (IOException e) { | |
210 | + throw e; | |
211 | + } finally { | |
212 | + if (urlConnection != null) | |
213 | + urlConnection.disconnect(); | |
214 | + } | |
215 | + } | |
216 | + | |
217 | + /** | |
218 | + * 默认的响应字符集 | |
219 | + */ | |
220 | + public String getDefaultContentEncoding() { | |
221 | + return this.defaultContentEncoding; | |
222 | + } | |
223 | + | |
224 | + /** | |
225 | + * 设置默认的响应字符集 | |
226 | + */ | |
227 | + public void setDefaultContentEncoding(String defaultContentEncoding) { | |
228 | + this.defaultContentEncoding = defaultContentEncoding; | |
229 | + } | |
230 | +} | |
0 | 231 | \ No newline at end of file | ... | ... |
titan-web/src/main/java/com/dili/titan/common/HttpResponse.java
0 → 100644
1 | +package com.dili.titan.common; | |
2 | + | |
3 | +import java.util.Vector; | |
4 | + | |
5 | +/** | |
6 | + * | |
7 | + * | |
8 | + * @author dev-center | |
9 | + * @since 2014-05-10 | |
10 | + */ | |
11 | +public class HttpResponse { | |
12 | + | |
13 | + String urlString; | |
14 | + | |
15 | + int defaultPort; | |
16 | + | |
17 | + String file; | |
18 | + | |
19 | + String host; | |
20 | + | |
21 | + String path; | |
22 | + | |
23 | + int port; | |
24 | + | |
25 | + String protocol; | |
26 | + | |
27 | + String query; | |
28 | + | |
29 | + String ref; | |
30 | + | |
31 | + String userInfo; | |
32 | + | |
33 | + String contentEncoding; | |
34 | + | |
35 | + String content; | |
36 | + | |
37 | + String contentType; | |
38 | + | |
39 | + int code; | |
40 | + | |
41 | + String message; | |
42 | + | |
43 | + String method; | |
44 | + | |
45 | + int connectTimeout; | |
46 | + | |
47 | + int readTimeout; | |
48 | + | |
49 | + Vector<String> contentCollection; | |
50 | + | |
51 | + public String getContent() { | |
52 | + return content; | |
53 | + } | |
54 | + | |
55 | + public String getContentType() { | |
56 | + return contentType; | |
57 | + } | |
58 | + | |
59 | + public int getCode() { | |
60 | + return code; | |
61 | + } | |
62 | + | |
63 | + public String getMessage() { | |
64 | + return message; | |
65 | + } | |
66 | + | |
67 | + public Vector<String> getContentCollection() { | |
68 | + return contentCollection; | |
69 | + } | |
70 | + | |
71 | + public String getContentEncoding() { | |
72 | + return contentEncoding; | |
73 | + } | |
74 | + | |
75 | + public String getMethod() { | |
76 | + return method; | |
77 | + } | |
78 | + | |
79 | + public int getConnectTimeout() { | |
80 | + return connectTimeout; | |
81 | + } | |
82 | + | |
83 | + public int getReadTimeout() { | |
84 | + return readTimeout; | |
85 | + } | |
86 | + | |
87 | + public String getUrlString() { | |
88 | + return urlString; | |
89 | + } | |
90 | + | |
91 | + public int getDefaultPort() { | |
92 | + return defaultPort; | |
93 | + } | |
94 | + | |
95 | + public String getFile() { | |
96 | + return file; | |
97 | + } | |
98 | + | |
99 | + public String getHost() { | |
100 | + return host; | |
101 | + } | |
102 | + | |
103 | + public String getPath() { | |
104 | + return path; | |
105 | + } | |
106 | + | |
107 | + public int getPort() { | |
108 | + return port; | |
109 | + } | |
110 | + | |
111 | + public String getProtocol() { | |
112 | + return protocol; | |
113 | + } | |
114 | + | |
115 | + public String getQuery() { | |
116 | + return query; | |
117 | + } | |
118 | + | |
119 | + public String getRef() { | |
120 | + return ref; | |
121 | + } | |
122 | + | |
123 | + public String getUserInfo() { | |
124 | + return userInfo; | |
125 | + } | |
126 | + | |
127 | +} | |
0 | 128 | \ No newline at end of file | ... | ... |
titan-web/src/main/java/com/dili/titan/common/ProductStatus.java
0 → 100644
1 | +package com.dili.titan.common; | |
2 | + | |
3 | +/** | |
4 | + * 商品状态常量类 | |
5 | + */ | |
6 | +public class ProductStatus { | |
7 | + | |
8 | + /** | |
9 | + * 第三方销售 | |
10 | + */ | |
11 | + public static final String SALE_TYPE_POP = "30"; | |
12 | + | |
13 | + /** | |
14 | + * 第三方商品 | |
15 | + */ | |
16 | + public static final int PRODUCT_POP = 1; | |
17 | + | |
18 | + /** | |
19 | + * 商品预览状态 | |
20 | + */ | |
21 | + public static final int PRODUCT_PREVIEW = -2; | |
22 | + | |
23 | + /** | |
24 | + * 商品删除状态 | |
25 | + */ | |
26 | + public static final int PRODUCT_DELETED = -1; | |
27 | + | |
28 | + /** | |
29 | + * 新建待审核商品 | |
30 | + */ | |
31 | + public static final int PRODUCT_NEW = 1; | |
32 | + | |
33 | + /** | |
34 | + * 审核失败商品 | |
35 | + */ | |
36 | + public static final int PRODUCT_DENIED = 2; | |
37 | + | |
38 | + /** | |
39 | + * 在架商品,在售商品 | |
40 | + */ | |
41 | + public static final int PRODUCT_ONSALE = 3; | |
42 | + | |
43 | + /** | |
44 | + * 在仓库中的商品,审核后直接放入仓库的商品 | |
45 | + */ | |
46 | + public static final int PRODUCT_IN_WAREHOUSE = 4; | |
47 | + /** | |
48 | + * 等待上架的商品 | |
49 | + */ | |
50 | + public static final int PRODUCT_WAITING_ONSALE = 5; | |
51 | + /** | |
52 | + * 过期下架的商品 | |
53 | + */ | |
54 | + public static final int PRODUCT_OVERDUE_DROPS = 6; | |
55 | + /** | |
56 | + * 手动下架 | |
57 | + */ | |
58 | + public static final int PRODUCT_MANUALLY_DROPS = 7; | |
59 | + | |
60 | + /** | |
61 | + * 放入仓库 | |
62 | + */ | |
63 | + public static final int PRODUCT_PUBLISH_WAREHOUSE = 1; | |
64 | + /** | |
65 | + * 立即上架 | |
66 | + */ | |
67 | + public static final int PRODUCT_PUBLISH_IMMEDIATELY = 2; | |
68 | + /** | |
69 | + * 指定时间上架 | |
70 | + */ | |
71 | + public static final int PRODUCT_PUBLISH_SPECIFY_TIME = 3; | |
72 | +} | ... | ... |
titan-web/src/main/java/com/dili/titan/common/datasource/DataSourceAspect.java
0 → 100644
1 | +package com.dili.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 (CONTEX.get() == null) { | |
37 | + log.debug("before:" + method.getName()); | |
38 | + CONTEX.set(method); | |
39 | + } | |
40 | + if (!CONTEX_THOLDER.get()) { | |
41 | + if (method != null && method.isAnnotationPresent(Transactional.class)) { | |
42 | + String lookUpKey = DataSourceSwitcher.WRITE + (DataSourceSwitcher.RANDOM.nextInt(mastersCount) + 1); | |
43 | + log.debug("Aspect获取数据源" + lookUpKey); | |
44 | + DataSourceSwitcher.setDataSource(lookUpKey); | |
45 | + CONTEX_THOLDER.set(true); | |
46 | + } else { | |
47 | + DataSourceSwitcher.setDataSource(DataSourceSwitcher.READ); | |
48 | + } | |
49 | + } | |
50 | + Object val = pjp.proceed(); | |
51 | + if (CONTEX.get() == method) { | |
52 | + CONTEX.set(null); | |
53 | + CONTEX_THOLDER.set(false); | |
54 | + log.debug("after:" + method.getName()); | |
55 | + } | |
56 | + return val; | |
57 | + } | |
58 | + | |
59 | + public Integer getMastersCount() { | |
60 | + return mastersCount; | |
61 | + } | |
62 | + | |
63 | + public void setMastersCount(Integer mastersCount) { | |
64 | + this.mastersCount = mastersCount; | |
65 | + } | |
66 | +} | ... | ... |
titan-web/src/main/java/com/dili/titan/common/datasource/DataSourceSwitcher.java
0 → 100644
1 | +package com.dili.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 | + | |
31 | +} | ... | ... |
titan-web/src/main/java/com/dili/titan/common/datasource/DynamicDataSource.java
0 → 100644
1 | +package com.dili.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-web/src/main/java/com/dili/titan/common/datasource/DynamicSource.java
0 → 100644
1 | +package com.dili.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 | +} | |
0 | 18 | \ No newline at end of file | ... | ... |
titan-web/src/main/java/com/dili/titan/common/enums/ChooseType.java
0 → 100644
1 | +package com.dili.titan.common.enums; | |
2 | + | |
3 | +import java.util.ArrayList; | |
4 | +import java.util.List; | |
5 | + | |
6 | +/** | |
7 | + * 存是,否的值。0非1是 | |
8 | + */ | |
9 | +@Deprecated | |
10 | +public enum ChooseType { | |
11 | + /** | |
12 | + * 1-是 | |
13 | + */ | |
14 | + Yes("是", 1), | |
15 | + /** | |
16 | + * 0-否 | |
17 | + */ | |
18 | + No("否", 0); | |
19 | + | |
20 | + private String name; | |
21 | + private int index; | |
22 | + | |
23 | + // 构造方法 | |
24 | + ChooseType(String name, int index) { | |
25 | + this.name = name; | |
26 | + this.index = index; | |
27 | + } | |
28 | + | |
29 | + // 普通方法 | |
30 | + public static String getName(int index) { | |
31 | + for (ChooseType c : ChooseType.values()) { | |
32 | + if (c.getIndex() == index) { | |
33 | + return c.name; | |
34 | + } | |
35 | + } | |
36 | + return null; | |
37 | + } | |
38 | + | |
39 | + public static ChooseType getTraceType(int index) { | |
40 | + for (ChooseType c : ChooseType.values()) { | |
41 | + if (c.getIndex() == index) { | |
42 | + return c; | |
43 | + } | |
44 | + } | |
45 | + return null; | |
46 | + } | |
47 | + | |
48 | + public static List<ChooseType> getEnumItemList() { | |
49 | + ChooseType[] itemList = ChooseType.values(); | |
50 | + List<ChooseType> filteredItemList = new ArrayList<ChooseType>(); | |
51 | + for (ChooseType status : itemList) { | |
52 | + filteredItemList.add(status); | |
53 | + } | |
54 | + return filteredItemList; | |
55 | + } | |
56 | + | |
57 | + // get set 方法 | |
58 | + public String getName() { | |
59 | + return name; | |
60 | + } | |
61 | + | |
62 | + public int getIndex() { | |
63 | + return index; | |
64 | + } | |
65 | + | |
66 | +} | ... | ... |
titan-web/src/main/java/com/dili/titan/common/enums/IndexCategoryStatusType.java
0 → 100644
1 | +package com.dili.titan.common.enums; | |
2 | + | |
3 | +import java.util.ArrayList; | |
4 | +import java.util.List; | |
5 | + | |
6 | +/** | |
7 | + * 类目状态类型。1 正常,-1 删除。 | |
8 | + */ | |
9 | +public enum IndexCategoryStatusType { | |
10 | + /** | |
11 | + * 1 正常 | |
12 | + */ | |
13 | + NORMAL("正常", 1), | |
14 | + /** | |
15 | + * -1 删除 | |
16 | + */ | |
17 | + DELETE("删除", -1); | |
18 | + | |
19 | + private String name; | |
20 | + private int index; | |
21 | + | |
22 | + // 构造方法 | |
23 | + IndexCategoryStatusType(String name, int index) { | |
24 | + this.name = name; | |
25 | + this.index = index; | |
26 | + } | |
27 | + | |
28 | + // 普通方法 | |
29 | + public static String getName(int index) { | |
30 | + for (IndexCategoryStatusType c : IndexCategoryStatusType.values()) { | |
31 | + if (c.getIndex() == index) { | |
32 | + return c.name; | |
33 | + } | |
34 | + } | |
35 | + return null; | |
36 | + } | |
37 | + | |
38 | + public static IndexCategoryStatusType getTraceType(int index) { | |
39 | + for (IndexCategoryStatusType c : IndexCategoryStatusType.values()) { | |
40 | + if (c.getIndex() == index) { | |
41 | + return c; | |
42 | + } | |
43 | + } | |
44 | + return null; | |
45 | + } | |
46 | + | |
47 | + public static List<IndexCategoryStatusType> getEnumItemList() { | |
48 | + IndexCategoryStatusType[] itemList = IndexCategoryStatusType.values(); | |
49 | + List<IndexCategoryStatusType> filteredItemList = new ArrayList<IndexCategoryStatusType>(); | |
50 | + for (IndexCategoryStatusType status : itemList) { | |
51 | + filteredItemList.add(status); | |
52 | + } | |
53 | + return filteredItemList; | |
54 | + } | |
55 | + | |
56 | + // get set 方法 | |
57 | + public String getName() { | |
58 | + return name; | |
59 | + } | |
60 | + | |
61 | + public int getIndex() { | |
62 | + return index; | |
63 | + } | |
64 | + | |
65 | +} | ... | ... |
titan-web/src/main/java/com/dili/titan/common/enums/PurchaseStatusType.java
0 → 100644
1 | +package com.dili.titan.common.enums; | |
2 | + | |
3 | +import java.util.ArrayList; | |
4 | +import java.util.List; | |
5 | + | |
6 | +/** | |
7 | + * 采购状态:1-进行中,2-已过期,3-已关闭,4-审核失败 5-待审核 | |
8 | + */ | |
9 | +@Deprecated | |
10 | +public enum PurchaseStatusType { | |
11 | + /** | |
12 | + * 1进行中 | |
13 | + */ | |
14 | + ING("进行中", 1), | |
15 | + /** | |
16 | + * 2已过期 | |
17 | + */ | |
18 | + EXPIRED("已过期", 2), | |
19 | + /** | |
20 | + * 3已关闭 | |
21 | + */ | |
22 | + CLOSED("已关闭", 3), | |
23 | + /** | |
24 | + * 4审核失败 | |
25 | + */ | |
26 | + FAIL("审核失败", 4), | |
27 | + /** | |
28 | + * 5待审核 | |
29 | + */ | |
30 | + WAIT("待审核", 5); | |
31 | + | |
32 | + private String name; | |
33 | + private int index; | |
34 | + | |
35 | + // 构造方法 | |
36 | + PurchaseStatusType(String name, int index) { | |
37 | + this.name = name; | |
38 | + this.index = index; | |
39 | + } | |
40 | + | |
41 | + // 普通方法 | |
42 | + public static String getName(int index) { | |
43 | + for (PurchaseStatusType c : PurchaseStatusType.values()) { | |
44 | + if (c.getIndex() == index) { | |
45 | + return c.name; | |
46 | + } | |
47 | + } | |
48 | + return null; | |
49 | + } | |
50 | + | |
51 | + public static PurchaseStatusType getTraceType(int index) { | |
52 | + for (PurchaseStatusType c : PurchaseStatusType.values()) { | |
53 | + if (c.getIndex() == index) { | |
54 | + return c; | |
55 | + } | |
56 | + } | |
57 | + return null; | |
58 | + } | |
59 | + | |
60 | + public static List<PurchaseStatusType> getEnumItemList() { | |
61 | + PurchaseStatusType[] itemList = PurchaseStatusType.values(); | |
62 | + List<PurchaseStatusType> filteredItemList = new ArrayList<PurchaseStatusType>(); | |
63 | + for (PurchaseStatusType status : itemList) { | |
64 | + filteredItemList.add(status); | |
65 | + } | |
66 | + return filteredItemList; | |
67 | + } | |
68 | + | |
69 | + // get set 方法 | |
70 | + public String getName() { | |
71 | + return name; | |
72 | + } | |
73 | + | |
74 | + public int getIndex() { | |
75 | + return index; | |
76 | + } | |
77 | + | |
78 | +} | ... | ... |
titan-web/src/main/java/com/dili/titan/common/enums/QuotationType.java
0 → 100644
1 | +package com.dili.titan.common.enums; | |
2 | + | |
3 | +import java.util.ArrayList; | |
4 | +import java.util.List; | |
5 | + | |
6 | +/** | |
7 | + * 报价类型 | |
8 | + */ | |
9 | +@Deprecated | |
10 | +public enum QuotationType { | |
11 | + /** | |
12 | + * 0未报价 | |
13 | + */ | |
14 | + WAIT("未报价", 0), | |
15 | + /** | |
16 | + * 1已报价 | |
17 | + */ | |
18 | + QUOTATION("已报价", 1), | |
19 | + /** | |
20 | + * 2地利已报价 | |
21 | + */ | |
22 | + DILI("地利已报价", 2); | |
23 | + | |
24 | + private String name; | |
25 | + private int index; | |
26 | + | |
27 | + // 构造方法 | |
28 | + QuotationType(String name, int index) { | |
29 | + this.name = name; | |
30 | + this.index = index; | |
31 | + } | |
32 | + | |
33 | + // 普通方法 | |
34 | + public static String getName(int index) { | |
35 | + for (QuotationType c : QuotationType.values()) { | |
36 | + if (c.getIndex() == index) { | |
37 | + return c.name; | |
38 | + } | |
39 | + } | |
40 | + return null; | |
41 | + } | |
42 | + | |
43 | + public static QuotationType getTraceType(int index) { | |
44 | + for (QuotationType c : QuotationType.values()) { | |
45 | + if (c.getIndex() == index) { | |
46 | + return c; | |
47 | + } | |
48 | + } | |
49 | + return null; | |
50 | + } | |
51 | + | |
52 | + public static List<QuotationType> getEnumItemList() { | |
53 | + QuotationType[] itemList = QuotationType.values(); | |
54 | + List<QuotationType> filteredItemList = new ArrayList<QuotationType>(); | |
55 | + for (QuotationType status : itemList) { | |
56 | + filteredItemList.add(status); | |
57 | + } | |
58 | + return filteredItemList; | |
59 | + } | |
60 | + | |
61 | + // get set 方法 | |
62 | + public String getName() { | |
63 | + return name; | |
64 | + } | |
65 | + | |
66 | + public int getIndex() { | |
67 | + return index; | |
68 | + } | |
69 | +} | ... | ... |
titan-web/src/main/java/com/dili/titan/common/enums/SourceType.java
0 → 100644
1 | +package com.dili.titan.common.enums; | |
2 | + | |
3 | +import java.util.ArrayList; | |
4 | +import java.util.List; | |
5 | + | |
6 | +/** | |
7 | + * 记录和区分日志的来源 | |
8 | + */ | |
9 | +public enum SourceType { | |
10 | + /** | |
11 | + * 1-PC端 | |
12 | + */ | |
13 | + Pc("PC端", 1), | |
14 | + /** | |
15 | + * 2-移动端 | |
16 | + */ | |
17 | + Mobile("移动端", 2), | |
18 | + /** | |
19 | + * 3-Titan_Web | |
20 | + */ | |
21 | + Titan_Web("Titan_Web", 3); | |
22 | + | |
23 | + private String name; | |
24 | + private int index; | |
25 | + | |
26 | + // 构造方法 | |
27 | + SourceType(String name, int index) { | |
28 | + this.name = name; | |
29 | + this.index = index; | |
30 | + } | |
31 | + | |
32 | + // 普通方法 | |
33 | + public static String getName(int index) { | |
34 | + for (SourceType c : SourceType.values()) { | |
35 | + if (c.getIndex() == index) { | |
36 | + return c.name; | |
37 | + } | |
38 | + } | |
39 | + return null; | |
40 | + } | |
41 | + | |
42 | + public static SourceType getTraceType(int index) { | |
43 | + for (SourceType c : SourceType.values()) { | |
44 | + if (c.getIndex() == index) { | |
45 | + return c; | |
46 | + } | |
47 | + } | |
48 | + return null; | |
49 | + } | |
50 | + | |
51 | + public static List<SourceType> getEnumItemList() { | |
52 | + SourceType[] itemList = SourceType.values(); | |
53 | + List<SourceType> filteredItemList = new ArrayList<SourceType>(); | |
54 | + for (SourceType status : itemList) { | |
55 | + filteredItemList.add(status); | |
56 | + } | |
57 | + return filteredItemList; | |
58 | + } | |
59 | + | |
60 | + // get set 方法 | |
61 | + public String getName() { | |
62 | + return name; | |
63 | + } | |
64 | + | |
65 | + public int getIndex() { | |
66 | + return index; | |
67 | + } | |
68 | +} | ... | ... |
titan-web/src/main/java/com/dili/titan/common/enums/SupplyStatusType.java
0 → 100644
1 | +package com.dili.titan.common.enums; | |
2 | + | |
3 | +import java.util.ArrayList; | |
4 | +import java.util.List; | |
5 | + | |
6 | +/** | |
7 | + * 供应状态类型。1-进行中,2-已过期,3-已关闭,4-审核失败 | |
8 | + */ | |
9 | +@Deprecated | |
10 | +public enum SupplyStatusType { | |
11 | + /** | |
12 | + * 1进行中 | |
13 | + */ | |
14 | + ING("进行中", 1), | |
15 | + /** | |
16 | + * 2已过期 | |
17 | + */ | |
18 | + EXPIRED("已过期", 2), | |
19 | + /** | |
20 | + * 3已关闭 | |
21 | + */ | |
22 | + CLOSED("已关闭", 3); | |
23 | + | |
24 | + private String name; | |
25 | + private int index; | |
26 | + | |
27 | + // 构造方法 | |
28 | + SupplyStatusType(String name, int index) { | |
29 | + this.name = name; | |
30 | + this.index = index; | |
31 | + } | |
32 | + | |
33 | + // 普通方法 | |
34 | + public static String getName(int index) { | |
35 | + for (SupplyStatusType c : SupplyStatusType.values()) { | |
36 | + if (c.getIndex() == index) { | |
37 | + return c.name; | |
38 | + } | |
39 | + } | |
40 | + return null; | |
41 | + } | |
42 | + | |
43 | + public static SupplyStatusType getTraceType(int index) { | |
44 | + for (SupplyStatusType c : SupplyStatusType.values()) { | |
45 | + if (c.getIndex() == index) { | |
46 | + return c; | |
47 | + } | |
48 | + } | |
49 | + return null; | |
50 | + } | |
51 | + | |
52 | + public static List<SupplyStatusType> getEnumItemList() { | |
53 | + SupplyStatusType[] itemList = SupplyStatusType.values(); | |
54 | + List<SupplyStatusType> filteredItemList = new ArrayList<SupplyStatusType>(); | |
55 | + for (SupplyStatusType status : itemList) { | |
56 | + filteredItemList.add(status); | |
57 | + } | |
58 | + return filteredItemList; | |
59 | + } | |
60 | + | |
61 | + // get set 方法 | |
62 | + public String getName() { | |
63 | + return name; | |
64 | + } | |
65 | + | |
66 | + public int getIndex() { | |
67 | + return index; | |
68 | + } | |
69 | +} | ... | ... |
titan-web/src/main/java/com/dili/titan/common/enums/SupplyType.java
0 → 100644
1 | +package com.dili.titan.common.enums; | |
2 | + | |
3 | +import java.util.ArrayList; | |
4 | +import java.util.List; | |
5 | + | |
6 | +/** | |
7 | + * 供应类型。1自营,2第三方 | |
8 | + */ | |
9 | +@Deprecated | |
10 | +public enum SupplyType { | |
11 | + /** | |
12 | + * 1自营 | |
13 | + */ | |
14 | + Dili("自营", 1), | |
15 | + /** | |
16 | + * 2第三方 | |
17 | + */ | |
18 | + Third("第三方", 2); | |
19 | + | |
20 | + private String name; | |
21 | + private int index; | |
22 | + | |
23 | + // 构造方法 | |
24 | + SupplyType(String name, int index) { | |
25 | + this.name = name; | |
26 | + this.index = index; | |
27 | + } | |
28 | + | |
29 | + // 普通方法 | |
30 | + public static String getName(int index) { | |
31 | + for (SupplyType c : SupplyType.values()) { | |
32 | + if (c.getIndex() == index) { | |
33 | + return c.name; | |
34 | + } | |
35 | + } | |
36 | + return null; | |
37 | + } | |
38 | + | |
39 | + public static SupplyType getTraceType(int index) { | |
40 | + for (SupplyType c : SupplyType.values()) { | |
41 | + if (c.getIndex() == index) { | |
42 | + return c; | |
43 | + } | |
44 | + } | |
45 | + return null; | |
46 | + } | |
47 | + | |
48 | + public static List<SupplyType> getEnumItemList() { | |
49 | + SupplyType[] itemList = SupplyType.values(); | |
50 | + List<SupplyType> filteredItemList = new ArrayList<SupplyType>(); | |
51 | + for (SupplyType status : itemList) { | |
52 | + filteredItemList.add(status); | |
53 | + } | |
54 | + return filteredItemList; | |
55 | + } | |
56 | + | |
57 | + // get set 方法 | |
58 | + public String getName() { | |
59 | + return name; | |
60 | + } | |
61 | + | |
62 | + public int getIndex() { | |
63 | + return index; | |
64 | + } | |
65 | +} | ... | ... |
titan-web/src/main/java/com/dili/titan/common/enums/ThirdSupplyStatusType.java
0 → 100644
1 | +package com.dili.titan.common.enums; | |
2 | + | |
3 | +import java.util.ArrayList; | |
4 | +import java.util.List; | |
5 | + | |
6 | +/** | |
7 | + * 第三方供应状态。1-进行中,2-已过期,3-已关闭,4-审核失败 | |
8 | + */ | |
9 | +@Deprecated | |
10 | +public enum ThirdSupplyStatusType { | |
11 | + /** | |
12 | + * 1审核通过 | |
13 | + */ | |
14 | + PASSED("审核通过", 1), | |
15 | + /** | |
16 | + * 2已过期 | |
17 | + */ | |
18 | + EXPIRED("已过期", 2), | |
19 | + /** | |
20 | + * 3已关闭 | |
21 | + */ | |
22 | + CLOSED("已关闭", 3), | |
23 | + /** | |
24 | + * 4审核失败 | |
25 | + */ | |
26 | + FAILURE("审核失败", 4), | |
27 | + /** | |
28 | + * 5待审核 | |
29 | + */ | |
30 | + WAIT("待审核", 5); | |
31 | + | |
32 | + private String name; | |
33 | + private int index; | |
34 | + | |
35 | + // 构造方法 | |
36 | + ThirdSupplyStatusType(String name, int index) { | |
37 | + this.name = name; | |
38 | + this.index = index; | |
39 | + } | |
40 | + | |
41 | + // 普通方法 | |
42 | + public static String getName(int index) { | |
43 | + for (ThirdSupplyStatusType c : ThirdSupplyStatusType.values()) { | |
44 | + if (c.getIndex() == index) { | |
45 | + return c.name; | |
46 | + } | |
47 | + } | |
48 | + return null; | |
49 | + } | |
50 | + | |
51 | + public static ThirdSupplyStatusType getTraceType(int index) { | |
52 | + for (ThirdSupplyStatusType c : ThirdSupplyStatusType.values()) { | |
53 | + if (c.getIndex() == index) { | |
54 | + return c; | |
55 | + } | |
56 | + } | |
57 | + return null; | |
58 | + } | |
59 | + | |
60 | + public static List<ThirdSupplyStatusType> getEnumItemList() { | |
61 | + ThirdSupplyStatusType[] itemList = ThirdSupplyStatusType.values(); | |
62 | + List<ThirdSupplyStatusType> filteredItemList = new ArrayList<ThirdSupplyStatusType>(); | |
63 | + for (ThirdSupplyStatusType status : itemList) { | |
64 | + filteredItemList.add(status); | |
65 | + } | |
66 | + return filteredItemList; | |
67 | + } | |
68 | + | |
69 | + // get set 方法 | |
70 | + public String getName() { | |
71 | + return name; | |
72 | + } | |
73 | + | |
74 | + public int getIndex() { | |
75 | + return index; | |
76 | + } | |
77 | +} | ... | ... |
titan-web/src/main/java/com/dili/titan/common/exception/AppException.java
0 → 100644
1 | +/* | |
2 | + * Copyright (c) 2014 www.diligrp.com All rights reserved. | |
3 | + * 本软件源代码版权归----所有,未经许可不得任意复制与传播. | |
4 | + */ | |
5 | +package com.dili.titan.common.exception; | |
6 | + | |
7 | +/** | |
8 | + * 自定义程序异常 | |
9 | + */ | |
10 | +public class AppException extends RuntimeException{ | |
11 | + private static final long serialVersionUID = 1L; | |
12 | + public AppException() { | |
13 | + super(); | |
14 | + } | |
15 | + | |
16 | + public AppException(String message) { | |
17 | + super(message); | |
18 | + } | |
19 | + | |
20 | + public AppException(String message, Throwable cause) { | |
21 | + super(message, cause); | |
22 | + } | |
23 | + | |
24 | + public AppException(Throwable cause) { | |
25 | + super(cause); | |
26 | + } | |
27 | +} | ... | ... |
titan-web/src/main/java/com/dili/titan/common/exception/TitanError.java
0 → 100644
1 | +package com.dili.titan.common.exception; | |
2 | + | |
3 | +/** | |
4 | + * 商品库异常类 | |
5 | + */ | |
6 | +public final class TitanError extends Exception { | |
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 | + public final static TitanError READ_BODY_ERROR = new TitanError(20, "读取请求内容失败"); | |
26 | + | |
27 | + /*** | |
28 | + * 业务错误 | |
29 | + **/ | |
30 | + // 库存错误 | |
31 | + public final static TitanError LOW_STOCKS = new TitanError(30, "库存不足"); | |
32 | + public final static TitanError DUPLICATE_DECRASE = new TitanError(31, "重复扣减库存"); | |
33 | + public final static TitanError DUPLICATE_INCRASE = new TitanError(31, "重复增加库存"); | |
34 | + | |
35 | + public int getCode() { | |
36 | + return code; | |
37 | + } | |
38 | + | |
39 | + public void setCode(int code) { | |
40 | + this.code = code; | |
41 | + } | |
42 | + | |
43 | + public String getResult() { | |
44 | + return result; | |
45 | + } | |
46 | + | |
47 | + public void setResult(String result) { | |
48 | + this.result = result; | |
49 | + } | |
50 | + | |
51 | + @Override | |
52 | + public String getMessage() { | |
53 | + return this.getResult(); | |
54 | + } | |
55 | + | |
56 | +} | ... | ... |
titan-web/src/main/java/com/dili/titan/common/log/LogBusinessIdUtils.java
0 → 100644
1 | +package com.dili.titan.common.log; | |
2 | + | |
3 | +import org.apache.commons.lang.StringUtils; | |
4 | + | |
5 | +import java.util.UUID; | |
6 | + | |
7 | +/** | |
8 | + * 用于设置线程的UUID,用于打印日志 | |
9 | + * | |
10 | + * @author cdwangyong3 | |
11 | + */ | |
12 | +public class LogBusinessIdUtils { | |
13 | + private static final ThreadLocal<String> businessLocal = new ThreadLocal<String>(); | |
14 | + | |
15 | + /** | |
16 | + * 返回当前线程对应的uuid | |
17 | + * | |
18 | + * @return | |
19 | + */ | |
20 | + public static String getCurBusinessId() { | |
21 | + String uuid = businessLocal.get(); | |
22 | + if (StringUtils.isEmpty(uuid)) { | |
23 | + uuid = UUID.randomUUID().toString().replace("-", ""); | |
24 | + businessLocal.set(uuid); | |
25 | + } | |
26 | + return uuid; | |
27 | + } | |
28 | + | |
29 | + | |
30 | + /** | |
31 | + * 给当前线程重新设置 | |
32 | + */ | |
33 | + public static void clear() { | |
34 | + //TODO 这代码在哪里被调用了? | |
35 | + businessLocal.set(null); | |
36 | + } | |
37 | +} | |
38 | + | ... | ... |
titan-web/src/main/java/com/dili/titan/common/log/LogHelper.java
0 → 100644
1 | +package com.dili.titan.common.log; | |
2 | + | |
3 | +import org.apache.commons.lang.StringUtils; | |
4 | +import org.apache.commons.logging.Log; | |
5 | +import org.apache.commons.logging.LogFactory; | |
6 | + | |
7 | +import java.io.PrintWriter; | |
8 | +import java.io.StringWriter; | |
9 | +import java.util.HashMap; | |
10 | +import java.util.Map; | |
11 | + | |
12 | +/** | |
13 | + * Describe: User: BjYangKai Date: 2011-4-21 Time: 12:00:33 | |
14 | + */ | |
15 | +public class LogHelper { | |
16 | + | |
17 | + /** | |
18 | + */ | |
19 | + private static Map<LogTypeEnum, Log> logMap = new HashMap<LogTypeEnum, Log>(); | |
20 | + | |
21 | + static { | |
22 | + for (LogTypeEnum ft : LogTypeEnum.values()) { | |
23 | + logMap.put(ft, LogFactory.getLog(ft.getKey())); | |
24 | + } | |
25 | + } | |
26 | + | |
27 | + /** | |
28 | + * | |
29 | + * @param str | |
30 | + * @return | |
31 | + */ | |
32 | + public static String addLogbusinessId(String str) { | |
33 | + if (StringUtils.isEmpty(str)) { | |
34 | + return str; | |
35 | + } else { | |
36 | + return "业务标示ID[" + LogBusinessIdUtils.getCurBusinessId() + "]," | |
37 | + + str; | |
38 | + } | |
39 | + } | |
40 | + | |
41 | + /** | |
42 | + * 使用默认的文件记录debug信息 | |
43 | + * | |
44 | + * @param str 日志信息 | |
45 | + */ | |
46 | + public static void debug(String str, Object... args) { | |
47 | + debug(LogTypeEnum.DEFAULT, str, args); | |
48 | + } | |
49 | + | |
50 | + /** | |
51 | + * 使用默认的文件记录info信息 | |
52 | + * | |
53 | + * @param str 日志信息 | |
54 | + */ | |
55 | + public static void info(String str, Object... args) { | |
56 | + info(LogTypeEnum.DEFAULT, str, args); | |
57 | + } | |
58 | + | |
59 | + /** | |
60 | + * 使用默认的文件记录warn信息 | |
61 | + * | |
62 | + * @param str 日志信息 | |
63 | + */ | |
64 | + public static void warn(String str, Object... args) { | |
65 | + warn(LogTypeEnum.DEFAULT, str, args); | |
66 | + } | |
67 | + | |
68 | + /** | |
69 | + * 使用默认的文件记录error信息 | |
70 | + * | |
71 | + * @param str 日志信息 | |
72 | + */ | |
73 | + public static void error(Throwable e, String str, Object... args) { | |
74 | + error(LogTypeEnum.DEFAULT, e, str, args); | |
75 | + } | |
76 | + | |
77 | + /** | |
78 | + * 使用默认的文件记录fatal信息 | |
79 | + * | |
80 | + * @param str 日志信息 | |
81 | + */ | |
82 | + public static void fatal(Throwable e, String str, Object... args) { | |
83 | + fatal(LogTypeEnum.DEFAULT, e, str, args); | |
84 | + } | |
85 | + | |
86 | + /** | |
87 | + * 记录运行期错误信息 | |
88 | + * | |
89 | + * @param e | |
90 | + */ | |
91 | + public static void execption(Throwable e) { | |
92 | + error(LogTypeEnum.EXCEPTION, getExceptionTrace(e)); | |
93 | + } | |
94 | + | |
95 | + /** | |
96 | + * 打印错误信息 | |
97 | + * | |
98 | + * @param e | |
99 | + * @return | |
100 | + */ | |
101 | + public static String getExceptionTrace(Throwable e) { | |
102 | + if (e != null) { | |
103 | + StringWriter sw = new StringWriter(); | |
104 | + PrintWriter pw = new PrintWriter(sw); | |
105 | + e.printStackTrace(pw); | |
106 | + return sw.toString(); | |
107 | + } else | |
108 | + return null; | |
109 | + } | |
110 | + | |
111 | + public static Log getLog(LogTypeEnum type) { | |
112 | + if (logMap.get(type) == null) { | |
113 | + return LogFactory.getLog(LogHelper.class); | |
114 | + } else { | |
115 | + return logMap.get(type); | |
116 | + } | |
117 | + } | |
118 | + | |
119 | + /** | |
120 | + * 日志消息占位符形式的替换,按照传入参数依次替换"{}" | |
121 | + * | |
122 | + * @param str 带占位符的日志消息 | |
123 | + * @param args 需要被替换的参数,除了字符串和基本类型的对象形式外,其他类型需要自己实现toString方法 | |
124 | + * @return | |
125 | + */ | |
126 | + public static <T extends Object> String replace(String str, T... args) { | |
127 | + if (str == null) { | |
128 | + return str; | |
129 | + } | |
130 | + if (args == null || args.length < 1) { | |
131 | + return addLogbusinessId(str.replaceAll("\\{\\}", " null")); | |
132 | + } | |
133 | + StringBuilder builder = new StringBuilder(str); | |
134 | + int start = builder.indexOf("{"); | |
135 | + int end = builder.indexOf("}", start); | |
136 | + for (Object arg : args) { | |
137 | + if (start == -1) { | |
138 | + break; | |
139 | + } | |
140 | + if (arg == null) { | |
141 | + arg = "null"; | |
142 | + } | |
143 | + builder.replace(start, end + 1, arg.toString()); | |
144 | + start = start + arg.toString().length(); | |
145 | + start = builder.indexOf("{", start); | |
146 | + end = builder.indexOf("}", start); | |
147 | + } | |
148 | + return addLogbusinessId(builder.toString()); | |
149 | + } | |
150 | + | |
151 | + /** | |
152 | + * 记录DEBUG信息 | |
153 | + * | |
154 | + * @param type 日志业务类型 | |
155 | + * @param str | |
156 | + */ | |
157 | + public static void debug(LogTypeEnum type, String str, Object... args) { | |
158 | + Log log = getLog(type); | |
159 | + if (log.isDebugEnabled()) { | |
160 | + String msg = replace(str, args); | |
161 | + log.debug(msg); | |
162 | + } | |
163 | + } | |
164 | + | |
165 | + /** | |
166 | + * 记录INFO信息 | |
167 | + * | |
168 | + * @param type 日志业务类型 | |
169 | + * @param str | |
170 | + */ | |
171 | + public static void info(LogTypeEnum type, String str, Object... args) { | |
172 | + Log log = getLog(type); | |
173 | + if (log.isInfoEnabled()) { | |
174 | + String msg = replace(str, args); | |
175 | + log.info(msg); | |
176 | + } | |
177 | + } | |
178 | + | |
179 | + /** | |
180 | + * 记录warn信息 | |
181 | + * | |
182 | + * @param type 日志业务类型 | |
183 | + * @param str | |
184 | + */ | |
185 | + public static void warn(LogTypeEnum type, String str, Object... args) { | |
186 | + Log log = getLog(type); | |
187 | + if (log.isWarnEnabled()) { | |
188 | + String msg = replace(str, args); | |
189 | + log.warn(msg); | |
190 | + } | |
191 | + } | |
192 | + | |
193 | + /** | |
194 | + * 记录error信息 | |
195 | + * | |
196 | + * @param type 日志业务类型 | |
197 | + * @param str | |
198 | + */ | |
199 | + public static void error(LogTypeEnum type, String str, Object... args) { | |
200 | + Log log = getLog(type); | |
201 | + if (log.isErrorEnabled()) { | |
202 | + String msg = replace(str, args); | |
203 | + log.error(msg); | |
204 | + } | |
205 | + } | |
206 | + | |
207 | + /** | |
208 | + * 记录fatal信息 | |
209 | + * | |
210 | + * @param type 日志业务类型 | |
211 | + * @param str 日志信息 | |
212 | + */ | |
213 | + public static void fatal(LogTypeEnum type, String str, Object... args) { | |
214 | + Log log = getLog(type); | |
215 | + if (log.isFatalEnabled()) { | |
216 | + String msg = replace(str, args); | |
217 | + log.fatal(msg); | |
218 | + } | |
219 | + } | |
220 | + | |
221 | + /** | |
222 | + * 记录error信息 | |
223 | + * | |
224 | + * @param type 日志业务类型 | |
225 | + * @param str | |
226 | + */ | |
227 | + public static void error(LogTypeEnum type, Throwable e, String str, | |
228 | + Object... args) { | |
229 | + Log log = getLog(type); | |
230 | + if (log.isErrorEnabled()) { | |
231 | + String msg = replace(str, args); | |
232 | + log.error(msg, e); | |
233 | + } | |
234 | + } | |
235 | + | |
236 | + /** | |
237 | + * 记录fatal信息 | |
238 | + * | |
239 | + * @param type 日志业务类型 | |
240 | + * @param str 日志信息 | |
241 | + */ | |
242 | + public static void fatal(LogTypeEnum type, Throwable e, String str, | |
243 | + Object... args) { | |
244 | + Log log = getLog(type); | |
245 | + if (log.isFatalEnabled()) { | |
246 | + String msg = replace(str, args); | |
247 | + log.fatal(msg, e); | |
248 | + } | |
249 | + } | |
250 | + | |
251 | + public static void main(String[] args) { | |
252 | + LogHelper.debug(LogTypeEnum.DEFAULT, "aaaa"); | |
253 | + System.out.println(); | |
254 | + } | |
255 | +} | ... | ... |
titan-web/src/main/java/com/dili/titan/common/log/LogTypeEnum.java
0 → 100644
1 | +package com.dili.titan.common.log; | |
2 | + | |
3 | +import org.apache.commons.lang.StringUtils; | |
4 | +import org.apache.commons.logging.Log; | |
5 | + | |
6 | +/** | |
7 | + * 日志的业务类型,对重要的业务日志需要在这里定义类型 | |
8 | + * | |
9 | + * @author dingjun | |
10 | + */ | |
11 | +public enum LogTypeEnum { | |
12 | + DEFAULT("DEFAULT", "默认"), | |
13 | + ATTRIBUTE("ATTRIBUTE", "属性"), | |
14 | + CATEGORY("CATEGORY", "类目"), | |
15 | + TEMPLETE("TEMPLETE", "模板"), | |
16 | + SUPPLY("TITAN_SUPPLY", "供应信息"), | |
17 | + PURCHASE("TITAN_PURCHASE", "求购信息"), | |
18 | + PRODUCT_POP("PRODUCT_POP", "第三方商品"), | |
19 | + GQ("TITAN_GQ", "供求"), | |
20 | + PRODUCT_MQ("PRODUCT_MQ", "MQ消息"), | |
21 | + EXCEPTION("EXCEPTION", "运行错误"); | |
22 | + | |
23 | + private String key; | |
24 | + private String value; | |
25 | + | |
26 | + LogTypeEnum() { | |
27 | + } | |
28 | + | |
29 | + LogTypeEnum(String key, String value) { | |
30 | + this.key = key; | |
31 | + this.value = value; | |
32 | + } | |
33 | + | |
34 | + public static String getValue(String key) { | |
35 | + for (LogTypeEnum ft : LogTypeEnum.values()) { | |
36 | + if (ft.getKey().equals(key)) { | |
37 | + return ft.getValue(); | |
38 | + } | |
39 | + } | |
40 | + return null; | |
41 | + } | |
42 | + | |
43 | + public String getKey() { | |
44 | + return key; | |
45 | + } | |
46 | + | |
47 | + public String getValue() { | |
48 | + return value; | |
49 | + } | |
50 | + | |
51 | + public Log getLog() { | |
52 | + return LogHelper.getLog(this); | |
53 | + } | |
54 | + | |
55 | + /** | |
56 | + * 增加日志打印class信息----暂时未用 | |
57 | + * | |
58 | + * @param str | |
59 | + * @return | |
60 | + */ | |
61 | + public static String getClassAndlin(String str) { | |
62 | + if (StringUtils.isEmpty(str)) { | |
63 | + return str; | |
64 | + } | |
65 | + StackTraceElement stack[] = Thread.currentThread().getStackTrace(); | |
66 | + boolean boo = false; | |
67 | + for (StackTraceElement ste : stack) { | |
68 | + if ((ste.getFileName().indexOf("LogTypeEnum.java")) != -1) { | |
69 | + boo = true; | |
70 | + } else if (boo) { | |
71 | + //TODO 我看这段代码永远都不会进来 | |
72 | + return new StringBuffer(MarkConstant.LEFT_BRACKET).append(ste.getFileName()).append(MarkConstant.SPLIT_CODE) | |
73 | + .append(ste.getLineNumber()).append(MarkConstant.RIGHT_BRACKET).append(MarkConstant.BLANK).append(str).toString(); | |
74 | + } | |
75 | + } | |
76 | + return str; | |
77 | + } | |
78 | + | |
79 | +} | ... | ... |
titan-web/src/main/java/com/dili/titan/common/log/MarkConstant.java
0 → 100644
1 | +package com.dili.titan.common.log; | |
2 | + | |
3 | +/** | |
4 | + * 标点符号常量类 | |
5 | + * | |
6 | + * @author gongsz | |
7 | + */ | |
8 | +public class MarkConstant { | |
9 | + /** | |
10 | + * 分隔符 - | |
11 | + */ | |
12 | + public static final String SPLIT_CODE = "-"; | |
13 | + /** | |
14 | + * 冒号 | |
15 | + */ | |
16 | + public static final String COLON = ":"; | |
17 | + /** | |
18 | + * 逗号 | |
19 | + */ | |
20 | + public static final String COMMA = ","; | |
21 | + | |
22 | + /** | |
23 | + * 左方括号 | |
24 | + */ | |
25 | + public static final String LEFT_BRACKETS = "["; | |
26 | + /** | |
27 | + * 右方括号 | |
28 | + */ | |
29 | + public static final String RIGHT_BRACKETS = "]"; | |
30 | + /** | |
31 | + * 换行 | |
32 | + */ | |
33 | + public static final String NEW_LINE = "\n"; | |
34 | + | |
35 | + /** | |
36 | + * 符号:点 | |
37 | + */ | |
38 | + public static final String SYMBOL_POINT = "."; | |
39 | + | |
40 | + /** | |
41 | + * 符号:/ | |
42 | + */ | |
43 | + public static final String SPRIT = "/"; | |
44 | + /** | |
45 | + * 符号:下划线 | |
46 | + */ | |
47 | + public static final String UNDERLINE = "_"; | |
48 | + /** | |
49 | + * 符号:& | |
50 | + */ | |
51 | + public static final String AND = "&"; | |
52 | + /** | |
53 | + * 空格 | |
54 | + */ | |
55 | + public static final String BLANK = " "; | |
56 | + | |
57 | + /** | |
58 | + * 左括号 | |
59 | + */ | |
60 | + public static final String LEFT_BRACKET = "("; | |
61 | + | |
62 | + /** | |
63 | + * 右括号 | |
64 | + */ | |
65 | + public static final String RIGHT_BRACKET = ")"; | |
66 | + | |
67 | +} | ... | ... |
titan-web/src/main/java/com/dili/titan/common/tools/DateUtils.java
0 → 100644
1 | +package com.dili.titan.common.tools; | |
2 | + | |
3 | +import org.slf4j.Logger; | |
4 | +import org.slf4j.LoggerFactory; | |
5 | + | |
6 | +import java.text.ParseException; | |
7 | +import java.text.SimpleDateFormat; | |
8 | +import java.util.Calendar; | |
9 | +import java.util.Date; | |
10 | +import java.util.GregorianCalendar; | |
11 | +import java.util.TimeZone; | |
12 | + | |
13 | +/** | |
14 | + * 日期工具类 | |
15 | + * | |
16 | + * @author dev-center | |
17 | + * @since 2014-05-10 | |
18 | + */ | |
19 | +public class DateUtils { | |
20 | + private final static Logger LOGGER = LoggerFactory.getLogger(DateUtils.class); | |
21 | + | |
22 | + public static long getServerTime() { | |
23 | + return System.currentTimeMillis(); | |
24 | + } | |
25 | + | |
26 | + /** | |
27 | + * 格式化日期,默认返回yyyy-MM-dd HH:mm:ss | |
28 | + * | |
29 | + * @param date | |
30 | + * @return | |
31 | + */ | |
32 | + public static String format(Date date) { | |
33 | + return format(date, "yyyy-MM-dd HH:mm:ss"); | |
34 | + } | |
35 | + | |
36 | + /** | |
37 | + * 格式化显示当前日期 | |
38 | + * | |
39 | + * @param format | |
40 | + * @return | |
41 | + */ | |
42 | + public static String format(String format) { | |
43 | + return format(new Date(), format); | |
44 | + } | |
45 | + | |
46 | + /** | |
47 | + * 日期格式化 | |
48 | + * | |
49 | + * @param date | |
50 | + * @param format | |
51 | + * @return | |
52 | + */ | |
53 | + public static String format(Date date, String format) { | |
54 | + try { | |
55 | + SimpleDateFormat sdf = new SimpleDateFormat(format); | |
56 | + return sdf.format(date); | |
57 | + } catch (Exception e) { | |
58 | + LOGGER.warn("日期格式化失败.{}", e.getMessage()); | |
59 | + } | |
60 | + return null; | |
61 | + } | |
62 | + | |
63 | + /** | |
64 | + * 时间格式化, 传入毫秒 | |
65 | + * | |
66 | + * @param time | |
67 | + * @return | |
68 | + */ | |
69 | + public static String dateFormat(long time) { | |
70 | + return format(new Date(time), "yyyy-MM-dd HH:mm:ss"); | |
71 | + } | |
72 | + | |
73 | + /** | |
74 | + * 时间格式化 | |
75 | + * | |
76 | + * @param date date | |
77 | + * @param p parameter | |
78 | + * @return dateFormat | |
79 | + * @author yangjianjun | |
80 | + * @creaetime Jul 18, 2012 7:22:29 PM | |
81 | + */ | |
82 | + public static String formatDateTime(Date date, int p) { | |
83 | + String pattern = "yyyy-MM-dd HH:mm:ss"; | |
84 | + switch (p) { | |
85 | + case 1: | |
86 | + pattern = "yyyy-MM-dd"; | |
87 | + break; | |
88 | + case 2: | |
89 | + pattern = "yyyy-MM-dd HH:mm:ss"; | |
90 | + break; | |
91 | + case 3: | |
92 | + pattern = "yyyy-MM-dd HH:mm:ss.SSS"; | |
93 | + break; | |
94 | + case 4: | |
95 | + pattern = "yyyy-MM"; | |
96 | + break; | |
97 | + case 5: | |
98 | + pattern = "MM-dd"; | |
99 | + break; | |
100 | + case 6: | |
101 | + pattern = "HH:mm:ss"; | |
102 | + break; | |
103 | + case 7: | |
104 | + pattern = "HH:mm"; | |
105 | + break; | |
106 | + case 8: | |
107 | + pattern = "MM-dd HH:mm:ss"; | |
108 | + break; | |
109 | + case 9: | |
110 | + pattern = "MM-dd HH:mm"; | |
111 | + break; | |
112 | + case 10: | |
113 | + pattern = "yyyyMMddHHmmssSSS"; | |
114 | + break; | |
115 | + default: | |
116 | + return null; | |
117 | + } | |
118 | + return new SimpleDateFormat(pattern).format(date); | |
119 | + } | |
120 | + | |
121 | + | |
122 | + /** | |
123 | + * 计算某个时间到某个时间的时差等信息 | |
124 | + * | |
125 | + * @param startTime beginTime | |
126 | + * @param endTime endTime | |
127 | + * @param format temple | |
128 | + * @param str 小时 | |
129 | + * @return 时差 | |
130 | + * @throws ParseException ParseException | |
131 | + * @author yangjianjun | |
132 | + * @creaetime Nov 28, 2014 3:16:21 PM | |
133 | + */ | |
134 | + public static Long dateDiff(String startTime, String endTime, | |
135 | + String format, String str) throws ParseException { | |
136 | + // 按照传入的格式生成一个simpledateformate对象 | |
137 | + SimpleDateFormat sd = new SimpleDateFormat(format); | |
138 | + long nd = 1000 * 24 * 60 * 60;// 一天的毫秒数 | |
139 | + long nh = 1000 * 60 * 60;// 一小时的毫秒数 | |
140 | + long nm = 1000 * 60;// 一分钟的毫秒数 | |
141 | + long ns = 1000;// 一秒钟的毫秒数 | |
142 | + long diff; | |
143 | + long day = 0; | |
144 | + long hour = 0; | |
145 | + long min = 0; | |
146 | + long sec = 0; | |
147 | + // 获得两个时间的毫秒时间差异 | |
148 | + diff = sd.parse(endTime).getTime() - sd.parse(startTime).getTime(); | |
149 | + day = diff / nd;// 计算差多少天 | |
150 | + hour = diff % nd / nh + day * 24;// 计算差多少小时 | |
151 | + min = diff % nd % nh / nm + day * 24 * 60;// 计算差多少分钟 | |
152 | + sec = diff % nd % nh % nm / ns;// 计算差多少秒 | |
153 | + // 输出结果 | |
154 | + System.out.println("时间相差:" + day + "天" + (hour - day * 24) + "小时" | |
155 | + + (min - day * 24 * 60) + "分钟" + sec + "秒。"); | |
156 | + System.out.println("hour=" + hour + ",min=" + min); | |
157 | + if (str.equalsIgnoreCase("h")) { | |
158 | + return hour; | |
159 | + } else { | |
160 | + return min; | |
161 | + } | |
162 | + } | |
163 | + | |
164 | + /** | |
165 | + * 计算结束时间到开始时间的秒数 | |
166 | + * | |
167 | + * @param startTime | |
168 | + * @param endTime | |
169 | + * @param format | |
170 | + * @return | |
171 | + * @author yangjianjun | |
172 | + * @createtime 2014年6月25日 下午2:09:10 | |
173 | + */ | |
174 | + public static Long dateDiff(String startTime, String endTime, | |
175 | + String format) { | |
176 | + SimpleDateFormat sf = new SimpleDateFormat(format); | |
177 | + long time = -1; | |
178 | + try { | |
179 | + time = sf.parse(endTime).getTime() - sf.parse(startTime).getTime(); | |
180 | + } catch (ParseException e) { | |
181 | + } | |
182 | + return time / 1000; | |
183 | + } | |
184 | + | |
185 | + /** | |
186 | + * this method is 将字符串转化为日期格式 | |
187 | + * | |
188 | + * @param time | |
189 | + * @param type | |
190 | + * @return | |
191 | + * @throws ParseException | |
192 | + * @createTime 2014年6月25日 下午2:14:09 | |
193 | + * @author yangjianjun | |
194 | + */ | |
195 | + public static Date stringToDate(String time, int type) throws ParseException { | |
196 | + Date date = null; | |
197 | + SimpleDateFormat simple = null; | |
198 | + | |
199 | + switch (type) { | |
200 | + case 1: | |
201 | + simple = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
202 | + break; | |
203 | + case 2: | |
204 | + simple = new SimpleDateFormat("yyyy-MM-dd"); | |
205 | + break; | |
206 | + default: | |
207 | + simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
208 | + break; | |
209 | + } | |
210 | + date = simple.parse(time); | |
211 | + return date; | |
212 | + } | |
213 | + | |
214 | + /** | |
215 | + * this method is 根据秒数求出时间 | |
216 | + * | |
217 | + * @param time | |
218 | + * @return | |
219 | + * @createTime 2014年6月25日 下午2:09:51 | |
220 | + * @author yangjianjun | |
221 | + */ | |
222 | + public static String paserTime(String time) { | |
223 | + System.setProperty("user.timezone", "Asia/Shanghai"); | |
224 | + TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai"); | |
225 | + TimeZone.setDefault(tz); | |
226 | + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
227 | + String times = format.format(new Date(Long.parseLong(time) * 1000L)); | |
228 | +// System.out.print("日期为:" + times); | |
229 | + return times; | |
230 | + } | |
231 | + | |
232 | + /** | |
233 | + * this method is 根据时间求出秒数 | |
234 | + * | |
235 | + * @param date | |
236 | + * @return | |
237 | + * @createTime 2014年6月25日 下午2:10:08 | |
238 | + * @author yangjianjun | |
239 | + */ | |
240 | + public static long paserSecond(Date date) { | |
241 | + long dates = date.getTime() / 1000L; | |
242 | + return dates; | |
243 | + } | |
244 | + | |
245 | + /** | |
246 | + * this method is 根据实际和天数计算出最新时间 | |
247 | + * | |
248 | + * @param dates 当前时间 | |
249 | + * @param day 当前天数 | |
250 | + * @return 最新时间 | |
251 | + * @createTime 2014年7月10日 上午11:11:51 | |
252 | + * @author yangjianjun | |
253 | + */ | |
254 | + public static Date getBeforeAfterDate(Date dates, int day) { | |
255 | + Calendar cal = new GregorianCalendar(); | |
256 | + cal.setTime(dates); | |
257 | + int Year = cal.get(Calendar.YEAR); | |
258 | + int Month = cal.get(Calendar.MONTH); | |
259 | + int Day = cal.get(Calendar.DAY_OF_MONTH); | |
260 | + int NewDay = Day + day; | |
261 | + cal.set(Calendar.YEAR, Year); | |
262 | + cal.set(Calendar.MONTH, Month); | |
263 | + cal.set(Calendar.DAY_OF_MONTH, NewDay); | |
264 | + return new Date(cal.getTimeInMillis()); | |
265 | + } | |
266 | +} | ... | ... |
titan-web/src/main/java/com/dili/titan/common/tools/NullTool.java
0 → 100644
1 | +package com.dili.titan.common.tools; | |
2 | + | |
3 | +/* | |
4 | + * Copyright 2003-2004 The Apache Software Foundation. | |
5 | + * | |
6 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
7 | + * you may not use this file except in compliance with the License. | |
8 | + * You may obtain a copy of the License at | |
9 | + * | |
10 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | + * | |
12 | + * Unless required by applicable law or agreed to in writing, software | |
13 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
15 | + * See the License for the specific language governing permissions and | |
16 | + * limitations under the License. | |
17 | + */ | |
18 | + | |
19 | +import org.apache.velocity.context.Context; | |
20 | + | |
21 | +/** | |
22 | + * 在vm页面使用,用于判断是否有空 | |
23 | + * | |
24 | + * Tool for working with <code>null</code> in Velocity templates. | |
25 | + * It provides a method to set a VTL reference back to <code>null</code>. | |
26 | + * Also provides methods to check if a VTL reference is <code>null</code> or not. | |
27 | + * <p> | |
28 | + * NOTE: These examples assume you have placed an | |
29 | + * instance of the current context within itself as 'ctx'. | |
30 | + * And, of course, the NullTool is assumed to be available as 'null'. | |
31 | + * </p> | |
32 | + * <p><pre> | |
33 | + * Example uses: | |
34 | + * $foo -> bar | |
35 | + * $null.isNull($foo) -> false | |
36 | + * $null.isNotNull($foo) -> true | |
37 | + * | |
38 | + * $null.setNull($ctx, "foo") | |
39 | + * $foo -> $foo (null) | |
40 | + * $null.isNull($foo) -> true | |
41 | + * $null.isNotNull($foo) -> false | |
42 | + * | |
43 | + * $null.set($ctx, $foo, "hoge") | |
44 | + * $foo -> hoge | |
45 | + * $null.set($ctx, $foo, $null.null) | |
46 | + * $foo -> $foo (null) | |
47 | + * </pre></p> | |
48 | + * | |
49 | + * <p>This tool is entirely threadsafe, and has no instance members. | |
50 | + * </p> | |
51 | + * | |
52 | + * @author <a href="mailto:shinobu@ieee.org">Shinobu Kawai</a> | |
53 | + * @version $Id: $ | |
54 | + */ | |
55 | +public class NullTool | |
56 | +{ | |
57 | + | |
58 | + /** | |
59 | + * Default constructor. | |
60 | + */ | |
61 | + public NullTool() | |
62 | + { | |
63 | + } | |
64 | + | |
65 | + /** | |
66 | + * Sets the given VTL reference back to <code>null</code>. | |
67 | + * @param context the current Context | |
68 | + * @param key the VTL reference to set back to <code>null</code>. | |
69 | + */ | |
70 | + public void setNull(Context context, String key) | |
71 | + { | |
72 | + if (this.isNull(context)) | |
73 | + { | |
74 | + return; | |
75 | + } | |
76 | + context.remove(key); | |
77 | + } | |
78 | + | |
79 | + /** | |
80 | + * Sets the given VTL reference to the given value. | |
81 | + * If the value is <code>null</code>, | |
82 | + * the VTL reference is set to <code>null</code>. | |
83 | + * @param context the current Context | |
84 | + * @param key the VTL reference to set. | |
85 | + * @param value the value to set the VTL reference to. | |
86 | + */ | |
87 | + public void set(Context context, String key, Object value) | |
88 | + { | |
89 | + if (this.isNull(context)) | |
90 | + { | |
91 | + return; | |
92 | + } | |
93 | + if (this.isNull(value)) | |
94 | + { | |
95 | + this.setNull(context, key); | |
96 | + return; | |
97 | + } | |
98 | + context.put(key, value); | |
99 | + } | |
100 | + | |
101 | + /** | |
102 | + * Checks if a VTL reference is <code>null</code>. | |
103 | + * @param object the VTL reference to check. | |
104 | + * @return <code>true</code> if the VTL reference is <code>null</code>, | |
105 | + * <code>false</code> if otherwise. | |
106 | + */ | |
107 | + public boolean isNull(Object object) | |
108 | + { | |
109 | + return object == null; | |
110 | + } | |
111 | + | |
112 | + /** | |
113 | + * Checks if a VTL reference is not <code>null</code>. | |
114 | + * @param object the VTL reference to check. | |
115 | + * @return <code>true</code> if the VTL reference is not <code>null</code>, | |
116 | + * <code>false</code> if otherwise. | |
117 | + */ | |
118 | + public boolean isNotNull(Object object) | |
119 | + { | |
120 | + return !this.isNull(object); | |
121 | + } | |
122 | + | |
123 | + /** | |
124 | + * A convinient method which returns <code>null</code>. | |
125 | + * Actually, this tool will work the same without this method, | |
126 | + * because Velocity treats non-existing methods as null. :) | |
127 | + * @return <code>null</code> | |
128 | + */ | |
129 | + public Object getNull() | |
130 | + { | |
131 | + return null; | |
132 | + } | |
133 | + | |
134 | +} | |
0 | 135 | \ No newline at end of file | ... | ... |
titan-web/src/main/java/com/dili/titan/common/tools/RegexUtils.java
0 → 100644
1 | +package com.dili.titan.common.tools; | |
2 | + | |
3 | +import java.util.regex.Matcher; | |
4 | +import java.util.regex.Pattern; | |
5 | + | |
6 | +/** | |
7 | + * 正则表达式工具 | |
8 | + */ | |
9 | +//TODO 这个竟然没用到?? | |
10 | +public class RegexUtils { | |
11 | + | |
12 | + /** | |
13 | + * 合法的属性名字正则表达式 | |
14 | + */ | |
15 | + public final static String VALID_ATTRIBUTE_NAME_REGEX = "^[a-zA-Z\\+\\/&\u4e00-\u9fa5]+$"; | |
16 | + | |
17 | + /** | |
18 | + * 检验字符串师傅匹配正则表达式 | |
19 | + * | |
20 | + * @param regex 正则表达式 | |
21 | + * @param content 匹配内容 | |
22 | + * @return | |
23 | + * @createTime 2014年6月3日 上午10:06:45 | |
24 | + * @author dili-guwenwu | |
25 | + */ | |
26 | + public static boolean match(String regex, String content) { | |
27 | + Pattern pattern = Pattern.compile(regex); | |
28 | + Matcher matcher = pattern.matcher(content); | |
29 | + return matcher.find(); | |
30 | + } | |
31 | +} | ... | ... |
titan-web/src/main/java/com/dili/titan/common/tools/Tools.java
0 → 100644
1 | +package com.dili.titan.common.tools; | |
2 | + | |
3 | +import java.math.BigDecimal; | |
4 | +import java.util.List; | |
5 | +import java.util.regex.Matcher; | |
6 | +import java.util.regex.Pattern; | |
7 | + | |
8 | +/** | |
9 | + * <B>Description</B> 工具类 | |
10 | + * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. <br /> | |
11 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | |
12 | + * <B>Company</B> 地利集团 | |
13 | + * | |
14 | + * @author yangjianjun | |
15 | + * @createTime 2014年6月25日 下午2:15:09 | |
16 | + */ | |
17 | +public class Tools { | |
18 | + /** | |
19 | + * this method is 判断是否是ASCII编码 | |
20 | + * | |
21 | + * @param string | |
22 | + * @return | |
23 | + * @createTime 2014年6月25日 下午2:14:50 | |
24 | + * @author yangjianjun | |
25 | + */ | |
26 | + public static boolean isASCIIEncoded(String string) { | |
27 | + if (string == null) { | |
28 | + string = ""; | |
29 | + } | |
30 | + return !Pattern.compile("[^\\x00-\\xff]").matcher(string).find(); | |
31 | + } | |
32 | + | |
33 | + | |
34 | + /** | |
35 | + * this method is 获取字符串长度,一个中文占2个长度 | |
36 | + * | |
37 | + * @param string | |
38 | + * @return | |
39 | + * @createTime 2014年6月25日 下午2:14:33 | |
40 | + * @author yangjianjun | |
41 | + */ | |
42 | + public static int getLength(String string) { | |
43 | + if (string == null) { | |
44 | + string = ""; | |
45 | + } | |
46 | + // String reg = "[^\\x00-\\x7f]"; | |
47 | + String reg = "[^\\x00-\\xff]"; | |
48 | + Pattern pattern = Pattern.compile(reg); | |
49 | + Matcher mathcher = pattern.matcher(string); | |
50 | + if (mathcher.find()) { | |
51 | + return string.length() * 2; | |
52 | + } | |
53 | + return string.length(); | |
54 | + } | |
55 | + | |
56 | + /** | |
57 | + * this method is 验证某个对象是否为空 | |
58 | + * | |
59 | + * @param obj | |
60 | + * @return | |
61 | + * @createTime 2014年6月25日 下午2:13:25 | |
62 | + * @author yangjianjun | |
63 | + */ | |
64 | + public static boolean objectIsNotNull(Object obj) { | |
65 | + return (null != obj) ? true : false; | |
66 | + } | |
67 | + | |
68 | + /** | |
69 | + * this method is 判断某一个集合对象是否为空 | |
70 | + * | |
71 | + * @param list | |
72 | + * @return | |
73 | + * @createTime 2014年6月25日 下午2:11:46 | |
74 | + * @author yangjianjun | |
75 | + */ | |
76 | + public static <T> boolean checkListNotNull(List<T> list) { | |
77 | + if (list == null || list.size() < 1) { | |
78 | + return true; | |
79 | + } | |
80 | + return false; | |
81 | + } | |
82 | + | |
83 | + /** | |
84 | + * 判断一个字符串是否在另一个字符串中存在 | |
85 | + * | |
86 | + * @param str0 字符串规则 | |
87 | + * @param str1 要检查的字符串 | |
88 | + * @return boolean | |
89 | + * @author yangjianjun | |
90 | + * @creaetime Nov 26, 2012 4:01:19 PM | |
91 | + */ | |
92 | + public static boolean isExistString(String str0, String str1) { | |
93 | + int indexOf = str0.indexOf(str1); | |
94 | + if (indexOf >= 0) { | |
95 | + return true; | |
96 | + } else { | |
97 | + return false; | |
98 | + } | |
99 | + } | |
100 | + | |
101 | + /** | |
102 | + * this method is 除法结果保留两位小数并按照第二位小数四舍五入 | |
103 | + * | |
104 | + * @param divisor 除数 | |
105 | + * @param dividend 被除数 | |
106 | + * @param k 保留小数的位数及四舍五入的位数 | |
107 | + * @return double数值 | |
108 | + * @createTime 2014年6月25日 下午2:09:10 | |
109 | + * @author yangjianjun | |
110 | + */ | |
111 | + public static double getRoundDecimal(long divisor, long dividend, int k) { | |
112 | + BigDecimal dec1 = new BigDecimal(divisor); | |
113 | + BigDecimal dec2 = new BigDecimal(dividend); | |
114 | + return dec1.divide(dec2, k, BigDecimal.ROUND_HALF_UP).doubleValue(); | |
115 | + } | |
116 | + | |
117 | +} | |
118 | + | |
0 | 119 | \ No newline at end of file | ... | ... |
titan-web/src/main/java/com/dili/titan/common/utils/SkuUtil.java
0 → 100644
1 | +package com.dili.titan.common.utils; | |
2 | + | |
3 | +import com.dili.titan.common.ProductStatus; | |
4 | +import com.dili.titan.common.exception.TitanError; | |
5 | +import org.apache.commons.lang.StringUtils; | |
6 | +import org.apache.log4j.Logger; | |
7 | + | |
8 | +import java.math.BigInteger; | |
9 | +import java.util.ArrayList; | |
10 | +import java.util.List; | |
11 | +import java.util.Map.Entry; | |
12 | +import java.util.Set; | |
13 | +import java.util.TreeMap; | |
14 | +import java.util.regex.Matcher; | |
15 | +import java.util.regex.Pattern; | |
16 | + | |
17 | +/** | |
18 | + * SKU转换 <B>Description</B>SKU操作类<br /> | |
19 | + * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. <br /> | |
20 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | |
21 | + * <B>Company</B> 地利集团 | |
22 | + * | |
23 | + * @author celine | |
24 | + * @createTime 2014年5月26日 下午11:15:12 | |
25 | + */ | |
26 | +public class SkuUtil { | |
27 | + | |
28 | + private final static Logger logger = Logger.getLogger(SkuUtil.class); | |
29 | + private final static int ORI_RADIX = 11;// 原始SKU进制 | |
30 | + private final static int SKU_RADIX = 62; | |
31 | + public final static String SPLIT = ":"; | |
32 | + | |
33 | + /** | |
34 | + * 将编码后不带版本号的skuEncWithoutVersion和version编码成新的SKU | |
35 | + * | |
36 | + * @param skuEncWithoutVersion pid+attVal编码后的sku | |
37 | + * @param version sku版本号 | |
38 | + * @createTime 2014年6月18日 下午8:28:42 | |
39 | + */ | |
40 | + public static String encode(String skuEncWithoutVersion, Integer version) { | |
41 | + String skuOri = decode(skuEncWithoutVersion, false); | |
42 | + return SkuUtil.encode(version + SPLIT + skuOri); | |
43 | + } | |
44 | + | |
45 | + /** | |
46 | + * 生成商品由属性值ID拼接成的SKU字符串,attrMap为空时,默认为没有销售属性,返回0 | |
47 | + * | |
48 | + * @param attrMap 属性项-属性值的Map | |
49 | + * @return | |
50 | + * @createTime 2014年6月18日 下午2:59:24 | |
51 | + * @author celine | |
52 | + */ | |
53 | + public static String getSkuByAttrId(TreeMap<Long, Long> attrMap, Long pid) { | |
54 | + if (attrMap == null || attrMap.size() == 0) { | |
55 | + return pid == null ? null : pid + SPLIT + "0"; | |
56 | + } | |
57 | + Set<Entry<Long, Long>> entries = attrMap.entrySet(); | |
58 | + | |
59 | + if (pid != null) { | |
60 | + StringBuilder sb = new StringBuilder(); | |
61 | + sb.append(pid + SPLIT); | |
62 | + int i = 0; | |
63 | + for (Entry<Long, Long> entry : entries) { | |
64 | + i++; | |
65 | + if (i < entries.size()) { | |
66 | + sb.append(entry.getValue() + SPLIT); | |
67 | + } else { | |
68 | + sb.append(entry.getValue()); | |
69 | + } | |
70 | + } | |
71 | + return sb.toString(); | |
72 | + } | |
73 | + return null; | |
74 | + | |
75 | + } | |
76 | + | |
77 | + /** | |
78 | + * 解析sku中的版本号 | |
79 | + * | |
80 | + * @param encSku 编码后的sku | |
81 | + * @return | |
82 | + * @throws TitanError | |
83 | + * @createTime 2014年6月18日 下午6:52:32 | |
84 | + */ | |
85 | + public static Integer getVersion(String encSku) throws TitanError { | |
86 | + try { | |
87 | + BigInteger bi = sixtytwoToTen(encSku); | |
88 | + String skuDe = tenToM(bi, ORI_RADIX); | |
89 | + String[] skuSplit = skuDe.split(SPLIT); | |
90 | + String verStr = skuSplit[0]; | |
91 | + Integer version = Integer.parseInt(verStr); | |
92 | + return version; | |
93 | + } catch (Exception e) { | |
94 | + throw new TitanError(0, "解析版本号失败"); | |
95 | + } | |
96 | + | |
97 | + } | |
98 | + | |
99 | + /** | |
100 | + * 从带版本号的sku中获取不带版本号的sku | |
101 | + * | |
102 | + * @param encSku 编码后的sku,包含版本号 | |
103 | + * @return 编码后的sku,不带版本号 | |
104 | + * @throws TitanError | |
105 | + * @createTime 2014年6月18日 下午6:52:32 | |
106 | + */ | |
107 | + public static String getSkuEncWithOutVersion(String encSku) { | |
108 | + String skuDe = decode(encSku); | |
109 | + return encode(skuDe); | |
110 | + | |
111 | + } | |
112 | + | |
113 | + /** | |
114 | + * 解析sku中的PID | |
115 | + * | |
116 | + * @param encSku 编码后的sku | |
117 | + * @param hasVersion sku中是否包含版本 | |
118 | + * @return | |
119 | + * @throws TitanError | |
120 | + * @createTime 2014年6月18日 下午6:52:32 | |
121 | + */ | |
122 | + public static Long getPid(String encSku, boolean hasVersion) throws TitanError { | |
123 | + try { | |
124 | + String skuDe = decode(encSku, hasVersion); | |
125 | + String[] skuSplit = skuDe.split(SPLIT); | |
126 | + String pidStr = skuSplit[0]; | |
127 | + Long pid = Long.parseLong(pidStr); | |
128 | + return pid; | |
129 | + } catch (Exception e) { | |
130 | + throw new TitanError(0, "解析商品ID失败"); | |
131 | + } | |
132 | + } | |
133 | + | |
134 | + /** | |
135 | + * 解析sku中的商品属性值ID | |
136 | + * | |
137 | + * @param encSku 编码后的sku | |
138 | + * @param hasVersion sku中是否包含版本 | |
139 | + * @return | |
140 | + * @throws TitanError | |
141 | + * @createTime 2014年6月18日 下午6:52:32 | |
142 | + */ | |
143 | + public static String getAttrVal(String encSku, boolean hasVersion) throws TitanError { | |
144 | + try { | |
145 | + String skuDe = decode(encSku, hasVersion); | |
146 | + return skuDe.substring(skuDe.indexOf(SPLIT) + 1, skuDe.length()); | |
147 | + } catch (Exception e) { | |
148 | + throw new TitanError(0, "解析SKU属性值失败"); | |
149 | + } | |
150 | + } | |
151 | + | |
152 | + /** | |
153 | + * 解析sku中的商品属性值ID | |
154 | + * | |
155 | + * @param encSku 编码后的sku | |
156 | + * @param hasVersion sku中是否包含版本 | |
157 | + * @return | |
158 | + * @throws TitanError | |
159 | + * @createTime 2014年6月18日 下午6:52:32 | |
160 | + */ | |
161 | + public static List<Long> getAttrValList(String encSku, boolean hasVersion) throws TitanError { | |
162 | + try { | |
163 | + String attrvalStr = getAttrVal(encSku, hasVersion); | |
164 | + if (StringUtils.isEmpty(attrvalStr)) | |
165 | + return null; | |
166 | + List<Long> list = new ArrayList<Long>(); | |
167 | + String[] attrvalIds = attrvalStr.split(SPLIT); | |
168 | + for (String attrvalId : attrvalIds) { | |
169 | + list.add(Long.parseLong(attrvalId)); | |
170 | + } | |
171 | + return list; | |
172 | + } catch (Exception e) { | |
173 | + throw new TitanError(0, "解析SKU属性值失败"); | |
174 | + } | |
175 | + } | |
176 | + | |
177 | + /** | |
178 | + * 通过sku确定商品的种类 1-第三方商品 2-供应商商品 3-网站商品 | |
179 | + * | |
180 | + * @param encSku | |
181 | + * @param hasVersion sku中是否包含version | |
182 | + * @return | |
183 | + * @createTime 2014年6月6日 下午6:28:58 | |
184 | + * @author celine | |
185 | + */ | |
186 | + public static int getProductType(String encSku, boolean hasVersion) { | |
187 | + String skuDe = decode(encSku, hasVersion); | |
188 | + String[] skuSplit = skuDe.split(SPLIT); | |
189 | + if (skuSplit.length > 0) { | |
190 | + String pidStart = skuSplit[0].substring(0, 1); | |
191 | + int flag = Integer.parseInt(pidStart); | |
192 | + return determineStype(flag); | |
193 | + } | |
194 | + return 0; | |
195 | + } | |
196 | + | |
197 | + /** | |
198 | + * 通过sku确定商品的种类 1-第三方商品 2-供应商商品 3-网站商品 | |
199 | + * | |
200 | + * @param encSku 编码后的sku,默认包含version | |
201 | + * @return | |
202 | + * @createTime 2014年6月6日 下午6:28:58 | |
203 | + * @author celine | |
204 | + */ | |
205 | + public static int getProductType(String encSku) { | |
206 | + return getProductType(encSku, true); | |
207 | + } | |
208 | + | |
209 | + /** | |
210 | + * 通过pid确定商品的种类 1-第三方商品 2-供应商商品 3-网站商品 | |
211 | + * | |
212 | + * @param sku | |
213 | + * @return | |
214 | + * @createTime 2014年6月6日 下午6:28:58 | |
215 | + * @author celine | |
216 | + */ | |
217 | + public static int getProductTypeByPid(String pid) { | |
218 | + if (pid != null && !pid.equals("")) { | |
219 | + String pidStart = pid.substring(0, 1); | |
220 | + int flag = Integer.parseInt(pidStart); | |
221 | + return determineStype(flag); | |
222 | + } | |
223 | + return 0; | |
224 | + } | |
225 | + | |
226 | + /** | |
227 | + * 对原始SKU串进行编码 | |
228 | + * | |
229 | + * @param oriStr | |
230 | + * @return | |
231 | + * @createTime 2014年5月27日 上午12:19:22 | |
232 | + * @author celine | |
233 | + */ | |
234 | + public static String encode(String oriStr) { | |
235 | + try { | |
236 | + BigInteger bi = elevenToTen(oriStr); | |
237 | + return tenToM(bi, SKU_RADIX); | |
238 | + } catch (Exception e) { | |
239 | + logger.error("Encode Error. ", e); | |
240 | + return null; | |
241 | + } | |
242 | + } | |
243 | + | |
244 | + /** | |
245 | + * 将编码后的SKU转换为PID:属性值形式 | |
246 | + * | |
247 | + * @param skuEnc 编码后的SKU,包含版本号 | |
248 | + * @return | |
249 | + * @createTime 2014年5月27日 上午12:20:17 | |
250 | + * @author celine | |
251 | + */ | |
252 | + public static String decode(String skuEnc) { | |
253 | + return decode(skuEnc, true); | |
254 | + } | |
255 | + | |
256 | + /** | |
257 | + * 将编码后的SKU转换为PID:属性值形式 | |
258 | + * | |
259 | + * @param skuEnc 编码后的SKU | |
260 | + * @param hasVersion sku中是否包含sku信息 | |
261 | + * @return | |
262 | + * @createTime 2014年5月27日 上午12:20:17 | |
263 | + * @author celine | |
264 | + */ | |
265 | + public static String decode(String skuEnc, boolean hasVersion) { | |
266 | + try { | |
267 | + BigInteger bi = sixtytwoToTen(skuEnc); | |
268 | + String skuOriWithVersion = tenToM(bi, ORI_RADIX); | |
269 | + if (hasVersion) { | |
270 | + return skuOriWithVersion.substring(skuOriWithVersion.indexOf(SPLIT) + 1, skuOriWithVersion.length()); | |
271 | + } | |
272 | + return skuOriWithVersion; | |
273 | + } catch (Exception e) { | |
274 | + logger.error("Decode Error. ", e); | |
275 | + return null; | |
276 | + } | |
277 | + } | |
278 | + | |
279 | + /** | |
280 | + * 将任意进制的数转换为十进制,本系统中用':'作为第十一位, | |
281 | + * | |
282 | + * @param s | |
283 | + * @param m 进制数 | |
284 | + * @return | |
285 | + * @createTime 2014年5月26日 下午10:27:05 | |
286 | + * @author celine | |
287 | + */ | |
288 | + private static BigInteger elevenToTen(String s) throws Exception { | |
289 | + | |
290 | + Pattern pattern = Pattern.compile("^[0-9:]+$"); | |
291 | + Matcher matcher = pattern.matcher(s); | |
292 | + | |
293 | + if (matcher.find()) { | |
294 | + BigInteger oriBi = BigInteger.valueOf(ORI_RADIX); | |
295 | + BigInteger tmpBi = new BigInteger("0"); | |
296 | + for (int i = 0; i < s.length(); i++) { | |
297 | + char tmpC = s.charAt(i); | |
298 | + int tmp = tmpC - '0'; | |
299 | + tmpBi = tmpBi.multiply(oriBi).add(BigInteger.valueOf(tmp)); | |
300 | + } | |
301 | + return tmpBi; | |
302 | + } else { | |
303 | + // 不全为数字和':' | |
304 | + logger.error("Invalid input " + s); | |
305 | + throw new Exception("Invalid input " + s); | |
306 | + } | |
307 | + } | |
308 | + | |
309 | + private static BigInteger sixtytwoToTen(String s) throws Exception { | |
310 | + Pattern pattern = Pattern.compile("^[0-9a-zA-z]+$"); | |
311 | + Matcher matcher = pattern.matcher(s); | |
312 | + | |
313 | + if (matcher.find()) { | |
314 | + BigInteger skuBi = BigInteger.valueOf(SKU_RADIX); | |
315 | + BigInteger tmpBi = new BigInteger("0"); | |
316 | + for (int i = 0; i < s.length(); i++) { | |
317 | + char tmpC = s.charAt(i); | |
318 | + int tmp = convertStringToInt62(tmpC); | |
319 | + tmpBi = tmpBi.multiply(skuBi).add(BigInteger.valueOf(tmp)); | |
320 | + } | |
321 | + return tmpBi; | |
322 | + } else { | |
323 | + // 不全为数字和大小写字母 | |
324 | + throw new Exception("Invalid input " + s); | |
325 | + } | |
326 | + } | |
327 | + | |
328 | + /** | |
329 | + * 将十进制转换为十一或六十二 | |
330 | + * | |
331 | + * @param bi | |
332 | + * @param m | |
333 | + * @throws Exception | |
334 | + * @createTime 2014年5月26日 下午10:58:20 | |
335 | + * @author celine | |
336 | + */ | |
337 | + private static String tenToM(BigInteger bi, int m) throws Exception { | |
338 | + StringBuffer bs = new StringBuffer(); | |
339 | + BigInteger zero = BigInteger.valueOf(0); | |
340 | + BigInteger targetBi = BigInteger.valueOf(m); | |
341 | + while (bi.compareTo(zero) > 0) { | |
342 | + BigInteger mod = bi.mod(targetBi); | |
343 | + if (m == ORI_RADIX) { | |
344 | + bs.insert(0, convertIntToString11(mod.intValue())); | |
345 | + } else if (m == SKU_RADIX) { | |
346 | + bs.insert(0, convertIntToString62(mod.intValue())); | |
347 | + } | |
348 | + bi = bi.divide(targetBi); | |
349 | + } | |
350 | + return bs.toString(); | |
351 | + } | |
352 | + | |
353 | + /** | |
354 | + * 将整数转换为对应62进制的字符 | |
355 | + * | |
356 | + * @param i | |
357 | + * @return | |
358 | + * @throws Exception | |
359 | + * @createTime 2014年5月26日 下午11:14:24 | |
360 | + * @author celine | |
361 | + */ | |
362 | + private static char convertIntToString62(int i) throws Exception { | |
363 | + if (i >= 0 && i <= 9) { | |
364 | + return (char) (i + '0'); | |
365 | + } else if (i > 9 && i < 36) { | |
366 | + return (char) ('a' + i - 10); | |
367 | + } else if (i >= 36 && i < 62) { | |
368 | + return (char) ('A' + i - 36); | |
369 | + } else { | |
370 | + throw new Exception("Invalid input " + i); | |
371 | + } | |
372 | + } | |
373 | + | |
374 | + /** | |
375 | + * 将整数转换为对应11进制的字符 | |
376 | + * | |
377 | + * @param i | |
378 | + * @return | |
379 | + * @throws Exception | |
380 | + * @createTime 2014年5月26日 下午11:30:15 | |
381 | + * @author celine | |
382 | + */ | |
383 | + private static char convertIntToString11(int i) throws Exception { | |
384 | + if (i >= 0 && i <= 10) { | |
385 | + return (char) (i + '0'); | |
386 | + } else { | |
387 | + throw new Exception("Invalid input " + i); | |
388 | + } | |
389 | + } | |
390 | + | |
391 | + private static int convertStringToInt62(char c) throws Exception { | |
392 | + if (c >= '0' && c <= '9') { | |
393 | + return c - '0'; | |
394 | + } else if (c >= 'a' && c <= 'z') { | |
395 | + return c - 'a' + 10; | |
396 | + } else if (c >= 'A' && c <= 'Z') { | |
397 | + return c - 'A' + 36; | |
398 | + } else { | |
399 | + throw new Exception("Invalid input " + c); | |
400 | + } | |
401 | + } | |
402 | + | |
403 | + /** | |
404 | + * 确定商品类型 | |
405 | + * | |
406 | + * @param flag | |
407 | + * @return | |
408 | + * @createTime 2014年6月6日 下午6:40:15 | |
409 | + * @author celine | |
410 | + */ | |
411 | + private static int determineStype(int flag) { | |
412 | + switch (flag) { | |
413 | + case 1: | |
414 | + case 2: | |
415 | + case 3: | |
416 | + case 4: | |
417 | + return ProductStatus.PRODUCT_POP; | |
418 | + case 5: | |
419 | + case 6: | |
420 | + case 7: | |
421 | + case 8: | |
422 | + case 9: | |
423 | + default: | |
424 | + break; | |
425 | + } | |
426 | + return 0; | |
427 | + } | |
428 | + | |
429 | + public static String getProductTypeByPid(Long pid) { | |
430 | + if (pid >= 1000000000l && pid < 5000000000l) { | |
431 | + return ProductStatus.SALE_TYPE_POP; | |
432 | + }else{ | |
433 | + return null; | |
434 | + } | |
435 | + } | |
436 | + public static void main(String[] args) { | |
437 | +// String [] str={"2t3on7sJ8o","dUFFyuPwZ","2t3on7A9ZX","2t3on7A9ZZ","dUFFyvvqA","dUFFyvvqC","dUFFywbFG","dUFFywbFF","dUFFywbFE"}; | |
438 | + String [] str={"8HaxIIqWR","8HaxIIqWT","N0XqBUPp","N0XqBUPr","N0XqC2rJ","N0XqC2rI"}; | |
439 | +// for(int i=0;i<str.length;i++){ | |
440 | +// System.out.println(SkuUtil.encode(str[i],1)); | |
441 | +// } | |
442 | +// System.out.println(SkuUtil.encode("3orUNksjei",1));8000000021:11:24 | |
443 | + System.out.println(SkuUtil.encode("8000000021:-1")); | |
444 | + System.out.println("true:"+SkuUtil.decode("1aRTiFaECUbT", true)); | |
445 | + System.out.println("false:"+SkuUtil.decode("1aRTiFaECUbS", false)); | |
446 | +// System.out.println(SkuUtil.decode("6HGkoES51V")); | |
447 | + | |
448 | + } | |
449 | +} | ... | ... |
titan-web/src/main/java/com/dili/titan/common/utils/SortList.java
0 → 100644
1 | +package com.dili.titan.common.utils; | |
2 | + | |
3 | +import java.lang.reflect.Method; | |
4 | +import java.util.Collections; | |
5 | +import java.util.Comparator; | |
6 | +import java.util.List; | |
7 | + | |
8 | +/** | |
9 | + * <B>Description</B> 对象排序 <br /> | |
10 | + * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. <br /> | |
11 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | |
12 | + * <B>Company</B> 地利集团 | |
13 | + * @param <E> | |
14 | + * @createTime 2014年6月10日 下午8:29:27 | |
15 | + * @author yangjianjun | |
16 | + */ | |
17 | +public class SortList<E>{ | |
18 | + /** | |
19 | + * this method is 对象排序 | |
20 | + * @param list list的泛型对象 | |
21 | + * @param method 排序的字段<getXXX> | |
22 | + * @param sort 若倒序填写desc;否则填null | |
23 | + * @createTime 2014年6月11日 上午10:00:21 | |
24 | + * @author yangjianjun | |
25 | + */ | |
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()); | |
35 | + 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 | + } | |
44 | +} | |
0 | 45 | \ No newline at end of file | ... | ... |
titan-web/src/main/java/com/dili/titan/common/utils/html/EscapeHtmlReference.java
0 → 100644
1 | +package com.dili.titan.common.utils.html; | |
2 | + | |
3 | +import org.apache.velocity.app.event.implement.EscapeReference; | |
4 | + | |
5 | +/** | |
6 | + * 过滤HTML、XML标签,防止XSS | |
7 | + * | |
8 | + */ | |
9 | +//TODO 没被用,应该很有用 | |
10 | +@Deprecated | |
11 | +public class EscapeHtmlReference extends EscapeReference { | |
12 | + | |
13 | + protected String escape(Object text) { | |
14 | + if (!(text instanceof String)) { | |
15 | + return text.toString(); | |
16 | + } | |
17 | + StringBuffer str = new StringBuffer(); | |
18 | + char[] cs = text.toString().toCharArray(); | |
19 | + for (char c : cs) { | |
20 | + if (c == '>') { | |
21 | + str.append(">"); | |
22 | + } else if (c == '<') { | |
23 | + str.append("<"); | |
24 | + } else { | |
25 | + str.append(c); | |
26 | + } | |
27 | + } | |
28 | + return str.toString(); | |
29 | + } | |
30 | + | |
31 | + protected String getMatchAttribute() { | |
32 | + return "eventhandler.escape.html.match"; | |
33 | + } | |
34 | +} | |
0 | 35 | \ No newline at end of file | ... | ... |
titan-web/src/main/java/com/dili/titan/common/utils/web/BaseController.java
0 → 100644
1 | +package com.dili.titan.common.utils.web; | |
2 | + | |
3 | +import com.alibaba.fastjson.JSON; | |
4 | +import com.alibaba.fastjson.JSONArray; | |
5 | +import com.alibaba.fastjson.JSONObject; | |
6 | +import com.dili.titan.common.utils.web.exception.WebException; | |
7 | +import org.apache.commons.lang.StringUtils; | |
8 | + | |
9 | +import javax.annotation.Resource; | |
10 | +import javax.servlet.http.HttpServletRequest; | |
11 | +import javax.servlet.http.HttpServletResponse; | |
12 | +import java.io.IOException; | |
13 | +import java.io.PrintWriter; | |
14 | +import java.util.ArrayList; | |
15 | +import java.util.HashMap; | |
16 | +import java.util.List; | |
17 | +import java.util.Map; | |
18 | + | |
19 | +/** | |
20 | + * BaseController | |
21 | + * | |
22 | + */ | |
23 | +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; | |
27 | + | |
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 | + } | |
49 | + | |
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 | + } | |
58 | + | |
59 | + protected Map<String, Object> getDefaultContext() { | |
60 | + Map<String, Object> context = new HashMap<String, Object>(); | |
61 | + return context; | |
62 | + } | |
63 | + | |
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 | + } | |
87 | + | |
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 | + } | |
108 | + | |
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 | + } | |
157 | +} | ... | ... |
titan-web/src/main/java/com/dili/titan/common/utils/web/DateFormatUtils.java
0 → 100644
1 | +package com.dili.titan.common.utils.web; | |
2 | + | |
3 | +import java.text.ParseException; | |
4 | +import java.text.SimpleDateFormat; | |
5 | +import java.util.Calendar; | |
6 | +import java.util.Date; | |
7 | + | |
8 | +public class DateFormatUtils { | |
9 | + /** | |
10 | + * 英文简写(默认)如:2010-12-01 | |
11 | + */ | |
12 | + public static final String FORMAT_SHORT = "yyyy-MM-dd"; | |
13 | + /** | |
14 | + * 英文全称 如:2010-12-01 23:15:06 | |
15 | + */ | |
16 | + public static final String FORMAT_LONG = "yyyy-MM-dd HH:mm:ss"; | |
17 | + /** | |
18 | + * 精确到毫秒的完整时间 如:yyyy-MM-dd HH:mm:ss.S | |
19 | + */ | |
20 | + public static final String FORMAT_FULL = "yyyy-MM-dd HH:mm:ss.S"; | |
21 | + /** | |
22 | + * 中文简写 如:2010年12月01日 | |
23 | + */ | |
24 | + public static final String FORMAT_SHORT_CN = "yyyy年MM月dd"; | |
25 | + /** | |
26 | + * 中文全称 如:2010年12月01日 23时15分06秒 | |
27 | + */ | |
28 | + public static final String FORMAT_LONG_CN = "yyyy年MM月dd日 HH时mm分ss秒"; | |
29 | + /** | |
30 | + * 精确到毫秒的完整中文时间 | |
31 | + */ | |
32 | + public static final String FORMAT_FULL_CN = "yyyy年MM月dd日 HH时mm分ss秒SSS毫秒"; | |
33 | + /** | |
34 | + * 获得默认的 date pattern | |
35 | + */ | |
36 | + public static String getDatePattern() { | |
37 | + return FORMAT_LONG; | |
38 | + } | |
39 | + /** | |
40 | + * 根据预设格式返回当前日期 | |
41 | + * @return | |
42 | + */ | |
43 | + public static String getNow() { | |
44 | + return format(new Date()); | |
45 | + } | |
46 | + /** | |
47 | + * 根据用户格式返回当前日期 | |
48 | + * @param format | |
49 | + * @return | |
50 | + */ | |
51 | + public static String getNow(String format) { | |
52 | + return format(new Date(), format); | |
53 | + } | |
54 | + /** | |
55 | + * 使用预设格式格式化日期 | |
56 | + * @param date | |
57 | + * @return | |
58 | + */ | |
59 | + public static String format(Date date) { | |
60 | + return format(date, getDatePattern()); | |
61 | + } | |
62 | + /** | |
63 | + * 使用用户格式格式化日期 | |
64 | + * @param date 日期 | |
65 | + * @param pattern 日期格式 | |
66 | + * @return | |
67 | + */ | |
68 | + public static String format(Date date, String pattern) { | |
69 | + String returnValue = ""; | |
70 | + if (date != null) { | |
71 | + SimpleDateFormat df = new SimpleDateFormat(pattern); | |
72 | + returnValue = df.format(date); | |
73 | + } | |
74 | + return (returnValue); | |
75 | + } | |
76 | + /** | |
77 | + * 使用预设格式提取字符串日期 | |
78 | + * @param strDate 日期字符串 | |
79 | + * @return | |
80 | + */ | |
81 | + public static Date parse(String strDate) { | |
82 | + return parse(strDate, getDatePattern()); | |
83 | + } | |
84 | + /** | |
85 | + * 使用用户格式提取字符串日期 | |
86 | + * @param strDate 日期字符串 | |
87 | + * @param pattern 日期格式 | |
88 | + * @return | |
89 | + */ | |
90 | + public static Date parse(String strDate, String pattern) { | |
91 | + SimpleDateFormat df = new SimpleDateFormat(pattern); | |
92 | + try { | |
93 | + return df.parse(strDate); | |
94 | + } catch (ParseException e) { | |
95 | + e.printStackTrace(); | |
96 | + return null; | |
97 | + } | |
98 | + } | |
99 | + /** | |
100 | + * 在日期上增加数个整月 | |
101 | + * @param date 日期 | |
102 | + * @param n 要增加的月数 | |
103 | + * @return | |
104 | + */ | |
105 | + public static Date addMonth(Date date, int n) { | |
106 | + Calendar cal = Calendar.getInstance(); | |
107 | + cal.setTime(date); | |
108 | + cal.add(Calendar.MONTH, n); | |
109 | + return cal.getTime(); | |
110 | + } | |
111 | + /** | |
112 | + * 在日期上增加天数 | |
113 | + * @param date 日期 | |
114 | + * @param n 要增加的天数 | |
115 | + * @return | |
116 | + */ | |
117 | + public static Date addDay(Date date, int n) { | |
118 | + Calendar cal = Calendar.getInstance(); | |
119 | + cal.setTime(date); | |
120 | + cal.add(Calendar.DATE, n); | |
121 | + return cal.getTime(); | |
122 | + } | |
123 | + /** | |
124 | + * 获取时间戳 | |
125 | + */ | |
126 | + public static String getTimeString() { | |
127 | + SimpleDateFormat df = new SimpleDateFormat(FORMAT_FULL); | |
128 | + Calendar calendar = Calendar.getInstance(); | |
129 | + return df.format(calendar.getTime()); | |
130 | + } | |
131 | + /** | |
132 | + * 获取日期年份 | |
133 | + * @param date 日期 | |
134 | + * @return | |
135 | + */ | |
136 | + public static String getYear(Date date) { | |
137 | + return format(date).substring(0, 4); | |
138 | + } | |
139 | + /** | |
140 | + * 按默认格式的字符串距离今天的天数 | |
141 | + * @param date 日期字符串 | |
142 | + * @return | |
143 | + */ | |
144 | + public static int countDays (String date) { | |
145 | + long t = Calendar.getInstance().getTime().getTime(); | |
146 | + Calendar c = Calendar.getInstance(); | |
147 | + c.setTime(parse(date)); | |
148 | + long t1 = c.getTime().getTime(); | |
149 | + return (int)(t/1000 - t1/1000)/3600/24; | |
150 | + } | |
151 | + /** | |
152 | + * 按用户格式字符串距离今天的天数 | |
153 | + * @param date 日期字符串 | |
154 | + * @param format 日期格式 | |
155 | + * @return | |
156 | + */ | |
157 | + public static int countDays (String date, String format) { | |
158 | + long t = Calendar.getInstance().getTime().getTime(); | |
159 | + Calendar c = Calendar.getInstance(); | |
160 | + c.setTime(parse(date, format)); | |
161 | + long t1 = c.getTime().getTime(); | |
162 | + return (int)(t/1000 - t1/1000)/3600/24; | |
163 | + } | |
164 | +} | ... | ... |